I found the solution with some help from colleagues.
There is two value in the CT metadata: RescaleSlope and RescaleIntercept.
To receive the HU values, you have to multiply the array values with the RescaleSlope and add RescaleIntercept.
It turns out, my CT-s had different RescaleSlope and RescaleIntercept values for each and every slice, therefore I had to apply the equation for every slice.
The CT filenames spread from 0000 to 0511.
Sorry for the very basic code, I'm sure it has a lot of unnecessary parts but it works for me.
ximgrescd=zeros(512,512,512);
for j=1:9
dicomFileName=strcat('CT-000',num2str(j),'.dcm')
ximglayer=dicomread(dicomFileName)
info=dicominfo(dicomFileName)
ximgrescd(:,:,j) = ximglayer * info.RescaleSlope + info.RescaleIntercept;
end
for j=10:99
dicomFileName=strcat('CT-00',num2str(j),'.dcm')
ximglayer=dicomread(dicomFileName)
info=dicominfo(dicomFileName)
ximgrescd(:,:,j) = ximglayer * info.RescaleSlope + info.RescaleIntercept;
end
for j=100:511
dicomFileName=strcat('CT-0',num2str(j),'.dcm')
ximglayer=dicomread(dicomFileName)
info=dicominfo(dicomFileName)
ximgrescd(:,:,j) = ximglayer * info.RescaleSlope + info.RescaleIntercept;
end


