[ACCEPTED]-What's the use of Canny before HoughLines (opencv)?-hough-transform

Accepted answer
Score: 13

First of all, to detect lines you need to 13 work on a boolean matrix image (or binary), I mean: the 12 color is black or white, there's no grayscale.

HoughLines()'s requirement 11 to work properly is to have this kind of 10 image as input. That's the reason you have 9 to use Canny or Treshold, to convert the colored image matrix 8 into a boolean one.

Hough transformation

A line in one picture is actually 7 an edge. Hough transform scans the whole 6 image and using a transformation that converts 5 all white pixel cartesian coordinates in polar 4 coordinates; the black pixels are left out. So 3 you won't be able to get a line if you first 2 don't detect edges, because HoughLines() don't know 1 how to behave when there's a grayscale.

Score: 13

Short Answer

cvCanny is used to detect Edges, as well 29 as increase contrast and remove image noise. HoughLines 28 which uses the Hough Transform is used to 27 determine whether those edges are lines 26 or not. Hough Transform requires edges to 25 be detected well in order to be efficient 24 and provide meaning results.

Long Answer

The Limitations 23 of the Hough Transform are described in more detail on 22 Wikipedia.

The efficiency of the Hough Transform 21 relies of the bin of acculumated pixel being 20 distinct, e.g. a direct contrast between 19 a pixel and its surrounding neighbours or 18 if using a mask region a pixel region and 17 its surrounds regions. If all pixels had 16 similar acculumated values nothing would 15 stand out as a line or circle. This leads 14 to the reduction of colour (colour to grayscale, grayscale 13 to black and white) in order to increase 12 contract.

The number of parameters to the 11 Hough Transform also increase the spread 10 of votes in the pixel bins and increase 9 the complexity of the transform, which mean 8 that normally only lines or circles are 7 reliably detected using it as they have 6 less than 3 parameters.

The edges need to 5 be detected well before running the Hough 4 Transform otherwise its efficiency suffers 3 further. Also noisy images don't work well 2 with Hough transform unless the noise is 1 removed before hand.

Score: 5

Theoretically, you are correct. Finding 16 edges is not absolutely required for the 15 Hough Line algorithm to work.

The way the 14 Hough works is basically it takes every 13 point and connects it to every other point, and 12 whatever points have the most lines going 11 through them, those lines stay. For this, we 10 need points. The Canny creates those points. Theoretically 9 you could use any sort of filter - isolate 8 all blue or purple points and connect them, whatever 7 - but edges works well.

The Hough also does 6 not weight its lines or points. To the 5 Hough, an image is binary - made up of either 4 1s or 0, points or not points. There is 3 no need for greyscale, and the canny conveniently 2 returns binary images.

Thus is the Canny 1 always part of the Hough.

More Related questions