You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
DICOM Images show greyish
7 views (last 30 days)
Show older comments
Hi there,
im curently working with CT and MRI Scans in DICOM Format. The MRI Images work completly fine, but the CT Images look this greyish. It is the same in the matlab Dicom Viewer but not in Online Viewers, there the Images are shown normal.
I already tried to rescale them, but it didn't help at all?
Has anybody an Idea where this comes from and how to fix it?
Thanks for your help :)
7 Comments
DGM
on 25 Oct 2021
Edited: DGM
on 25 Oct 2021
You might attach an example of the dcm image so that the native data range is known.
I'm assuming you intend to make the circular "background" region black, but that normalization techniques fail because the image corners are black. If the corners are indeed the global minima, then you'll have to decide how to otherwise identify the background color. How to do that would depend on what all the images look like.
For example, let's assume it's sufficient to sample the top row and find the most common color:
% load image
A = rgb2gray(imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/777493/image.jpeg'));
% normalize based on background sample and global maximum
A = mat2gray(A,double([mode(A(1,:)) max(A(:))]));
imshow(A)
DGM
on 25 Oct 2021
Edited: DGM
on 25 Oct 2021
It depends what you mean by changing the contrast. The above example does increase the contrast.
A = rgb2gray(imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/777493/image.jpeg'));
range(double(A(:)))/mean(double(A(:))) % example contrast metric
ans = 1.2804
A = mat2gray(A,double([mode(A(1,:)) max(A(:))]));
range(double(A(:)))/mean(double(A(:))) % check contrast again
ans = 12.5577
imadjust will let you adjust input and output black/white points (linear) and optionally adjust gamma. stretchlim() can be used for finding the values needed by imadjust(). I'm sure there are other things that can be done too, depending on what you need. Phrases like "contrast adjustment" or "contrast enhancement" are unfortunately kind of vague, since they can mean contradictory things in different contexts.
Answers (2)
Image Analyst
on 25 Oct 2021
Try using [] in imshow() to scale your min to 0 and max to 255:
imshow(yourGrayScaleImage, []);
21 Comments
Simon
on 25 Oct 2021
But i also got a bigger problem at the moment.
Is there any way to scale two object to the same size?
Cause i got now two object wich I want o compare, but they are in different size and location.
The spatial resolution is here very important.
Image Analyst
on 25 Oct 2021
I'd use regionprops() to find the equivalent circular diameter. Then I'd use imresize() to resize the smaller one by the ratio of those diameters. Then I'd find the centroids with regionprops() and use imtranslate() to shift one of them so that the centroids align. Something like
props1 = regionprops(mask1, 'EquivDiameter');
props2 = regionprops(mask2, 'EquivDiameter');
d1 = props1.EquivDiameter
d2 = props2.EquivDiameter
ratio = d1/d2;
mask2 = imresize(mask2, ratio) % Assuming mask2 is smaller.
props1 = regionprops(mask1, 'Centroid');
props2 = regionprops(mask2, 'Centroid');
imtranslate()
% etc.
Rik
on 25 Oct 2021
You have the DICOM metadata of both? Then I would use that information to rescale. Only the translation should be done on the image, unless you have used fidutials on both scanners to tie the scanner coordinate grid to your object.
Image Analyst
on 25 Oct 2021
Maybe try imfinfo().
Rik
on 26 Oct 2021
There are two fields that are important for you now: the RescaleSlope and the RescaleIntercept. You can convert the image data of your slice to HU with this line:
%convert to double to allow full data range
data=info.RescaleSlope*double(data)+info.RescaleIntercept;
%for CT: genrally 1 generally -1024
That will give you the proper image data.
You should dig around in the other fields to figure out which fields might encode information about the voxel size. If the SliceIncrement doesn't exist, you need to use the ImagePositionPatient for two subsequent slices.
if ~isfield(info1,'SliceIncrement')
if isempty(info2)
%Single slice image, so increment doesn't exist.
info=info1;
else
SliceIncrement=...
(info2.ImagePositionPatient(3)-info1.ImagePositionPatient(3))/...
(info2.InstanceNumber-info1.InstanceNumber);
info=info1;info.SliceIncrement=abs(SliceIncrement);
end
end
Rik
on 26 Oct 2021
Your data is probably loaded as int16, so you need to convert it to the double datatype to allow decimal values as well. This might not be required, but it can prevent strange issues later on.
Have you done a basic Matlab tutorial? Dicom is complex enough on its own. You should first make sure you are familiar with Matlab itself.
Image Analyst
on 26 Oct 2021
Attach what you see for dicominfo here.
Image Analyst
on 26 Oct 2021
I don't see the field of view in real world units in the dicominfo you posted. Maybe I overlooked it. Do you see it? I know it's 512x512 pixels but do you see the real world field of view in cm there?
Otherwise, why do you think the spatial calibration is different between the two images? Are you sure the one disc object really isn't smaller than the other one?
Image Analyst
on 26 Oct 2021
OK since the reconstruction diameter is 500 for one of the images, and the image is 512x512 for both images, what is the reconstruction diameter for the other image? If the discs are the same size in the real world then the cm per pixel spatial calibration factor must be different for the two images because the discs shows up with a different pixel diameter in the two images.
See Also
Categories
Find more on 3-D Volumetric Image Processing in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)