Sucran
9/27/2017 - 7:51 AM

Numpy image patches operations

sample_size = count
imgs_all = np.zeros((sample_size,4,size_input,size_input), dtype=np.float32)
i = 0
for x in range(0,width-size_input,stride):
    for y in range(0 , heigh-size_input ,stride):
        sub_tiny = im_tiny[x : x+size_input, y : y+size_input]
        tiny_area = sum(sum(sub_tiny))
        if tiny_area>=500: #删除没显著标记为新建的,没显著标记不参与运算
            imgs_all[i,0,:,:]=im_2015_ln[x : x+size_input, y : y+size_input]
            #imgs_all[i,1,:,:]=im_2015_IR[x : x+size_input, y : y+size_input]
            imgs_all[i,1,:,:]=im_2017_ln[x : x+size_input, y : y+size_input]
            #imgs_all[i,3,:,:]=im_2017_IR[x : x+size_input, y : y+size_input]
            imgs_all[i,2,:,:]=im_cada[x : x+size_input, y : y+size_input]
            imgs_all[i,3,:,:]=sub_tiny #label
            i=i+1
width, heigh = im_tiny.shape
count = 0
for x in range(0,width-size_input,stride):
    for y in range(0 , heigh-size_input ,stride):
        sub_tiny = im_tiny[x : x+size_input, y : y+size_input]
        tiny_area = sum(sum(sub_tiny))
        if tiny_area>=500: #删除没显著标记的,没显著标记不参与运算
            count=count+1
print '训练数据:'+str(count