Clear Filters
Clear Filters

shannon entropy and entropy of grayscale

17 views (last 30 days)
How can i find the entropy of a gray image without using the "entropy(I)" , "entropy" command? with just codes and arrays?

Accepted Answer

the cyclist
the cyclist on 8 Apr 2023
I = imread('image.png');
% Using histogram from imhist
p = imhist(I);
p = p/numel(I);
p(p==0) = [];
entropyFromImhist = -sum(p.*log2(p))
entropyFromImhist = 4.3978
% Built-in entropy function
ans = 4.3978

More Answers (1)

埃博拉酱 on 8 Apr 2023
Entropy.m is open source, why don't you just check out its source code?
edit entropy

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!