Content deleted Content added
Ectech2000 (talk | contribs) mNo edit summary |
mNo edit summary |
||
(41 intermediate revisions by 17 users not shown) | |||
Line 1:
{{Short description|Algorithm}}
In image processing, '''
[[Category:Image processing]]▼
▲In image processing, '''Line detection''' is an algorithm that takes a collection of n [[edge detection|edge points]] and finds all the lines on which these edge points lie.<ref name=":0">{{Cite book|url=https://www.worldcat.org/oclc/491888664|title=Digital image processing and analysis : human and computer vision applications with CVIPtools|last=Umbaugh|first=Scott E.|date=2011|publisher=CRC Press|isbn=9781439802052|edition=2nd|___location=Boca Raton, FL|oclc=491888664}}</ref> The most popular line detectors are the [[Hough transform]] and [[Kernel (image processing)|convolution]] based techniques.<ref>{{Cite web|url=http://www.mathworks.com/help/images/ref/hough.html|title=Hough transform - MATLAB hough|website=www.mathworks.com|access-date=2018-04-23}}</ref>
== Hough transform ==
The
== Convolution-based technique ==
In a [[Kernel (image processing)|
<references group="https://homepages.inf.ed.ac.uk/rbf/HIPR2/linedet.htm" />a) Horizontal mask(R1)
{| class="wikitable"
| −1
| −1
| −1
|-
| 2
| 2
| 2
|-
| −1
| −1
| −1
|}
(b) Vertical (R3)
{| class="wikitable"
| −1
| 2
| −1
|-
| −1
| 2
| −1
|-
| −1
| 2
| −1
|}
(C) Oblique (+45 degrees)(R2)
{| class="wikitable"
| −1
| −1
| 2
|-
| −1
| 2
| −1
|-
| 2
| −1
| −1
|}
(d) Oblique (
{| class="wikitable"
| 2
| −1
| −1
|-
| −1
| 2
| −1
|-
| −1
| −1
| 2
|}
<ref name=":1" />
'''R(x, y) = max(|R1 (x, y)|, |R2 (x, y)|, |R3 (x, y)|, |R4 (x, y)|''')
Line 79 ⟶ 76:
|}
As can be seen below, if mask is overlay on the image (horizontal line), multiply the coincident values, and sum all these results, the output will be the (convolved image)
== Example ==
{| class="wikitable sortable"
|
Line 149 ⟶ 148:
| -
|-
|
|
|
|
|
Line 177 ⟶ 176:
|
|-
|
|
|
|
|
Line 248 ⟶ 247:
== Code example ==
The code was used to detect only the vertical lines in an image using Matlab and the result is below. The original image is the one on the top and the result is below it. As can be seen on the picture on the right, only the vertical lines were detected
[[File:Testbuilding.jpg|thumb|Original Image]]
[[File:LineImage.png|thumb|line detection]]
<syntaxhighlight lang="matlab">
clear all
clc
% this MATLAB program will only detect vertical lines in an image
tol = 5; % define a tolerance in the angle to account for noise or edge▼
▲tol = 5;%define a tolerance in the angle to account for noise or edge
% that may look vertical but when the angle is computed
% it may not appear to be
[~, angle] = imgradient(building);
out = (angle >= 180 - tol | angle <= -180 + tol);
%this part will filter the line
out_filter = bwareaopen(out, 50);
figure, imshow(
figure, imshow(out_filter), title('Detected Lines');
</syntaxhighlight>
==See also==
* [[Digital image processing]]
* [[Canny edge detector]]
* [[Sobel operator]]
*
==References==
{{reflist}}
▲[[Category:Image processing]]
__FORCETOC__
|