I have 193 dcm files in a folder. I will like to combine these images into .dcm.gz format (e.g. images.dcm.gz) and I was wondering how this could be done in Mathematica. Thank you in anticipation of your kind suggestions!
$\begingroup$
$\endgroup$
2
-
2$\begingroup$ "I will like to combine these images in a gzip" <-- A gzip file cannot hold more than one file. It always holds only a single one. This is why tar is typically used together with gzip: tar is for combining, gzip is for compressing. Each tool has a single function according to the Unix philosophy. $\endgroup$– SzabolcsCommented Jul 21, 2022 at 12:12
-
$\begingroup$ Oh! thank you for the clarification. All I just want to do is to combine the dcm files into a single file in .dcm.gz format. Meanwhile, I have made appropriate edits to my question. $\endgroup$– DeanCommented Jul 21, 2022 at 12:20
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
Export
"ZIP"
As explained by @Szabolcs, "GZIP"
will not accept more than one file, so here I show an example with "ZIP"
.
Where I use a single image, you can have many.
img = Import["https://i.sstatic.net/gZ8oj.png"]
Export[
"TestFile.ZIP"
,{
img
}
,{
"ZIP"
,{
{"image.dcm","DICOM"}
}
}
]
In your case, change the list {img}
with all the image objects and {{"image.dcm","DICOM"}}
with the file and format names.
CreateFile
Alternatively you could use CreateFile
with a similar syntax.
-
$\begingroup$ @ rhermans, I dont understand what you meant by "change the list {img} with all the image objects", I have made some modifications to the question in this direction. Many thanks! $\endgroup$– DeanCommented Jul 21, 2022 at 12:27