I have been studying the algorithms of card.io and I have some difficulties when reading the Hough transform script.
For Hough transform, it is required to setup the accumulator, a grid that stores the vote in (rho, theta) space.
In card.io-dmz/cv/hough.cpp (https://github.com/card-io/card.io-dmz/blob/master/cv/hough.cpp#L99) line 99, It saids the number of rho numrho is given by
numrho = cvRound(((width + height) * 2 + 1) / rho);
Here width and height are the dimension of the ROI and rho is the distance resolution.
Question: I do not understand why the numerator is (width + height) * 2 + 1.
My guess is that + 1 is to count the zero value, and * 2 is to count both +ve rho and -ve rho.
But I still don't understand why width + height appears. I think it is more intuitive to replace it by sqrt(width*width + height*height), which is the largest possible value in rho.
This setting is also used in OpenCV (see this link: https://github.com/opencv/opencv/blob/master/modules/imgproc/src/hough.cpp#L128)
Any help would be appreciated. Thanks