I'm trying to implement Hough transform algorithm.
I set the origin of cartesian plane in upper left corner of the image.
The range of theta (angle between rho and X axis) is 1..180, with a step of 1 degree. The maximum size of rho is the size of diagonal of the image. I want to calculate the accumulator matrix. Given the information above its size should be Y: rho, X: 180 (theta).
The algorithm seems simple to me, but there is a problem with rho. There will be negative values for it. For theta from 0 to PI/2 rho will be only positive, because sin and cos are positive. Yet for theta from PI/2 to PI, because cos is negative here, while sin positive, depending on x, y coordinates of the point, rho might have negative values.
My question is: how should I deal with the negative values of rho when calculating the accumulator matrix? Where should I place them?