From c43986d6d603f31b123b32b06e48b099e020ff5a Mon Sep 17 00:00:00 2001 From: spotter Date: Tue, 12 Mar 2013 16:15:41 +0100 Subject: [PATCH] ENH: Adding tests for new stain separation functions. --- skimage/color/colorconv.py | 1 + skimage/color/tests/test_colorconv.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 4d90b67c..2615d63e 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -46,6 +46,7 @@ from __future__ import division __all__ = ['convert_colorspace', 'rgb2hsv', 'hsv2rgb', 'rgb2xyz', 'xyz2rgb', 'rgb2rgbcie', 'rgbcie2rgb', 'rgb2grey', 'rgb2gray', 'gray2rgb', 'xyz2lab', 'lab2xyz', 'lab2rgb', 'rgb2lab', 'rgb2hed', 'hed2rgb', + 'separate_stains', 'combine_stains', 'is_rgb', 'is_gray' ] diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index ddbfa594..3365bb1c 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -22,6 +22,8 @@ from skimage.color import ( rgb2hsv, hsv2rgb, rgb2xyz, xyz2rgb, rgb2hed, hed2rgb, + separate_stains, + combine_stains, rgb2rgbcie, rgbcie2rgb, convert_colorspace, rgb2grey, gray2rgb, @@ -132,6 +134,22 @@ class TestColorconv(TestCase): img_rgb = img_as_float(self.img_rgb) assert_array_almost_equal(hed2rgb(rgb2hed(img_rgb)), img_rgb) + # RGB<->HDX roundtrip with ubyte image + def test_hdx_rgb_roundtrip(self): + from skimage.color.colorconv import hdx_from_rgb, rgb_from_hdx + img_rgb = self.img_rgb + conv = combine_stains(separate_stains(img_rgb, hdx_from_rgb), + rgb_from_hdx) + assert_equal(img_as_ubyte(conv), img_rgb) + + # RGB<->HDX roundtrip with ubyte image + def test_hdx_rgb_roundtrip(self): + from skimage.color.colorconv import hdx_from_rgb, rgb_from_hdx + img_rgb = img_as_float(self.img_rgb) + conv = combine_stains(separate_stains(img_rgb, hdx_from_rgb), + rgb_from_hdx) + assert_array_almost_equal(conv, img_rgb) + # RGB to RGB CIE def test_rgb2rgbcie_conversion(self): gt = np.array([[[ 0.1488856 , 0.18288098, 0.19277574],