Beispiel #1
0
 def setUp(self):
     names = ['zspace', 'yspace', 'xspace']
     shape = (10,20,30)
     self.img = Image(np.zeros(shape), 
                      Affine.from_start_step(names, names, (0,)*3, (1,)*3))
     self.img2 = Image(np.ones(shape), 
                       Affine.from_start_step(names, names, (0,)*3, (1,)*3))
                    
     shape = (3,5,4)
     self.img3 = Image(np.zeros(shape), 
                       Affine.from_start_step(names, names, (0,)*3, (1,)*3))
     self.img4 = Image(np.zeros(shape), 
                       Affine.from_start_step(names, names, (0,)*3, (1,)*3))
Beispiel #2
0
def test_nonaffine():
    # resamples an image along a curve through the image.
    #
    # FIXME: use the reference.evaluate.Grid to perform this nicer
    # FIXME: Remove pylab references
    def curve(x): # function accept N by 1, returns N by 2 
        return (np.vstack([5*np.sin(x.T),5*np.cos(x.T)]).T + [52,47])
    for names in (('xy', 'ij', 't', 'u'),('ij', 'xy', 't', 's')):
        in_names, out_names, tin_names, tout_names = names
        g = Affine.from_params(in_names, out_names, np.identity(3))
        img = Image(np.ones((100,90)), g)
        img[50:55,40:55] = 3.
        tcoordmap = Affine.from_start_step(
            tin_names,
            tout_names,
            [0],
            [np.pi*1.8/100])
        ir = resample(img, tcoordmap, curve, (100,))
    if gui_review:
        import pylab
        pylab.figure(num=3)
        pylab.imshow(img, interpolation='nearest')
        d = curve(np.linspace(0,1.8*np.pi,100))
        pylab.plot(d[0], d[1])
        pylab.gca().set_ylim([0,99])
        pylab.gca().set_xlim([0,89])
        pylab.figure(num=4)
        pylab.plot(np.asarray(ir))