如何处理RGB到YUV的转换 [英] How to deal with RGB to YUV conversion
问题描述
公式说:
Y = 0.299 * R + 0.587 * G + 0.114 * B;
U = -0.14713 * R - 0.28886 * G + 0.436 * B;
V = 0.615 * R - 0.51499 * G - 0.10001 * B;
例如,如果U变量变为负数怎么办?
What if, for example, the U variable becomes negative?
U = -0.14713 * R - 0.28886 * G + 0.436 * B;
假设R和G(1)的最大值和B = 0
那么,我我有兴趣在OpenCV中实现这个对流功能,
那么,如何处理负值呢?
使用浮动图像?无论如何请解释我,可能是我不明白的东西..
Assume maximum values for R and G (ones) and B = 0 So, I am interested in implementing this convetion function in OpenCV, So, how to deal with negative values? Using float image? anyway please explain me, may be I don't understand something..
推荐答案
你可以在OpenCV中转换RGB< - > YUV cvtColor 使用代码
CV_YCrCb2RGB
用于YUV-> RGB和 CV_RGBYCrCb
用于RGB-> YUV。
You can convert RGB<->YUV in OpenCV with cvtColor using the code
CV_YCrCb2RGB
for YUV->RGB and CV_RGBYCrCb
for RGB->YUV.
void cvCvtColor(const CvArr* src, CvArr* dst, int code)
将图像从一个颜色空间
转换为另一个颜色空间。
Converts an image from one color space to another.
这篇关于如何处理RGB到YUV的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!