求高手注释MATLAB 程序。边缘检测的特征提取。

%小波模极大值用于边缘提取clc;clear%下载图像loadwoman%X=double(imread('1.bmp'));SIZE=length(X);%图像尺寸%多... % 小波模极大值用于边缘提取
clc;clear
% 下载图像
load woman
% X=double(imread('1.bmp'));
SIZE=length(X); % 图像尺寸
% 多尺度
m=1.0;
delta=2^m;

% 构造高斯函数的偏导
N=20; % 滤波器长度(需要调整,必须是偶数)
A=-1/sqrt(2*pi); % 幅度

for index_x=1:N;
for index_y=1:N;
x=index_x-(N+1)/2;
y=index_y-(N+1)/2;
phi_x(index_x,index_y)=A*(x/delta^2).*exp(-(x.*x+y.*y)/(2*delta^2));
phi_y(index_x,index_y)=A*(y/delta^2).*exp(-(x.*x+y.*y)/(2*delta^2));
end
end;

phi_x=phi_x/norm(phi_x); % 能量归一化
phi_y=phi_y/norm(phi_y); % 能量归一化

% 对图象做行列卷积
Gx=conv2(X,phi_x,'same');
Gy=conv2(X,phi_y,'same');

% 求梯度
Grads=sqrt((Gx.*Gx)+(Gy.*Gy));

% 求幅角(梯度方向)
angle_array=zeros(SIZE,SIZE); % 角度
% 遍历
for i=1:SIZE;
for j=1:SIZE
if (abs(Gx(i,j))>eps*100) % x的绝对值足够大
p=atan(Gy(i,j)/Gx(i,j))*180/pi; % 反正切求角度值(1,4象限)
if (p<0) % 负的幅角(4象限)
p=p+360;
end;
if (Gx(i,j)<0 & p>180) % 2象限的特殊处理
p=p-180;
elseif (Gx(i,j)<0 & p<180) % 3象限的特殊处理
p=p+180;
end
else % 90或270度
p=90;
end
angle_array(i,j)=p; % 幅角赋值
end
end;

% 找边缘
edge_array=zeros(SIZE,SIZE);
% 遍历
for i=2:SIZE-1
for j=2:SIZE-1
if ((angle_array(i,j)>=(-22.5) & angle_array(i,j)<=22.5) | ...
(angle_array(i,j)>=(180-22.5) & angle_array(i,j)<=(180+22.5))) % 0/180
if (Grads(i,j)>Grads(i+1,j) & Grads(i,j)>Grads(i-1,j))
edge_array(i,j)=Grads(i,j);
end
elseif ((angle_array(i,j)>=(90-22.5) & angle_array(i,j)<=(90+22.5)) | ...
(angle_array(i,j)>=(270-22.5) & angle_array(i,j)<=(270+22.5))) % 90/270
if (Grads(i,j)>Grads(i,j+1) & Grads(i,j)>Grads(i,j-1))
edge_array(i,j)=Grads(i,j);
end
elseif ((angle_array(i,j)>=(45-22.5) & angle_array(i,j)<=(45+22.5)) | ...
(angle_array(i,j)>=(225-22.5) & angle_array(i,j)<=(225+22.5))) % 45/225
if (Grads(i,j)>Grads(i+1,j+1) & Grads(i,j)>Grads(i-1,j-1))
edge_array(i,j)=Grads(i,j);
end
else % 135/215
if (Grads(i,j)>Grads(i+1,j-1) & Grads(i,j)>Grads(i-1,j+1))
edge_array(i,j)=Grads(i,j);
end
end
end
end
% 去除伪边缘
MAX_E=max(max(edge_array).'); % 最大幅度值
edge_array=edge_array/MAX_E; % 最大幅度值
threshold=0.2; % 阈值(需要调整)
% 遍历
for m=1:SIZE
for n=1:SIZE
if (edge_array(m,n)>threshold)
edge_array(m,n)=1;
else
edge_array(m,n)=0;
end
end
end
% 显示图像和边缘
figure(1)
subplot(1,2,1)
imshow(X,map)
title('图像')
subplot(1,2,2)
imshow(edge_array)
title('边缘')
展开
 我来答
oys02xnu
2011-03-31 · TA获得超过921个赞
知道小有建树答主
回答量:651
采纳率:0%
帮助的人:400万
展开全部
clf;
t = 0:0.0005:1;
f = 150;
xa =3*sin(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_(t)');
axis([0 0.2 -3 3])
subplot(2,1,2);
T =1.9531e-004;
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0:length(n)-1;
stem(k,xs,'.');grid;
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]');
axis([0 500 -2 2])
%欠采样部分
figure;
t = 0:0.000005:1;
f = 3000;
xa =3*sin(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_(t)');
axis([0 0.01 -3 3])
subplot(2,1,2);
T =1.9531e-004;
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0:length(n)-1;
stem(k,xs,'.');grid;
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]');
axis([0 500 -2 2])
追问
??這是啥子呀?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
东莞大凡
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进... 点击进入详情页
本回答由东莞大凡提供
baoaiya66
2011-03-31
知道答主
回答量:18
采纳率:0%
帮助的人:16.9万
展开全部
同学%分号后面的汉字就是注释呀!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式