convert 16 bits medical image (.dcm) into 8 bits
22 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2018-12-31
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.
0 个评论
更多回答(1 个)
Image Analyst
2018-12-31
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 个评论
Walter Roberson
2018-12-31
编辑:Walter Roberson
2019-1-1
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
2019-1-1
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
- use imadjust() to normalize to a certain percentage of tails in the histogram, or
- 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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!