Ask Your Question

Converting Y + biplanar CrCb into RGB Mat

asked 2017-06-08 05:00:38 -0600

I have a data stored in a layout with two planes. First plane is Y plane and second one is CrCb, where those values are interleaved. Each pixel in Y plane is 8 bit long and each pixel of CrCb plane is 16 bits long (8 bits Cr and 8 bits for Cb). How can I create a cv::Mat from this format and convert it to ordinary RGB (or BGR) format? Thank you.

edit retag flag offensive close merge delete


can you show, how you acquire that data ?

berak gravatar imageberak ( 2017-06-09 08:24:55 -0600 )edit

You'll have to map it into two cv::Mat. The first is the Y data, and the second is a two channel Mat to hold the U and V. Then split the U and V, and merge all three.

Then it's just a standard cvtColor.

Tetragramm gravatar imageTetragramm ( 2017-06-09 15:40:25 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-01-23 06:18:05 -0600

n00dle gravatar image

Just to update this for anyone coming from Google - there is now a cvtColorTwoPlane method for precisely this use case, docs here:

edit flag offensive delete link more


Is there a way to go in reverse? From the RGB/A Mat to Y Mat and CbCr Mat?

dsweeney gravatar imagedsweeney ( 2019-09-26 16:37:17 -0600 )edit

Question Tools

1 follower


Asked: 2017-06-08 05:00:38 -0600

Seen: 1,130 times

Last updated: Jun 08 '17