I load some .mdh and .raw files for medical images, but one thing bothers me. I understand that in .dicom file, you can convert pixel intensity to HU by using rescale.slope and rescale.intercept, which .mhd file fail to include. Therefore, I am wondering how I can get a better view of my image data from .mdh and .raw file.This is the image that I generate, this is the kind of image that I want to accomplish.
Here I load a slice from the data, and plot the histogram of the values of each 'pixel' (no sure whether to call them pixel or voxel).
Though I do get an idea to simply reset the pixel with the smallest value, I really want to hear from the experienced peers if there is any more sophisticated way to achieve this.
itk_img = SimpleITK.ReadImage(mhd_file)
img_array = SimpleITK.GetArrayFromImage(itk_img)
plt.imshow(img_array[80], cmap=plt.cm.gray) # show a slice from a 3D data
plt.show()
plt.hist(img_array[80].flatten(), bins=80, color='c')
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
I have uploaded all my pictures to github since I am yet allowed to upload images, so please feel free to click in.
Many thanks!
The values stored in an .mhd/.mha file are already the HU values. What you are thinking of is the Window and Level of an image viewer, which remaps HU values to pixel values that can be displayed on a monitor.
I don't recommend rescaling the values in the files themselves, as that will result in a loss of information. Rather, I suggest downloading a program capable of displaying the images, such as ITK-Snap and/or MeVisLab, which allows you to adjust your window and level