本篇文章主要分享python的图像的直方图自动匹配方法,类似matlab中的histeq()函数。
from skimage.exposure import match_histograms
import cv2
import numpy as np
path1='E:/Vscode/NewData/Paper3Data/visible-infrared/3/visible1.tif'
path2='E:/Vscode/NewData/Paper3Data/visible-infrared/3/infrared1.tif'
img1=cv2.imread(path1)
img2=cv2.imread(path2)
matched =match_histograms(img2,img1)
cv2.namedWindow('1',cv2.WINDOW_NORMAL)
cv2.imshow('1',img1)
cv2.namedWindow('2',cv2.WINDOW_NORMAL)
cv2.imshow('2',img2)
cv2.namedWindow('match_img12',cv2.WINDOW_NORMAL)
cv2.imshow('match_img12',matched.astype(np.uint8))
cv2.waitKey(0)
cv2.destroyAllWindows()