Ask Your Question

learner123's profile - activity

2018-09-19 23:45:55 -0600 received badge  Famous Question (source)
2015-07-27 01:30:52 -0600 received badge  Notable Question (source)
2014-11-19 03:36:17 -0600 received badge  Nice Question (source)
2014-10-14 10:29:14 -0600 received badge  Popular Question (source)
2013-07-16 07:15:08 -0600 commented answer uniform LBP - mapping using lookup table

@berak hi...i have a question regarding pre-processing steps. Currently I pre-process my image in following order: ("face" contains facial iamge)

GaussianBlur( face, face, Size(3,3), 0, 0 );
resize(face, face, Size(150, 150) );
equalizeHist( face, face );

Now, it surely improved my results. But, what if I chnage the order of above preprocessing steps...lets say i resize first and then add gaussian blur. The point is, there are many permutations for order of above steps. I can try them out to check. But, conceptually what should be the order? How does it matter?

thanks!!!

2013-07-15 09:01:34 -0600 commented answer uniform LBP - mapping using lookup table

@berak I see.....thanks a lot mate!! I really appreciate your inputs a lot!!!

2013-07-15 08:31:40 -0600 commented answer uniform LBP - mapping using lookup table

@berak so this opencv lbp uses single neighbour or k-neighbours?

2013-07-15 07:23:03 -0600 commented answer uniform LBP - mapping using lookup table

@berak I'm afraid I don't understand such high level codes! I'm learning it all.....could you please tell me in short whats the pipeline of LBP in OpenCV? Distance matching, k-nearest-neigbour? thanks a lot!

2013-07-15 07:08:09 -0600 commented answer uniform LBP - mapping using lookup table

@berak well..well..well!!! There seems to be more to LBP in OpenCV! Just checked this link and your answers: http://answers.opencv.org/question/12036/confidence-value-and-threshold-in-opencv/ what exactly is happening?? We find distance to closest matches....and then nearest neighbour? What exactly is happening? I wish all this was there in documentation...I'm still novice at all this!

2013-07-15 07:01:09 -0600 commented answer uniform LBP - mapping using lookup table

@berak i was going through this: http://answers.opencv.org/question/7865/updating-eigenfacerecognizer-with-more-faces/ can you please tell me what is this threshold and confidence value? Currently, I am getting 75% accuracy on average...got to increase it...would it help to resize images to fixed size and equalizing histograms?

2013-07-15 06:54:15 -0600 commented answer uniform LBP - mapping using lookup table

@berak where is this? I don't see it :(

2013-07-15 06:38:31 -0600 commented answer uniform LBP - mapping using lookup table

@berak: are you sure? is there some more information on it? any link may be.....i need to document it...

2013-07-15 06:09:21 -0600 commented answer uniform LBP - mapping using lookup table

@berak I'm still working on it. I have been able to implement uniform LBP. Now, I'm looking forward to incorporating HOG features with LBP features into same vector and train MLP on it.

2013-07-15 06:07:08 -0600 commented answer uniform LBP - mapping using lookup table

@berak Hello again, do you know what kind of distance measure is used in OpenCV's LBP prediction? Is it Euclidean/Manhattan/Chebyshev?

2013-07-02 06:59:29 -0600 marked best answer uniform LBP - mapping using lookup table

Hello, I have basic implemented Local Binary Pattern (LBP), without interpolation, using OpenCV and C++. Following is the code:

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace cv;
using namespace std;

cv::Mat LBP(string src_image)   
{   
  cv::Mat temp_image = imread(src_image.c_str(), 1); 
  cv::Mat Image(temp_image.rows, temp_image.cols, CV_8UC1);
  cv::Mat lbp(temp_image.rows, temp_image.cols, CV_8UC1);

  if (temp_image.channels() == 3)   
    cvtColor(temp_image, Image, CV_BGR2GRAY);     

  imshow("src_image", Image); 

  int center = 0;   
  int center_lbp = 0;   

  for (int row = 1; row < Image.rows; row++)   
  {
    for (int col = 1; col < Image.cols; col++)   
    {   
      center = Image.at<int>(row, col);
      center_lbp = 0;   

      if ( center <= Image.at<int>(row-1, col-1) )   
    center_lbp += 1;   

      if ( center <= Image.at<int>(row-1, col)   )    
        center_lbp += 2;   

      if ( center <= Image.at<int>(row-1, col+1) )   
        center_lbp += 4;   

      if ( center <= Image.at<int>(row, col-1)   )   
        center_lbp += 8;   

      if ( center <= Image.at<int>(row, col+1)   )   
        center_lbp += 16;   

      if ( center <= Image.at<int>(row+1, col-1) )   
        center_lbp += 32;   

      if ( center <= Image.at<int>(row+1, col)   )   
        center_lbp += 64;

      if ( center <= Image.at<int>(row+1, col+1) )   
        center_lbp += 128;   

      cout << "center lbp value: " << center_lbp << endl;
      lbp.at<int>(row, col) = center_lbp;
    }
  }

    imshow("lbp_image", lbp);
    waitKey(0);   
    destroyAllWindows();

    return lbp;
} 

