图像互信息(MI)的计算(Python版本)

此篇文章用Python编写MI计算两张图片的相似性
MI值越高,相互包含的信息量越多,图像匹配程度越好,当两区域或图像完全相同时,它们值最大。

from sklearn.metrics.cluster import  mutual_info_score
import numpy as np
path1=''
path2=''
img1=cv2.imread(path1)
img2=cv2.imread(path2)
img_ref = np.array(img1, dtype=np.int32)   
img_sen = np.array(img2, dtype=np.int32)     
img_ref=img_ref .reshape(-1)
img_sen_roi=img_sen .reshape(-1)
MIValue=mutual_info_score(img_ref, img_sen_roi)
print('MI',MIValue)

此部分代码为Python自带库中的函数,有时间为大家更新自写函数。有问题的加Q联系:1399212294

猜你喜欢

转载自blog.csdn.net/qq_37770754/article/details/123032513