Reputation: 369
Here is the code that i used to display the DICOM image, When i give the full display range it shows burred image like left, and when i increase the lower display range the image looks more clear.
[img, map] = dicomread('D:\Work 2017\Mercy\trial\trial4\Export0000\MG0001.dcm');
info = dicominfo('D:\Work 2017\Mercy\trial\trial4\Export0000\MG0001.dcm' );
mini = min(img(:));
maxi = max(img(:));
figure,
subplot(131), imshow(img, [mini maxi]); title('Full display range')
subplot(132), imshow(img, [maxi*0.7 maxi]); title('70% and above display range')
subplot(133), imshow(img, [maxi*0.8 maxi]); title('80% and above display range')
I want to always see an image something similar to right side image without giving the display range that I used in the above code
Upvotes: 1
Views: 636
Reputation: 65430
Typically a DICOM will have WindowCenter
and WindowWidth
tags that specify the recommended window/level settings. You can convert these to color limits in the following way
% Get the DICOM header which contains the WindowCenter and WindowWidth tags
dcm = dicominfo(filename);
% Compute the lower and upper ranges for display
lims = [dcm.WindowCenter - (dcm.WindowWidth / 2), ...
dcm.WindowCenter + (dcm.WindowWidth / 2)];
% Load in the actual image data
img = dicomread(dcm);
% Display with the limits computed above
imshow(img, lims);
Or more briefly
lims = dcm.WindowCenter + [-0.5 0.5] * dcm.WindowWidth;
If those values aren't acceptable, then it's likely best to provide a user-adjustable window/level (such as the contrast tool in imtool
) as there is unlikely any way to reliably get "acceptable" contrast since it is subjective.
Upvotes: 2