What's the difference between a classical Hough transform and a multi-scale Hough transform?

Viewed 119

I'm looking at the documentation of OpenCV's cv2.HoughLines(), and the documentation references a multi-scale Hough transform. What is the difference between a classical Hough transform and a multi-scale Hough transform?

1 Answers

First you will need to understand how the Hough Transform algorithm works in general. It is not clear from your question how familiar you are with it.
I recomend to read the following if needed:

  1. The description of the algorithm, refered to from the opencv documentation you mentioned in your qeustion: Hough Transform.
  2. OpenCV's tutorial for Hough Line Transform.

In a nutshell, the classical algorithm is composed of the following elements (all the angles are represented in degrees rather than radians only for conveniency):

  1. A line is parametrized by it's perpendicular distance from the origin (ρ - rho), and the angle formed by this perpendicular line (θ - theta).
  2. The rho and theta parameters of cv::HoughLines actuallly determine the resolution of ρ and θ. Since the distance is bound by the image diagonal size, and the angle is 0..180, we can create a matrix of all the combinations of distances and angles (according to the resolution). This is called the accumulator.
    E.g.: if image diagonal is 100 and rho parameter is 20, we'll get the following ρ values in the matrix: 0,20,40,60,80,100. same applies for the angle. Each cell in the accumulator matrix represents one potential line (with a specific ρ,θ) .
  3. The input image must be a binary mask. We traverse all the "lit" pixels. Each pixel can belong to multiple lines (according to various ρ and θ). We increment each cell in the accumulator that correspond to any of these lines. This is like voting for it.
  4. Eventually we pick the lines with the highest votes (depending on the threshold) as the output.

The multi-scale version adds the following, to form an iterative process:

  1. Instead of applying a single resolution for ρ, srn parameter determined the divisor for the distance resolution.
  2. Similarly instead of applying a single resolution for θ, stn parameter determined the divisor for the angle resolution.
  3. There are also min_theta and max_theta parameters that can limit the range of the angles we track.

In general the multi-scale version can offer better result (due to trying more resolutions), for the price of heavier computation.
I haven't found formal documentation about the exact way this iterative process is done.
But from the comments in the opencv source code, it seems like at least 2 iterations are done: One coarse (with rho and theta) and one fine (with rho/srn and theta/stn).

I recommend you to try both and compare result quality and processing time in your specific case.

Note that there is also a probabalistic version - see cv::HoughLinesP

Related