How to extract all pixels in houghlines top accumulator?

asked 2018-03-31 23:54:59 -0500

I am running houghlines transform on the edges of an image, and I would like to gather all the pixels found on the perceived line and do a least square method on the pixels. Hence, I would have to extract all the pixels from the top vote of houghlines.

I am doing some adjustments to the source code. I do so by creating a new function in my code. However, I am having trouble understanding this from the source code.

// stage 1. fill accumulator
for( i = 0; i < height; i++ )
    for( j = 0; j < width; j++ )
        if( image[i * step + j] != 0 )
            for(int n = 0; n < numangle; n++ )
                int r = cvRound( j * tabCos[n] + i * tabSin[n] );
                r += (numrho - 1) / 2;
                accum[(n+1) * (numrho+2) + r+1]++;

What does accum[(n+1) * (numrho+2) + r+1] mean? Why is it filling up a whole column?

Anyone know how to save the i and j whereby I can extract the i and j of the highest voted rho and theta?

edit retag flag offensive close merge delete


You don't need to save i and j. Using highest voted (rho and theta) you can draw the line using lineiterator and get all points

LBerger gravatar imageLBerger ( 2018-04-01 03:02:57 -0500 )edit

It will show all the points of the picture? I only want i and j that are dark pixels on the image. I have just read about the bresanham line algorithm, but it does not take into account the gaps in the edges that may occur

Splintersfur gravatar imageSplintersfur ( 2018-04-01 03:54:35 -0500 )edit