Mahotas 简明教程

Mahotas - Local Binary Patterns

局部二值模式 (LBP) 是一种生成二进制模式的方法。它比较中心像素与相邻像素的强度值。

如果邻域中的每个像素大于或等于中心像素的强度,则为其分配值 1,否则为 0。

这些二进制模式用于计算统计度量或直方图表示,以捕捉图像中的纹理信息。

生成的描述符可用于各种应用中,例如纹理分类、对象识别、图像检索。

局部二值模式使用一种称为线性二进制模式的技术。线性二值模式考虑线性(直线)邻域来创建二进制模式。让我们在下面简要讨论一下线性二进制模式。

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()

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.