예제 #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))
예제 #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))
예제 #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)
예제 #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)
예제 #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
예제 #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
예제 #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)
예제 #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)
예제 #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)
예제 #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]))
예제 #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)
예제 #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]))