How to calculate the median and mode of an image from the histogram

I have used the following code to calculate the mode
[pixelCount grayLevels] = imhist(LBP_Im);
maximum=max(pixelCount);
r=find(pixelCount==maximum);
whether this is correct to calculate the mode. Likewise I wish to know the code for calculating the median of an image

 Accepted Answer

Why not simply use the mode and median function?
imgmode = mode(LBP_Im(:));
imgmedian = median(LBP_Im(:));

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!