Hi, I am try to get convert a dicom image into jpeg, png or bmp. I would like to know if converting the image array from dicom to jpeg or any other format results loss in image data information? Thanks,Jiten
Yes, you lose important information, such as slice position, spacing, axis directions, slice order, coordinate system axis unit. Depending on the chosen format, you also lose image quality (due to compression artifacts) or make the images essentially unusable (8-bit is insufficient for most medical images). You also lose compatibility with most medical imaging software (many of them can import jpg/png image stacks but since there is no standard for storing missing metadata, they all make up the missing information in different ways). You also lose ability to reliably detect missing files.
Even though conversion of medical images into consumer file formats may be tempting (e.g., to run random deep learning example codes that you find on the web), it should be avoided. Instead, you should convert to standard research formats (nrrd, nifti) or directly to numpy arrays.
There are a few exceptions, where conversion to consumer image file formats is appropriate, such as exporting images or movies for creating slides for presentations.
Thanks @lassoan that makes sense. Thats great insight to convert medical images directly into numpy arrays, however just thinking out loud, once my program gets the dicom image I extract image data as numpy array and then can I save numpy array as some lossless image format like png/tiff?
Research file formats (such as nrrd and nifti) store essential 3D medical imaging metadata, therefore they can be used as a simpler alternative to DICOM when you are strictly interested in the image data only.
Numpy arrays are nice because they can store large hypercubes of preprocessed (aligned, cropped, resampled, …) data, they can be directly used directly as inputs of many machine learning toolkits, and can be written to/read from files efficiently.
Consumer file formats just don’t fit anywhere in this DICOM -> research file format -> numpy array -> tensor data flow.
makes absolute sense @lassoan This is very helpful! Thanks, Jiten