Differences between Gray to YUV conversion (CvtColor VS Create a Mat with Y component)

asked 2018-02-12 04:10:47 -0600

isra60 gravatar image

AFAIK , A YUV image from Gray8 image is just copy the Gray8 image data to the Y-component. Meaning that the crominances are 0 value.

Based on this

https://en.wikipedia.org/wiki/YUV#/me...

So if I have a gray8 Mat (heightwidth) my YUV Mat result is a Mat(1.5height * width) So I just create a Mat with the first (heightwidth) bytes to Y and the rest of bytes just to 0 values.

But when I tried to use cvtColor Conversion; First Gray->BGR and then BGR->YUV420 (cvtcolor does not have direct conversion) my result Mat is a Mat(1.5height * width), but the last values of each frame (the crominances) are 128 not 0-values...

I don't understand this difference but it seems the second one (created with cvtcolor) is the correct one. My own created Mat from the gray8 data results on a Green Image...

Any hints??

edit retag flag offensive close merge delete