You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment the code used to convert the x-rays from DICOMs to JPGs is not publicly available as it's tied up in another repo. It would be good to have a publicly executable set of code that converts DICOMs to JPGs in the same way as we did to create MIMIC-CXR-JPG from MIMIC-CXR. The core function used was:
importnumpyasnpimportpydicomimportcv2defdcm2img(input_file_path, output_file_path):
"""Extract the image from a DICOM and write it to an image file."""# Read the DICOM and extract the image.dcm_file=pydicom.dcmread(input_file_path)
raw_image=dcm_file.pixel_arrayassertlen(raw_image.shape) ==2,\
"Expecting single channel (grayscale) image."# Normalize pixels to be in [0, 255].raw_image=raw_image-raw_image.min()
normalized_image=raw_image/raw_image.max()
rescaled_image= (normalized_image*255).astype(np.uint8)
# Correct image inversion.ifdcm_file.PhotometricInterpretation=="MONOCHROME1":
rescaled_image=cv2.bitwise_not(rescaled_image)
# Perform histogram equalization.final_image=cv2.equalizeHist(rescaled_image)
# Write the image to file.cv2.imwrite(output_file_path, final_image)
The text was updated successfully, but these errors were encountered:
At the moment the code used to convert the x-rays from DICOMs to JPGs is not publicly available as it's tied up in another repo. It would be good to have a publicly executable set of code that converts DICOMs to JPGs in the same way as we did to create MIMIC-CXR-JPG from MIMIC-CXR. The core function used was:
The text was updated successfully, but these errors were encountered: