cmc色差的matlab程序,[转载]计算CIEDE2000色差公式的matlab程序

function DE=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

% book: http://www.wileyeurope.com/WileyCDA/WileyTitle/productCd-0471486884.html

% web: http://www.digitalcolour.org

% 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;h=hue_angle(a,b);

Ls=LAB(:,1);as=LAB(:,2);bs=LAB(:,3);

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

%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=(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);

%find the mean chroma and hue for each

reference/sample pair

Cm=(C+Cs)/2;

hm=(h+hs)/2;

j=find(abs(h-hs)>180);hm(j)=hm(j)-180;

rad=pi/180;

Dh=angle_diff(h,hs);

DL=abs(L-Ls);

DC=abs(C-Cs);

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));

%calculate weighting factors SL, SC, SH

SL=1+(0.015.*((L+Ls)./2-50).^2)./(20+((L+Ls)./2-50).^2).^.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;

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值