Uniform LBP Features and Spatial Histogram Computation

Introduction

In the earlier article we had seen that we had computed a LBP image.Each pixel in this image still can take $2^8$ possible values. The idea of uniform LBP is to perform lossy encoding so that we eliminate some irrelevant data and retain useful information which takes on 58 possible values. In this article we will look at Uniform LBP and computation of Spatial Histogram of LBP which can be used as a feature for image description.
• Uniform LBP features are considered as one which have only 2 contigious regions corresponding to 0's and 1's,while non uniform LBP have more than 1 contigious regions corresponding to 0's and 1's.
• This we need a mapping from which assign each on $2^8$ possible codes to one of 58 encoded uniform LBP values.
• All the non uniform codes are assigned to a single values.
• The uniform LBP's can be viewed as corners,line,ramp gradient
• The non uniform LBP's are assumed to be irrelevant and can be ignored.
• A uniform binary pattern can be identified by performing a bit wise traversal and checking if number of bit transitions are atmost 2 .
• This is done by first circular right/left shifting the given code and performing XOR operation with the original code.
• Since we need to only consider 8 bit numbers ,we need perform circular shift and masking MSB for integers.
• Now number of bit operations is simply the number of set bits in the result
• The code for this can be as follows
• the method to count bits is naive way and since we are using 8 bit words,it will take 8 iterations of the for loop.
• Brian Kernighan's method performs this by going through as many iterations as set bits
• The result can be precomputed for possible input code to determine if a LBP is a uniform code or not.
• The next task is to map the LBP codes to one of 58 uniform codes.
• The encoding will be done along the rows as per the below figure
• Since we known the possible input codes before hand,we can prepare a lookup table before hand to check if a uniform code or not
• Now if it is a uniform code we need to map it to one of possible 58 codes.
• To do this we move from all numbers from $0-2^8$,check if they are uniform and assign them to a one of 58 possible code.
• However we can see than
• Thus we modify the existing lbp image code to return only uniform lbp coded as destination lbp image by performing a simple lookup operations.
• Now next task is to compute a spatial histogram,the histogram may be computed over the entire image or dividing the image into grids
• The LBP spatial histogram can be used as a texture descriptor.
• However the LBP image is a gradient image in some sense,it encode information about different types of gradiants
• The LBP pattern can be used to identify isolated corners or flat region ( all 0 or 1)
• The LBP pattern can be used to identify corner a continuous run of 0 or 1 of length (5-8 and its rotated version)
• The LBP pattern can be used to identify a edge a continous run of 0 or 1(length 4 and rotated version )
• The LBP pattern can be used to identify horizontal or vertical edge ( vertical/horizontal run of 0 and 1 )
• The LBP pattern can be used to identify a line end (1000000 and its rotated version)
• The LBP pattern with 2 continuous 1'2 can be considered as a horizontal or vertical line

Code

• The code for the same can be found at git rep https://github.com/pi19404/OpenVision/ in ImgFeatures/lbpfeatures.cpp and ImgFeatures/lbpfeatures.hpp files.

References

• Description of interest regions with local binary patterns by Heikkil,Pietikֳ & Schmid
• Rotation invariant image description with local binary pattern histogram fourier features. by Ahonen T. and Matas J. and He C & Pietikֳinen M.
• Multiresolution gray-scale and rotation invariant texture classification with Local Binary Patterns by Ojala