How to calculate entropy of a DICOM image (16-bit depth)?

3 views (last 30 days)
According to MatLab,
  • By default, entropy uses two bins for logical arrays and 256 bins for uint8, uint16, or double arrays.
  • entropy converts any class other than logical to uint8 for the histogram count calculation so that the pixel values are discrete and directly correspond to a bin value.
How to calculate exact value of entropy for 16-bit DICOM image without converting to uint8 class, i.e, utilizing 2^(16) bins?

Accepted Answer

DGM
DGM on 12 Jun 2021
Just open up entropy() or look at the docs to see how it works.
% just grab some image and make it into an example
inpict = imread('cameraman.tif'); % this is uint8
inpict = im2uint16(inpict); % make it uint16
% process it to move the data outside of 2^8 locations
inpict = imfilter(inpict,fspecial('disk',3));
% this is what entropy() does
counts = imhist(inpict(:),2^16);
numel(counts) % it's using 65536 bins
counts = counts(counts~=0); % get rid of empty bins
numel(counts) % how many bins are left?
counts = counts/numel(inpict); % normalize the sum
E = -sum(counts.*log2(counts)) % this is the result with 65536 bins
F = entropy(inpict) % this is the result with 256 bins
For illustrative purposes, try commenting out the imfilter() line and see what happens to the bin counts and the relationship between E and F.

More Answers (0)

Categories

Find more on DICOM Format in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!