红外图像非均匀矫正——两点矫正
红外芯片由于工艺问题存在严重的分均匀性,所以非均匀矫正一直是影响红外图像质量的第一因素。分均匀矫正的算法也是红外图像处理研究的重点区域,建立了一些矫正的方式方法。其中最常用最简单的就应该算是两点温度定标算法。
应用两点法校正有两个前提条件,第一,探测器的响应在所关注的温度范围内是线性变化的,第二,探测器的响应具有时间的稳定性,并且其受随机噪声的影响较小,则非均匀性引入固定模式的乘性和加性噪声。
具体过程基本分为三步:
一、两温度下采集均匀原始数据
二、根据原始数据计算校正参数
三、将矫正参数带入实时原始图进行校正
matlab实现的的.m文件内容如下:
clear;
clc;
%%%%%%%%%%%%%%低温下对9帧图像取平均值%%%%%%%%%%%%%
save1=zeros(3,2,9,'uint16');
for i = 1:9; %连续读M帧图像,存入三维数组
fid = textread(strcat('300',num2str(i),'b.txt'),'%s');
fid1 = hex2dec(fid);
save1(:,:,i) = reshape(fid1,3,2);
end
%求M帧的平均值,消除偶然误差
sample1 = zeros(3,2,'double');
sample1 = double(save1(:,:,1)+save1(:,:,2)+save1(:,:,3)+save1(:,:,4)+save1(:,:,5)+save1(:,:,6)+save1(:,:,7)+save1(:,:,8)+save1(:,:,9))/9;
subplot(2,2,1), imshow(uint8(sample1));
title('T1温度原始图');
%%%%%%%%%%%%%低温下对9帧图像取平均值%%%%%%%%%%%%%%%
save2=zeros(3,2,9,'uint16');
for i = 1:9;
fid = textread(strcat('700',num2str(i),'b.txt'),'%s');
fid1 = hex2dec(fid);
save2(:,:,i) = reshape(fid1,3,2);
end
sample2 = zeros(3,2,'double');
sample2= double(save2(:,:,1)+save2(:,:,2)+save2(:,:,3)+save2(:,:,4)+save2(:,:,5)+save2(:,:,6)+save2(:,:,7)+save2(:,:,8)+save2(:,:,9))/9;
subplot(2,2,2),imshow(uint8(sample2));
title('T2温度原始图');
%%%%%%%%%%%%%%%计算校正因子%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
avr1=sum(sample1(:))/(3*2);
avr2=sum(sample2(:))/(3*2);
G = zeros(3,2,'double');
O = zeros(3,2,'double');
M = zeros(3,2,'double');
for i=1:3;
for j=1:2;
G(i,j) = (avr2-avr1)/(sample2(i,j)-sample1(i,j)); %计算增益
O(i,j) = avr1-G(i,j)*sample1(i,j); %计算偏移量
%O(i,j) =(avr2*double(sample1(i,j))-avr1*double(sample2(i,j)))/double(sample1(i,j)-sample2(i,j));
end
end
file = fopen('2dian4p000s17.txt','wt');
count = fwrite(file,G,'uint16');
%%%%%%%%%%%%%%校正场景图片%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid = textread('4p000s.txt','%s');
fid1 = hex2dec(fid);
test2=reshape(fid1,3,2);
%%%%%%%%%%%%%%%%%%%%%%%%%校正得到全部结果%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:3;
for j=1:2;
M(i,j) = G(i,j)*double(test2(i,j))+O(i,j);
end
end
for i=1:3;
for j=1:2;
final(i,j) = uint16(M(i,j));
end
end
subplot(2,2,3),imshow(uint8(final));title('校正后 ');
subplot(2,2,4),imshow(uint8(test2));title('非均匀原始图');
file = fopen('2dian4p000s16.txt','wt');
count = fwrite(file,final,'double');
运行结果如下所示:
可以自己造图才跑,数据文件上传太繁琐了就没上传,如果有兴趣可以找我来要。
QQ:356636122