How can I calculate the joint entropy of two images in Opencv

I need to calculate mutual information between two gray scaled images. For this I have to calculate the Entropy and Joint-Entropy of the images. But I cannot find any entropy and joint entropy function in Opencv. Can anyone help me find the Entropy and Articular Entropy functions in Opencv?

+3


source to share


1 answer


To do this, you need to calculate the histogram of the image, which you can do in OpenCV with the function calcHist()

. Then you normalize your histogram to get the probabilities by dividing the value in each box by the total number of pixels in your images. Then the entropy of the image is set as follows:

formula



where each item formula2is the value of your histogram (assuming your histogram is above the range [0-255]). You have to be careful with null values ​​as they evaluate the -infinity value when running the log.

+1


source







All Articles