how can I obtain hounsfield units(HU) from a .dcm image?

hi
if I have a CT image how can I obtain hounsfield units from this... I know that we can read .dcm Image with dicomread(img)..
and I should say when I use dicomread(img) and then I want to imshow this I just see a black screen...

 Accepted Answer

After loading your image:
yourImage = dicomread('yourImage.dcm');
You can go straight to
info = dicominfo('yourImage.dcm');
Now, you have to find your DICOM attribute that corresponds to the Hounsfield units.
This attribute leads you the the linear correlation between the voxel value in the image and the Hounsfield units.
The DICOM attribute I´m talking about is (0028, 1053), or the 'Rescale Slope' attibute.
H_unit(x,y) = voxel_value(x,y)*RescaleSlope + Intercept.
It is exactly like y = a.x + b.
You can do like this:
rSlope = info.RescaleSlope;
for j = 1 : size(yourImage, 1) % This loop multiply each voxel value by the rescale slope
for i = 1 : size(yourImage, 2)
hounsfieldImage(i,j) = yourImage(i,j)*rSlope;
end
end
figure
imshow(hounsfieldImage, 'DisplayRange', []);
Cheers

7 Comments

Or without loops and with the intercept (which is probably a lot more relevant, as the slope tends to be 1 and the intercept -1024):
hounsfieldImage=double(yourImage)*info.RescaleSlope+info.RescaleIntercept;
Hi. İ want to calculate hounsfield units but dicominfo does not has rescale slope field. Can you help me
Are you sure your file is a valid CT DICOM file? Can other viewers make sense of the file?
If he dicominfo does not have RescaleSlope or RescaleIntercept then
hounsfieldImage = double(YourImage);
However, you should do some cross-checks:
  • if the array has any values less than -6000 then this scaling does not apply
  • if the array does not have any negative values, then this scaling might not apply. That is, there should be some negative numbers for raw data, but sometimes programs filter out the negatives
yildis, it is common to have such DICOM headers on CT images. Did you get it from an example, or from an CT scanner? Anyway, I do reforce Walter words about the cross-checks.
If you’re in a dead end, I suggest you to retrieve your min and max pixel value and and make your own linear function with HU units.
thank you for your kindly reply. ı can not see resclae slope and intercept from matlab but in microdicom viewer rescale slope is 1 and rescale intercept is -8192. I wrote this value manually in my code but ı think this value is wrong. Can you help me ?
has the image already had water suppressed?

Sign in to comment.

More Answers (1)

Hi, well, first you need to do the reading of the image:
Image1=dicomread('Image.dcm');
After you convert the dicom image in uint16:
Image1 = uint16(Image1); % This is very important, if you don't declare this, can make you troubles
After you make a vector of the size of the image:
[m,n] = size(Image1);
After that you need two matrices of zeros of the size of the image(after this you will see the use of both)
B1 = zeros(m,n);
S1 = zeros(m,n);
Then you make a vector with the values of the Hounsfield units, example
Bone = [200,300,3000]; % The information of this i take it from wikipedia https://en.wikipedia.org/wiki/Hounsfield_scale
And then you do two for loops, these will be repeated according to the size of the image, of rows and columns
for i=1:m
for j=1:n
P=Image1(i,j); %This contain the information of the image
if(P>Bone(1,1) && P<Bone(1,2)) % Make the condition that allows compare the information in the variable "P"
B1(i,j) = 1; % Make a bit image and change the values of zeros for ones
S1(i,j) = P; % This transform the value of P that contain the image information
end
end
end
B1=uint8(B1); % Transforms the double-to-single bit image
S1=uint8(S1*255); % This is the same that the line above but multiplies the result for 255
And then for show it:
figure(1)
subplot(2,1,1);
imshow(S1);
title('Image treated');
subplot(2,1,2);
imshow(Image1*255); % This multiplies the values of the image just to observe them
title('Original Image');
I tried and it work out, but is in the bones from a CT in the skull, I hope it helps you.

2 Comments

This does not look anything like I would expect? Generally calculation of HU involves looking at the dicom headers and doing a linear transformation. The process is described at https://www.mathworks.com/matlabcentral/answers/114123-how-to-calculation-hounsfield-unit#answer_127872
Hello Macro Castro. is that right? I wanna see bone figure

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 5 Sep 2014

Commented:

on 24 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!