cvtColor() can give wrong results for float Lab -> RGB conversion (Bug #2368)


Added by Patrick Mihelich over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-09-19
Priority:Normal Due date:
Assignee:Ilya Lavrenov % Done:

0%

Category:imgproc, video
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

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

Revision ce42593f
Added by Roman Donchenko about 11 years ago

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

Also available in: Atom PDF