示例#1
0
 def setUp(self):
     self.lena = scipy.misc.lena().astype(numpy.float32)
     self.shape = self.lena.shape
     self.extra = (10, 11)
     #        self.img = scipy.ndimage.shift(self.lena, (7, 5))
     #        self.img = scipy.ndimage.rotate(self.lena, -20, reshape=False, order=3)
     #        self.img = scipy.ndimage.shift(scipy.ndimage.rotate(self.lena, 20, reshape=False, order=3), (7, 5))
     self.img = scipy.ndimage.affine_transform(self.lena,
                                               [[1.1, -0.1], [0.05, 0.9]],
                                               [7, 5])
     self.align = LinearAlign(self.lena, context=ctx)
示例#2
0
    def setUp(self):
        self.lena = scipy.misc.lena().astype(numpy.float32)
        self.shape = self.lena.shape
        self.extra = (10, 11)
#        self.img = scipy.ndimage.shift(self.lena, (7, 5))
#        self.img = scipy.ndimage.rotate(self.lena, -20, reshape=False, order=3)
#        self.img = scipy.ndimage.shift(scipy.ndimage.rotate(self.lena, 20, reshape=False, order=3), (7, 5))
        self.img = scipy.ndimage.affine_transform(self.lena, [[1.1, -0.1], [0.05, 0.9]], [7, 5])
        self.align = LinearAlign(self.lena, context=ctx)
示例#3
0
class test_linalign(unittest.TestCase):
    def setUp(self):
        self.lena = scipy.misc.lena().astype(numpy.float32)
        self.shape = self.lena.shape
        self.extra = (10, 11)
        #        self.img = scipy.ndimage.shift(self.lena, (7, 5))
        #        self.img = scipy.ndimage.rotate(self.lena, -20, reshape=False, order=3)
        #        self.img = scipy.ndimage.shift(scipy.ndimage.rotate(self.lena, 20, reshape=False, order=3), (7, 5))
        self.img = scipy.ndimage.affine_transform(self.lena,
                                                  [[1.1, -0.1], [0.05, 0.9]],
                                                  [7, 5])
        self.align = LinearAlign(self.lena, context=ctx)

    def test_align(self):
        """
        tests the combine (linear combination) kernel
        """
        out = self.align.align(self.img, 0, 1)
        for i in out:
            if i in ["offset", "matrix"]:
                print i
                print out[i]
        self.align.log_profile()
        out = out["result"]

        if PROFILE and out is not None:
            fig = pylab.figure()
            sp0 = fig.add_subplot(221)
            im0 = sp0.imshow(self.lena)
            sp1 = fig.add_subplot(222)
            im1 = sp1.imshow(self.img)
            sp2 = fig.add_subplot(223)
            im2 = sp2.imshow(out)
            sp3 = fig.add_subplot(224)
            delta = (out - self.lena)[100:400, 100:400]
            im3 = sp3.imshow(delta)
            print({
                "min": delta.min(),
                "max:": delta.max(),
                "mean": delta.mean(),
                "std:": delta.std()
            })
            pylab.show()
            raw_input("enter")
示例#4
0
class test_linalign(unittest.TestCase):
    def setUp(self):
        self.lena = scipy.misc.lena().astype(numpy.float32)
        self.shape = self.lena.shape
        self.extra = (10, 11)
#        self.img = scipy.ndimage.shift(self.lena, (7, 5))
#        self.img = scipy.ndimage.rotate(self.lena, -20, reshape=False, order=3)
#        self.img = scipy.ndimage.shift(scipy.ndimage.rotate(self.lena, 20, reshape=False, order=3), (7, 5))
        self.img = scipy.ndimage.affine_transform(self.lena, [[1.1, -0.1], [0.05, 0.9]], [7, 5])
        self.align = LinearAlign(self.lena, context=ctx)


    def test_align(self):
        """
        tests the combine (linear combination) kernel
        """
        out = self.align.align(self.img, 0, 1)
        for i in out:
            if i in ["offset","matrix"]:
                print i
                print out[i]
        self.align.log_profile()
        out = out["result"]

        if PROFILE and out is not None:
            fig = pylab.figure()
            sp0 = fig.add_subplot(221)
            im0 = sp0.imshow(self.lena)
            sp1 = fig.add_subplot(222)
            im1 = sp1.imshow(self.img)
            sp2 = fig.add_subplot(223)
            im2 = sp2.imshow(out)
            sp3 = fig.add_subplot(224)
            delta = (out - self.lena)[100:400, 100:400]
            im3 = sp3.imshow(delta)
            print({"min":delta.min(), "max:":delta.max(), "mean":delta.mean(), "std:":delta.std()})
            pylab.show()
            raw_input("enter")