matlab 检测图像中的线段

matlab 检测图像中的线段_第1张图片

matlab 检测图像中的线段_第2张图片

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);

 

你可能感兴趣的:(图形图像处理,matlab)