Search code examples
c++opencvtransformprobability

Question about hough transform probabilistic


I am implementing a hough transform probabilistic algorithm.

I got the conept of the algorithm, but there is a thing that I don't understand.

The code below is from OpenCV, I understand that the rest of lines, but why do they set numrho to be ((width * height)*2 + 1) / rho other than the distance from (0,0) to (width,height)?

int i, j;
float irho = 1 / rho;

CV_Assert( img.type() == CV_8UC1 );

const uchar* image = img.ptr();
int step = (int)img.step;
int width = img.cols;
int height = img.rows;


int numangle = cvRound((max_theta - min_theta) / theta);
int numrho = cvRound(((width + height) * 2 + 1) / rho);

This is a question about algorithm, there is no error messages to put


Solution

  • rho and theta are discretization steps, you can set them to any value you prefer.

    "(width + height) * 2" is the perimeter (alias: "circumference" of your image) to be discretized