MATLAB: Estimation/measure of entropy entropy How to calculate entropy of an image without using the inbuilt functions? Entropy is the measure of loss of information. -summation(P.*log2 P) P is the count of histogram..but not getting the proper result!Anyone plz help. Best Answer Make sure you run log2 only on values > 0. Otherwise you would get NaN.I = im2double(rgb2gray(imread('peppers.png')));P = hist(I(:), linspace(0, 1, 256)); P = P(:); P = P(P(:)>0);E = -sum(P.*log2(P)) Related SolutionsMATLAB: Approximate Entropy Calculation for an Image function E = entropy(I)% Assume I in the range 0..1p = hist(I(:), linspace(0,1,256)); % create histogramp(p==0) = []; % remove zero entries that would cause log2 to return NaNp = p/numel(I); % normalize histogram to unityE = -sum(p.*log2(p)); % entropy definition MATLAB: How to write a function which gives me entropy using discrete probability distribution as input.thanks in advance entropy = @(P) -sum(P.*log2(P)) Related QuestionDifferent answer using inbuilt function and own code for entropyWhy am i getting NaN from the functionCount in a loop
Best Answer