%%
clear all;
close all;
load x09402_HH.mat
load x09402_HV.mat
load x09402_VV.mat
HH= x09402_HH(1:120,1:120);
% HV= x09402_HV(1800:2100,1800:2100);
% VV= x09402_VM(1800:2100,1800:2100);
% HH= x09402_HH;
% HV= x09402_HV;
% VV= x09402_VM;
% [m,n]=size(HH);
% s=zeros(m,n,3);
% s(:,:,1)=HH;
% s(:,:,2)=HV;
% s(:,:,3)=VV;
f=HH;
figure(1);
% imagesc(f);
imshow(f);
%%
[m,n]=size(f);
for i=11:m-10,
for j=11:n-10,
temp1=f(i-3:i+3,j-3:j+3);
temp2=f(i+4:i+10,j+4:j+10);
temp3=f(i-10:i-4,j-10:j-4);
u1=mean(mean(temp1));
u2=mean(mean(temp2));
u3=mean(mean(temp3));
r12=1-min(u1/u2,u2/u1);
r13=1-min(u1/u3,u3/u1);
r(i,j)=min(r12,r13);
c12=u1/u2;c13=u1/u3;
b1=std(temp1(:),0);
b2=std(temp2(:),0);
b3=std(temp3(:),0);
r1=b1/u1;
r2=b2/u2;
r3=b3/u3;
x12=1/[1+2*(r1.^2*c12.^2+r2.^2)/(c12-1).^2];
x13=1/[1+2*(r1.^2*c13.^2+r3.^2)/(c13-1).^2];
p12=sqrt(x12);
p13=sqrt(x13);
p(i,j)=min(p12,p13);
end
end
figure(2);imshow(r);
figure(3);imshow(p);
rmin=0.5;
pmin=0.5;
for i=1:m-20,
for j=1:n-20,
x(i,j)=r(i+10,j+10);
y(i,j)=p(i+10,j+10)
x(i,j)=max(0,x(i,j)+0.5-rmin);
y(i,j)=max(0,y(i,j)+0.5-pmin);
x=x(i,j);
y=y(i,j);
deta(i,j)=(x*y)/(1-x-y+2*x*y);
if deta(i,j)>0.5
deta(i,j)=1;
else deta(i,j)=0;
end
end
end
% for i=11:m-10,
% for j=11:n-10,
% r(i,j)=max(0,r(i,j)+0.5-rmin);
% p(i,j)=max(0,p(i,j)+0.5-pmin);
% x=r(i,j);
% y=p(i,j);
% deta(i,j)=(x*y)/(1-x-y+2*x*y);
% if deta(i,j)>0.5
% deta(i,j)=1;
% else deta(i,j)=0;
% end
% end
% end
figure(4);imshow(deta);
%%
BW=edge(deta,'canny');
figure(5);
imshow(BW);title('自动阈值的sobel算子边缘检测');
ff=bwmorph(BW,'skel',6);
figure(6),imshow(ff);
%%
% [h,theta,rho]=hough(BW);
% figure(7),imshow(h,[],'XData',theta,'YData',rho,'InitialMagnification','fit');
% xlabel('\theta'), ylabel('\rho');
% axis on, axis normal, hold on;
% P = houghpeaks(h,m,'threshold',ceil(0.3*max(h(:))));
% x = theta(P(:,2)); y =rho(P(:,1));
% plot(x,y,'s','color','white');
% lines = houghlines(BW,theta,rho,P,'FillGap',5,'MinLength',7);
% figure(8), imshow(BW), hold on
% max_len = 10;
% for k = 1:length(lines)
% xy = [lines(k).point1; lines(k).point2];
% plot(xy(:,1),xy(:,2),'LineWidth',1,'Color','green');
% %determine the endpoints of the longest line segment
% len = norm(lines(k).point1 - lines(k).point2);
% if ( len > max_len)
% max_len = len;
% xy_long = xy;
% end
% end
%%
基于滑动窗口的方法对SAR图像中的建筑物进行检测
4星 · 超过85%的资源 需积分: 48 182 浏览量
2013-09-25
15:37:04
上传
评论 2
收藏 3KB RAR 举报
mu_chenxi
- 粉丝: 0
- 资源: 2
- 1
- 2
前往页