示例#1
0
文件: image_ops.py 项目: 0rchard/CUV
def gray_test(ni):
    src = cp.push(to_cmuc(np.tile(ni,(1,4))))
    dst = cp.dev_matrix_cmf(src.h,src.w)
    cp.fill(dst,0)
    cp.image_move(dst,src,128,128,1,-10,-4)
    res = cp.pull(dst)
    #set_trace()
    plt.matshow(res[0:128**2,0].reshape(128,128))
    plt.colorbar()
    plt.show()
示例#2
0
def gray_test(ni):
    src = cp.push(to_cmuc(np.tile(ni, (1, 4))))
    dst = cp.dev_matrix_cmf(src.h, src.w)
    cp.fill(dst, 0)
    cp.image_move(dst, src, 128, 128, 1, -10, -4)
    res = cp.pull(dst)
    #set_trace()
    plt.matshow(res[0:128**2, 0].reshape(128, 128))
    plt.colorbar()
    plt.show()
示例#3
0
文件: image_ops.py 项目: 0rchard/CUV
def color_test(ni):
    ts = 128
    src = cp.push(to_cmuc(np.tile(ni,(1,4))))
    dst = cp.dev_matrix_cmf(ts**2*3,src.w)
    cp.fill(dst,0)
    cp.image_move(dst,src,128,ts,4,-10,-4)
    res = cp.pull(dst)
    plt.matshow(res[0:ts**2,0].reshape(ts,ts), cmap = plt.cm.bone_r)
    plt.matshow(res[ts**2:2*ts**2,0].reshape(ts,ts), cmap = plt.cm.bone_r)
    plt.matshow(res[2*ts**2:3*ts**2,0].reshape(ts,ts), cmap = plt.cm.bone_r)
    plt.show()
示例#4
0
 def setMiniBatch(self, mb, dst_layer):
     self.sampleset_ = mb
     self.sampleset  = cp.dev_tensor_uc_cm(self.sampleset_.copy('F'))
     shift = np.random.randint(-self.maxmov,self.maxmov+1, 2).astype('int32')
     cp.image_move(dst_layer,self.sampleset,self.src_size, self.dst_size, self.src_num_maps, shift[0],shift[1])
     if self.noise_std != 0:
         cp.add_rnd_normal(dst_layer,self.noise_std)
     if self.norm:
         self.norm(dst_layer)
     self.sampleset.dealloc()
     self.sampleset = dst_layer.copy()
示例#5
0
def color_test(ni):
    ts = 128
    src = cp.push(to_cmuc(np.tile(ni, (1, 4))))
    dst = cp.dev_matrix_cmf(ts**2 * 3, src.w)
    cp.fill(dst, 0)
    cp.image_move(dst, src, 128, ts, 4, -10, -4)
    res = cp.pull(dst)
    plt.matshow(res[0:ts**2, 0].reshape(ts, ts), cmap=plt.cm.bone_r)
    plt.matshow(res[ts**2:2 * ts**2, 0].reshape(ts, ts), cmap=plt.cm.bone_r)
    plt.matshow(res[2 * ts**2:3 * ts**2, 0].reshape(ts, ts),
                cmap=plt.cm.bone_r)
    plt.show()
示例#6
0
 def setMiniBatch(self, mb, dst_layer):
     self.sampleset_ = mb
     self.sampleset = cp.dev_tensor_uc_cm(self.sampleset_.copy('F'))
     shift = np.random.randint(-self.maxmov, self.maxmov + 1,
                               2).astype('int32')
     cp.image_move(dst_layer, self.sampleset, self.src_size, self.dst_size,
                   self.src_num_maps, shift[0], shift[1])
     if self.noise_std != 0:
         cp.add_rnd_normal(dst_layer, self.noise_std)
     if self.norm:
         self.norm(dst_layer)
     self.sampleset.dealloc()
     self.sampleset = dst_layer.copy()