Ask Your Question

Hm's profile - activity

2020-09-09 10:34:31 -0600 received badge  Popular Question (source)
2018-06-10 06:20:30 -0600 received badge  Popular Question (source)
2017-04-27 04:41:58 -0600 received badge  Notable Question (source)
2016-03-18 08:45:29 -0600 received badge  Popular Question (source)
2014-12-06 05:07:42 -0600 asked a question what is the error in my code

i have code for reading data from text file to put them into array of double element the code has no error in compiling but when executing and print the element of array i found they have no data, where is the error the text file has the data and loaded correctly

this is my code:

    double** TrainData = new double*[NumTrn];
for (int i = 0; i < NumTrn; i++)
    TrainData[i] = new double[NumFe];

double** TestData = new double*[NumTst];
for (int i = 0; i < NumTst; i++)
    TestData[i] = new double[NumFe];

int* TrainLabels = new int[NumTrn];
int* TestLabels = new int[NumTst];

const char* trnfile = "Winners.trn";
const char* tstfile = "Winners.tst";

ifstream Trn(trnfile);
ifstream Tst(tstfile);
for (int i = 0; i < NumTrn; i++)
{
    Trn >> TrainLabels[i];
    for (int j = 0; j < NumFe; j++)
    {
        Trn >> TrainData[i][j];
        cout << TrainLabels[i] << "\t" << TrainData[i][j] << "\t";
    }
    cout << "\n";
}

for (int i = 0; i < NumTst; i++)
{
    Tst >> TestLabels[i];
    //cout<<TestLabels[i]<<"\t";
    for (int j = 0; j < NumFe; j++)
        Tst >> TestData[i][j];
}

thanks

2014-12-06 04:25:18 -0600 asked a question where is the error in my code

i have code for reading data from text file to put them into array of double element the code has no error in compiling but when executing and print the element of array i found they have no data, where is the error the text file has the data and loaded correctly

this is my code:

    double** TrainData = new double*[NumTrn];
for (int i = 0; i < NumTrn; i++)
    TrainData[i] = new double[NumFe];

double** TestData = new double*[NumTst];
for (int i = 0; i < NumTst; i++)
    TestData[i] = new double[NumFe];

int* TrainLabels = new int[NumTrn];
int* TestLabels = new int[NumTst];

const char* trnfile = "Winners.trn";
const char* tstfile = "Winners.tst";

ifstream Trn(trnfile);
ifstream Tst(tstfile);
for (int i = 0; i < NumTrn; i++)
{
    Trn >> TrainLabels[i];
    for (int j = 0; j < NumFe; j++)
    {
        Trn >> TrainData[i][j];
        cout << TrainLabels[i] << "\t" << TrainData[i][j] << "\t";
    }
    cout << "\n";
}

for (int i = 0; i < NumTst; i++)
{
    Tst >> TestLabels[i];
    //cout<<TestLabels[i]<<"\t";
    for (int j = 0; j < NumFe; j++)
        Tst >> TestData[i][j];
}

thanks

2014-11-06 04:08:53 -0600 commented question copyTo error

i can't change croped_ image size as it is detected area from another image and i want to put it in center of black image in order to make it with another size without using resizing as resize function make my data low accuracy

2014-11-05 13:39:08 -0600 asked a question copyTo error

i need to copy a cropped image with different size to the center of another black image with fixed size , when i use copyTo function i have an error

the function as:

Mat black_image(55,50,CV_8UC1,Scalar(0));
crop_image.copyTo(black_image(Rect((black_image.cols - crop_image.cols )/2, (black_image.rows +crop_image.rows )/2,crop_image.cols, crop_image.rows)));

the error as:

opencv error:assertion failed obj->size size<cols,rows> core\src\matrix line 1392

2014-09-28 14:48:38 -0600 asked a question k-nearest neighborhood interruption

i downloaded knn c++ code this code takes two text files train file and test file each has vectors and its labels the vector in text file is look like: 1.2,2.2,5.6,....,1 2.1,1,5,5.5,....,1 1.2,2.5,3.6,....,2 the last index in vector is the label for this vector the code read the data from these files with this function

