資源簡介
小波邊緣檢測matlab程序。小波邊緣檢測matlab程序。小波邊緣檢測matlab程序
代碼片段和文件信息
%load?woman;
X=imread(‘Miss.bmp‘);
clear?coef1;
clear?coef2;
clear?coef3;
clear?form;
x=X;
x=double(x);%200?line300?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 ????
????????if?(coef3(ij)>0?&?coef3(ij+1)<0)?|?(coef3(ij)<0?&?coef3(ij+1)>0?)%找到左位置j
????????????for?k=j+1:column-1
???????????????
????????????????if?coef3(ik)*coef3(ij)>=0%找到右位置k
????????????????????for?m=j:k
????????????????????????if?abs(coef3(im))>max
????????????????????????????max=abs(coef3(im));
????????????????????????????max_loc=m;
????????????????????????end
????????????????????end
????????????????????if?max>max_num
???????????????????????form(imax_loc)=1;
????????????????????end
????????????????????j=k;
????????????????????max=0;
????????????????????break;
????????????????end
????????????end%for?k
????????????if?k==column-1
????????????????j=column-1;
????????????end
????????else
????????????j=j+1;
????????end%if
????end%while
end
%for?i=1:line
%????for?j=1:column
%????????if?abs(coef1(ij))>=2*abs(coef2(ij))?%是否加絕對值?!!!!!!!!!!!!!!!!!!!!!!!!!!!
%???????????form(ij)=0;%第一種方法去噪聲
%????????end
%????end
%end
%*****************************************************
%對列作小波變換
x=x‘;
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;
for?i=1:line
????j=1;
????while?j ????
????????if?(coef3(ij)>0?&?coef3(ij+1)<0)?|?(coef3(ij)<0?&?coef3(ij+1)>0?)%找到左位置j
????????????for?k=j+1:column-1
???????????????
????????????????if?coef3(ik)*coef3(ij)>=0%找到右位置k
????????????????????for?m=j:k
????????????????????????if?abs(coef3(im))>max
????????????????????????????max=abs(coef3(im));
????????????????????????????max_loc=m;
????????????????????????end
????????????????????end
????????????????????if?max>max_num
???????????????????????form(max_loci)=1;
????????????????????end
????????????????????j=k;
????????????????????max=0;
????????????????????break;
????????????????end
????????????end%for?k
????????????if?k==column-1
????????????????j=column-1;
????????????end
????????else
????????????j=j+1;
????????end%if
????en
- 上一篇:經典三幀差法代碼
- 下一篇:matlab實現牛頓迭代法求解N次非線性方程
評論
共有 條評論