資源簡介
小波的代碼-local_max_mode.m
zhengxing.m sub_m.m rank_c.m mulscale_edge.m mul_c.m max_c.m M_shift1.m local_max_mode.m local_max_dujiaoxian
zhengxing.m sub_m.m rank_c.m mulscale_edge.m mul_c.m max_c.m M_shift1.m local_max_mode.m local_max_dujiaoxian
代碼片段和文件信息
%求縱向細節(jié)v和橫行細節(jié)h的合成及模極大值
function?[out1out2]?=?local_max_mode(vhthra0n);
[rowcol]?=size(v);
for?irow=1:row
????for?jcol=1:col
????????mf(irowjcol)?=?sqrt(v(irowjcol)^2?+?h(irowjcol)^2);
????????af(irowjcol)?=?atand(v(irowjcol)/(h(irowjcol)+eps));
????end
end
m1=(n+1)/2;%n為奇數(shù)是模板的大小
m2=(n-1)/2;
max_mf=wthresh(mf‘h‘thr);
temp_mf=max_mf;
%對模長取自適應(yīng)閥值
for?irow=m1:(row-m1)
????for?jcol=m1:(col-m1)
????????if?max_mf(irowjcol)>0
???????????lefttop_h=irow-m2;%左上角橫坐標
???????????lefttop_v=jcol-m2;%左上角縱坐標
???????????sub_c=sub_m(max_mflefttop_hlefttop_vn);
%????????????mean_arry=mean(sub_c);
%????????????mean_thr=mean(mean_arry);
%????????????sub_c=wthresh(sub_c‘h‘mean_thr);
???????????if?rank_c(sub_cmax_mf(irowjcol)m1^2)
??????????????temp_mf(irowjcol)=0;
???????????else
??????????????mean_array=mean(sub_c);
??????????????adapt_thr=mean(mean_array)*a0;
??????????????temp_mf(irowjcol)=wthresh(max_mf(irowjcol)‘h‘a(chǎn)dapt_thr);
???????????end
????????end
????end
end
max_mf=temp_mf;
edge_mf(rowcol)=0;%模的極大值
%?grad(rowcol)=-1;%梯度方向
%?-1代表非極值點
%?0代表-22.5度至22.5度
%?1代表22.5度至67.5度
%?3代表-22.5度至-67.5度
%?2代表67.5度至90度以及-67.5度至-90度
for?irow=2:row-1
????for?jcol=2:col-1
???????if?max_mf(irowjcol
評論
共有 條評論