zoukankan      html  css  js  c++  java
  • 记2014年数学建模国赛

    下面给出,嫦娥三号在粗、精避过程中的算法,python 2.7

     1 #coding=gbk
     2 '''
     3 Created on 2014-9-10
     4 
     5 @author: Administrator
     6 '''
     7 from libtiff import TIFF
     8 import numpy
     9 import math
    10 #filename='C:\3.tif'                        #导入附件三文件
    11 filename='C:\4.tif'                          #导入附件四文件
    12 tif = TIFF.open(filename, mode='r')
    13 image = tif.read_image()
    14 
    15 
    16 def seq(p,a):                               #计算每个区域的标准差函数
    17     sum = 0.0
    18     sum1 =0.0
    19     
    20     narray=numpy.array(p)
    21     sum = narray.sum()
    22     ave = sum/10000.0           
    23     
    24     for i in range(100):
    25         for j in range(100):
    26             sum1 = sum1 + int(p[i][j])*int(p[i][j])
    27     s = (sum1-10000.0*(ave**2))/10000.0
    28     if math.sqrt(s)<5:                    #人为设定的筛选精度
    29         print '第%d个块的标准差为:%f' %(a,math.sqrt(s))
    30 
    31 #size=23                                #2.4km处大图分割参数
    32 size=10                                 #100m处大图分割参数
    33 a = 0
    34 for i in range(size):                           #迭代求解
    35     for j in range(size):
    36         q = image[i*100:(i+1)*100,j*100:(j+1)*100]
    37         a = a+1
    38         seq(q,a)
    39         
    40 tif.close()
  • 相关阅读:
    【转】acm小技巧
    poj-1703-Find them, Catch them
    poj-1611-The Suspects
    poj-2236-Wireless Network
    hdu-4496-D-City
    hdu-1213-How Many Tables
    hdu-1856-More is better
    gcd和ex_gcd
    递归趣文
    算法实质【Matrix67】
  • 原文地址:https://www.cnblogs.com/lovecc/p/3969218.html
Copyright © 2011-2022 走看看