Hi,
Is there a function in SITK to convert the pixel values in dicom CT images to Hounsfield Units (HU) ? This is what I currently do:
def transform_to_hu(slices):
images = np.stack([file.pixel_array for file in slices]) #axis=-1 for depth in the last channel -> this yielded weired image
images = images.astype(np.int16)
images[images >= 1000] = 0
for n in range(len(slices)):
intercept = slices[n].RescaleIntercept
slope = slices[n].RescaleSlope
if slope != 1:
images[n] = slope * images[n].astype(np.float64)
images[n] = images[n].astype(np.int16)
images[n] += np.int16(intercept)
return np.array(images, dtype=np.int16), slices
I am specifically interested in clipping the values as follows: images[images >= 1000] = 0
. When I do this on sitk to numpy converted images, it doesn’t work (plotted images are different).