cmc色差的matlab程序,计算CIEDE2000色差公式的matlab程序

function [DE,RT,hm,Dt,Rot]=CIEDE2000(LABREF,LAB,K)

% DE2000 calculates colour difference between a reference and

sample

% using CIEDE2000 colour difference (as defined in Luo, Cui and

Rigg (2000))

%

% Input data can be single values or multiple values arranged in

columns

% LABREF can be a single value while LAB is a column

%

% Colour Engineering

Toolbox

% author: ?Phil

Green

% version: 1.1

% date: 17-01-2001

% modified: Zheng Yuanlin,

2010-08-23 %

% set the values of parametric weighting factors

KL,KC,KH

if nargin>2

if

length(K)>2

kL=K(1);kC=K(2);kH=K(3);

end

else

kL=1;kC=1;kH=1;

end

%___________________________________________________________________

L=LABREF(:,1);

a=LABREF(:,2);

b=LABREF(:,3);

C=(a.^2+b.^2).^0.5;

Ls=LAB(:,1);

as=LAB(:,2);

bs=LAB(:,3);

Cs=(as.^2+bs.^2).^0.5;

%find G and recompute a', C' and h'

Cm=(C+Cs)/2;

G=0.5*(1-(Cm.^7./(Cm.^7+25^7)).^0.5); %

a轴调整因子

a=(1+G).*a;

as=(1+G).*as;

C=(a.^2+b.^2).^0.5;

h=hue_angle(a,b);

Cs=(as.^2+bs.^2).^0.5;

hs=hue_angle(as,bs);

zcidx = (C.*Cs == 0);

%% find the mean chroma and hue for each reference/sample

pair

Cm=(C+Cs)/2; % 彩度平均值

%% 色相角平均值

% hm=hmean_GS(h,hs,C,Cs);

hm=(h+hs)/2;

hm=hm-360*(abs(h-hs)>360);

hm=hm+(hm<0)*360;

hm(zcidx)=h(zcidx)+hs(zcidx);

%% 色相角差

% Dh=angle_diff_GS(h,hs,C,Cs); Dh=hs-h;

Dh = Dh - 2*180* (Dh > 180 );

Dh = Dh + 2*180* (Dh < (-180) );

Dh(zcidx)=0;

%%

rad=pi/180;

DL=(L-Ls); %

亮度差

DC=Cs-C; % 彩度差

DH=2*((C.*Cs).^0.5).*sin(rad*(Dh)/2); % 色相差

% calculate T

T=1-0.17*cos(rad*(hm-30))+0.24*cos(rad*2*hm)+0.32*cos(rad*(3*hm+6))-0.2*cos(rad*(4*hm-63));

%权重因子 SL, SC, SH

SL=1+(0.015.*((L+Ls)./2-50).^2)./(20+((L+Ls)./2-50).^2).^0.5;

SC=1+0.045.*Cm;

SH=1+0.015.*Cm.*T;

Dt=30*exp(-(((hm-275)/25).^2));

RC=2.*((Cm.^7)./(Cm.^7+25.^7)).^.5;

RT=-sin(2*rad*Dt).*RC;

Rot=RT.*(DC./(SC.*kC)).*(DH./(SH.*kH)); % 调整项

DE=((DL./(SL.*kL)).^2+(DC./(SC.*kC)).^2+(DH./(SH.*kH)).^2+Rot).^0.5;

return

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值