%CIE1931伪彩色
clc
close all
clearvars
%% R G B
CIE1931 =[[380,0.0272,-0.0115,0.9843];%380[385,0.0268,-0.0114,0.9846];%385[390,0.0263,-0.0114,0.9851];%390[395,0.0256,-0.0113,0.9857];%395[400,0.0247,-0.0112,0.9865];%400[405,0.0237,-0.0111,0.9874];%405[410,0.0225,-0.0109,0.9884];%410[415,0.0207,-0.0104,0.9897];%415[420,0.0181,-0.0094,0.9913];%420[425,0.0142,-0.0076,0.9934];%425[430,0.0088,-0.0048,0.9960];%430[435,0.0012,-0.0007,0.9995];%435[440,-0.0084,0.0018,1.0036];%440[445,-0.0213,0.0120,1.0093];%445[450,-0.0390,0.0218,1.0172];%450[455,-0.0618,0.0345,1.0273];%455[460,-0.0909,0.0517,1.0392];%460[465,-0.1281,0.0762,1.0519];%465[470,-0.1821,0.1175,1.0646];%470[475,-0.2584,0.1840,1.0744];%475[480,-0.3667,0.2906,1.0761];%480[485,-0.5200,0.4568,1.0632];%485[490,-0.7150,0.6996,1.0154];%490[495,-0.9459,1.0247,0.9212];%495[500,-1.1685,1.3905,0.7780];%500[505,-1.3182,1.7195,0.5987];%505[510,-1.3371,1.9318,0.4053];%510[515,-1.2076,1.9699,0.2377];%515[520,-0.9830,1.8534,0.1296];%520[525,-0.7386,1.6662,0.0724];%525[530,-0.5159,1.4761,0.0398];%530[535,-0.3304,1.3105,0.0199];%535[540,-0.1707,1.1628,0.0079];%540[545,-0.0293,1.0282,0.0011];%545[550,0.0974,0.9051,-0.0025];%550[555,0.2121,0.7919,-0.0040];%555[560,0.3164,0.6881,-0.0045];%560[565,0.4112,0.5932,-0.0044];%565[570,0.4973,0.5067,-0.0040];%570[575,0.5751,0.4283,-0.0034];%575[580,0.6449,0.3579,-0.0028];%580[585,0.7071,0.2952,-0.0023];%585[590,0.7617,0.2402,-0.0019];%590[595,0.8087,0.1928,-0.0015];%595[600,0.8475,0.1537,-0.0012];%600[605,0.8800,0.1209,-0.0009];%605[610,0.9059,0.0949,-0.0008];%610[615,0.9265,0.0741,-0.0006];%615[620,0.9425,0.0580,-0.0005];%620[625,0.9550,0.0454,-0.0004];%625[630,0.9649,0.0354,-0.0003];%630[635,0.9730,0.0272,-0.0002];%635[640,0.9797,0.0205,-0.0002];%640[645,0.9850,0.0152,-0.0002];%645[650,0.9888,0.0113,-0.0001];%650[655,0.9918,0.0083,-0.0001];%655[660,0.9940,0.0061,-0.0001];%660[665,0.9954,0.0047,-0.0001];%665[670,0.9966,0.0035,-0.0001];%670[675,0.9975,0.0025,0.0000];%675[680,0.9984,0.0016,0.0000];%680[685,0.9991,0.0009,0.0000];%685[690,0.9996,0.0004,0.0000];%690[695,0.9999,0.0001,0.0000];%695[700,1.0000,0.0000,0.0000];%700[705,1.0000,0.0000,0.0000];%705[710,1.0000,0.0000,0.0000];%710[715,1.0000,0.0000,0.0000];%715[720,1.0000,0.0000,0.0000];%720[725,1.0000,0.0000,0.0000];%725[730,1.0000,0.0000,0.0000];%730[735,1.0000,0.0000,0.0000];%735[740,1.0000,0.0000,0.0000];%740[745,1.0000,0.0000,0.0000];%745[750,1.0000,0.0000,0.0000];%750[755,1.0000,0.0000,0.0000];%755[760,1.0000,0.0000,0.0000];%760[765,1.0000,0.0000,0.0000];%765[770,1.0000,0.0000,0.0000];%770[775,1.0000,0.0000,0.0000];%775[780,1.0000,0.0000,0.0000]];%780%%
image_path = 'E:\仿真代码\双色散自监督\CAVE 数据集\feathers_ms\feathers_ms\\';
image_name =dir(strcat(image_path,'*.png'));
table = CIE1931;for image_idx =1:31
tmp =imread([image_path,image_name(image_idx).name]);
tmp =double(uint8(tmp/255));
tmp_RGB =zeros(512,512,3);
mean_gray =402;%输入图像的波长
cie =zeros(1,3);for i=1:3
result=GetLineValue(table,mean_gray,i);cie(:,i)=result;
end
tmp_R = tmp*(cie(1,1)/(cie(1,1)+cie(1,2)+cie(1,3)));
tmp_G = tmp*(cie(1,2)/(cie(1,1)+cie(1,2)+cie(1,3)));
tmp_B = tmp*(cie(1,3)/(cie(1,1)+cie(1,2)+cie(1,3)));tmp_RGB(:,:,1)= tmp_R;tmp_RGB(:,:,2)= tmp_G;tmp_RGB(:,:,3)= tmp_B;
name =image_name(image_idx).name;
name =name(1:end-4);imwrite(uint8(tmp_RGB),['E:\仿真代码\论文\其他融合算法\',name,'.bmp']);
end
获取图像的RGB的CIE的函数
function Yaxis=GetLineValue(Arr,Xaxis,i)
Left =0;%%//循环变量左值
Flg =0;%%//标志位
Lng=80;if i==1
num=2;
elseif i==2
num=3;else
num=4;
end
if Xaxis <=Arr(1,1)
Yaxis =Arr(1,num);
elseif Xaxis >=Arr(Lng,1)
Yaxis =Arr(Lng,num);else
Right = Lng;while(Left < Right-1)%%//循环比较,不满足左值小于右值时退出
Middle =ceil((Left +Right)/2);%%//取中间值if Xaxis <Arr(Middle,1)
Right = Middle;
elseif Xaxis >Arr(Middle,1)
Left = Middle;else
Flg =1;
Yaxis =Arr(Middle,num);break;
end
end
if Flg ==0
Yaxis =(Arr(Left +2,num)-Arr(Left+1,num))*(Xaxis -Arr(Left+1,1))/(Arr(Left+2,1)-Arr(Left+1,1))+Arr(Left+1,num);
end
end
end