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:Ais the Hough “accumulator” array of integer vote counts, rows represent \(\rho\) and columns represent \(\theta\).votesis a list of the number of lines found versus threshold, it can be used to select an optimal threshold. Elementtis the number of lines thatlinesreturns forminvotes=t, to within rounding, since a line is a cell ofAthat exceeds the threshold and is a local maximum.tis the highest threshold at which a line is still found.extentis \([\theta_{\mbox{min}}, \theta_{\mbox{max}}, \rho_{\mbox{min}}, \rho_{\mbox{max}}]\), the edges of the array for plotting.
Warning
The OpenCV
HoughLinesfunction does not expose its accumulator array, so it is computed here directly by voting, with the same quantization. Unlike the lines returned bylines, which are only the peaks,Aholds the votes of every cell. The peaks ofAand 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
Ais the complete array and not just its peaks, andextentspans the whole range of \(\rho\). Previously it was reconstructed from repeated calls ofHoughLines, which was slow. Theskipargument has been removed since every threshold is now counted.See also