Which conversion formula does matlab use for rgb2ycbcr?
12 次查看(过去 30 天)
显示 更早的评论
In the documentation for rgb2ycbcr, the jpeg recommendation https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf is given as reference. However, i checked the values of luminance channel using rgb2ycbcr as well as directly using the jpeg recommended conversion formula and the luminance channel values are not the same.
i=imread('peppers.png');
YCBCR = rgb2ycbcr(i);
y=YCBCR(:,:,1);
r=i(:,:,1);g=i(:,:,2);b=i(:,:,3);
oury=min(max(0,round(0.299*r+0.587*g+0.114*b)),255);
The values in y and oury differ by ~10. I want to confirm if there's something wrong with my manual approach or matlab uses a slightly different formula?
0 个评论
采纳的回答
Walter Roberson
2021-2-13
Assuming uint8, the code uses
[0.256788235294118 0.504129411764706 0.0979058823529412
-0.148223529411765 -0.290992156862745 0.43921568627451
0.43921568627451 -0.367788235294118 -0.0714274509803921] * [R;G;B] + [16;128;128]
% This matrix comes from a formula in Poynton's, "Introduction to
% Digital Video" (p. 176, equations 9.6).
See the source code, line 66 or so, matrix origT and divide by the scale factor 255 for uint8
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Color 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!