void histogram(cv::Mat image)
{
  int histSize = 256;
  float range[] = { 0, 256 } ;
  const float* histRange = { range }; 

  bool uniform = true; bool accumulate = false;

  Mat hist;

  calcHist( &image, 1, 0, Mat(), hist, 1, &histSize, &histRange, uniform, accumulate );

  int hist_w = 512; int hist_h = 400;
  int bin_w = cvRound( (double) hist_w/histSize );

  Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );

  /// Normalize the result to [ 0, histImage.rows ]
  normalize(hist, hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );

  /// Draw 
  for( int i = 1; i < histSize; i++ )
  {
      line( histImage, Point( bin_w*(i-1), hist_h - cvRound(hist.at<float>(i-1)) ) ,
                       Point( bin_w*(i), hist_h - cvRound(hist.at<float>(i)) ),
                       Scalar( 255, 0, 0), 2, 8, 0  );
  }

  imshow("LBP image Histogram", histImage );
  waitKey(0);
}

//--------------------------------------------------------   
int main()   
{
  cv::Mat LBPimage = LBP("a.ppm");
  histogram(LBPimage);

  return 0;   
}

I now stuck at implementing uniform LBP. Can't figure out how to proceed. How to map using lookup table....can anybody please help?

thanks!

2013-06-27 07:32:38 -0600 received badge  Scholar (source)
2013-06-27 04:30:52 -0600 commented answer uniform LBP - mapping using lookup table

@berak i have a doubt! the literature I read on LBP...all mentioned dividing image into 8x8 patches and you also suggested the same thing. But, here we set x_grid = 8 and y_grid = 8. So, the width is: src.cols/x_rid = 512/8 = 64 AND height is: src.rows/y_grid = 768/8 = 96 which means...the patch is size: 96x64 but wasn't it supposed to be 8x8 ??

sry if I'm missing out on smthng here...but its important to know this...

thanks again!

2013-06-27 04:14:47 -0600 commented answer uniform LBP - mapping using lookup table

@berak aahaann!!! on reshaping it...the size is 1x16384. and this is exactly the size returned by OpenCV's LBP function!!! so this means the concept of uniform patterns is not implemented there!!! working on things practically is so mch fun!! thanks to u!

2013-06-27 03:59:23 -0600 commented answer uniform LBP - mapping using lookup table

@berak I would go for reshaping hist because ultimately i have to input it to MLP....so a 1d-vector would help there....

2013-06-26 11:09:14 -0600 commented answer uniform LBP - mapping using lookup table

@berak alright! i would work further....thanks a lot! i am working with face images only...

2013-06-26 10:35:33 -0600 commented answer uniform LBP - mapping using lookup table

@berak hi, i moved further and the final histogram that I am getting is of size: 64x256. This is because, I divided my entire image into 64 blocks/patches. And each patch then gives me a 1x256 histogram. Becuase of the line: " result.push_back(hist); " each of 1x256 histogram for every patch is being pushed back into main histogram and thus forms 64x256 histogram. I wanted to ask:

---1) is this correct? the size of main histogram: 64x256

---2) currently my image gets divided into 64, "96x64 patch"....should they be smaller? my image size is: 768x512

I was expecting the main histogram to b a 1-D vector like "1xlarge_number"...but its coming out at 64x256. I gave x_grid = 8 and y_grid = 8

thanks a lot!

2013-06-25 09:00:49 -0600 commented answer uniform LBP - mapping using lookup table

@berak could you please explain the logic behind this:

int transitions = 0;

for ( int j=0; j&lt;numNeighbours-1; j++ )

    transitions += (bit(i,j) != bit(i,j+1));

transitions += (bit(i,numNeighbours-1) != bit(i,0));
2013-06-25 07:59:55 -0600 commented answer uniform LBP - mapping using lookup table

got it! its giving value of 2^numSlots

2013-06-25 07:51:09 -0600 commented answer uniform LBP - mapping using lookup table

@berak in the line: int numSlots = 1 << numNeighbours; I tried to output numSlots value....it gives 256. How did that happen? I have never seen this kind of declaration before...could you please tell me? thank you!