简体   繁体   English

将RGB图像转换为Matlab中的两倍

[英]convert RGB image to double in matlab

why we convert rgb image to double precision before applying the transformation formula that convert from rgb to ycbcr? 为什么在应用将rgb转换为ycbcr的转换公式之前将rgb图像转换为双精度?

rgb = im2double(in);

% These equations transform RGB in [0,1] to YCBCR in [0, 255]
out(:,:,1) = 16 + 65.481 * rgb(:,:,1) + 128.553 * rgb(:,:,2) + 24.966 * rgb(:,:,3);
out(:,:,2) = 128 - 37.797 * rgb(:,:,1) - 74.203 * rgb(:,:,2) + 112 * rgb(:,:,3);
out(:,:,3) = 128 + 112 * rgb(:,:,1) - 93.786 * rgb(:,:,2) -18.214 * rgb(:,:,3);

im2double scales the RGB image from a 0-255 range into a 0-1 range, which is needed by the conversion equations. im2double将RGB图像从0-255范围缩放到0-1范围,这是转换方程式所需的。

Also, the image should be in double format, rather than uint8, so that precision is not lost during calculation. 另外,图像应为双格式,而不是uint8,这样在计算过程中不会损失精度。 If the image was not double, the result would be rounded and would be less accurate. 如果图像不是两倍,结果将被四舍五入,并且精度会降低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM