MATLAB提取边缘点坐标,在曲线上每隔几个像素或相同的距离采一个特征点,然后提取出边缘点坐标,方法如下:
%寻找像素为1的点 col为横坐标 row为纵坐标[col,row]=find(I == 1)
%在一定范围内筛选坐标
for(col=1:1024 )
for(row=1:768)
if(col>374 & col<481 &row>146 &row<246)
[col,row] %输出坐标
end
end
end
clft = 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])
I=imread('lena.bmp')% 提取图像BW1=edge(I,'sobel')%用SOBEL算子进行边缘检测
BW2=edge(I,'roberts')%用Roberts算子进行边缘检测
BW3=edge(I,'prewitt')%用prewitt算子进行边缘检测
BW4=edge(I,'log')%用log算子进行边缘检测
BW5=edge(I,'canny')%用canny算子进行边缘检测
h=fspecial('gaussian’,5)
BW6=edge(I,’canny’)
subplot(2,3,1), imshow(BW1)
title(‘sobel edge check’)
subplot(2,3,2), imshow(BW2)
title(‘sobel edge check’)
subplot(2,3,3), imshow(BW3)
title(‘prewitt edge check’)
subplot(2,3,4), imshow(BW4)
title(‘log edge check’)
subplot(2,3,5), imshow(BW5)
title(‘canny edge check’)
subplot(2,3,6), imshow(BW6)
title(‘gasussian&canny edge check’)%此为用高斯滤波后Canny算子边缘检测结果
(注意:代码中有一些标点是中文模式,若输入代码后标点显示红色,则为中文标点,改回来就行了)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)