function [edgemap]=roewa(I,ratioT)
%對影像I進行ROEWA法邊緣檢測 得到最終的二值邊緣圖bwedge edgemap;邊緣檢測強度圖 double型別
%ratioT:判決門限比率值 ratioT=判決值/max(edgemap(:))
% I=imread('首爾L波段9米解析度.bmp');%輸入影像
%I=imread('seashore.bmp');%輸入影像
% a=imread('roadsw_gray_crop.jpg');
% I=rgb2gray(a)
% I=a
%I=frost(I);
%ratioT=0.8;%判決門限比率值
proto_I=I;
I=double(I);
alfa=0.1;
b=exp(-alfa);
a=1-b;
[r,c]=size(I);
%計算水平方向邊緣圖
s1=zeros(r,c);
s2=zeros(r,c);
s1(1,:)=I(1,:);
for j=1:c
for i=2:r
s1(i,j)=a*(I(i,j)-s1(i-1,j))+s1(i-1,j);
end
end
s2(r,:)=s1(r,:);
for j=1:c
for i=r-1:-1:1
s2(i,j)=a*(I(i,j)-s2(i+1,j))+s2(i+1,j);
end
end
s=s1/(1+b)+b*s2/(1+b);
x1=zeros(r,c);
x2=zeros(r,c);
x1(:,1)=s(:,1);
for i=1:r
for j=2:c
x1(i,j)=a*(s(i,j)-x1(i,j-1))+x1(i,j-1);
end
end
x2(:,c)=s(:,c);
for i=1:r
for j=c-1:-1:1
x2(i,j)=a*(s(i,j)-x2(i,j+1))+x2(i,j+1);
end
end
%計算垂直方向邊緣圖
s1=zeros(r,c);
s2=zeros(r,c);
s1(:,1)=I(:,1);
for i=1:r
for j=2:c
s1(i,j)=a*(I(i,j)-s1(i,j-1))+s1(i,j-1);
end
end
s2(:,c)=s1(:,c);
for i=1:r
for j=c-1:-1:1
s2(i,j)=a*(I(i,j)-s2(i,j+1))+s2(i,j+1);
end
end
s=s1/(1+b)+b*s2/(1+b);
y1=zeros(r,c);
y2=zeros(r,c);
y1(1,:)=s(1,:);
for j=1:c
for i=2:r
y1(i,j)=a*(s(i,j)-y1(i-1,j))+y1(i-1,j);
end
end
y2(r,:)=s2(r,:);
for j=1:c
for i=r-1:-1:1
y2(i,j)=a*(s(i,j)-y2(i+1,j))+y2(i+1,j);
end
end
edgemap=zeros(r,c);
rx=zeros(r,c);
ry=zeros(r,c);
for i=1:r
for j=1:c
rx(i,j)=max(x1(i,j)/x2(i,j),x2(i,j)/x1(i,j));
ry(i,j)=max(y1(i,j)/y2(i,j),y2(i,j)/y1(i,j));
edgemap(i,j)=sqrt(rx(i,j)^2+ry(i,j)^2);
end
end
最終用ostu閾值化效果圖怎么是這個樣子的,看看我的邊緣強度的計算是不是有錯
uj5u.com熱心網友回復:
博主當年這個演算法實作程序應該是沒有問題的吧,邊緣有點粗是比較奇怪轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/86634.html
標籤:其他開發語言
上一篇:Anaconda萌新求助
