Hello,
I am trying to reduce dicom file size when creating a new dicom by converting from bmp to png but I do not see the file size getting reduced, png use compession so logically I have less file size.
Best Regards
George
Hello,
I am trying to reduce dicom file size when creating a new dicom by converting from bmp to png but I do not see the file size getting reduced, png use compession so logically I have less file size.
Best Regards
George
Hello @George_Z,
It is not clear what it is that you are attempting to do. Three file formats are mentioned in the post, DICOM, bmp and png. You can easily save an image to disk using these formats. Using the SimpleITK logo we read the image and save in each of the formats:
import SimpleITK as sitk
image = sitk.ReadImage("SimpleITK.jpg")
use_compression = True
sitk.WriteImage(image, "SimpleITK.dcm", use_compression)
sitk.WriteImage(image, "SimpleITK.bmp", use_compression)
sitk.WriteImage(image, "SimpleITK.png", use_compression)
Please provide additional details if this does not address your issue. For additional information and IO examples see this jupyter notebook, section titled Reading and Writing.
I am trying to generate a dicom file from png images with 22kb and I always get 8.2MB which is a very big dicom and I am trying to reduce that by converting to a proper number of samples per picture.
I do not want to use a compression because I am trying to get similar results to the original image which is 2.8MB. the transfer syntax is little endian, photometric interpretation is palaete color and depth of bits is 8.
Do you have a tool to convert the dicom to a different samples per pixel
Hello @George_Z,
All three component images in ITK/SimpleITK which use the GDCM library underneath the hood are saved using an “RGB” photometric interpretation, “0028|0004” (see code here), so unfortunately, you cannot save it using a value of “PALETTE COLOR”.
If you are looking for finer control of DICOM reading/writing, allowing you to configure all the settings, you can use packages that focus on that GDCM or pydicom.
Hello,
I can only use C++, so I noticed when I opened the dicom that it has many padding and spaces? do you have any idea to reduce that?
I noticed that it also not really valid to call on sample oer pixel as 3, so it must be corrupted.
Also, How do you recommend to craete a dicom from multiple png images
Best Regards
George
Hello @George_Z,
It is not clear what you mean by “has many padding and spaces”. With respect to samples per pixel as 3, that is a valid value when the photometric interpretation is set to RGB (see details here).
What exactly are you trying to do with the multiple png images? Based on your questions, it appears to be that you are looking for advanced control of the image writing process and that it be in C++. I would recommend that you go for GDCM and ask the questions on the GDCM mailing list.
Also, when asking a question you should provide as many details as you can so that someone can help you (programming language and specific task you want to perform).
Converting color (24-bit RGB) image to paletted (8-bit index into lookup table) is compression. If the original image is full-color image then data loss is very significant. If the original is just grayscale image with a little colored annotations (e.g., 8-bit grayscale ultrasound with burnt-in patient information, ruler, etc. using only a few discrete colors) then you may only need to remove a few gray levels, so the information loss may be negligible.
If you want to avoid information loss and minimize the file size then you can use lossless compression (JPEG-LS, RLE, etc). However, the compression ratio is not that high and it may cause compatibility issues and reduces reading speed. Since storage is cheap, often compression is not worth the trouble.
If you don’t modify the image data then you can preserve the original the image data and only modify the metadata using GDCM.
I agree with @zivy that since you seem to have very special requirements, you probably need to use low-level APIs (figure out what pixel encoding you want to use and set each DICOM tag manually using GDCM) to fulfill them.
If you describe the overall clinical goal and solution you are considering (e.g., you develop an AI model that segments structures on ultrasound images and you want to save the results in DICOM files) then we may be able to give more useful advice.