Is it possible to obtain a binary image representation of a DICOM IMAGE?
6 views (last 30 days)
Show older comments
Pratik Datta
on 12 Feb 2015
Commented: Image Analyst
on 3 Mar 2015
I have converted a DICOM image to a grayscale image first and then used then used 'im2bw' function to get the binary image but the output is totally different from the input.the code is given as:
clear all;
X = dicomread('000018.dcm');
figure,imshow(X,[]),title('Original Dicom Image');
img = double(X);
img = (img - min(img(:))) / (max(img(:)) - min(img(:)));
img = uint8(255*img);
figure,imshow(img,[]),title('Original Grayscale Image');
The input dicom image is:
But the output after im2bw is:
Can i get an image like this ?
I got this binary image by converting the dicom file to jpeg and then using im2bw but it results in compression and hence loss of data. I need to get it directly from the dicom image. Is it possible?
3 Comments
Accepted Answer
Image Analyst
on 2 Mar 2015
You just threshold
binaryImage = grayImage > lowThreshold & grayImage < highThreshold;
imshow(binaryImage);
Of course it results in a loss of data - you're converting a gray scale image to a binary image with only two gray levels. What do you expect?
There is no need to convert to JPEG, and in fact, you are not even doing that, so that's good.
2 Comments
Image Analyst
on 3 Mar 2015
HIstogram equalization merely spreads out the histogram bins over a different range. It's totally unnecessary for thresholding, and in fact, usually produces harsh unnatural looking images. There is no binary image that you can't get without running a histogram equalization so it's unnecessary. In other words, you can get the same binary image with or without histogram equalization, it's just that the threshold gray level you choose will be different. So skip the equalization and save some time.
To set values of -2000 (or any negative values) to 0 just do this:
grayImage(grayImage < 0) = 0;
Maybe that will allow graythresh() to pick a gray level automatically without doing histogram equalization.
More Answers (0)
See Also
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!