cvtColor() can give wrong results for float Lab -> RGB conversion (Bug #2368)
Description
After the intermediate conversion to linear RGB, the components may be slightly negative. That breaks the gamma table lookup to sRGB. There's probably a symmetric issue if the components exceed 1.0. These values should be clamped to [0,1] before spline interpolation, or the interpolation function should clamp to [0,n].
Below the output green channel should be 0, but has the garbage value 4.71:
>>> import cv2 >>> import numpy as np >>> lab = np.array([[[41, 102, 54]]], dtype=np.float32) >>> cv2.cvtColor(lab, cv2.COLOR_LAB2RGB) array([[[ 0.92965227, 4.714746 , 0.07073302]]], dtype=float32) >>> cv2.cvtColor(lab, cv2.COLOR_LAB2LRGB) array([[[ 0.84736991, -0.08669905, 0.00606543]]], dtype=float32)
Encountered with OpenCV 2.4.2 as distributed with ROS Fuerte, on Linux x64.
Associated revisions
Merge pull request #2368 from asmorkalov:ocv_gcc48_warning_fix
History
Updated by Vadim Pisarevsky over 12 years ago
- Target version deleted ()
- Assignee deleted (
Vadim Pisarevsky)
Updated by Vadim Pisarevsky over 12 years ago
- Assignee set to Ilya Lavrenov
Updated by Ilya Lavrenov over 12 years ago
Thanks for the report!
Fixed in 5f9aed
- Status changed from Open to Done
Updated by Andrey Kamaev about 12 years ago
- Target version set to 2.4.3