bool readData4File (char *filename, TRAINING_EXAMPLES_LIST *rlist, 
                    int *rlistExamples)
{
    FILE *fp = NULL;
    int len = 0;
    char line[LINE_MAX+1];
    int lineSize = LINE_MAX;
    TrainingExample *TEObj;
    int index = 0;
    int numExamples = 0;

    *rlistExamples = 0;

    line[0] = 0;

    if((fp = fopen (filename, "r")) == NULL)
    {
        cout<<"Error in opening file."<<endl;
        return false;
    }

    //Initialize weights to random values
    srand (time(NULL));

    char *tmp;
    int tmpParams = 0; //NO_OF_ATT;
    int i = 0;
    double cd = 0.0;

    /* Read the data file line by line */
    while((len = GetLine (line, lineSize, fp))!=0) 
    {
        TEObj = new TrainingExample ();
        tmp = strtok (line,",");
        while (tmp != NULL)
        {
            cd = atof (tmp);
            TEObj->Value[tmpParams] = cd;
            tmpParams ++;

            tmp = strtok (NULL, ",");

            if(tmpParams == NO_OF_ATT)
            {
                tmpParams = 0;
                cd = 0.0;
                line[0] = 0;
                numExamples ++;

                //Not using this normalization anymore. 
                // N(y) = y/(1+y)
                // Doing normalization by standard deviation and mean
                //TEObj->NormalizeVals ();

                /* Generating random weights for instances. */
                /* These weights are used in instance WKNN  */
                double rno = (double)(rand () % 100 + 1);
                TEObj->Weight = rno/100;
                TEObj->index = index++;
                TEObj->isNearest2AtleastSome = false;
                break;
            }
        }

        rlist->insert (rlist->end(), *TEObj);

        delete TEObj;
    }

then the code send the list of vectors in order to classify test vectors i have 1405 train vector and 810 test vector, when running the code read the number of vectors as 1405 and 810 but the list of training and text vectors has 2810 and 1620 index what is the content of these lists and why they have the double number of train and test vectors! my result is 183% for accuracy as the code send the list not the examples why!

2014-09-15 17:14:39 -0600 commented question self organizing map accuracy

i'm not totally sure about this code but i need from my code to obtain accuracy by comparing the result of test images classes with the true classes for these images

2014-09-15 16:27:19 -0600 commented question self organizing map accuracy

Ok, do you have a better code for this function

2014-09-15 15:49:34 -0600 asked a question self organizing map accuracy

i have a self organizing map c++ code which give me an accuracy for recognition system but when using this code i have a wrong accuracy by classification function anyone here can tell me where is the error with this code or give me better code for accuracy

 void  Network::classify()
{float acc;

int f=0;
for(int i=0; i<TstImgNum;i++)
{
    if((ilayer->ID[i])==label[i])
        f++;
}
 acc=((float) f / (float)TstImgNum) *100;
cout <<"\nSOM ACC="<<(((float) f / (float)TstImgNum) *100)<<"%";
cout <<"\nSOM ACC="<<acc<<"%/n";
}
2014-06-12 14:51:48 -0600 asked a question knn c++ code changing

i have c++ code for knn classifier i can use this code after self organizing map, it give me accuracy for classification but now i have group of vectors each has mean in my knn code: it take No of train image, No of test image, and som map dimension but with these vector: i have No of train vectors, No of test vectors, and its mean what about map dimension now how can i change this code in order to take these vectors and make classification with only its mean without self organizing map this is my code which work with som code and i need to work it without som:

#include "knn.h"
#include <string>

KNN::KNN(int Ntrn,int Ntest,int NF)
{

    NumTrn=Ntrn;
    NumTst=Ntest;
    NumFe=NF;
    TrainData=new int*[Ntrn];
    for(int i=0;i<Ntrn;i++)
        TrainData[i]=new int[NF];

    TestData=new int*[Ntest];
    for(int i=0;i<Ntest;i++)
        TestData[i]=new int[NF];

    Dist=new double*[Ntest];
    for(int i=0;i<Ntest;i++)
        Dist[i]=new double[Ntrn];

    SLabels=new int*[Ntest];
    for(int i=0;i<Ntest;i++)
        SLabels[i]=new int[Ntrn];

    TrainLabels=new int[Ntrn];
    TestLabels=new int[Ntest];
    index=new int[Ntest];

    DistLabels=new int[Ntrn];

    Count=new int*[Ntest];
    for(int i=0;i<Ntest;i++)
        Count[i]=new int[Ntrn];

    for(int i=0;i<Ntest;i++)
        for(int j=0;j<Ntrn;j++)
            Count[i][j]=0;

}

void KNN::LoadData(const char*TrnFile,const char*TstFile)
{
    ifstream Trn(TrnFile);
    ifstream Tst(TstFile);
    for(int i=0;i<NumTrn;i++)
    {
        Trn>>TrainLabels[i];
        for(int j=0;j<NumFe;j++)
            Trn>>TrainData[i][j];
    }
    for(int i=0;i<NumTst;i++)
    {
        Tst>>TestLabels[i];
        for(int j=0;j<NumFe;j++)
            Tst>>TestData[i][j];
    }

    //ofstream sam("name.txt");
    int k=0;
    for(int i=0;i<NumTrn;i++)
    {
        DistLabels[i]=k;
        //j=i+1;
        while(TrainLabels[i]==TrainLabels[i+1])
            {
                DistLabels[i++]=k;

        }k++;}

    NumClasses=k;

}



void KNN::Distance()
{
    ofstream Dis("Distance.trn");
    ofstream Lab("labels.trn");


    double sum;

    for(int i=0;i<NumTst;i++)
    {

        for(int j=0;j<NumTrn;j++)
        {
            sum=0.0;
            SLabels[i][j]=TrainLabels[j];
            for(int k=0;k<NumFe;k++)
                sum+=pow((double)(TestData[i][k]-TrainData[j][k]),2);
            Dist[i][j]=sqrt(sum);
            Dis<<Dist[i][j]<<"\t";
            Lab<<SLabels[i][j]<<"\t";
        }
        Dis<<endl;
        Lab<<endl;

    }
}
//Sort the array Dist using insertion sort in ascending order
void KNN::Sort()
{
    double keyd;
    int keyl;
    int k;
    ofstream Sor("sort.trn");
    for(int i=0;i<NumTst;i++)
    {
        for(int j=1;j<NumTrn;j++)
        {
            keyd=Dist[i][j];
            keyl=SLabels[i][j];//sorted labels
            k=j-1;
            while(k>=0&&Dist[i][k]>keyd)
            {
                Dist[i][k+1]=Dist[i][k];
                SLabels[i][k+1]=SLabels[i][k];
                k--;
            }
            Dist[i][k+1]=keyd;
            SLabels[i][k+1]=keyl;

        }

        for(int j=0;j<NumTrn;j++)
            Sor<<Dist[i][j]<<"\t";
        Sor<<endl ...
(more)
2014-06-09 05:32:31 -0600 asked a question problem with lbp result

i have a number of images these images are prepossessed using uniform local binary pattern and spatial histogram then i take the result to self organizing code aimed to enhance the result of SOM when i run lbp code i have a black images with a few data and the accuracy is worse any one here has this combined code or an idea of how i enhance the result

this is the code of uniform

int LBPFeatures::countSetBits(int code)
{
  int count=0;
  int v=code;
  for(count=0;v;count++)
  {
  v&=v-1; //clears the LSB
  }
  return count;
}

int LBPFeatures::rightshift(int num, int shift)
{
    return (num >> shift) | ((num << (8 - shift)&0xFF));
}


bool LBPFeatures::checkUniform(int code)
{
    int b = rightshift(code,1);
  ///int d = code << 1;
  int c = code ^ b;
  //d= code ^d;
  int count=countSetBits(c);
  //int count1=countSetBits(d);
  if (count <=2 )
      return true;
  else
      return false;
}


void LBPFeatures::initUniform( int check)
{

    lookup.resize(256);
    int index=0;

    for(int i=0;i<=255;i++)
    {
        bool status=checkUniform(check);
        if(status==true)
        {
            lookup[i]=index;
            index++;
        }
        else
        {
            lookup[i]=59;
        }
    }
    spatialhist Hist;
Hist.initHistogram();

}


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=(uchar)ptr[j+i*width];
            unsigned char code=0;

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

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


            //heck if the code is uniform code
            //encode only if it is a uniform code else
            //assign it a number 255
            initUniform(code);
            //lookup.push_back(code);
            optr[j+i*width]=lookup[code];

        }
    }

}

