[{"@context":"http:\/\/schema.org\/","@type":"BlogPosting","@id":"https:\/\/wiki.edu.vn\/en\/wiki40\/line-detection-wikipedia\/#BlogPosting","mainEntityOfPage":"https:\/\/wiki.edu.vn\/en\/wiki40\/line-detection-wikipedia\/","headline":"Line detection – Wikipedia","name":"Line detection – Wikipedia","description":"before-content-x4 From Wikipedia, the free encyclopedia after-content-x4 Algorithm In image processing, line detection is an algorithm that takes a collection","datePublished":"2015-04-03","dateModified":"2015-04-03","author":{"@type":"Person","@id":"https:\/\/wiki.edu.vn\/en\/wiki40\/author\/lordneo\/#Person","name":"lordneo","url":"https:\/\/wiki.edu.vn\/en\/wiki40\/author\/lordneo\/","image":{"@type":"ImageObject","@id":"https:\/\/secure.gravatar.com\/avatar\/c9645c498c9701c88b89b8537773dd7c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c9645c498c9701c88b89b8537773dd7c?s=96&d=mm&r=g","height":96,"width":96}},"publisher":{"@type":"Organization","name":"Enzyklop\u00e4die","logo":{"@type":"ImageObject","@id":"https:\/\/wiki.edu.vn\/wiki4\/wp-content\/uploads\/2023\/08\/download.jpg","url":"https:\/\/wiki.edu.vn\/wiki4\/wp-content\/uploads\/2023\/08\/download.jpg","width":600,"height":60}},"image":{"@type":"ImageObject","@id":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/3\/3e\/Testbuilding.jpg\/220px-Testbuilding.jpg","url":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/3\/3e\/Testbuilding.jpg\/220px-Testbuilding.jpg","height":"197","width":"220"},"url":"https:\/\/wiki.edu.vn\/en\/wiki40\/line-detection-wikipedia\/","about":["Wiki"],"wordCount":2038,"articleBody":" (adsbygoogle = window.adsbygoogle || []).push({});before-content-x4From Wikipedia, the free encyclopedia (adsbygoogle = window.adsbygoogle || []).push({});after-content-x4AlgorithmIn image processing, line detection is an algorithm that takes a collection of n edge points and finds all the lines on which these edge points lie.[1] The most popular line detectors are the Hough transform and convolution-based techniques.[2] (adsbygoogle = window.adsbygoogle || []).push({});after-content-x4Table of ContentsHough transform[edit]Example[edit]Code example[edit]See also[edit]References[edit]Hough transform[edit]The Hough transform[3] can be used to detect lines and the output is a parametric description of the lines in an image, for example \u03c1 = r cos(\u03b8) + c sin(\u03b8).[1] If there is a line in a row and column based image space, it can be defined \u03c1, the distance from the origin to the line along a perpendicular to the line, and \u03b8, the angle of the perpendicular projection from the origin to the line measured in degrees clockwise from the positive row axis. Therefore, a line in the image corresponds to a point in the Hough space.[4] The Hough space for lines has therefore these two dimensions \u03b8 and \u03c1, and a line is represented by a single point corresponding to a unique set of these parameters. The Hough transform can then be implemented by choosing a set of values of \u03c1 and \u03b8 to use. For each pixel (r, c) in the image, compute r cos(\u03b8) + c sin(\u03b8) for each values of \u03b8, and place the result in the appropriate position in the (\u03c1, \u03b8) array. At the end, the values of (\u03c1, \u03b8) with the highest values in the array will correspond to strongest lines in the imageIn a convolution-based technique, the line detector operator consists of a convolution masks tuned to detect the presence of lines of a particular width n and a \u03b8 orientation. Here are the four convolution masks to detect horizontal, vertical, oblique (+45 degrees), and oblique (\u221245 degrees) lines in an image. (adsbygoogle = window.adsbygoogle || []).push({});after-content-x4a) Horizontal mask(R1)\u22121\u22121\u22121222\u22121\u22121\u22121(b) Vertical (R3)\u221212\u22121\u221212\u22121\u221212\u22121(C) Oblique (+45 degrees)(R2)\u22121\u221212\u221212\u221212\u22121\u22121(d) Oblique (\u221245 degrees)(R4)2\u22121\u22121\u221212\u22121\u22121\u221212[5]In practice, masks are run over the image and the responses are combined given by the following equation:R(x, y) = max(|R1 (x, y)|, |R2 (x, y)|, |R3 (x, y)|, |R4 (x, y)|)If R(x, y) > T, then discontinuityAs 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). For example, (\u22121)(0)+(\u22121)(0)+(\u22121)(0) + (2)(1) +(2)(1)+(2)(1) + (\u22121)(0)+(\u22121)(0)+(\u22121)(0) = 6 pixels on the second row, second column in the (convolved image) starting from the upper left corner of the horizontal lines.[1] page 82Example[edit]Horizontal lineconvolved image0000––––1111=–66–Mask*0000––––\u22121\u22121\u22121222\u22121\u22121\u22121*Vertical lineconvolved image0010––––0010=–00–0010––––These masks above are tuned for light lines against a dark background, and would give a big negative response to dark lines against a light background.[5]Code example[edit]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 clear allclc% this MATLAB program will only detect vertical lines in an imagebuilding = imread('building.jpg'); % This will upload the image buildingtol = 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 (adsbygoogle = window.adsbygoogle || []).push({});after-content-x4"},{"@context":"http:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https:\/\/wiki.edu.vn\/en\/wiki40\/#breadcrumbitem","name":"Enzyklop\u00e4die"}},{"@type":"ListItem","position":2,"item":{"@id":"https:\/\/wiki.edu.vn\/en\/wiki40\/line-detection-wikipedia\/#breadcrumbitem","name":"Line detection – Wikipedia"}}]}]