This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

VLIB Hough Transform Parameter

Hello,

For a lane detection algorithm I want to use the VLIB_houghLineFromList() from VLIB. I'm working on a TDA3x and the algo should run on a C66x DSP.

My question is: How do I get the houghLineFromList function to produce correct theta and rho values? Let's say in my case i have an image/ROI of 1920x500 pixel. How do I choose the right values for NUMTHETA and RHOMAX to get correct results? If I want theta to range from -90° to 89° do I simply set NUMTHETA to 180? And should I set RHOMAX to 2*sqrt(W^2 + H^2)?

I looked at the HoughLinesDemo included in the VLIB release and couldn't really understand why you choose the values 267(NUMTHETA) and 600 (RHOMAX). I also searched through the e2e forums, but unfortunately I couldn't find an answer. I'm using vlib_c66x_3_3_0_3.

Thanks in advance,

Tobias

  • Hi Tobias,

    I've forwarded this to the c66c DSP libraries experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Hello all,

    I am also interested in an answer to the question.

    Best regards,
    Milan

  • Hello,

    can anyone of the experts help me with this issue?

    I also noticed that i have to set RHOMAX to an high value (6000) to get an actual line thats only 1 pixel wide (in the draw_line function). If I set RHOMAX low (e.g. 600) the printed line is like 6 pixel wide. But theta values seem to be correct then..

    Regards,
    Tobias
  • Hi,
    RHOMAX is related to the diameter parameter in the HoughforLines kernel. Diameter is typically set to sqrt(W^2+H^2). So, if you want a rho resolution of 1 in your histogram graph, then you can set RHOMAX = 2*diameter. (-RHOMAX to +RHOMAX).
    NUMTHETA is the number of bins you want on the theta side. The kernel uses theta resolution to be one. You can use NUMTHETA for any range you want (-90 to 89 as you desire). However, the theta values are generated and stored based on the lookup table. Hence, you need to modify your lookup table accordingly. Hope this helps.
  • Hi Prashanth,
    thank you for your answer.

    I got one more question: I set my RHOMAX to 3846 (2*sqrt(1920^2+100^2) and NUMTHETA to 180 (-90 to 80, I modified the LUTs). As a test picture I used an Image containing only one straight vertical line which is 500 pixels away from the left border of the image. After VLIB_houghLineFromList and the code from the HoughLinesDemo I get some results for maxRho and maxTheta:
    maxTheta is set to 90, which seems correct, because the 90th element in my Theta-LUT is Theta for an angle of 0 degrees. (vertical line)
    maxRho is set to 2274, which makes no sense to me. I expected maxRho to be 500 or 2420 (1920+500) depending on where the start point for rho measurement is located. How can i turn the maxRho value into the "correct" one?

    Regards,
    Tobias
  • Hi Tobias,

      The Diameter in the kernel is not computed as 2*sqrt(W^2 + H^2). Instead, it is optimized to be sqrt(2) * max(W,H) according to the kernel. You can set RHOMAX accordingly. Also, there could be rounding off occurring due to aligned accesses. The final houghspace buffer is divided into 4 buffers ping, pong, peng and pang each of size of RHOMAX length. These buffers are updated assuming they are aligned accesses. So, you would need to account for that as well.

    Anyway, one question I have is: when you back map the maxRho/maxtheta of 2274 to the image co-ordinates, does it represent the vertical line in the image?

  • Hey Prashant,

    Do you mean the draw_line function? Yes, it outputs the correct x- and y-coordinates and draws in the line correctly (from [500:0] till [500:99] in the image). So I guess its working correctly, but with distorted maxRho values which I dont understand.

    For working pusposes I made a little workaround and calculated the "real" Rho from x, y and Theta using the formula Rho = (x * cos(Theta) + y * sin(Theta)) which works fine for now.

    Regards,
    Tobias
  • So do you know, which exact values I have to use for RHOMAX or the "diameter" parameter in draw_line() to get an maxRho value of 500 or 2420 (1920+500)? Because that would be the correct Rho value by definition, am I right? (see here en.wikipedia.org/.../Hough_transform) And these are the values I could work with more easily..

    Thanks!
  • As I mentioned earlier, please take into account the formula for diameter used in the kernel, and all the optimizations done in the kernel and set the rhomax accordingly. I havent tried it myself, so I do not know the answer for your particular example.