opencv图像处理学习(十八)——直方图对比

版权声明:不得随意转载 https://blog.csdn.net/qq_35789421/article/details/88927549

直方图对比用来计算两幅图像的直方图相似程度,要比较两个直方图的相似程度,需要一定的衡量对比标准。

常用的四种对比标准如下:

(1)相关系数(method=CV_COMP_CORREL)

d(H_{1},H_{2})=\frac{\sum _{I}(H_{1}(I)-H_{1}^{-})(H_{2}(I)-H_{2}(I)-H_{2}^{-})}{\sqrt{\sum _{I}(H_{1}(I)-H_{1}^{-})^{2}(H_{2}(I)-H_{2}^{-})^{2}}}

其中,H_{k}^{-}=\frac{1}{N}\sum _{J}H_{k}(J),N代表直方图中bins的数量

(2)卡方系数(method=CV_COMP_CHISQR)

d(H_{1},H_{2})=\sum _{I}min(\frac{(H_{1}(I)-H_{2}(I))^{2}}{H_{1}(I)})

(3)相交系数(method=CV_COMP_INTERSECT)

d(H_{1},H_{2})=\sum _{I}min(H_{1}(I),H_{2}(I))

(4)巴氏系数(method=CV_COMP_BHATTACHARYYA method=CV_COMP_HELLINGER)

d(H_{1},H_{2})=\sqrt{1-\frac{1}{\sqrt{H_{1}^{-}H_{2}^{-}N^{2}}}}\sum _{I}\sqrt{H_{1}(I)H_{2}(I)}

opencv中提供的函数为void compareHist(Mat src,Mat base,compare_method)

参数src是源图像,base为对比图像,compare_method为对比方法。

猜你喜欢

转载自blog.csdn.net/qq_35789421/article/details/88927549