bushu
This commit is contained in:
17
guanghuaban/LBP.py
Normal file
17
guanghuaban/LBP.py
Normal file
@ -0,0 +1,17 @@
|
||||
from skimage import feature
|
||||
import matplotlib.pyplot as plt
|
||||
import cv2
|
||||
import numpy as np
|
||||
# 读取图像
|
||||
img = cv2.imread("2.jpg", cv2.IMREAD_GRAYSCALE)
|
||||
# 计算 LBP 图像
|
||||
radius = 3
|
||||
n_points = 8 * radius
|
||||
lbp = feature.local_binary_pattern(img, n_points, radius, method='uniform')
|
||||
|
||||
# 统计 LBP 直方图
|
||||
hist, _ = np.histogram(lbp, bins=256, range=(0, 256))
|
||||
|
||||
# 直方图熵(越高表示纹理越复杂)
|
||||
entropy = -np.sum(hist * np.log(hist + 1e-9))
|
||||
print(f"LBP Entropy: {entropy:.3f}")
|
||||
Reference in New Issue
Block a user