资源描述
一、图像的非均匀性矫正
二、图像增强
三、程序代码(MATLAB)
%%%%%%%%%%%%%%%%%%%%555555555555555555555555555555555一点矫正
HIGH_T=fopen('highdat_151.dat','rb');
HIGH=fread(HIGH_T,[200,200],'uint8');
HIGH=uint8(HIGH); %类型转化为uint8
subplot(321);imshow(HIGH); title('原始高温图像');
subplot(322);mesh(double(HIGH));title('原始高温图像三维显示');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LOW_T=fopen('lowdat_151.dat','rb');
LOW=fread(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('原始手形图像三维显示');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%选取低温图进行定标
S=mean2(LOW(:)); % S为定标值
S_LOW=S*ones(200,200);
S_LOW=uint8(S_LOW); %S_LOW为定标矩阵
D_LOW=LOW-S_LOW; %校正系数D_LOW
figure;
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('经低温矫正后的低温图像');
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_HIGH; %校正系数D_HIGH
figure;
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);imshow(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_1
G_2=HIGH-LOW; %矩阵G_2
G=zeros(200,200);
figure;
G_3=zeros(200,200);
O=zeros(200,200);
HIGH_HL=zeros(200,200);
for x=1:200
for y=1:200
G(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);%对盲元处进行矫正
end
end
HIGH_HL=uint8(HIGH_HL);
subplot(321); imshow(HIGH_HL,[]);title('两点矫正后的高温图像');
subplot(322);mesh(double(HIGH_HL)); title('两点矫正后的高温图像三维显示');
LOW_HL=zeros(200,200);
for x=1:200
for y=1:200
G(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);%对盲元处进行矫正
end
end
LOW_HL=uint8(LOW_HL);
subplot(323);imshow(LOW_HL,[]); title('两点矫正后的低温图像');
subplot(324);mesh(double(LOW_HL)); title('两点矫正后的低温图像三维显示');
HAND_HL=zeros(200,200);
for x=1:200
for y=1:200
G(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);%对盲元处进行矫正
end
end
HAND_HL=uint8(HAND_HL);
subplot(325);imshow(HAND_HL,[]); title('两点矫正后的手图像');
subplot(326);mesh(double(HAND_HL)); title('两点矫正后的手图像三维显示');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%直方图均衡增强
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:N
for y=1:M
graydis(1,TU(x,y))=graydis(1,TU(x,y))+1;
end
end
graydispro=graydis./sum(graydis);
for i=2:256
graydispro(1,i)=graydispro(1,i)+graydispro(1,i-1);
end
%计算和原始灰度对应的新的灰度t[],建立映射关系
for i=1:256
t(1,i)=floor(254*graydispro(1,i)+0.5);
end
for x=1:N
for y=1:M
NEW_TU(x,y)=t(1,TU(x,y));
end
end
%%%%%%%%%%%%%%%%%%%%5555555555555555555改进图像增强算法
I=TU;
m=mean(I(:));%获得图像阈值
for i=1:200
for j=1:200
if I(i,j)>m+2 && I(i,j)<=255 %灰度大于阈值灰度按一定比值进行增加
l=I(i,j)-m; %灰度差值
k=20*l/(255-m); %%灰度增加量
I1(i,j)=I(i,j)+k;
else
I1(i,j)=I(i,j)-80; %灰度小于阈值,灰度减小
end
end
end
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<=d
h=0;
else
h=1;
end
s(i,j)=(p+q*h)*s(i,j);
end
end
s=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('对应三维响应图');
展开阅读全文