Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

does any one has a uniform lbp c++ code with it's spatial histogram

i have a code but with error

void LBPFeatures::computeuniformlbp(Mat image,Mat &dst)
{
    uchar *ptr=image.data;
    image.copyTo(dst);
    uchar *optr=dst.data;
    int width=image.cols;
    int height=image.rows;

for(int i=1;i<height-1;i++)
{
    for(int j=1;j<width-1;j++)
    {
        int center=(int)ptr[j+i*width];
        unsigned char code=0;

        //for(int k=7;k>=0;k++)

        code|=((int)ptr[(j-1)+(i-1)*width] >=center)<<7;
        code|=((int)ptr[j+(i-1)*width] >=center)<<6 ;
        code|=((int)ptr[(j+1)+(i-1)*width] >=center)<<5 ;
        code|=((int)ptr[(j+1)+(i)*width] >=center)<<4 ;
        code|=((int)ptr[(j+1)+(i+1)*width] >=center)<<3 ;
        code|=((int)ptr[j+(i+1)*width] >=center)<<2 ;
        code|=((int)ptr[j-1+(i+1)*width] >=center)<<1 ;
        code|=((int)ptr[j-1+(i)*width] >=center)<<0 ;

       // int check=0;
        //check=code;
        //heck if the code is uniform code
        //encode only if it is a uniform code else
        //assign it a number 255
        optr[j+i*width]=lookup[code];

    }
}
initUniform();
}

can you find my error

click to hide/show revision 2
retagged

updated 2014-05-24 01:01:12 -0500

berak gravatar image

does any one has a uniform lbp c++ code with it's spatial histogram

i have a code but with error

void LBPFeatures::computeuniformlbp(Mat image,Mat &dst)
{
    uchar *ptr=image.data;
    image.copyTo(dst);
    uchar *optr=dst.data;
    int width=image.cols;
    int height=image.rows;

for(int i=1;i<height-1;i++)
{
    for(int j=1;j<width-1;j++)
    {
        int center=(int)ptr[j+i*width];
        unsigned char code=0;

        //for(int k=7;k>=0;k++)

        code|=((int)ptr[(j-1)+(i-1)*width] >=center)<<7;
        code|=((int)ptr[j+(i-1)*width] >=center)<<6 ;
        code|=((int)ptr[(j+1)+(i-1)*width] >=center)<<5 ;
        code|=((int)ptr[(j+1)+(i)*width] >=center)<<4 ;
        code|=((int)ptr[(j+1)+(i+1)*width] >=center)<<3 ;
        code|=((int)ptr[j+(i+1)*width] >=center)<<2 ;
        code|=((int)ptr[j-1+(i+1)*width] >=center)<<1 ;
        code|=((int)ptr[j-1+(i)*width] >=center)<<0 ;

       // int check=0;
        //check=code;
        //heck if the code is uniform code
        //encode only if it is a uniform code else
        //assign it a number 255
        optr[j+i*width]=lookup[code];

    }
}
initUniform();
}

can you find my error