Clear Filters
Clear Filters

How to implement Uniform LBP?

17 views (last 30 days)
Sanjib
Sanjib on 24 Mar 2022
Answered: yanqi liu on 25 Mar 2022
I would like to implement uniform LBP. This is the definiton given by wikipedia for uniform LBP.
A local binary pattern is called uniform if the binary pattern contains at most two bitwise transitions from 0 to 1 or vice versa when the bit pattern is traversed circularly. For example, the patterns 00000000 (0 transitions), 01110000 (2 transitions) and 11001111 (2 transitions) are uniform whereas the patterns 11001001 (4 transitions) and 01010010 (6 transitions) are not. In the computation of the LBP labels, uniform patterns are used so that there is a separate label for each uniform pattern and all the non-uniform patterns are labeled with a single label. For example, when using (8,R) neighborhood, there are a total of 256 patterns, 58 of which are uniform, which yields in 59 different labels.
I have written code for LBP but not sure how to convert it to a uniform LBP. Below is the code for LBP
for row = 2 : rows - 1
for col = 2 : columns - 1
centerPixel = grayImage(row, col);
pixel7=grayImage(row-1, col-1) >= centerPixel;
pixel6=grayImage(row-1, col) >= centerPixel;
pixel5=grayImage(row-1, col+1) >= centerPixel;
pixel4=grayImage(row, col+1) > =centerPixel;
pixel3=grayImage(row+1, col+1) >= centerPixel;
pixel2=grayImage(row+1, col) >= centerPixel;
pixel1=grayImage(row+1, col-1) >= centerPixel;
pixel0=grayImage(row, col-1) > = centerPixel;
eightBitNumber = uint8(...
pixel7 * 2^7 + pixel6 * 2^6 + ...
pixel5 * 2^5 + pixel4 * 2^4 + ...
pixel3 * 2^3 + pixel2 * 2^2 + ...
pixel1 * 2 + pixel0);
Kindly please help me with code!

Answers (1)

yanqi liu
yanqi liu on 25 Mar 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!