HoughFeature.accumulator#

HoughFeature.accumulator() → None[source][source]#

Compute the Hough accumulator

Every set pixel \((u, v)\) of the image votes for all the lines that pass through it, one for each quantized \(\theta\), with

\[\rho = u \cos \theta + v \sin \theta\]

quantized into steps of drho. It creates the following attributes for the instance:

  • A is the Hough “accumulator” array of integer vote counts, rows represent \(\rho\) and columns represent \(\theta\).

  • votes is a list of the number of lines found versus threshold, it can be used to select an optimal threshold. Element t is the number of lines that lines returns for minvotes=t, to within rounding, since a line is a cell of A that exceeds the threshold and is a local maximum.

  • t is the highest threshold at which a line is still found.

  • extent is \([\theta_{\mbox{min}}, \theta_{\mbox{max}}, \rho_{\mbox{min}}, \rho_{\mbox{max}}]\), the edges of the array for plotting.

Warning

The OpenCV HoughLines function does not expose its accumulator array, so it is computed here directly by voting, with the same quantization. Unlike the lines returned by lines, which are only the peaks, A holds the votes of every cell. The peaks of A and the lines from OpenCV can differ by a very few cells, where OpenCV’s single-precision arithmetic rounds a \(\rho\) value differently. This is helpful for pedagogy but it is not the array that OpenCV used.

Changed in version 2.5.0: The accumulator is computed directly by voting, so A is the complete array and not just its peaks, and extent spans the whole range of \(\rho\). Previously it was reconstructed from repeated calls of HoughLines, which was slow. The skip argument has been removed since every threshold is now counted.