MATLAB: CT slices appear with different intensity

ct

Hi!
I have a problem with some rabbit CT-s.
When I import them to matlab with dicomread, some of the slices have increased or decreased intensity for the same tissue structure.
However if I open the same set of iamges in DICOM viewer, it looks normal.
How can I address this?
Screenshot 2019-05-29 12.04.04.png
Screenshot 2019-05-29 12.07.01.png

Best Answer

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