convert 16 bits medical image (.dcm) into 8 bits

8 views (last 30 days)
I’m working in the project related to medical image processing. I need medical image (.dcm) of 8 bits. Unfortunately, I couldn’t find this type. I have just image (.dcm) of 16 bits. How can convert 16 bits medical image into 8 bits
Regards
Majid
  2 Comments
Rik
Rik on 30 Dec 2018
Do you want to store the values in 8 bits, or do you want to process them in 8 bits?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 31 Dec 2018
im2uint8() to do the conversion.
Note: 16 bit DICOM data is often int16 with a range of about -3000 to +10000 or so, or else uint16 with a range of about 3000 to 16000 or so for the interesting data. These are full ranges recorded by the instruments, but you would typically only be interested in a subset of that range for conversion to uint8. Sometimes you can do useful automatic conversion with mat2gray(), but more often you end up having to play with the data to figure out what range you want. If you have a new enough MATLAB, then volumeViewer() can be useful for figuring out what range you want.

More Answers (1)

Image Analyst
Image Analyst on 31 Dec 2018
Why do you want to store the images in 8 bits?
You could just convert to 8 bit with gray2mat():
im8 = uint8(255 * mat2gray(im16)); % Scale min=0, max = 255
dicomwrite(im8, filename);
  2 Comments
Walter Roberson
Walter Roberson on 31 Dec 2018
Edited: Walter Roberson on 1 Jan 2019
If it is uint16 then a lot of the time in practice mat2gray() without further parameters will not produce good results, as it will scale based upon the full range of data, but uint16 datasets often have an upper range of several thousand above what is of interest, due to the mix of bone with organs. The interesting data often tops out about 12000 or 14000.
Image Analyst
Image Analyst on 1 Jan 2019
True. Often some cameras give 14 bits of data and they store it in a 16 bit image in two ways, within the lower 14 bits (which can lead to dark looking images in some software) or within the upper 16 bits, which makes the image brighter, but no longer radiometrically linear of course, if it even was in the first place since some devices add a gamma.
mat2gray() will scale regardless if the max was 65535 or 12000, so all images get their full gray level range scaled to the gray level range of the display regardless of what their original range was. Of course if you have one spec of noise that's abnormally bright then you could end up with an image too dark to see well since that bright speck will end up as 255 instead of the meaningful/interesting data. In that case, you might want to either
  1. use imadjust() to normalize to a certain percentage of tails in the histogram, or
  2. apply a gamma.
That's why I asked what the intent/need for storing these in 8 bits was. Simply saying "I want to store the values in 8 bits" when there is no reason that the image data cannot be stored in its original 16 bits is not really all that helpful.

Sign in to comment.

Categories

Find more on Convert Image Type 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!