小编Kay*_*zhi的帖子

比较python中的LBP

我生成了这样的纹理图像

我必须比较两个纹理。我使用了直方图比较方法。

image_file = 'output_ori.png'
img_bgr = cv2.imread(image_file)
height, width, channel = img_bgr.shape

hist_lbp = cv2.calcHist([img_bgr], [0], None, [256], [0, 256])
print("second started")

image_fileNew = 'output_scan.png'
img_bgr_new = cv2.imread(image_fileNew)
height_new, width_new, channel_new = img_bgr_new.shape
print("second lbp")

hist_lbp_new = cv2.calcHist([img_bgr_new], [0], None, [256], [0, 256])

print("compar started")

compare = cv2.compareHist(hist_lbp, hist_lbp_new, cv2.HISTCMP_CORREL)

print(compare)
Run Code Online (Sandbox Code Playgroud)

但是这种方法无效。对于两种不同的图像纹理,它显示出相似的结果。同样,它并没有显示太多变化来识别打印和扫描效果。如何比较纹理?我想到分析GLCM特性。

import cv2
import numpy as np
from skimage.feature import greycomatrix

img = cv2.imread('images/noised_img1.jpg', 0)

image = np.array(img, dtype=np.uint8)
g = greycomatrix(image, [1, 2], [0, np.pi/2], levels=4, normed=True, …
Run Code Online (Sandbox Code Playgroud)

python image-processing scikit-image lbph-algorithm glcm

5
推荐指数
1
解决办法
794
查看次数