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.

Question for Hough space definition

 

Dear all:

(1)Excuse me; we want to clarify what the coordinate is for Hough space in VLIB? ρ(horizontal axis) /θ(vertical axis) or ρ(vertical axis) /θ(horizontal axis)?

 

 

(2)Suppose the hough space is Uint16 houghOut[267*267] which is one dimension array, what is the sequence order which correspond to the one dimension array? Distance index change first or angle index change first?

 

 

Regards,

Alan

  • Dear all:

    After looking at the demo code on VLIB, it seems tell us some ideas from code segments below:

    ===========================================================

    extern short TableSineBK_Minus80toPlus80resZeroPointSix_Q8[267];

    extern short TableCosineBK_Minus80toPlus80resZeroPointSix_Q8[267];

    extern unsigned short pEdgeMapList[2*30];

     

    #define W 100

    #define H 60

     

    unsigned short calculatedOutHoughSpace[267*267];

    unsigned short ping[267];

    unsigned short pong[267];

    unsigned short pang[267];

    unsigned short peng[267];

     

     

    void main( )

    {

            //Creating input image

        int i;

            unsigned short x,y;

            unsigned char Im[W*H];

            unsigned int listsize[1];

     

        int maxRho, maxTheta,maxVal,maxIndex;

     

       //generating input image

       memset(Im,0,W*H);

     

       for(i=0;i<30;i++)

       {

               x=i+3;

               y=x*2+10;

               Im[x+y*W]=1;

       }

       //Convert the binary image to Edge list

       wrap_binarymatrix2index(Im,W,H,pEdgeMapList,listsize);

     

       //Hough space voting memset(calculatedOutHoughSpace,0,267*267);

                   

            VLIB_houghLineFromList(

                    pEdgeMapList,

                    calculatedOutHoughSpace,

                    W, // outBlkWidth             

                    H, // outBlkHeight            

                                    30,   // listSize

                    267, // thetaRange,

                    267, // rhoMaxLength

                                    TableSineBK_Minus80toPlus80resZeroPointSix_Q8,

                               TableCosineBK_Minus80toPlus80resZeroPointSix_Q8,

                               ping,

                               pong,

                               pang,

                               peng );

       

        //Finding max

            maxVal=0;

     

            for(i=0;i<267*267;i++)

            {

                    if(calculatedOutHoughSpace[i]>maxVal)

                    {

                    maxVal= calculatedOutHoughSpace[i];

                    maxIndex = i;

                    }

            }

       

            maxRho   = maxIndex%267;

            maxTheta = maxIndex/267;

     

            draw_line(Im,W,H,maxRho,maxTheta,TableSineBK_Minus80toPlus80resZeroPointSix_Q8,TableCosineBK_Minus80toPlus80resZeroPointSix_Q8);

     

     

     

    void draw_line

    (

    unsigned char * Im,

    unsigned short W,

    unsigned short H,

    short rho,

    short theta,

    const signed short *pSIN,

    const signed short *pCOS

    )

    {                                                                     

        int x,y;

            short a,b;

            int r1;

            short rho1;

           

      signed int normLength;

      signed int diameter;      

           

      diameter = SQRTof2_Q8*max(W,H);

     

      normLength = 267 << 16;

      normLength /= diameter;  

      normLength /= 2;              

     

            a=pCOS[theta];

        b=pSIN[theta];

     

        for(y = 0; y<H; y++)

        {

                for(x = 0; x<W; x++)

            {   

                     r1=x*a+y*b;

                 rho1 = (unsigned short) (((r1+diameter) * normLength + 32768) >> 16); //unwarping the parameter rho                                

                    

                     if (abs(rho1-rho) <1)

                      Im[x+y*W]=1;

                     

             }        

        }            

       

     

    }

     

     

    What we though are:

    (1) maxRho = maxIndex%267; and maxTheta = maxIndex/267; so the coordinate for hough space is ρ(horizontal axis) /θ(vertical axis).

    (2) ρ>0 and -80°<θ<80°, which both mapping to ρ[0:267] and θ[0:267].

    (3)According to draw_line, we get one distance value for each angle value, but we can not understand the code segment below, can anyone reply the question?

    =====================================

      diameter = SQRTof2_Q8*max(W,H);

     

      normLength = 267 << 16; ????

      normLength /= diameter; ????

      normLength /= 2;       ????   

     

    …..

      rho1 = (unsigned short) (((r1+diameter) * normLength + 32768) >> 16); //unwarping the parameter rho  ????

    …..

     

     

    Regards,

    Alan