예제 #1
0
 def test_rgb_lch_roundtrip(self):
     rgb = img_as_float(self.img_rgb)
     lab = rgb2lab(rgb)
     lch = lab2lch(lab)
     lab2 = lch2lab(lch)
     rgb2 = lab2rgb(lab2)
     assert_array_almost_equal(rgb, rgb2)
예제 #2
0
    def test_rgb2lab_brucelindbloom(self):
        """
        Test the RGB->Lab conversion by comparing to the calculator on the
        authoritative Bruce Lindbloom
        [website](http://brucelindbloom.com/index.html?ColorCalculator.html).
        """
        # Obtained with D65 white point, sRGB model and gamma
        # ftm: off
        gt_for_colbars = cp.asarray([
            [100, 0, 0],
            [97.1393, -21.5537, 94.4780],
            [91.1132, -48.0875, -14.1312],
            [87.7347, -86.1827, 83.1793],
            [60.3242, 98.2343, -60.8249],
            [53.2408, 80.0925, 67.2032],
            [32.2970, 79.1875, -107.8602],
            [0, 0, 0]]).T

        # ftm: on
        gt_array = cp.swapaxes(gt_for_colbars.reshape(3, 4, 2), 0, 2)
        assert_array_almost_equal(rgb2lab(self.colbars_array), gt_array,
                                  decimal=2)
예제 #3
0
 def _get_lab0(self):
     rgb = img_as_float(self.img_rgb[:1, :1, :])
     return rgb2lab(rgb)[0, 0, :]
예제 #4
0
 def test_lab_lch_roundtrip(self):
     rgb = img_as_float(self.img_rgb)
     lab = rgb2lab(rgb)
     lab2 = lch2lab(lab2lch(lab))
     assert_array_almost_equal(lab2, lab)
예제 #5
0
    def test_rgb2lab_dtype(self):
        img = self.colbars_array.astype('float64')
        img32 = img.astype('float32')

        assert rgb2lab(img).dtype == img.dtype
        assert rgb2lab(img32).dtype == img32.dtype
예제 #6
0
 def test_lab_rgb_roundtrip(self):
     img_rgb = img_as_float(self.img_rgb)
     assert_array_almost_equal(lab2rgb(rgb2lab(img_rgb)), img_rgb)