这是最初版本,还会继续修改。
function infradDepartion
tic;
f=imread('G:\20所项目\相关代码\usedForTests\9.jpg');
if ndims(f)>2
f=rgb2gray(f);
end;
order=4;
depth=4;
f=double(f);
%f=medfilt2(f);
T=wpdec2(f,order,'db8')
firstIndex=(order^depth-1)/3 % depo2ind(order,[depth,0]);
lastIndex=((order^(depth+1)-1)/3)-1 %depo2ind(order,[depth,order^depth])-1;
gaus=[];
for i=firstIndex:lastIndex
cfs=wpcoef(T,i);
cfs=cfs*1.5;
igass=judgeGauss(cfs);
gaus=[gaus,igass];
if i==firstIndex
cp=wpcoef(T,i);
[h,w]=size(cp);
y=zeros(h,w);
T=write(T,'cfs',i,y);
end;
if igass==1
m=i;
cp=wpcoef(T,m);
[h,w]=size(cp);
y=zeros(h,w);
T=write(T,'cfs',m,y);
end;
end;
f1=wprec2(T);
means=mean2(f1)
stds=std2(f1);
v=means+stds*3;
[l1,l2]=size(f1);
for i=1:l1
for j=1:l2
if f1(i,j)
f1(i,j)=0;
else
f1(i,j)=1;
end;
end;
end;
figure(1);subplot(121);
imagesc(f);
title('原始红外图像');
colormap('gray');
subplot(122);
imagesc(uint8(f1));
title('分割后的结果');
colormap('gray');
toc;
function isGauss=judgeGauss(wpacketcoef)
L=numel(wpacketcoef);
[row,col]=size(wpacketcoef);
sum1=0;
sum2=0;
Confidence=0.95;
for i=1:row
for j=1:col
temp1=wpacketcoef(i,j)^4;
temp2=wpacketcoef(i,j)^2;
sum1=sum1+temp1;
sum2=sum2+temp2;
end;
end;
k=L*(sum1/(sum2^2))-3;
if abs(k)
isGauss=1;
else
isGauss=0;
end;
实验结果一
实验结果二
实验结果三