📄 double_rgb2ycrcb.m
字号:
function [matlab_y, matlab_cr, matlab_cb] = double_rgb2ycrcb(R,G,B, AC, BC, CC, DC)
% double precision YCrCb to RGB color-space conversion.
% Coefficients derived from RGB to YCrCb conversion matrix
% Inputs R, G and B are assumed in the 0.0 - 1.0 range
% AC=612/2048; % 0.299 => Biometric constants
% BC=233/2048; % 0.114
% CC=0.5/(1-AC); % Scaling constants reducing the dynamic range
% DC=0.5/(1-BC); % of Cb and Cr to -0.5 to 0.5 (0 to 1 with offset compensation
COFFSET = 0.5;
YOFFSET = 0;
min_val = min(min(min([R,G,B])));
max_val = max(max(max([R,G,B])));
range = max(2,pow2(ceil(log2(double(max_val-min_val)))))-1;
if (min_val<0) min_p2 = -pow2(ceil(log2(double(-min_val))));
else min_p2 = 0; end ;
r = double(R-min_p2)/range; % normalizing inputs to the 0..1 range;
g = double(G-min_p2)/range;
b = double(B-min_p2)/range;
matlab_y=AC*r+(1-AC-BC)*g+BC*b;
matlab_cr=CC*(r-matlab_y)+COFFSET;
matlab_cb=DC*(b-matlab_y)+COFFSET;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -