Ask Your Question
0

RGB to YUV color space conversion for a image

asked 2014-02-26 05:27:10 -0500

Sajal Gupta gravatar image

Can anybody help me out with the complete method/code/inbuilt library function for converting an rgb mat image to an yuv color space.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-02-26 08:05:30 -0500

updated 2014-02-26 08:12:35 -0500

It is very simple, you just have to know that YUV is as good as the same as YCrCb color space, the second one is for digital tv compared to YUV being for analogue tv signals, but the results are quite similar.

Mat original_image = imread("path_to_image");
Mat converted_image = original.clone();
cvtColor(original_image, converted_image, CV_BGR2YCrCb);

Do mind that openCV doesn't read images in RGB order but in BGR order!

edit flag offensive delete link more

Comments

Isn't it true that the BGR image is 3 channel, 24 bits per pixel and padded with additional 8 bits to make it 32-bits per pixel? How is the YCrCb image representation done? It would be 3 channel (2 for Y, 1 for Cr and 1 for Cb), but would it be 24-bits per pixel or 32-bits per pixel? What exact member variable of converted_image matrix be different from original_image matrix?

Srujan gravatar imageSrujan ( 2016-09-12 20:26:22 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-02-26 05:27:10 -0500

Seen: 11,426 times

Last updated: Feb 26 '14