spatialhist code

spatialhist::spatialhist(){
     sizeb=59;
}

Mat spatialhist::computeHistogram(Mat& cell)
{
     Mat histogram;
  histogram=  hist.BuildHistogram(cell);

    return histogram;

}


void spatialhist::initHistogram()
{
    vector<int> channel;
    channel.push_back(0);
    hist.setChannel(channel);
    vector<int> size;
    size.push_back(sizeb);
    hist.setHistSize(size);
    vector<float> range;
    range.push_back(0);
    range.push_back(59);
    hist.setRange(range);

}



vector<float> spatialhist::spatialHistogram( const Mat& lbpImage, const Size& grid)
{
    vector<float> histograms;
    histograms.resize(grid.width*grid.height*sizeb);
    int width=lbpImage.cols/grid.width;
    int height=lbpImage.rows/grid.height;
    int cnt=0;
    //#pragma omp parallel for
    for(int i=0;i<grid.height;i++)
    {
        for(int j=0;j<grid.width;j++)
        {
            Mat cell=lbpImage(Rect(j*width,i*height,width,height));
            Mat cell_hist=computeHistogram(cell);
            histogramsimage.push_back(cell_hist);
            //imshow("FFF",cell_hist);

            Mat tmp_feature;
           Mat feature =cell_hist.reshape(1,1);
            feature.convertTo(tmp_feature,CV_32FC1);

            float * ptr=tmp_feature.ptr<float>(0);
            for(int k=0;k<tmp_feature.cols-1;k++)
            {
                if ...
(more)
2014-05-31 11:34:11 -0600 asked a question what is the difference between calchist parameter using lbp and using uniformlbp

i need to calculate histogram for uniform lbp image. parameters in calchist with lbp is image= source lbpimage (which i need it's histogram) nimage= number of source image channel= index of channel (for gray image is 0) mask= Mat() (for full image) output= the histogram image (which result) dims= Histogram dimensionality (1) histsize= number of bins (256 for gray level bin for each pixel) ranges= 0,256 (for gray level) uniform= true (ranges= { , } accumulate= false (for one histogram from one image)

this is for normal lbp what about uniform lbp (dims, histsize, ranges, ) is there any difference

thanks

2014-05-30 03:19:06 -0600 commented question how can i deal with these outputs

ok i will take the short answer and ignore them

2014-05-29 12:35:40 -0600 asked a question how can i deal with these outputs

when i run my code i have these outputs

'mycode.exe': Loaded 'D:\Projects\mycodehend\mycodefinal\Release\mycode.exe', Symbols loaded.
'mycode.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'D:\opencvhend\opencvh\build\x86\vc10\bin\opencv_core249.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\msvcp100.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\msvcr100.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'D:\opencvhend\opencvh\build\x86\vc10\bin\opencv_highgui249.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\comctl32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\avifil32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\msacm32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\msvfw32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\avicap32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'D:\opencvhend\opencvh\**strong text**build\x86\vc10\bin\opencv_imgproc249.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'mycode.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
The program '[4640] mycode.exe: Native' has exited with code 0 (0x0).
2014-05-29 06:17:24 -0600 asked a question i want to obtain the histogram of an image

i have an image and i want to compute and draw its histogram i use the calchist function but i'm confused about its previous calculations now i'm a new a bout the c function which deal with memory so i need an explain to this code or anew easiest code for calchist function

this is my code:

Mat Histogram::BuildHistogram(Mat srcImage,bool accumulate){
Mat histMat;
//compute histogram
int *c=(int *)calloc(sizeof(int),_channels.size());
for(int i=0;i<_channels.size();i++)
{
c[i]=_channels[i];

}

int *h=(int *)calloc(sizeof(int),_channels.size());
for(int i=0;i<_channels.size();i++)
{
h[i]=_histSize[_channels[i]];

}

float **ranges=(float **)calloc(sizeof(float*),_channels.size());
int size=_channels.size();
for(int i=0;i<size;i++)>
{
float *x=(float *)calloc(sizeof(float),2);
int index=2*_channels[i];
x[0]=_histRange[index];
x[1]=_histRange[index+1];
ranges[i]=x;

}
if(accumulate==true)
_histMat.copyTo(histMat);

calcHist(&srcImage,1,c,_mask,histMat,_channels.size(),h,(const float **)ranges, true, accumulate);
for(int i=0;i<size;i++)>
{
free(ranges[i]);
}
free(ranges);
free(c);
free(h);
//normalize histogram
normalize( histMat, _histMat,1,0,NORM_L1);
Scalar v=cv::sum(_histMat);
if(accumulate==true)
histMat.copyTo(_histMat);
//return histogram
return histMat;
}
2014-05-29 05:16:12 -0600 commented answer how can i convert a vector of float into mat image

ok i do it but when i reach the imwrite function i have this error

Unhandled exception at 0x7592812f in mycode.exe: Microsoft C++ exception: cv::Exception at memory location 0x001aefe4.. opencv error: unspecified error<could not find a writer for the specified extension> in cv:: imwrite_, file......\ opencv\modules\highui\src\loadsave.cpp,line275

2014-05-28 16:10:43 -0600 commented question how can i convert a vector of float into mat image

or can i convert it from vector of mat into just one mat image

2014-05-28 16:02:12 -0600 commented question how can i convert a vector of float into mat image

i re-edit the question pls see it and tell me can i use the histogramsimg mat vector for my need instead of converting the histogrames vector or can i convert it from vector of mat into just one mat image

2014-05-28 15:56:20 -0600 received badge  Editor (source)
2014-05-28 15:27:02 -0600 commented question how can i convert a vector of float into mat image

i run the code with this new resize function but i have the same error

2014-05-28 15:18:39 -0600 commented question how can i convert a vector of float into mat image

how can i do this sorry i don't understand i need the image to be 50*50

2014-05-28 15:04:58 -0600 asked a question how can i convert a vector of float into mat image

i i need to convert vector of float to mat image then use this image in imgshow and resize function i have this function but it doesn't work

   memcpy(lbp.data,Vtrn.data(),Vtrn.size()*sizeof(float)); 
    resize(lbp, lbp, cvSize(50, 50),100,100,1); //in order to make all image same size
    imwrite(In.vectorofotrainpath[i].c_str(),lbp);// true with mat image or not

i have this error

   Windows has triggered a breakpoint in mycode.exe.
  This may be due to a corruption of the heap, which indicates a bug in mycode.exe or any of the DLLs it has loaded.

  This may also be due to the user pressing F12 while mycode.exe has focus.

the vector i want to convert is the histograms vector i obtained from this function

vector<float> spatialhist::spatialHistogramforknnorsvm( const Mat& lbpImage, const Size& grid)
{
    vector<float> histograms;
    histograms.resize(grid.width*grid.height*sizeb);
     int width=lbpImage.cols/grid.width;
    int height=lbpImage.rows/grid.height;
    int cnt=0;
    vector<Mat> histogramsimage;
    //#pragma omp parallel for
for(int i=0;i<grid.height;i++)
{
    for(int j=0;j<grid.width;j++)
    {
        Mat cell=lbpImage(Rect(j*width,i*height,width,height));
        Mat cell_hist=computeHistogram(cell);
        histogramsimage.push_back(cell_hist);
        //imshow("FFF",cell_hist);

        Mat tmp_feature;
       Mat feature =cell_hist.reshape(1,1);
        feature.convertTo(tmp_feature,CV_32FC1);

        float * ptr=tmp_feature.ptr<float>(0);
        for(int k=0;k<tmp_feature.cols-1;k++)
        {
            if(ptr[k]==0)
                ptr[k]=1.0/sizeb;
            histograms[(cnt*sizeb)+k]=ptr[k];
          //  cerr << ptr[k] << endl;
        }
        cnt++;
    }

}


return histograms;
}
2014-05-28 14:43:00 -0600 commented question vector subscript out of range

thanks that's right it work now

2014-05-28 14:13:05 -0600 asked a question vector subscript out of range

i have acode for check the lbp code for pgm image if it is uniform code or not but when i run the code i have this vector out of range error: debug assertion failed vector out of range this is my code:

  void LBPFeatures::initUniform( int check)
   {

lookup.resize(255);
int index=0;

for(int i=0;i<=255;i++)
{
    bool status=checkUniform(check);
    if(status==true)
    {
        lookup[i]=index;
        index++;
    }
    else
    {
        lookup[i]=59;
    }
}
spatialhist Hist;
 Hist.initHistogram();

}
2014-05-23 23:07:41 -0600 asked a question 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