Ask Your Question
0

Can anyone confirm the range of various color spaces such as LAB, LUV and YUV in OpenCV ?

asked 2015-06-02 09:03:20 -0600

Priyaa gravatar image

I am just struggling to find the range of various color spaces I am trying to use in my program in OpenCV. I am sure that HSV range from 0-180 for H, 0-255 for S, 0-255 for V and RGB range from 0-255, 0-255, 0-255 for R,G and B. Please anyone can confirm the range of LAB, LUV and YUV?

edit retag flag offensive close merge delete

Comments

1

this helps ? cvtcolor doc

pklab gravatar imagepklab ( 2015-06-02 14:25:52 -0600 )edit

Thanks for your comment.

Still need some clarification regarding YUV range. It is mentioned in the OpenCV documnetation as Y, Cr, and Cb cover the whole value range.

If so, is it 0-255 for Y,U and V component?

Thanks..

Priyaa gravatar imagePriyaa ( 2015-06-02 15:09:59 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-06-04 13:47:09 -0600

pklab gravatar image

Range depends to datatype.

Again, looking at cvtColor doc

Y = 0.299*R + 0.587*G + 0.114*B
Cr = (R-Y)*0.713 + delta
Cb = (B-Y)*0.564 + delta

Y componets represent luma, its coefficients sums 1 than Y has same range of RGB.

Cr, Cb represent color difference that can be max +/- 50% of the range. Given that delta is defined to be half of data type range, we can conclude that, in OpenCV, Cr and Cb cover whole data type value.

definitely, if data type is 8-bit

Y: 0 -> 255 , Cr:0.58 -> 255.45,  Cb: 0.58 -> 255.42
Cr(min): R=0 G=255 B=255    Cr(max): R=255 G=0 B=0   
Cb(min): R=255 G=255 B=0    Cb(max): R=0 G=0 B=255

I don't know if OpenCV uses integer aritmetic or simply round it. In case of round it becomes

Y: 0 -> 255 , Cr:1 -> 255,  Cb: 1 -> 255

Concluding...may be the doc could be more explict as is for other color conversion

edit flag offensive delete link more

Comments

I would suggest you to add a pull request with the mentioned extra documentation?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-06-05 03:52:58 -0600 )edit

great answer, thanks

VanGog gravatar imageVanGog ( 2016-06-23 21:25:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-02 09:03:20 -0600

Seen: 3,246 times

Last updated: Jun 04 '15