求注释,看不懂!(小波变换的图像边缘检测算法) 20

clearall;loadwbarb;I=ind2gray(X,map);%检索图转成灰度图imshow(I);I1=imadjust(I,stretchlim(I),[... clear all;
load wbarb;
I = ind2gray(X,map);%检索图转成灰度图
imshow(I);
I1 = imadjust(I,stretchlim(I),[0,1]);%调整图像的像素值,可以改变对比度和颜色
figure;
imshow(I1);
[N,M] = size(I);

h = [0.125,0.375,0.375,0.125];
g = [0.5,-0.5];
delta = [1,0,0];

J = 3;

a(1:N,1:M,1,1:J+1) = 0;
dx(1:N,1:M,1,1:J+1) = 0;
dy(1:N,1:M,1,1:J+1) = 0;
d(1:N,1:M,1,1:J+1) = 0;

a(:,:,1,1) = conv2(h,h,I,'same');
dx(:,:,1,1) = conv2(delta,g,I,'same');
dy(:,:,1,1) = conv2(g,delta,I,'same');

x = dx(:,:,1,1);
y = dy(:,:,1,1);
d(:,:,1,1) = sqrt(x.^2+y.^2);
I1 = imadjust(d(:,:,1,1),stretchlim(d(:,:,1,1)),[0 1]);figure;imshow(I1);

lh = length(h);
lg = length(g);

for j = 1:J+1
lhj = 2^j*(lh-1)+1;
lgj = 2^j*(lg-1)+1;
hj(1:lhj)=0;
gj(1:lgj)=0;
for n = 1:lh
hj(2^j*(n-1)+1)=h(n);
end

for n = 1:lg
gj(2^j*(n-1)+1)=g(n);
end

a(:,:,1,j+1) = conv2(hj,hj,a(:,:,1,j),'same');
dx(:,:,1,j+1) = conv2(delta,gj,a(:,:,1,j),'same');
dy(:,:,1,j+1) = conv2(gj,delta,a(:,:,1,j),'same');

x = dx(:,:,1,j+1);
y = dy(:,:,1,j+1);
dj(:,:,1,j+1) = sqrt(x.^2+y.^2);

I1 = imadjust(dj(:,:,1,j+1),stretchlim(dj(:,:,1,j+1)),[0 1]);figure;imshow(I1);
End
该程序的注释有没有人知道,详细点。谢了。
展开
 我来答
晰美酒窝
2015-05-18 · TA获得超过6732个赞
知道大有可为答主
回答量:4544
采纳率:27%
帮助的人:1540万
展开全部
举个例子,希望有所帮助。clc; clear all; close all;
X=rgb2gray(imread('lena.jpg'));
x=X;
x=double(x);
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
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;
end
end%for k
if k==column-1
j=column-1;
end
else
j=j+1;
end%if
end%while
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<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(max_loc,i)=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
endfor i=2:line-2
for j=2:column-2
%链长为1
if form(i,j-1)==0 & form(i,j+1)==0 & form(i-1,j-1)==0 & form(i-1,j)==0 & form(i-1,j+1)==0 & form(i+1,j-1)==0 & form(i+1,j)==0 & form(i+1,j+1)==0
form(i,j)=0;%
end

if form(i,j)==1 & form(i,j+1)==1 & sum(sum(form(i-1:i+1,j-1:j+2)))==2
form(i,j)=0;
form(i,j+1)=0;
end if form(i,j)==1 & form(i+1,j)==1 & sum(sum(form(i-1:i+2,j-1:j+1)))==2
form(i,j)=0;
form(i+1,j)=0;
end if form(i,j)==1 & form(i+1,j+1)==1 & sum(sum(form(i:i+1,j:j+1)))==2
if sum(sum(form(i-1:i+2,j-1:j+2)))==3 & ( form(i-1,j+2)==1 | form(i+2,j-1)==1)
form(i,j)=0;
form(i+1,j+1)=0;
end
if sum(sum(form(i-1:i+2,j-1:j+2)))==4 & form(i-1,j+2)==1 & form(i+2,j-1)==1
form(i,j)=0;
form(i+1,j+1)=0;
end
end if form(i,j+1)==1 & form(i+1,j)==1 & sum(sum(form(i:i+1,j:j+1)))==2
if sum(sum(form(i-1:i+2,j-1:j+2)))==3 & ( form(i-1,j-1)==1 | form(i+2,j+2)==1)
form(i,j+1)=0;
form(i+1,j)=0;
end
if sum(sum(form(i-1:i+2,j-1:j+2)))==4 & form(i-1,j-1)==1 & form(i+2,j+2)==1
form(i,j+1)=0;
form(i+1,j)=0;
end
end
end
endmax=0;
for i=3:line-3
for j=3:column-3
s=sum(sum(form(i-2:i+2,j-2:j+2)));
for m=i-2:i+2
for n=j-2:j+2
if s>=7 & abs(coef3(m,n))<=s*3
form(m,n)=0;
end
end
end
end
endfigure;
imshow(form, []);
东莞大凡
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进... 点击进入详情页
本回答由东莞大凡提供
YaoYee
2019-10-24
知道答主
回答量:2
采纳率:0%
帮助的人:1334
展开全部
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式