From 46f6733fc9f108638c2a6dc536c1f633b7eb0190 Mon Sep 17 00:00:00 2001 From: Dharhas Pothina Date: Fri, 20 Jul 2012 17:00:36 -0500 Subject: [PATCH 1/6] added xyz2lab, lab2xyz not quite working --- skimage/color/colorconv.py | 149 ++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 1 deletion(-) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 5e2fa5e1..7f8687db 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -44,7 +44,9 @@ References from __future__ import division __all__ = ['convert_colorspace', 'rgb2hsv', 'hsv2rgb', 'rgb2xyz', 'xyz2rgb', - 'rgb2rgbcie', 'rgbcie2rgb', 'rgb2grey', 'rgb2gray', 'gray2rgb'] + 'rgb2rgbcie', 'rgbcie2rgb', 'rgb2grey', 'rgb2gray', 'gray2rgb', + 'xyz2lab', 'lab2xyz', + ] __docformat__ = "restructuredtext en" @@ -543,3 +545,148 @@ def gray2rgb(image): M, N = image.shape return np.dstack((image, image, image)) + + +#---------------------- +# Constants for CIE LAB +#---------------------- +_one_third = 1.0 / 3.0 +_sixteen_hundred_sixteenth = 16.0 / 116.0 +# Observer= 2A, Illuminant= D65 +_xref = 0.95047 +_yref = 1.0 +_zref = 1.08883 +_inv_xref = 1.0 / _xref +_inv_yref = 1.0 / _yref +_inv_zref = 1.0 / _zref + +#-------------------------------------------------------------- +# The conversion functions that make use of the constants above +#-------------------------------------------------------------- + +def xyz2lab(xyz): + """XYZ to CIE-LAB color space conversion. + + Parameters + ---------- + xyz : array_like + The image in XYZ format, in a 3-D array of shape (.., .., 3). + + Returns + ------- + out : ndarray + The image in CIE-LAB format, in a 3-D array of shape (.., .., 3). + + Raises + ------ + ValueError + If `xyz` is not a 3-D array of shape (.., .., 3). + + Notes + ----- + Observer= 2A, Illuminant= D65 + CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883 + + References + ---------- + .. [1] http://www.easyrgb.com/index.php?X=MATH&H=07#text7 + .. [2] http://en.wikipedia.org/wiki/Lab_color_space + + Examples + -------- + >>> import os + >>> from skimage import data_dir + >>> from skimage.color import rgb2xyz, xyz2lab + >>> from skimage.io import imread + >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> lena_xyz = rgb2xyz(lena) + >>> lena_lab = xyz2lab(lena_xyz) + """ + arr = _prepare_colorarray(xyz) + out = np.empty_like(arr) + + # scale by CIE XYZ tristimulus values of the reference white point + x, y, z = arr[:, :, 0], arr[:, :, 1], arr[:, :, 2] + x *= _inv_xref + y *= _inv_yref + z *= _inv_zref + + # Nonlinear distortion and linear transformation + mask = arr > 0.008856 + arr[mask] = np.power(arr[mask], _one_third) + arr[~mask] = 7.787 * arr[~mask] + _sixteen_hundred_sixteenth + + # Vector scaling + L = (116. * y) - 16. + a = 500.0 * (x - y) + b = 200.0 * (y - z) + + # -- output + out[:, :, 0] = L + out[:, :, 1] = a + out[:, :, 2] = b + + # remove NaN + out[np.isnan(out)] = 0 + + return out + +def lab2xyz(lab): + """CIE-LAB to XYZcolor space conversion. + + Parameters + ---------- + lab : array_like + The image in lab format, in a 3-D array of shape (.., .., 3). + + Returns + ------- + out : ndarray + The image in XYZ format, in a 3-D array of shape (.., .., 3). + + Raises + ------ + ValueError + If `lab` is not a 3-D array of shape (.., .., 3). + + Notes + ----- + Observer= 2A, Illuminant= D65 + CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883 + + References + ---------- + .. [1] http://www.easyrgb.com/index.php?X=MATH&H=07#text7 + .. [2] http://en.wikipedia.org/wiki/Lab_color_space + + """ + + arr = _prepare_colorarray(lab) + out = np.empty_like(arr) + + L, a, b = arr[:, :, 0], arr[:, :, 1], arr[:, :, 2] + y = (L + 16.) / 116. + x = a / 500. + y + z = y - b / 200. + + out[:, :, 0] = x + out[:, :, 1] = y + out[:, :, 2] = z + + out_cube = np.power(out,3) + mask = out > 0.206893 + out[mask] = np.power(out[mask], 3.) + out[~mask] = (out[~mask] - _sixteen_hundred_sixteenth) / 7.787 + + # rescale Observer= 2 deg, Illuminant= D65 + #x, y, z = out[:, :, 0], out[:, :, 1], out[:, :, 2] + out[:, :, 0] *= _xref + out[:, :, 1] *= _yref + out[:, :, 2] *= _zref + + # remove NaN + out[np.isnan(out)] = 0 + + return out + + From fedad0d82675b9ca61a1aab0f883efb475960942 Mon Sep 17 00:00:00 2001 From: Dharhas Pothina Date: Fri, 20 Jul 2012 18:45:56 -0500 Subject: [PATCH 2/6] fixed array being modified in place. lab2xyz working --- skimage/color/colorconv.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 7f8687db..352e3039 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -553,13 +553,15 @@ def gray2rgb(image): _one_third = 1.0 / 3.0 _sixteen_hundred_sixteenth = 16.0 / 116.0 # Observer= 2A, Illuminant= D65 -_xref = 0.95047 -_yref = 1.0 -_zref = 1.08883 +_xref = 0.95047 +_yref = 1. +_zref = 1.08883 _inv_xref = 1.0 / _xref _inv_yref = 1.0 / _yref _inv_zref = 1.0 / _zref + + #-------------------------------------------------------------- # The conversion functions that make use of the constants above #-------------------------------------------------------------- @@ -602,7 +604,7 @@ def xyz2lab(xyz): >>> lena_xyz = rgb2xyz(lena) >>> lena_lab = xyz2lab(lena_xyz) """ - arr = _prepare_colorarray(xyz) + arr = _prepare_colorarray(xyz).copy() out = np.empty_like(arr) # scale by CIE XYZ tristimulus values of the reference white point @@ -661,22 +663,21 @@ def lab2xyz(lab): """ - arr = _prepare_colorarray(lab) + arr = _prepare_colorarray(lab).copy() out = np.empty_like(arr) L, a, b = arr[:, :, 0], arr[:, :, 1], arr[:, :, 2] y = (L + 16.) / 116. - x = a / 500. + y - z = y - b / 200. + x = (a / 500.) + y + z = y - (b / 200.) out[:, :, 0] = x out[:, :, 1] = y out[:, :, 2] = z - out_cube = np.power(out,3) - mask = out > 0.206893 + mask = out > 0.2068966 out[mask] = np.power(out[mask], 3.) - out[~mask] = (out[~mask] - _sixteen_hundred_sixteenth) / 7.787 + out[~mask] = (out[~mask] - _sixteen_hundred_sixteenth) / 7.787*1000 # rescale Observer= 2 deg, Illuminant= D65 #x, y, z = out[:, :, 0], out[:, :, 1], out[:, :, 2] From 8cd912a89467835be5a79d6b1620d16c0563d17d Mon Sep 17 00:00:00 2001 From: Dharhas Pothina Date: Sat, 21 Jul 2012 09:10:05 -0500 Subject: [PATCH 3/6] tests added for xyz2lab and lab2xyz --- skimage/color/tests/test_colorconv.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index cfe81c58..7be4f454 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -23,7 +23,8 @@ from skimage.color import ( rgb2xyz, xyz2rgb, rgb2rgbcie, rgbcie2rgb, convert_colorspace, - rgb2grey, gray2rgb + rgb2grey, gray2rgb, + xyz2lab, lab2xyz, ) from skimage import data_dir @@ -43,6 +44,20 @@ class TestColorconv(TestCase): colbars_point75 = colbars * 0.75 colbars_point75_array = np.swapaxes(colbars_point75.reshape(3, 4, 2), 0, 2) + xyz_array = np.array([[[0.4124, 0.21260, 0.01930]], #red + [[0, 0, 0]], #black + [[.9505, 1., 1.089]], #white + [[.1805, .0722, .9505]], #blue + [[.07719, .15438, .02573]], #green + ]) + + lab_array = np.array([[[53.233, 80.109, 67.220]], #red + [[0.,0.,0.]], #black + [[100.0, 0.005, -0.010]], #white + [[32.303, 79.197, -107.864]], #blue + [[46.229, -51.7, 49.898]], #green + ]) + # RGB to HSV def test_rgb2hsv_conversion(self): rgb = img_as_float(self.img_rgb)[::16, ::16] @@ -149,6 +164,13 @@ class TestColorconv(TestCase): def test_rgb2grey_on_grey(self): rgb2grey(np.random.random((5, 5))) + # test matrices for xyz2lab and lab2xyz generated using http://www.easyrgb.com/index.php?X=CALC + # Note: easyrgb website displays xyz*100 + def test_xyz2lab(self): + assert_array_almost_equal(xyz2lab(self.xyz_array), self.lab_array, decimal=3) + + def test_lab2xyz(self): + assert_array_almost_equal(lab2xyz(self.lab_array), self.xyz_array, decimal=3) def test_gray2rgb(): x = np.array([0, 0.5, 1]) From 3448e419b391e160a985e07718a0642c03e6c98f Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Thu, 26 Jul 2012 22:44:02 +0100 Subject: [PATCH 4/6] ENH slight cleanup, fixed *1000 bug, added test and rgb2lab convenience. --- skimage/color/colorconv.py | 119 +++++++++++++++----------- skimage/color/tests/test_colorconv.py | 35 +++++--- 2 files changed, 91 insertions(+), 63 deletions(-) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 352e3039..ebc18bfb 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -45,7 +45,7 @@ from __future__ import division __all__ = ['convert_colorspace', 'rgb2hsv', 'hsv2rgb', 'rgb2xyz', 'xyz2rgb', 'rgb2rgbcie', 'rgbcie2rgb', 'rgb2grey', 'rgb2gray', 'gray2rgb', - 'xyz2lab', 'lab2xyz', + 'xyz2lab', 'lab2xyz', 'lab2rgb', 'rgb2lab' ] __docformat__ = "restructuredtext en" @@ -547,21 +547,6 @@ def gray2rgb(image): return np.dstack((image, image, image)) -#---------------------- -# Constants for CIE LAB -#---------------------- -_one_third = 1.0 / 3.0 -_sixteen_hundred_sixteenth = 16.0 / 116.0 -# Observer= 2A, Illuminant= D65 -_xref = 0.95047 -_yref = 1. -_zref = 1.08883 -_inv_xref = 1.0 / _xref -_inv_yref = 1.0 / _yref -_inv_zref = 1.0 / _zref - - - #-------------------------------------------------------------- # The conversion functions that make use of the constants above #-------------------------------------------------------------- @@ -588,50 +573,47 @@ def xyz2lab(xyz): ----- Observer= 2A, Illuminant= D65 CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883 - + References ---------- .. [1] http://www.easyrgb.com/index.php?X=MATH&H=07#text7 .. [2] http://en.wikipedia.org/wiki/Lab_color_space - + Examples -------- >>> import os - >>> from skimage import data_dir + >>> from skimage import data_dir >>> from skimage.color import rgb2xyz, xyz2lab >>> from skimage.io import imread >>> lena = imread(os.path.join(data_dir, 'lena.png')) >>> lena_xyz = rgb2xyz(lena) >>> lena_lab = xyz2lab(lena_xyz) """ - arr = _prepare_colorarray(xyz).copy() - out = np.empty_like(arr) + arr = _prepare_colorarray(xyz) + + #---------------------- + # Constants for CIE LAB + #---------------------- + # Observer= 2A, Illuminant= D65 + ref_white = np.array([0.95047, 1., 1.08883]) # scale by CIE XYZ tristimulus values of the reference white point - x, y, z = arr[:, :, 0], arr[:, :, 1], arr[:, :, 2] - x *= _inv_xref - y *= _inv_yref - z *= _inv_zref + arr = arr / ref_white # Nonlinear distortion and linear transformation mask = arr > 0.008856 - arr[mask] = np.power(arr[mask], _one_third) - arr[~mask] = 7.787 * arr[~mask] + _sixteen_hundred_sixteenth - + arr[mask] = np.power(arr[mask], 1. / 3.) + arr[~mask] = 7.787 * arr[~mask] + 16. / 116. + + x, y, z = arr[:, :, 0], arr[:, :, 1], arr[:, :, 2] + # Vector scaling L = (116. * y) - 16. a = 500.0 * (x - y) b = 200.0 * (y - z) - # -- output - out[:, :, 0] = L - out[:, :, 1] = a - out[:, :, 2] = b + return np.dstack([L, a, b]) - # remove NaN - out[np.isnan(out)] = 0 - - return out def lab2xyz(lab): """CIE-LAB to XYZcolor space conversion. @@ -664,30 +646,69 @@ def lab2xyz(lab): """ arr = _prepare_colorarray(lab).copy() - out = np.empty_like(arr) L, a, b = arr[:, :, 0], arr[:, :, 1], arr[:, :, 2] y = (L + 16.) / 116. x = (a / 500.) + y z = y - (b / 200.) - out[:, :, 0] = x - out[:, :, 1] = y - out[:, :, 2] = z + out = np.dstack([x, y, z]) mask = out > 0.2068966 out[mask] = np.power(out[mask], 3.) - out[~mask] = (out[~mask] - _sixteen_hundred_sixteenth) / 7.787*1000 + out[~mask] = (out[~mask] - 16.0 / 116.) / 7.787 # rescale Observer= 2 deg, Illuminant= D65 - #x, y, z = out[:, :, 0], out[:, :, 1], out[:, :, 2] - out[:, :, 0] *= _xref - out[:, :, 1] *= _yref - out[:, :, 2] *= _zref - - # remove NaN - out[np.isnan(out)] = 0 - + ref_white = np.array([0.95047, 1., 1.08883]) + out *= ref_white return out +def rgb2lab(rgb): + """RGB to lab color space conversion. + + Parameters + ---------- + rgb : array_like + The image in RGB format, in a 3-D array of shape (.., .., 3). + + Returns + ------- + out : ndarray + The image in Lab format, in a 3-D array of shape (.., .., 3). + + Raises + ------ + ValueError + If `rgb` is not a 3-D array of shape (.., .., 3). + + Notes + ----- + This function uses rgb2xyz and xyz2lab. + """ + return xyz2lab(rgb2xyz(rgb)) + + +def lab2rgb(lab): + """Lab to RGB color space conversion. + + Parameters + ---------- + rgb : array_like + The image in Lab format, in a 3-D array of shape (.., .., 3). + + Returns + ------- + out : ndarray + The image in RGB format, in a 3-D array of shape (.., .., 3). + + Raises + ------ + ValueError + If `lab` is not a 3-D array of shape (.., .., 3). + + Notes + ----- + This function uses lab2xyz and xyz2rgb. + """ + return xyz2rgb(lab2xyz(lab)) diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index 7be4f454..316d801a 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -25,6 +25,7 @@ from skimage.color import ( convert_colorspace, rgb2grey, gray2rgb, xyz2lab, lab2xyz, + lab2rgb, rgb2lab ) from skimage import data_dir @@ -44,18 +45,17 @@ class TestColorconv(TestCase): colbars_point75 = colbars * 0.75 colbars_point75_array = np.swapaxes(colbars_point75.reshape(3, 4, 2), 0, 2) - xyz_array = np.array([[[0.4124, 0.21260, 0.01930]], #red - [[0, 0, 0]], #black - [[.9505, 1., 1.089]], #white - [[.1805, .0722, .9505]], #blue - [[.07719, .15438, .02573]], #green + xyz_array = np.array([[[0.4124, 0.21260, 0.01930]], # red + [[0, 0, 0]], # black + [[.9505, 1., 1.089]], # white + [[.1805, .0722, .9505]], # blue + [[.07719, .15438, .02573]], # green ]) - - lab_array = np.array([[[53.233, 80.109, 67.220]], #red - [[0.,0.,0.]], #black - [[100.0, 0.005, -0.010]], #white - [[32.303, 79.197, -107.864]], #blue - [[46.229, -51.7, 49.898]], #green + lab_array = np.array([[[53.233, 80.109, 67.220]], # red + [[0., 0., 0.]], # black + [[100.0, 0.005, -0.010]], # white + [[32.303, 79.197, -107.864]], # blue + [[46.229, -51.7, 49.898]], # green ]) # RGB to HSV @@ -167,10 +167,17 @@ class TestColorconv(TestCase): # test matrices for xyz2lab and lab2xyz generated using http://www.easyrgb.com/index.php?X=CALC # Note: easyrgb website displays xyz*100 def test_xyz2lab(self): - assert_array_almost_equal(xyz2lab(self.xyz_array), self.lab_array, decimal=3) + assert_array_almost_equal(xyz2lab(self.xyz_array), + self.lab_array, decimal=3) + + def test_lab2xyz(self): + assert_array_almost_equal(lab2xyz(self.lab_array), + self.xyz_array, decimal=3) + + def test_lab_rgb_roundtrip(self): + img_rgb = img_as_float(self.img_rgb) + assert_array_almost_equal(lab2rgb(rgb2lab(img_rgb)), img_rgb) - def test_lab2xyz(self): - assert_array_almost_equal(lab2xyz(self.lab_array), self.xyz_array, decimal=3) def test_gray2rgb(): x = np.array([0, 0.5, 1]) From b54817c5b39e46ea71bd905d04912dda0b2f640c Mon Sep 17 00:00:00 2001 From: Dharhas Pothina Date: Mon, 30 Jul 2012 10:07:33 -0500 Subject: [PATCH 5/6] minor cleanup of comments & move ref_white to global lab_ref_white --- skimage/color/colorconv.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index ebc18bfb..75b7649b 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -288,6 +288,9 @@ grey_from_rgb = np.array([[0.2125, 0.7154, 0.0721], [0, 0, 0], [0, 0, 0]]) +# CIE LAB constants for Observer= 2A, Illuminant= D65 +lab_ref_white = np.array([0.95047, 1., 1.08883]) + #------------------------------------------------------------- # The conversion functions that make use of the matrices above #------------------------------------------------------------- @@ -547,10 +550,6 @@ def gray2rgb(image): return np.dstack((image, image, image)) -#-------------------------------------------------------------- -# The conversion functions that make use of the constants above -#-------------------------------------------------------------- - def xyz2lab(xyz): """XYZ to CIE-LAB color space conversion. @@ -581,24 +580,16 @@ def xyz2lab(xyz): Examples -------- - >>> import os - >>> from skimage import data_dir + >>> from skimage import data >>> from skimage.color import rgb2xyz, xyz2lab - >>> from skimage.io import imread - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> lena = data.lena() >>> lena_xyz = rgb2xyz(lena) >>> lena_lab = xyz2lab(lena_xyz) """ arr = _prepare_colorarray(xyz) - #---------------------- - # Constants for CIE LAB - #---------------------- - # Observer= 2A, Illuminant= D65 - ref_white = np.array([0.95047, 1., 1.08883]) - # scale by CIE XYZ tristimulus values of the reference white point - arr = arr / ref_white + arr = arr / lab_ref_white # Nonlinear distortion and linear transformation mask = arr > 0.008856 @@ -659,8 +650,7 @@ def lab2xyz(lab): out[~mask] = (out[~mask] - 16.0 / 116.) / 7.787 # rescale Observer= 2 deg, Illuminant= D65 - ref_white = np.array([0.95047, 1., 1.08883]) - out *= ref_white + out *= lab_ref_white return out From f74ca8685b165ab99dd7a70fa40d4c6e2febd4be Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Tue, 31 Jul 2012 22:00:32 +0100 Subject: [PATCH 6/6] MISC minor cleanup in doctests / examples --- skimage/color/colorconv.py | 61 ++++++++++++-------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 75b7649b..2640f3be 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -83,11 +83,8 @@ def convert_colorspace(arr, fromspace, tospace): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> from skimage import data + >>> lena = data.lena() >>> lena_hsv = convert_colorspace(lena, 'RGB', 'HSV') """ fromdict = {'RGB': lambda im: im, 'HSV': hsv2rgb, 'RGB CIE': rgbcie2rgb, @@ -151,11 +148,9 @@ def rgb2hsv(rgb): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> from skimage import color + >>> from skimage import data + >>> lena = data.lena() >>> lena_hsv = color.rgb2hsv(lena) """ arr = _prepare_colorarray(rgb) @@ -226,11 +221,8 @@ def hsv2rgb(hsv): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> from skimage import data + >>> lena = data.lena() >>> lena_hsv = rgb2hsv(lena) >>> lena_rgb = hsv2rgb(lena_hsv) """ @@ -351,14 +343,11 @@ def xyz2rgb(xyz): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread + >>> from skimage import data >>> from skimage.color import rgb2xyz, xyz2rgb - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> lena = data.lena() >>> lena_xyz = rgb2xyz(lena) - >>> lena_rgb = xyz2rgb(lena_hsv) + >>> lena_rgb = xyz2rgb(lena_xyz) """ return _convert(rgb_from_xyz, xyz) @@ -392,11 +381,8 @@ def rgb2xyz(rgb): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> from skimage import data + >>> lena = data.lena() >>> lena_xyz = rgb2xyz(lena) """ return _convert(xyz_from_rgb, rgb) @@ -426,12 +412,9 @@ def rgb2rgbcie(rgb): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread + >>> from skimage import data >>> from skimage.color import rgb2rgbcie - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> lena = data.lena() >>> lena_rgbcie = rgb2rgbcie(lena) """ return _convert(rgbcie_from_rgb, rgb) @@ -461,14 +444,11 @@ def rgbcie2rgb(rgbcie): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread + >>> from skimage import data >>> from skimage.color import rgb2rgbcie, rgbcie2rgb - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> lena = data.lena() >>> lena_rgbcie = rgb2rgbcie(lena) - >>> lena_rgb = rgbcie2rgb(lena_hsv) + >>> lena_rgb = rgbcie2rgb(lena_rgbcie) """ return _convert(rgb_from_rgbcie, rgbcie) @@ -508,12 +488,9 @@ def rgb2grey(rgb): Examples -------- - >>> import os - >>> from skimage import data_dir - >>> from skimage.io import imread >>> from skimage.color import rgb2grey - - >>> lena = imread(os.path.join(data_dir, 'lena.png')) + >>> from skimage import data + >>> lena = data.lena() >>> lena_grey = rgb2grey(lena) """ if rgb.ndim == 2: