Ask Your Question
0

CV_8UC3 pixel format question Update

asked 2013-04-26 09:01:56 -0600

updated 2020-11-07 02:58:16 -0600

Thanks to berak's answer I've been able to get something going with OpenCV that uses much less code than the FFmpeg equivalent.

My new problem is that the resultant YUV image doesn't look correct. Following tutorials for saving/showing the image, it looks like the Y and/or U component are missing.

Both images: Original first, YUV second

edit retag flag offensive close merge delete

Comments

cv::Mat input_image = cv::imread("CustomInput.jpg"); cv::Mat output_image; cv::cvtColor(input_image, output_image, CV_BGR2YUV); cv::imwrite("/home/nmenne/hri/trunk/dsat/dsat_lsa/CustomOutput.jpg", output_image);

the1evilgenius gravatar imagethe1evilgenius ( 2013-04-26 14:21:57 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-04-26 09:12:13 -0600

berak gravatar image
cv::Mat rgb=imread("lena.jpg");

cv::Mat yuv;
cv::cvtColor(rgb,yuv,CV_RGB2YUV);
edit flag offensive delete link more

Comments

This does the trick. Would you happen to know why the resultant yuv mat looks like the Y' and maybe the U components are missing?

the1evilgenius gravatar imagethe1evilgenius ( 2013-04-26 15:40:24 -0600 )edit
1

answered 2013-04-26 09:19:39 -0600

What kind of YUV do you want? There is cvtColor function in OpenCV. It converts images from one color space to another. You need to use one of CV_BGR2YUVxxx constant.

edit flag offensive delete link more

Comments

YUV420 would be the desired constant, i think.

Do you know where this is documented? The cvtColor documentation doesn't have any of the YUV options listed.

the1evilgenius gravatar imagethe1evilgenius ( 2013-04-26 10:59:25 -0600 )edit

Question Tools

Stats

Asked: 2013-04-26 09:01:56 -0600

Seen: 3,007 times

Last updated: Apr 26 '13