MATLAB: Reducing depth of image

image processingImage Processing Toolbox

I have a collection of 16-bit tif images and I would like to check if all 16 bits are used or I can downscale to an 8-bit representation. What is the best way of doing that? Maybe looking at the histogram? But what should I look after in the histogram? Skewness? (I included the histogram for one of the examples for reference)

Best Answer

It looks like not all 65,535 gray levels are used. Only up to 25,000 are used, and most are less than 6000. I don't know why you want to down-convert to 8 bit. Why? Are you extremely memory limited because you (think) you need to have hundreds of images in memory at the same time? If so, I'd see how you can restructure your program to minimize the number of images in memory at the same time.
If you really want to convert to 8 bit for some reason, I suggest you use imadjust() to adjust it to about 0-6000, and then uint8() and mat2gray() to get it to 0-255 uint8 class:
image8 = uint8(255 * mat2gray(imadjust(image16)));