Add note on loss of precision.

This commit is contained in:
Ralf Gommers
2009-10-19 14:45:33 +02:00
parent 1657a4d1b8
commit 6097565337
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -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
+1 -1
View File
@@ -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):