Finds lines in a binary image using the standard Hough transform.
cv2.HoughLines(image, rho, theta, threshold[, lines[, srn[, stn[, min_theta[, max_theta]]]]]) → lines
rho
. The coarse accumulator distance resolution is rho
and the accurate accumulator resolution is rho/srn
. If both srn=0
and stn=0
, the classical Hough transform is used. Otherwise, both these parameters should be positive. Default is 0.theta
. Default is 0.max_theta
. Default is 0.min_theta
and CV_PI
. Default is CV_PI
.In general, lines can be represented by the equation \(\rho = x \cos \theta + y \cos \theta\), where \(\theta\) lies in the range \([0, \pi]\) and \(\rho\) has a finite range determined by the image. The parameters \(\rho\) and \(\theta\) in the function signature determine how many pieces these finite ranges are partitioned into. For each pixel \((x,y)\) in the image, and for each value of \(\theta\), the value of \(\rho\) can be determined by the line equation. This value is then used to update an accumulator matrix to track the number of pixels satisfying each potential combination of \(\rho\) and \(\theta\).
Once the accumulator matrix has been constructed, the threshold parameter determines which entries in the accumulator matrix are large enough (have enough pixels mapped) to form a line. A larger threshold value will result in fewer lines.