% 0,1,2分别代表三幅图:高温,低温,手型图
% A代表原图;B代表数据类型转换或者校正后的图;D代表一点校正系数
% C代表高温图和低温图的灰度值差矩阵;G代表两点校正斜率系数矩阵;
f = fopen('highdat_151.dat');
A0 = fread(f,[200,200]); %double
B0 = uint8(A0);
f1 = fopen('lowdat_151.dat');
A1 = fread(f1,[200,200]); %double
B1 = uint8(A1);
f2 = fopen('handdat_50.dat');
A2 = fread(f2,[200,200]); %double
B2 = uint8(A2);
%求校正系数
B0_Average = (sum(A0(:))/(200*200))* ones(200,200); %double
B1_Average = (sum(A1(:))/(200*200))* ones(200,200); %double
D0_H = A0 - B0_Average; %double型的高温校正系数
D0_L = A1 - B1_Average; %double型的低温校正系数
%高温一点校正
B0_One_P_H = uint8(A0 - D0_H); %uint8型的一点高温校正后的数据
B1_One_P_H = uint8(A1 - D0_H); %uint8型的一点高温校正后的数据
B2_One_P_H = uint8(A2 - D0_H); %uint8型的一点高温校正后的数据
%低温一点校正
B0_One_P_L = uint8(A0 - D0_L); %uint8型的一点低温校正后的数据
B1_One_P_L = uint8(A1 - D0_L); %uint8型的一点低温校正后的数据
B2_One_P_L = uint8(A2 - D0_L); %uint8型的一点低温校正后的数据
%两点校正
SUM_Two_H = zeros(200,200);
SUM_Two_L = zeros(200,200);
SUM_Two_Hand = zeros(200,200);
B0_Two_H = zeros(200,200);
B1_Two_L = zeros(200,200);
B2_Two_Hand = zeros(200,200);
G = zeros(200,200);
C = A0 - A1; %double
for i = 1:200
for j = 1:200
if C(i,j) == 0 %盲元检测
for a = (i-4):(i+4)
for b = (j-4):(j+4)
SUM_Two_H(i,j) = A0(a,b) + SUM_Two_H(i,j);
SUM_Two_L(i,j) = A1(a,b) + SUM_Two_L(i,j);
SUM_Two_Hand(i,j) = A2(a,b) + SUM_Two_Hand(i,j);
end
end
B0_Two_H(i,j) = (SUM_Two_H(i,j) - A0(i,j))/80;
B1_Two_L(i,j) = (SUM_Two_L(i,j) - A1(i,j))/80;
B2_Two_Hand(i,j) = (SUM_Two_Hand(i,j) - A2(i,j))/80;
else
G(i,j) = (B0_Average(i,j) - B1_Average(i,j)) ./ C(i,j);
B0_Two_H(i,j) = G(i,j).*A0(i,j) + B1_Average(i,j) - G(i,j).*A1(i,j);
B1_Two_L(i,j) = G(i,j).*A1(i,j) + B1_Average(i,j) - G(i,j).*A1(i,j);
B2_Two_Hand(i,j) = G(i,j).*A2(i,j) + B1_Average(i,j) - G(i,j).*A1(i,j);
end
end
end
%图像增强
%直方图均衡法
B_E1 = histeq(uint8(B2_Two_Hand));
%中值滤波法
B_E2 = medfilt2(B2_Two_Hand);
figure(1);
subplot(2,3,1),imshow(B0),title('高温原图');
subplot(2,3,2),imshow(B1),title('低温原图');
subplot(2,3,3),imshow(B2),title('手型原图');
subplot(2,3,4),surf(double(B0)),title('高温原图三维响应图');
subplot(2,3,5),surf(double(B1)),title('低温原图三维响应图');
subplot(2,3,6),surf(double(B2)),title('手型原图三维响应图');
figure(2);
subplot(2,3,1),imshow(B0_One_P_H),title('高温定标点下的高温图一点校正');
subplot(2,3,2),imshow(B1_One_P_H),title('高温定标点下的低温图一点校正');
subplot(2,3,3),imshow(B2_One_P_H),title('高温定标点下的手型图一点校正');
subplot(2,3,4),surf(double(B0_One_P_H)),title('高温定标点下的高温图一点校正三维响应图');
subplot(2,3,5),surf(double(B1_One_P_H)),title('高温定标点下的低温图一点校正三维响应图');
subplot(2,3,6),surf(double(B2_One_P_H)),title('高温定标点下的手型图一点校正三维响应图');
figure(3);
subplot(2,3,1),imshow(B0_One_P_L),title('低温定标点下的高温图一点校正');
subplot(2,3,2),imshow(B1_One_P_L),title('低温定标点下的低温图一点校正');
subplot(2,3,3),imshow(B2_One_P_L),title('低温定标点下的手型图一点校正');
subplot(2,3,4),surf(double(B0_One_P_L)),title('低温定标点下的高温图一点校正三维响应图');
subplot(2,3,5),surf(double(B1_One_P_L)),title('低温定标点下的低温图一点校正三维响应图');
subplot(2,3,6),surf(double(B2_One_P_L)),title('低温定标点下的手型图一点校正三维响应图');
figure(4);
subplot(2,3,1),imshow(uint8(B0_Two_H)),title('高温图二点校正');
subplot(2,3,2),imshow(uint8(B1_Two_L)),title('低温图二点校正');
subplot(2,3,3),imshow(uint8(B2_Two_Hand)),title('手型图二点校正');
subplot(2,3,4),surf(double(B0_Two_H)),title('高温图二点校正三维响应图');
subplot(2,3,5),surf(double(B1_Two_L)),title('低温图二点校正三维响应图');
subplot(2,3,6),surf(double(B2_Two_Hand)),title('手型图二点校正三维响应图');
figure(5);
subplot(2,3,1),imshow(B2),title('手型原图');
subplot(2,3,2),imshow(uint8(B_E1)),title('二点校正后采用直方图均衡增强');
subplot(2,3,3),imshow(uint8(B_E2)),title('二点校正后采用中值滤波增强');
subplot(2,3,4),surf(double(B2)),title('手型原图三维响应图');
subplot(2,3,5),surf(double(B_E1)),title('直方图均衡增强三维响应图');
subplot(2,3,6),surf(double(B_E2)),title('中值滤波增强三维响应图');
%{
figure(6);
subplot(2,2,1),imhist(uint8(B2_Two_Hand));
subplot(2,2,2),imhist(B_E1);
%}
评论1