OpenCV HLS 颜色 space 范围

OpenCV HLS color space range

看我的代码,为什么控制台的第二行是170 10 121

H170S10,但为什么L121。因为 L 必须小于 100:

如您在 OpenCV documentation

中所见

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

If H<0 then H=H+360. On output 0 <= L <= 1, 0 <= S <= 1, 0 <= H <= 360.

The values are then converted to the destination data type:

  • 8-bit images: S,L are scaled in [0,255], H=H/2, so H range is in [0-180]
  • 32-bit (float) images: value are left as is.

因此,最后,对于 CV_8U 个图像,您将拥有以下值:

H in [0,180]
S,L in [0,255]