clear
I0 = imread('E:\QQ文档\1476077642\FileRecv\指纹图像\光盘上指纹\0.bmp');
I1 = imread('E:\QQ文档\1476077642\FileRecv\指纹图像\光盘上指纹\60.bmp');
I2 = imread('E:\QQ文档\1476077642\FileRecv\指纹图像\光盘上指纹\120.bmp');%读入I0,I1,I2,I3图像
I0=wiener2(I0,[3,3]);
I1=medfilt2(I1,[3,3]);
I2=medfilt2(I2,[3,3]);
figure,imshow(I0,[]);
%灰度化
I=(2/3)*(I0+I1+I2);
Q=(4/3)*(I0-0.5*I1-0.5*I2);
U=(2/3^0.5)*(I1-I2);%计算斯托克斯矢量的参量值
P=((double(Q).^2+double(U).^2).^0.5)./double(I);
A=0.5*atan(double(U)./double(Q));%计算偏振度和偏振角
figure,imshow(P,[]);title('偏振度图像');
[m,n]=size(P);
e=0;
for i = 1:m
for j = 1:n
e=e+log2(abs(double(P(i,j))));
end
end
Epp=-e/m*n;%计算偏振度图像P的信息熵
[m,n]=size(P);
g=0;
for i = 1:m-1
for j = 1:n-1
g=g+sqrt(((double(P(i,j))-double(P(i+1,j)))^2+(double(P(i,j))-double(P(i,j)))^2)*0.5);
end
end
Gpp=g/(m-1)*(n-1);%计算偏振度图像P的平均梯度
figure,imshow(A,[]);title('偏振相角图像');
figure,imshow(I,[]);title('强度图像');%得到图像P,I,A
P=mat2gray(P);
I=mat2gray(I);
A=mat2gray(A);%归一化处理
% P=wiener2(P,[3,3]);
% I=wiener2(I,[3,3]);
% A=wiener2(A,[3,3]);%维纳滤波处理
figure,imshow(P);title('归一滤波偏振度图像');
figure,imshow(I);title('归一滤波强度图像');
figure,imshow(A);title('归一滤波偏振角图像');%得到归一滤波后的偏振度和偏振相角图像
[m,n]=size(P);
sp=0;
for x = 1:m
for y = 1:n
sp=sp+(P(x,y))^2;
end
end
Ep=1/(m*n)*sp;
[m,n]=size(A);
sa=0;
for x = 1:m
for y = 1:n
sa=sa+(A(x,y))^2;
end
end
Ea=1/(m*n)*sa;
P=(double(P).*Ep+double(A).*Ea)/(Ep+Ea);
figure,imshow(P);title('偏振特征图像');%得到偏振特征图像
[m,n]=size(P);
e=0;
for i = 1:m
for j = 1:n
e=e+log2(abs(double(P(i,j))));
end
end
Eppp=-e/m*n;%计算偏振特征图像P的信息熵
[m,n]=size(P);
g=0;
for i = 1:m-1
for j = 1:n-1
g=g+sqrt(((double(P(i,j))-double(P(i+1,j)))^2+(double(P(i,j))-double(P(i,j)))^2)*0.5);
end
end
Gppp=g/(m-1)*(n-1);%计算偏振特征图像P的平均梯度
N=3;%分解层数
[C,S]=wavedec2(P,N,'haar');
[R,T]=wavedec2(I,N,'haar');%基于小波基函数对P和I进行小波分解
cA=appcoef2(C,S,'haar',N);
rA=appcoef2(R,T,'haar',N);%提取N层低频系数
CA=0.5*(cA+rA); %计算融合后的低频系数
[cH1,cV1,cD1] = detcoef2('all',C,S,1);
[rH1,rV1,rD1] = detcoef2('all',R,T,1);%提取第一层高频系数
[t,r]=size(cH1);
si=0;
for x = 1:t
for y = 1:r
si=si+(cH1(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rH1);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rH1(x,y))^2;
end
end
Ei=sp1/(m*n);
CH1=(cH1*Ep1+rH1*Ei)./(Ep1+Ei);
[t,r]=size(cV1);
si=0;
for x = 1:t
for y = 1:r
si=si+(cH1(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rV1);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rV1(x,y))^2;
end
end
Ei=sp1/(m*n);
CV1=(cV1*Ep1+rV1*Ei)./(Ep1+Ei);
[t,r]=size(cD1);
si=0;
for x = 1:t
for y = 1:r
si=si+(cD1(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rD1);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rD1(x,y))^2;
end
end
Ei=sp1/(m*n);
CD1=(cD1*Ep1+rD1*Ei)./(Ep1+Ei);%计算第一层融合后的高频系数
[cH2,cV2,cD2] = detcoef2('all',C,S,2);
[rH2,rV2,rD2] = detcoef2('all',R,T,2);%提取第二层高频系数
[t,r]=size(cH2);
si=0;
for x = 1:t
for y = 1:r
si=si+(cH2(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rH2);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rH2(x,y))^2;
end
end
Ei=sp1/(m*n);
CH2=(cH2*Ep1+rH2*Ei)./(Ep1+Ei);
[t,r]=size(cV2);
si=0;
for x = 1:t
for y = 1:r
si=si+(cV2(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rV2);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rV2(x,y))^2;
end
end
Ei=sp1/(m*n);
CV2=(cV2*Ep1+rV2*Ei)./(Ep1+Ei);
[t,r]=size(cD2);
si=0;
for x = 1:t
for y = 1:r
si=si+(cD2(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rD2);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rD2(x,y))^2;
end
end
Ei=sp1/(m*n);
CD2=(cD2*Ep1+rD2*Ei)./(Ep1+Ei);%计算第二层融合后的高频系数
[cH3,cV3,cD3] = detcoef2('all',C,S,3);
[rH3,rV3,rD3] = detcoef2('all',R,T,3);%提取第三层高频系数
[t,r]=size(cH3);
si=0;
for x = 1:t
for y = 1:r
si=si+(cH3(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rH3);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rH3(x,y))^2;
end
end
Ei=sp1/(m*n);
CH3=(cH3*Ep1+rH3*Ei)./(Ep1+Ei);
[t,r]=size(cV3);
si=0;
for x = 1:t
for y = 1:r
si=si+(cV3(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rV3);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rV3(x,y))^2;
end
end
Ei=sp1/(m*n);
CV3=(cV3*Ep1+rV3*Ei)./(Ep1+Ei);
[t,r]=size(cD3);
si=0;
for x = 1:t
for y = 1:r
si=si+(cD3(x,y))^2;
end
end
Ep1=si/(t*r);
[m,n]=size(rD3);
sp1=0;
for x = 1:m
for y = 1:n
sp1=sp1+(rD3(x,y))^2;
end
end
Ei=sp1/(m*n);
CD3=(cD3*Ep1+rD3*Ei)./(Ep1+Ei);%计算第三层融合后的高频系数
l1=S(1,1)*S(1,2);
l2=S(3,1)*S(3,2);
l3=S(4,1)*S(4,2);
C(1:l1)=CA(1:end);
C(l1+1:2*l1)=CH3(1:end);
C(2*l1+1:3*l1)=CV3(1:end);
C(3*l1+1:4*l1)=CD3(1:end);
C(4*l1+1:4*l1+l2)=CH2(1:end);
C(4*l1+l2+1:4*l1+2*l2)=CV2(1:end);
C(4*l1+2*l2+1:4*l1+3*l2)=CD2(1:end);
C(4*l1+3*l2+1:4*l1+3*l2+l3)=CH1(1:end);
C(4*l1+3*l2+l3+1:4*l1+3*l2+2*l3)=CV1(1:end);
C(4*l1+3*l2+2*l3+1:4*l1+3*l2+3*l3)=CD1(1:end);%将低频融合系数和各层的高频融合系数转换到一个行向量中
F=waverec2(C,S,'haar');%小波逆变换
F=255-F;
figure,imshow(F,[]); title('最终融合图像');%得到最终的融合图像
- 1
- 2
前往页