예제 #1
0
 def test_02_02_must_be_binary_throws(self):
     x = cpi.ImageSet(0, {}, {})
     x.add(IMAGE_NAME, cpi.Image(np.zeros((10, 20), float)))
     self.assertRaises(ValueError,
                       x.get_image,
                       IMAGE_NAME,
                       must_be_binary=True)
예제 #2
0
 def test_05_03_must_be_rgb_throws_5_channel(self):
     x = cpi.ImageSet(0, {}, {})
     np.random.seed(22)
     x.add(IMAGE_NAME, cpi.Image(np.random.uniform(size=(10, 20, 5))))
     self.assertRaises(ValueError,
                       x.get_image,
                       IMAGE_NAME,
                       must_be_rgb=True)
예제 #3
0
 def test_04_02_must_be_color_throws(self):
     x = cpi.ImageSet(0, {}, {})
     np.random.seed(22)
     x.add(IMAGE_NAME, cpi.Image(np.random.uniform(size=(10, 20))))
     self.assertRaises(ValueError,
                       x.get_image,
                       IMAGE_NAME,
                       must_be_color=True)
예제 #4
0
 def test_05_04_must_be_rgb_alpha(self):
     x = cpi.ImageSet(0, {}, {})
     x.add(IMAGE_NAME, cpi.Image(np.zeros((10, 20, 4), float)))
     image = x.get_image(IMAGE_NAME, must_be_rgb=True)
     self.assertEqual(tuple(image.pixel_data.shape), (10, 20, 3))
예제 #5
0
 def test_03_03_must_be_gray_color(self):
     x = cpi.ImageSet(0, {}, {})
     x.add(IMAGE_NAME, cpi.Image(np.zeros((10, 20, 3), float)))
     image = x.get_image(IMAGE_NAME, must_be_grayscale=True)
     self.assertEqual(tuple(image.pixel_data.shape), (10, 20))
예제 #6
0
 def test_02_01_must_be_binary(self):
     x = cpi.ImageSet(0, {}, {})
     x.add(IMAGE_NAME, cpi.Image(np.zeros((10, 20), bool)))
     image = x.get_image(IMAGE_NAME, must_be_binary=True)
     self.assertEqual(tuple(image.pixel_data.shape), (10, 20))
예제 #7
0
 def test_01_02_get_image(self):
     x = cpi.ImageSet(0, {}, {})
     x.add(IMAGE_NAME, cpi.Image(np.zeros((10, 20))))
     image = x.get_image(IMAGE_NAME)
     self.assertEqual(tuple(image.pixel_data.shape), (10, 20))
예제 #8
0
 def test_01_01_add(self):
     x = cpi.ImageSet(0, {}, {})
     x.add(IMAGE_NAME, cpi.Image(np.zeros((10, 20))))
     self.assertEqual(len(x.providers), 1)
     self.assertEqual(x.providers[0].name, IMAGE_NAME)