matlab中显示ycbcr图像,rgb到matlab中的ycbcr转换

“rgb2ycbcr”函数(图像处理工具箱):

路径:

MATLAB \ R2013a \工具箱\图像\色彩空间\ rgb2ycbcr.m

代码:

function ycbcr = rgb2ycbcr(varargin)

rgb = parse_inputs(varargin{:});

isColormap = false;

if (ndims(rgb) == 2)

isColormap=true;

colors = size(rgb,1);

rgb = reshape(rgb, [colors 1 3]);

end

origT = [65.481 128.553 24.966;-37.797 -74.203 112; 112 -93.786 -18.214];

origOffset = [16;128;128];

scaleFactor.double.T = 1/255;

scaleFactor.double.offset = 1/255;

scaleFactor.uint8.T = 1/255;

scaleFactor.uint8.offset = 1;

scaleFactor.uint16.T = 257/65535;

scaleFactor.uint16.offset = 257;

classIn = class(rgb);

T = scaleFactor.(classIn).T * origT;

offset = scaleFactor.(classIn).offset * origOffset;

ycbcr = zeros(size(rgb),classIn);

for p = 1:3

ycbcr(:,:,p) = imlincomb(T(p,1),rgb(:,:,1),T(p,2),rgb(:,:,2), T(p,3),rgb(:,:,3),offset(p));

end

if isColormap

ycbcr = reshape(ycbcr, [colors 3 1]);

end

你可能感兴趣的:(matlab中显示ycbcr图像,rgb到matlab中的ycbcr转换)