一个小波边缘检测的 MATLAB 程序
%load woman;
X=imread('Miss.bmp');
clear coef1;
clear coef2;
clear coef3;
clear form;
x=X;
x=double(x);%200 line,300 column;
line=250;
column=250;
J=6;
Tu=7;
smooth_area_num=20;
edge_area_num=40;
for i=1:line
coef1(i, :)=cwt(x(i,:),1,'bior4.4');
coef2(i,:)=cwt(x(i,:),2,'bior4.4');
coef3(i,:)=cwt(x(i,:),J,'bior4.4');
end
%正值 1,负值 0 的矩阵 temp 表示(突变点左位置)
max=0;
max_loc=0;
max_num=15;
for i=1:line
j=1;
while j<column-1
if (coef3(i,j)>0 & coef3(i,j+1)<0) | (coef3(i,j)<0 & coef3(i,j+1)>0 )%找到左位置 j
for k=j+1:column-1
if coef3(i,k)*coef3(i,j)>=0%找到右位置 k
for m=j:k
if abs(coef3(i,m))>max
max=abs(coef3(i,m));
max_loc=m;
end
end
if max>max_num
form(i,max_loc)=1;
end
j=k;
max=0;
break;
评论0