Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)