forked from divyanshusrivastava/dsp-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline_detection.m
40 lines (29 loc) · 1.06 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
33
34
35
36
37
38
39
40
%% 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('myself.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);
%%
figure
imshow(horizontal_building), title('Horizontal edges')
figure
imshow(vertical_building), title('Vertical edges')
figure
imshow(diagonal_1_building), title('Diagonal UP edges')
figure
imshow(diagonal_2_building), title('Diagonal DOWN edges')