Mahotas - Local Binary Patterns



Local Binary Patterns (LBP) is a method that generates a binary pattern. It compares the intensity values of a central pixel with its neighbors.

Each pixel in the neighborhood is assigned a value of 1 if it is greater than or equal to the center pixel's intensity, and 0 otherwise.

The binary patterns are used to compute statistical measures or histogram representations that capture the texture information in the image.

The resulting descriptors can be utilized in various applications, such as texture classification, object recognition, and image retrieval.

Local Binary Patterns uses a technique known as Linear Binary Patterns. The Linear Binary Pattern considers a linear (straight) neighborhood for creating a binary pattern. Let us discuss briefly about linear binary patterns below.

Linear Binary Patterns

Linear Binary Patterns are used to describe the texture of an image. It works by comparing the intensity values of pixels in a neighborhood around a central pixel and encoding the result as a binary number.

In simpler terms, LBP looks at the pattern formed by the pixel values around a particular pixel and represents that pattern with a series of 0s and 1s.

Here, we look at linear binary patterns of an image −

Linear Binary Patterns

Example

In the example mentioned below, we are trying to perform the above discussed function.

import mahotas as mh
import numpy as np
import matplotlib.pyplot as mtplt
image = mh.imread('nature.jpeg', as_grey=True)
# Linear Binary Patterns
lbp = mh.features.lbp(image, 5, 5)
mtplt.hist(lbp)
mtplt.title('Linear Binary Patterns')
mtplt.xlabel('LBP Value')
mtplt.ylabel('Frequency')
mtplt.show()

Output

After executing the above code, we obtain the following output −

Linear Binary Patterns1

We will discuss about the linear binary patterns in detail in the further chapter.

Advertisements