-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathline_detection.m
32 lines (26 loc) · 1.09 KB
/
line_detection.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%% Experiment 13
%% Line Detection
% In Edge Detection, a pixel is attenuated, if there is a dramatic change
% in color in any direction.
% Line detection is a special kind of edge detection. For line detection,
% the direction in which a color changes is considered is restricted.
%%
% The common filter kernels are
edge = [-1 -1 -1;- 1 8 -1;-1 -1 -1];
horizontal = [-1 -1 -1;2 2 2;-1 -1 -1];
vertical = [-1 2 -1;-1 2 -1;-1 2 -1];
diagonal_1 = [-1 -1 2;-1 2 -1; 2 -1 -1];
diagonal_2 = [2 -1 -1;-1 2 -1;-1 -1 2];
%%
building = imread('build.jpg');
imshow(building), title('ORIGINAL IMAGE')
%%
horizontal_building = imfilter(building, horizontal);
vertical_building = imfilter(building, vertical);
diagonal_1_building = imfilter(building, diagonal_1);
diagonal_2_building = imfilter(building, diagonal_2);
%%
subplot(221),imshow(horizontal_building), title('Horizontal edges')
subplot(222),imshow(vertical_building), title('Vertical edges')
subplot(223),imshow(diagonal_1_building), title('Diagonal UP edges')
subplot(224),imshow(diagonal_2_building), title('Diagonal DOWN edges')