紅外芯片由於工藝問題存在嚴重的分均勻性,所以非均勻矯正一直是影響紅外圖像質量的第一因素。分均勻矯正的算法也是紅外圖像處理研究的重點區域,建立了一些矯正的方式方法。其中最常用最簡單的就應該算是兩點溫度定標算法。
應用兩點法校正有兩個前提條件,第一,探測器的響應在所關注的溫度範圍內是線性變化的,第二,探測器的響應具有時間的穩定性,並且其受隨機噪聲的影響較小,則非均勻性引入固定模式的乘性和加性噪聲。
具體過程基本分爲三步:
一、兩溫度下采集均勻原始數據
二、根據原始數據計算校正參數
三、將矯正參數帶入實時原始圖進行校正
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