From 6097565337daf0efbb5fee23608a79b932c23f0d Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 19 Oct 2009 14:45:33 +0200 Subject: [PATCH] Add note on loss of precision. --- scikits/image/color/colorconv.py | 18 ++++++++++++++++++ scikits/image/color/tests/test_colorconv.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/scikits/image/color/colorconv.py b/scikits/image/color/colorconv.py index 9130738a..065f1d31 100644 --- a/scikits/image/color/colorconv.py +++ b/scikits/image/color/colorconv.py @@ -31,6 +31,15 @@ def rgb2hsv(rgb): ValueError If `rgb` is not a 3-D array of shape (.., .., 3). + Notes + ----- + Conversion between RGB and HSV color spaces results in some loss of + precision, due to integer arithmetic and rounding [1]_. + + References + ---------- + .. [1] http://en.wikipedia.org/wiki/HSL_and_HSV + Examples -------- >>> import os @@ -102,6 +111,15 @@ def hsv2rgb(hsv): ValueError If `hsv` is not a 3-D array of shape (.., .., 3). + Notes + ----- + Conversion between RGB and HSV color spaces results in some loss of + precision, due to integer arithmetic and rounding [1]_. + + References + ---------- + .. [1] http://en.wikipedia.org/wiki/HSL_and_HSV + Examples -------- >>> import os diff --git a/scikits/image/color/tests/test_colorconv.py b/scikits/image/color/tests/test_colorconv.py index f40dcec5..67f641bb 100644 --- a/scikits/image/color/tests/test_colorconv.py +++ b/scikits/image/color/tests/test_colorconv.py @@ -54,7 +54,7 @@ class TestColorconv(TestCase): hsv = np.array([colorsys.rgb_to_hsv(pt[0], pt[1], pt[2]) for pt in rgb.reshape(-1, 3)]).reshape(rgb.shape) # convert back to RGB and compare with original. - # float32 -> relative precision about 1e-6 + # relative precision for RGB -> HSV roundtrip is about 1e-6 assert_almost_equal(rgb, hsv2rgb(hsv), decimal=4) def test_hsv2rgb_error_grayscale(self):