matlab 检测图像中的线段

版权声明:文章版权归作者所有,请不要随意转载抄袭,情节严重,追究法律责任!! https://blog.csdn.net/Ibelievesunshine/article/details/84898360

close all;clear all;clc;
I=imread('gantrycrane.png');
I=rgb2gray(I);
h1=[-1 -1 -1;2 2 2;-1 -1 -1];
h2=[-1 -1  2;-1 2 -1;2 -1 -1];
h3=[-1 2 -1;-1 2 -1;-1 2 -1];
h4=[2 -1 -1;-1 2 -1;-1 -1 2];
J1=imfilter(I,h1);
J2=imfilter(I,h2);
J3=imfilter(I,h3);
J4=imfilter(I,h4);
J=J1+J2+J3+J4;
figure;
subplot(121);imshow(I);
subplot(122);imshow(J);

猜你喜欢

转载自blog.csdn.net/Ibelievesunshine/article/details/84898360
今日推荐