clear all
load('E:\我的文档\作业文档\sar去斑作业\radarsat_image');
yuantu=mat2gray(orig);
[row,column]=size(yuantu);%图像大小%
tuu=zeros(row,column); %RCS重构矩阵%
tu=double(yuantu); %转换数据类型%
I_mean=zeros(row,column);%设置大窗均值初始矩阵%
V_mean=zeros(row,column);%设置大窗方差初始矩阵%
v=zeros(row,column);%设置大窗等效视数初始矩阵%
w=zeros(12,1); %相关邻域12个模板归一化方差%
q=zeros(12,1);
L=1.9185;%原图等效视数%
for i=2:row-1
for j=2:column-1
if i<=4|j<=4|i>=row-3|j>=column-3
%计算大窗均值、方差矩阵%
I_mean(i,j)=mean(mean(tu(i-1:i+1,j-1:j+1)));
V_mean(i,j)=sum(sum((tu(i-1:i+1,j-1:j+1)-I_mean(i,j)).^2))/(9*I_mean(i,j)*I_mean(i,j));
v(i,j)=(1+1/L)/(V_mean(i,j)-1/L);
else
I_mean(i,j)=mean(mean(tu(i-3:i+3,j-3:j+3)));
V_mean(i,j)=sum(sum((tu(i-3:i+3,j-1:j+3)-I_mean(i,j)).^2))/(49*I_mean(i,j)*I_mean(i,j));
v(i,j)=(1+1/L)/(V_mean(i,j)-1/L);
end
if v(i,j)>=L
tuu(i,j)=I_mean(i,j);
else
w(1)=((tu(i,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i,j+1)-I_mean(i,j))^2)/((tu(i,j-1))^2+tu(i,j)^2+tu(i,j+1)^2);
w(2)=((tu(i-1,j)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i+1,j)-I_mean(i,j))^2)/((tu(i-1,j))^2+tu(i,j)^2+tu(i+1,j)^2);
w(3)=((tu(i-1,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i+1,j+1)-I_mean(i,j))^2)/((tu(i-1,j-1))^2+tu(i,j)^2+tu(i+1,j+1)^2);
w(4)=((tu(i+1,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i-1,j+1)-I_mean(i,j))^2)/((tu(i+1,j-1))^2+tu(i,j)^2+tu(i-1,j+1)^2);
w(5)=((tu(i,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i-1,j+1)-I_mean(i,j))^2)/((tu(i,j-1))^2+tu(i,j)^2+tu(i-1,j+1)^2);
w(6)=((tu(i,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i+1,j+1)-I_mean(i,j))^2)/((tu(i,j-1))^2+tu(i,j)^2+tu(i+1,j+1)^2);
w(7)=((tu(i+1,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i-1,j)-I_mean(i,j))^2)/((tu(i+1,j-1))^2+tu(i,j)^2+tu(i-1,j)^2);
w(8)=((tu(i-1,j)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i+1,j+1)-I_mean(i,j))^2)/((tu(i-1,j))^2+tu(i,j)^2+tu(i+1,j+1)^2);
w(9)=((tu(i-1,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i,j+1)-I_mean(i,j))^2)/((tu(i-1,j-1))^2+tu(i,j)^2+tu(i,j+1)^2);
w(10)=((tu(i+1,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i,j+1)-I_mean(i,j))^2)/((tu(i+1,j-1))^2+tu(i,j)^2+tu(i,j+1)^2);
w(11)=((tu(i-1,j-1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i+1,j)-I_mean(i,j))^2)/((tu(i-1,j-1))^2+tu(i,j)^2+tu(i+1,j)^2);
w(12)=((tu(i-1,j+1)-I_mean(i,j))^2+(tu(i,j)-I_mean(i,j))^2+(tu(i+1,j)-I_mean(i,j))^2)/((tu(i-1,j+1))^2+tu(i,j)^2+tu(i+1,j)^2);
[value,position]=min(w);%相关性最大的走向,找出对应的位置position%
q1='tu(i,j-1)+tu(i,j+1)';
q2='tu(i-1,j)+tu(i+1,j)';
q3='tu(i-1,j-1)+tu(i+1,j+1)';
q4='tu(i+1,j-1)+tu(i-1,j+1)';
q5='tu(i,j-1)+tu(i-1,j+1)';
q6='tu(i,j-1)+tu(i+1,j+1)';
q7='tu(i+1,j-1)+tu(i-1,j)';
q8='tu(i-1,j)+tu(i+1,j+1)';
q9='tu(i-1,j-1)+tu(i,j+1)';
q10='tu(i+1,j-1)+tu(i,j+1)';
q11='tu(i-1,j-1)+tu(i+1,j)';
q12='tu(i-1,j+1)+tu(i+1,j)';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p1='tu(i,j-1)-tu(i,j+1)';
p2='tu(i-1,j)-tu(i+1,j)';
p3='tu(i-1,j-1)-tu(i+1,j+1)';
p4='tu(i+1,j-1)-tu(i-1,j+1)';
p5='tu(i,j-1)-tu(i-1,j+1)';
p6='tu(i,j-1)-tu(i+1,j+1)';
p7='tu(i+1,j-1)-tu(i-1,j)';
p8='tu(i-1,j)-tu(i+1,j+1)';
p9='tu(i-1,j-1)-tu(i,j+1)';
p10='tu(i+1,j-1)-tu(i,j+1)';
p11='tu(i-1,j-1)-tu(i+1,j)';
p12='tu(i-1,j+1)-tu(i+1,j)';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t(1)=eval(q1); r(1)=eval(p1);
t(2)=eval(q2); r(2)=eval(p2);
t(3)=eval(q3); r(3)=eval(p3);
t(4)=eval(q4); r(4)=eval(p4);
t(5)=eval(q5); r(5)=eval(p5);
t(6)=eval(q6); r(6)=eval(p6);
t(7)=eval(q7); r(7)=eval(p7);
t(8)=eval(q8); r(8)=eval(p8);
t(9)=eval(q9); r(9)=eval(p9);
t(10)=eval(q10); r(10)=eval(p10);
t(11)=eval(q11); r(11)=eval(p11);
t(12)=eval(q12); r(12)=eval(p12);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%计算当前像素相关邻域内元素的等效视数%
alpha=r(position)^2/t(position)^2;
%计算当前像素的灰度值%
tuu(i,j)=I_mean(i,j)*((v(i,j)-2*alpha-L-1)-((2*alpha+L+1-v(i,j))^2-4*v(i,j)*(alpha*t(position)+L*tu(i,j))/I_mean(i,j))^0.5)/(2*v(i,j));
end
end
end
tuu(1,1:column)=tu(1,1:column);
tuu(1:row,1)=tu(1:row,1);
tuu(row,1:column)=tu(row,1:column);
tuu(1:row,column)=tu(1:row,column);
评论0