Hi can you help me to calculate the entropy of a grayscale image using Matlab? Here I've shown below the code that I tried. The code was working but I got the value of the entropy of my image as 'NaN'. So, please help me to find the entropy value of a grayscale image correctly.
I = imread('152.bmp');x = entropy(I);%functionH = MyEntropy(x);
imshow(x);figure()[Height,Width] = size(x);[m,Binsx]=imhist(x);m = m/(Height*Width);sprintf('the sum of the histogram value is = %g',sum(m));figure,plot(Binsx,m,'k')xlabel('pixel value'),ylabel('relative count')H = sum(-m.*log2(m));sprintf('the entropy of the image is = %g',H)
Best Answer