LBP.py 809 B

12345678910111213141516
  1. # Divide the examined window to cells (e.g. 16x16 pixels for each cell).
  2. # For each pixel in a cell, compare the pixel to each of its 8 neighbors
  3. # (on its left-top, left-middle, left-bottom, right-top, etc.). Follow the
  4. # pixels along a circle, i.e. clockwise or counter-clockwise.
  5. # Where the center pixel's value is greater than the neighbor, write "1".
  6. # Otherwise, write "0". This gives an 8-digit binary number (which is usually
  7. # converted to decimal for convenience).
  8. # Compute the histogram, over the cell, of the frequency of each "number"
  9. # occurring (i.e., each combination of which pixels are smaller and which are
  10. # greater than the center).
  11. # Optionally normalize the histogram. Concatenate normalized histograms of all
  12. # cells. This gives the feature vector for the window.