def test_translationpositive1_2(self):
     image = np.array(io.imread('images/sample1024x1024.jpg'),
                      dtype=np.float)
     tf_image = idct2(translation(dct2(image), 100, axis=1))
     image[:, 100:] = image[:, :-100]
     image[:, :100] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
 def test_idct2_3(self):
     image = np.array(io.imread('images/sample2048x2048.jpg'),
                      dtype=np.float)
     idct_image = idct2(image)
     blocks = skimage.util.view_as_blocks(image, (8, 8))
     blocks[:] = idctn(blocks, axes=(2, 3), norm='ortho')
     self.assertTrue(np.max(np.abs(image - idct_image)) < 1e-10)
 def test_translationnegative1_3(self):
     image = np.array(io.imread('images/sample2048x2048.jpg'),
                      dtype=np.float)
     tf_image = idct2(translation(dct2(image), -100, axis=1))
     image[:, :-100] = image[:, 100:]
     image[:, -100:] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
 def test_translationnegative0_2(self):
     image = np.array(io.imread('images/sample1024x1024.jpg'),
                      dtype=np.float)
     tf_image = idct2(translation(dct2(image), -100, axis=0))
     image[:-100, :] = image[100:, :]
     image[-100:, :] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
Exemple #5
0
 def test_mask_small_3(self):
     image = np.array(io.imread('images/sample2048x2048.jpg'),
                      dtype=np.float)
     ulx, lrx, uly, lry = 104, 112, 104, 112
     tf_image = idct2(mask(dct2(image), ulx=ulx, lrx=lrx, uly=uly, lry=lry))
     image[ulx:lrx, uly:lry] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
Exemple #6
0
 def test_mask_horizontal_2(self):
     image = np.array(io.imread('images/sample1024x1024.jpg'),
                      dtype=np.float)
     ulx, lrx, uly, lry = 105, 108, 200, 304
     tf_image = idct2(mask(dct2(image), ulx=ulx, lrx=lrx, uly=uly, lry=lry))
     image[ulx:lrx, uly:lry] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
Exemple #7
0
 def test_mask_small_1(self):
     image = np.array(io.imread('images/sample512x512.jpg'), dtype=np.float)
     for _ in range(100):
         original_image = image.copy()
         ulx = random.randint(0, image.shape[0] - 1)
         uly = random.randint(0, image.shape[1] - 1)
         lrx = random.randint(ulx + 1, image.shape[0])
         lry = random.randint(uly + 1, image.shape[1])
         tf_image = idct2(
             mask(dct2(image), ulx=ulx, lrx=lrx, uly=uly, lry=lry))
         original_image[ulx:lrx, uly:lry] = 0
         self.assertTrue(np.max(np.abs(original_image - tf_image)) < 1e-10)
 def test_dctidct_3(self):
     image = np.array(io.imread('images/sample2048x2048.jpg'),
                      dtype=np.float)
     dct_image = idct2(dct2(image))
     self.assertTrue(np.max(np.abs(image - dct_image)) < 1e-10)
 def test_rotate90_1(self):
     image = np.array(io.imread('images/sample512x512.jpg'), dtype=np.float)
     tf_image = idct2(rotate90(dct2(image)))
     image = np.rot90(image, k=1)
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
 def test_rotate270_3(self):
     image = np.array(io.imread('images/sample2048x2048.jpg'),
                      dtype=np.float)
     tf_image = idct2(rotate270(dct2(image)))
     image = np.rot90(image, k=3)
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
 def test_rotate180_2(self):
     image = np.array(io.imread('images/sample1024x1024.jpg'),
                      dtype=np.float)
     tf_image = idct2(rotate180(dct2(image)))
     image = np.rot90(image, k=2)
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
Exemple #12
0
 def test_reflecion0_1(self):
     image = np.array(io.imread('images/sample512x512.jpg'), dtype=np.float)
     tf_image = idct2(reflection(dct2(image), axis=0))
     image = np.flipud(image)
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
Exemple #13
0
 def test_reflecion1_3(self):
     image = np.array(io.imread('images/sample2048x2048.jpg'),
                      dtype=np.float)
     tf_image = idct2(reflection(dct2(image), axis=1))
     image = np.fliplr(image)
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
 def test_translationpositive0_1(self):
     image = np.array(io.imread('images/sample512x512.jpg'), dtype=np.float)
     tf_image = idct2(translation(dct2(image), 100, axis=0))
     image[100:, :] = image[:-100, :]
     image[:100, :] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
 def test_translationzero_2(self):
     image = np.array(io.imread('images/sample512x512.jpg'), dtype=np.float)
     tf_image = idct2(translation(dct2(image), image.shape[1] * 2, axis=0))
     image[:] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)
Exemple #16
0
 def test_mask_vertical_4(self):
     image = np.array(io.imread('images/sample512x512.jpg'), dtype=np.float)
     ulx, lrx, uly, lry = 200, 304, 104, 112
     tf_image = idct2(mask(dct2(image), ulx=ulx, lrx=lrx, uly=uly, lry=lry))
     image[ulx:lrx, uly:lry] = 0
     self.assertTrue(np.max(np.abs(image - tf_image)) < 1e-10)