1、一、图像的非均匀性矫正二、图像增强三、程序代码(MATLAB )%555555555555555555555555555555555 一点矫正HIGH_T=fopen(highdat_151.dat,rb);HIGH=fread(HIGH_T,200,200,uint8);HIGH=uint8(HIGH); %类型转化为 uint8subplot(321);imshow(HIGH); title(原始高温图像); subplot(322);mesh(double(HIGH);title(原始高温图像三维显示 );%LOW_T=fopen(lowdat_151.dat,rb);LOW=fread
2、(LOW_T,200,200,uint8);LOW=uint8(LOW); subplot(323);imshow(LOW); title(原始低温图像); subplot(324);mesh(double(LOW); title(原始低温图像三维显示);%HAND_D=fopen(handdat_60.dat,rb);HAND=fread(HAND_D,200,200,uint8);HAND=uint8(HAND); subplot(325),imshow(HAND); title(原始手形图像); subplot(326),mesh(double(HAND); title(原始手形图像三维
3、显示);%选取低温图进行定标S=mean2(LOW(:); % S 为定标值S_LOW=S*ones(200,200);S_LOW=uint8(S_LOW); %S_LOW 为定标矩阵D_LOW=LOW-S_LOW; %校正系数 D_LOWfigure;HIGH_L=HIGH-D_LOW;subplot(321);imshow(HIGH_L); title(经低温矫正后的高温图像);subplot(322);mesh(double(HIGH_L); title(经低温矫正后的高温图像三维显示);LOW_L=S_LOW;subplot(323);imshow(LOW_L); title(经低温矫
4、正后的低温图像);subplot(324);mesh(double(LOW_L); title(经低温矫正后的低温图像三维显示);HAND_L=HAND-D_LOW;subplot(325);imshow(HAND_L); title(经低温矫正后的原始手图像 );subplot(326);mesh(double(HAND_L); title(经低温矫正后的原始手图像三维显示);%选取高温图进行定标S=mean2(HIGH(:); % S 为定标值S_HIGH=S*ones(200,200);S_HIGH=uint8(S_HIGH); %S_LOW 为定标矩阵D_HIGH=HIGH-S_HIG
5、H; %校正系数 D_HIGHfigure;HIGH_H=S_HIGH;subplot(321);imshow(HIGH_H); title(经高温矫正后的高温图像);subplot(322);mesh(double(HIGH_H); title(经高温矫正后的高温图像三维显示 );LOW_H=LOW-D_HIGH;subplot(323);imshow(LOW_H); title(经高温矫正后的低温图像);subplot(324);mesh(double(LOW_H); title(经高温矫正后的低温图像三维显示 );HAND_H=HAND-D_HIGH;subplot(325);imsho
6、w(HAND_H); title(经高温矫正后的原始手图像);subplot(326);mesh(double(HAND_H); title(经高温矫正后的原始手图像三维显示);%5555555555555555555555555555555555555555 两点矫正%在上述程序基础之上S_L=mean2(LOW(:); % S_L 为矫正点定标值S_H=mean2(HIGH(:); % S_H 为矫正点定标值G_1=S_H-S_L; %数 G_1G_2=HIGH-LOW; %矩阵 G_2G=zeros(200,200);figure;G_3=zeros(200,200);O=zeros(2
7、00,200);HIGH_HL=zeros(200,200);for x=1:200for y=1:200G(x,y)=G_1/G_2(x,y);%乘性增益G_3(x,y)=G(x,y)*LOW(x,y);O(x,y)=S_L-G_3(x,y); %加性增益HIGH_HL(x,y)=HIGH(x,y)*G(x,y)+O(x,y);%对盲元处进行矫正 endendHIGH_HL=uint8(HIGH_HL);subplot(321); imshow(HIGH_HL,);title(两点矫正后的高温图像);subplot(322);mesh(double(HIGH_HL); title(两点矫正后
8、的高温图像三维显示 );LOW_HL=zeros(200,200);for x=1:200for y=1:200G(x,y)=G_1/G_2(x,y);%乘性增益G_3(x,y)=G(x,y)*LOW(x,y);O(x,y)=S_L-G_3(x,y); %加性增益 LOW_HL(x,y)=LOW(x,y)* G(x,y)+O(x,y);%对盲元处进行矫正 endendLOW_HL=uint8(LOW_HL);subplot(323);imshow(LOW_HL,); title(两点矫正后的低温图像);subplot(324);mesh(double(LOW_HL); title(两点矫正后的
9、低温图像三维显示);HAND_HL=zeros(200,200);for x=1:200for y=1:200G(x,y)=G_1/G_2(x,y);%乘性增益G_3(x,y)=G(x,y)*LOW(x,y);O(x,y)=S_L-G_3(x,y); %加性增益HAND_HL(x,y)=HAND(x,y)* G(x,y)+O(x,y);%对盲元处进行矫正 endendHAND_HL=uint8(HAND_HL);subplot(325);imshow(HAND_HL,); title(两点矫正后的手图像);subplot(326);mesh(double(HAND_HL); title(两点矫
10、正后的手图像三维显示);%直方图均衡增强TU=HAND_HL; graydis=zeros(1,256); %设置矩阵大小graydispro=zeros(1,256);new_graydis=zeros(1,256);new_graydispro=zeros(1,256);N,M=size(TU);NEW_TU=zeros(N,M);for x=1:Nfor y=1:Mgraydis(1,TU(x,y)=graydis(1,TU(x,y)+1;endendgraydispro=graydis./sum(graydis);for i=2:256graydispro(1,i)=graydispr
11、o(1,i)+graydispro(1,i-1);end%计算和原始灰度对应的新的灰度 t,建立映射关系for i=1:256t(1,i)=floor(254*graydispro(1,i)+0.5);endfor x=1:Nfor y=1:MNEW_TU(x,y)=t(1,TU(x,y);endend%5555555555555555555 改进图像增强算法I=TU;m=mean(I(:);%获得图像阈值for i=1:200for j=1:200if I(i,j)m+2 %灰度差值k=20*l/(255-m); %灰度增加量I1(i,j)=I(i,j)+k;elseI1(i,j)=I(i,
12、j)-80; %灰度小于阈值,灰度减小endendend s=fftshift(fft2(I1);a,b=size(s); a0=round(a/2);b0=round(b/2);d=0.001; p=0.9;q=1; for i=1:a for j=1:b distance=sqrt(i-a0)2+(j-b0)2);if distance=dh=0; else h=1; ends(i,j)=(p+q*h)*s(i,j);endends=uint8(real(ifft2(ifftshift(s);figure;subplot(321);imshow(TU,);title(两点矫正后的手图);subplot(322);mesh(double(TU);title(对应的三为响应图);subplot(323);imshow(NEW_TU,);title(直方图均衡化后的图);subplot(324);mesh(double(NEW_TU);title(对应的三为响应图);subplot(325);imshow(s,);title(算法增强后所得图像);subplot(326);mesh(double(s);title(对应三维响应图);