Ejemplo n.º 1
0
 def test_multiple_dimensional_integer_shift(self):
     shape = array([2, 2, 3, 2])
     x = zeros(shape)
     x[0, 0, 0, 0] = 1
     shift = []
     for max_shift in shape:
         shift.append(randint(max_shift))
     xx = mm.circshift(x, shift)
     i = unravel_index(argmax(xx), x.shape)
     self.assertListEqual(list(shift), list(i))
Ejemplo n.º 2
0
 def test_multiple_dimensional_integer_shift(self):
     shape = array([2, 2, 3, 2])
     x = zeros(shape)
     x[0, 0, 0, 0] = 1
     shift = []
     for max_shift in shape:
         shift.append(randint(max_shift))
     xx = mm.circshift(x, shift)
     i = unravel_index(argmax(xx), x.shape)
     self.assertListEqual(list(shift), list(i))
Ejemplo n.º 3
0
    def test_upsample_1000(self):
        img0 = scipy.misc.lena()
        ny, nx = img0.shape
        row_shift = (rand() - 0.5)*ny
        col_shift = (rand() - 0.5)*nx
        img1 = mm.circshift(img0, (row_shift, col_shift))

        val, row, col = mm.register(img0, img1, upsample=105)
        self.assertAlmostEqual(row, row_shift, places=2)
        self.assertAlmostEqual(col, col_shift, places=2)
Ejemplo n.º 4
0
    def test_upsample_1000(self):
        img0 = scipy.misc.lena()
        ny, nx = img0.shape
        row_shift = (rand() - 0.5) * ny
        col_shift = (rand() - 0.5) * nx
        img1 = mm.circshift(img0, (row_shift, col_shift))

        val, row, col = mm.register(img0, img1, upsample=105)
        self.assertAlmostEqual(row, row_shift, places=2)
        self.assertAlmostEqual(col, col_shift, places=2)
Ejemplo n.º 5
0
    def setUp(self):
        img0 = scipy.misc.lena()
        ny, nx = img0.shape
        row_shift = randint(-ny/2, ny/2)
        col_shift = randint(-nx/2, nx/2)
        img1 = mm.circshift(img0, (row_shift, col_shift))

        self.img0 = img0
        self.img1 = img1
        self.nx = nx
        self.ny = ny
        self.col_shift = col_shift
        self.row_shift = row_shift
Ejemplo n.º 6
0
    def setUp(self):
        img0 = scipy.misc.lena()
        ny, nx = img0.shape
        row_shift = randint(-ny / 2, ny / 2)
        col_shift = randint(-nx / 2, nx / 2)
        img1 = mm.circshift(img0, (row_shift, col_shift))

        self.img0 = img0
        self.img1 = img1
        self.nx = nx
        self.ny = ny
        self.col_shift = col_shift
        self.row_shift = row_shift
Ejemplo n.º 7
0
    def test_upsample_1(self):
        """Test algorithm without subpixel registration."""

        img0 = scipy.misc.lena()
        ny, nx = img0.shape
        row_shift = randint(-ny/2, ny/2)
        col_shift = randint(-nx/2, nx/2)
        row_shift = 10
        col_shift = 27
        img1 = mm.circshift(img0, (row_shift, col_shift))
        img1 = abs(img1)

        if PLOTTING:
            subplot(211)
            imshow(img0)
            title('original')
            subplot(212)
            imshow(img1)
            title('shifted by {}x{}'.format(row_shift, col_shift))
            show()

        val, row, col = mm.register(img0, img1)
        self.assertEqual(row, row_shift)
        self.assertEqual(col, col_shift)
Ejemplo n.º 8
0
    def test_upsample_1(self):
        """Test algorithm without subpixel registration."""

        img0 = scipy.misc.lena()
        ny, nx = img0.shape
        row_shift = randint(-ny / 2, ny / 2)
        col_shift = randint(-nx / 2, nx / 2)
        row_shift = 10
        col_shift = 27
        img1 = mm.circshift(img0, (row_shift, col_shift))
        img1 = abs(img1)

        if PLOTTING:
            subplot(211)
            imshow(img0)
            title('original')
            subplot(212)
            imshow(img1)
            title('shifted by {}x{}'.format(row_shift, col_shift))
            show()

        val, row, col = mm.register(img0, img1)
        self.assertEqual(row, row_shift)
        self.assertEqual(col, col_shift)
Ejemplo n.º 9
0
 def test_allones(self):
     N = randint(2, 30)
     shift = 2*N*rand()
     x = ones([N])
     xx = mm.circshift(x, shift)
     self.assertArraysClose(x, xx)
Ejemplo n.º 10
0
 def test_single_dim_integer_shift(self):
     a = arange(6)
     shift = 1
     a_s = around(mm.circshift(a, shift))
     self.assertArraysClose(a_s, array([5, 0, 1, 2, 3, 4]))
Ejemplo n.º 11
0
 def test_allones(self):
     N = randint(2, 30)
     shift = 2 * N * rand()
     x = ones([N])
     xx = mm.circshift(x, shift)
     self.assertArraysClose(x, xx)
Ejemplo n.º 12
0
 def test_single_dim_integer_shift(self):
     a = arange(6)
     shift = 1
     a_s = around(mm.circshift(a, shift))
     self.assertArraysClose(a_s, array([5, 0, 1, 2, 3, 4]))