def test_yuv(self):
     rgb = np.array([[[1.0, 1.0, 1.0]]])
     assert_array_almost_equal(rgb2yuv(rgb), np.array([[[1, 0, 0]]]))
     assert_array_almost_equal(rgb2yiq(rgb), np.array([[[1, 0, 0]]]))
     assert_array_almost_equal(rgb2ypbpr(rgb), np.array([[[1, 0, 0]]]))
     assert_array_almost_equal(rgb2ycbcr(rgb), np.array([[[235, 128, 128]]]))
     assert_array_almost_equal(rgb2ydbdr(rgb), np.array([[[1, 0, 0]]]))
     rgb = np.array([[[0.0, 1.0, 0.0]]])
     assert_array_almost_equal(rgb2yuv(rgb), np.array([[[0.587, -0.28886916, -0.51496512]]]))
     assert_array_almost_equal(rgb2yiq(rgb), np.array([[[0.587, -0.27455667, -0.52273617]]]))
     assert_array_almost_equal(rgb2ypbpr(rgb), np.array([[[0.587, -0.331264, -0.418688]]]))
     assert_array_almost_equal(rgb2ycbcr(rgb), np.array([[[144.553,   53.797,   34.214]]]))
     assert_array_almost_equal(rgb2ydbdr(rgb), np.array([[[0.587, -0.883, 1.116]]]))
 def test_yuv(self):
     rgb = np.array([[[1.0, 1.0, 1.0]]])
     assert_array_almost_equal(rgb2yuv(rgb), np.array([[[1, 0, 0]]]))
     assert_array_almost_equal(rgb2yiq(rgb), np.array([[[1, 0, 0]]]))
     assert_array_almost_equal(rgb2ypbpr(rgb), np.array([[[1, 0, 0]]]))
     assert_array_almost_equal(rgb2ycbcr(rgb), np.array([[[235, 128, 128]]]))
     assert_array_almost_equal(rgb2ydbdr(rgb), np.array([[[1, 0, 0]]]))
     rgb = np.array([[[0.0, 1.0, 0.0]]])
     assert_array_almost_equal(rgb2yuv(rgb), np.array([[[0.587, -0.28886916, -0.51496512]]]))
     assert_array_almost_equal(rgb2yiq(rgb), np.array([[[0.587, -0.27455667, -0.52273617]]]))
     assert_array_almost_equal(rgb2ypbpr(rgb), np.array([[[0.587, -0.331264, -0.418688]]]))
     assert_array_almost_equal(rgb2ycbcr(rgb), np.array([[[144.553,   53.797,   34.214]]]))
     assert_array_almost_equal(rgb2ydbdr(rgb), np.array([[[0.587, -0.883, 1.116]]]))
Exemple #3
0
 def test_yuv_roundtrip(self):
     img_rgb = img_as_float(self.img_rgb)[::16, ::16]
     assert_array_almost_equal(yuv2rgb(rgb2yuv(img_rgb)), img_rgb)
     assert_array_almost_equal(yiq2rgb(rgb2yiq(img_rgb)), img_rgb)
     assert_array_almost_equal(ypbpr2rgb(rgb2ypbpr(img_rgb)), img_rgb)
     assert_array_almost_equal(ycbcr2rgb(rgb2ycbcr(img_rgb)), img_rgb)
     assert_array_almost_equal(ydbdr2rgb(rgb2ydbdr(img_rgb)), img_rgb)
 def test_yuv_roundtrip(self):
     img_rgb = img_as_float(self.img_rgb)[::16, ::16]
     assert_array_almost_equal(yuv2rgb(rgb2yuv(img_rgb)), img_rgb)
     assert_array_almost_equal(yiq2rgb(rgb2yiq(img_rgb)), img_rgb)
     assert_array_almost_equal(ypbpr2rgb(rgb2ypbpr(img_rgb)), img_rgb)
     assert_array_almost_equal(ycbcr2rgb(rgb2ycbcr(img_rgb)), img_rgb)
     assert_array_almost_equal(ydbdr2rgb(rgb2ydbdr(img_rgb)), img_rgb)
 def test_yuv_roundtrip(self, channel_axis):
     img_rgb = img_as_float(self.img_rgb)[::16, ::16]
     img_rgb = np.moveaxis(img_rgb, source=-1, destination=channel_axis)
     assert_array_almost_equal(
         yuv2rgb(rgb2yuv(img_rgb, channel_axis=channel_axis),
                 channel_axis=channel_axis), img_rgb)
     assert_array_almost_equal(
         yiq2rgb(rgb2yiq(img_rgb, channel_axis=channel_axis),
                 channel_axis=channel_axis), img_rgb)
     assert_array_almost_equal(
         ypbpr2rgb(rgb2ypbpr(img_rgb, channel_axis=channel_axis),
                   channel_axis=channel_axis), img_rgb)
     assert_array_almost_equal(
         ycbcr2rgb(rgb2ycbcr(img_rgb, channel_axis=channel_axis),
                   channel_axis=channel_axis), img_rgb)
     assert_array_almost_equal(
         ydbdr2rgb(rgb2ydbdr(img_rgb, channel_axis=channel_axis),
                   channel_axis=channel_axis), img_rgb)
Exemple #6
0
 def __call__(self, img):
     img = np.asarray(img, np.uint8)
     img = color.rgb2ydbdr(img)
     return img