Nadia Ali
Nadia Ali

Reputation: 31

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

I have to calculate the Mutual Information between two gray scaled images. For that I have to calculate Entropy and Joint-Entropy of the images. But I cannot find any function of Entropy and Joint Entropy in Opencv .Can any one help me to find Entropy and Joint Entropy functions in Opencv?

Upvotes: 3

Views: 4864

Answers (1)

Max Allan
Max Allan

Reputation: 2395

To do this you need to compute the image histogram which you can do in OpenCV with the calcHist() function. You then normalize your histogram to get probabilities by dividing the value in each bin by the total number of pixels in your image(s). The image entropy is then given by:

formula

where each element formula2 is a value from your histogram (assuming that your histogram is over the range [0-255]). You will need to be careful with zero values as these evaluate to -infinity when the log is taken.

Upvotes: 1

Related Questions