Files
zjsh_yolov11/guanghuaban/LBP.py
琉璃月光 df7c0730f5 bushu
2025-10-21 14:11:52 +08:00

17 lines
491 B
Python

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}")