page_title: Line detection
section_title: Code example
hierarchical_section_title: Line detection / Code example
caption_attribution_description: English: line detection
context_page_description: In 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. The most popular line detectors are the Hough transform and convolution-based techniques.
context_section_description: 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 <= -180 + tol);%this part will filter the lineout_filter = bwareaopen(out, 50);figure, imshow(building), title('Original Image');figure, imshow(out_filter), title('Detected Lines');
caption: line detection
exif: {}