Mahotas 简明教程

Mahotas - Local Binary Patterns

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

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

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

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.

简单来说,LBP 查看某个特定像素周围像素的值形成的模式,并用一系列 0 和 1 表示该模式。

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.