modisread.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:modis-mpf 作者: anjaroesel 项目源码 文件源码
def bowtie_polynom(modis_img,cs,folder):
    print 'Determine overlap pattern... '
    sw=10000/cs #stripwidth
    overlaplist=[]#define list to store number of overlapped lines
    #devide in parts with a width of 40 pixel
    for i in sp.arange(0,modis_img.shape[1]-40,40):
        part=modis_img[:,i:i+39]
        #search in every scanning strip
        samples=[]
        for j in sp.arange(sw-2,part.shape[0]-sw,sw):
            target=part[j-1:j+1,:] #cut out a target, which overlapped counter-part shall be found
            searchwindow=part[j+2:j+sw+2] #,: cut out the window, where the overlapped counter part might be located
            #start the search
            c=[] #calculate correlation coefficients of every given offset from 3 to 11
            for offset in sp.arange(3,sw/2+1):
                imgpart=searchwindow[offset-3:offset-1] #,: cut out image, which has to be compared with the target
                c.append(sp.corrcoef(imgpart.flatten(),target.flatten())[0,1])#calculate correlatoin coefficient
            c=sp.array(c)
            overl=sp.ndimage.measurements.maximum_position(c)[0]+3 #find the overlap with the highes correlation coefficient
            samples.append([overl,c.max()]) #attach overlap and correlation coefficient to the sample list
        samples=sp.array(samples)
        #print i, samples[:,1].mean()
        if samples[:,1].mean() > 0.9: #chek the mean correlation coefficient:
            #print('Bowtie Correlation high - removing effect')
            overlaplist.append([i+20,samples[:,0].mean()]) #save result, if correlation coefficient is high
            #print(overlaplist)
            o=sp.array(overlaplist)
            X=o[:,0]
            overlap=o[:,1]
            #Calculate a second order Polynom to describe the overlap
            p=sp.polyfit(X,overlap,2)
            #print 'done, Overlap polynom: '+str(p)
        else:
            #print('low Bowtie correlation')
            p = [1.,  1.,  1.]
            #overlaplist.append([i+20,1])
            #os.system('rm -r '+folder)
            #print('scene deleted') 
    return p
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号