multiframe (multiple sclices) dicom to png or jpg

11 ビュー (過去 30 日間)
Rehan
Rehan 2021 年 5 月 27 日
コメント済み: Rehan 2021 年 5 月 28 日
Hi,
I want to convert multiframe dicom to png or jpg.
On internet noramlly people are doing single dicom to single png, but how to convert, if dicom is a multframe file.

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 5 月 27 日
編集済み: Walter Roberson 2021 年 5 月 27 日
There is more than one way of storing multiple frames in a dicom file. If you are using the terminology "frame" then chances are that when you use dicomread() you will get back an array that has all of the data already present in a single 3D or 4D array, with the last dimension being the frame number.
The alternative DICOM storage methods, that need more work, are usually talked about with the terminology "sequences". Those kinds of files are common for some modalities, but those are modalities that I have not happened to have reason to work with.
Once you have a multidimensional array, then to store into png (jpg is not recommended for science work!), you can loop using imwrite() one page at a time. Or you can use montage(). Or you can use reshape() (perhaps with permute()) to lay out the images beside each other in an array, and imwrite() that array. Writing one frame per file would be the more common method.
  2 件のコメント
Rehan
Rehan 2021 年 5 月 27 日
ok thanks for suggestion,i'll try and update you.
Rehan
Rehan 2021 年 5 月 28 日
I have tried it in python and it worked
import SimpleITK as sitk
import os
image = sitk.ReadImage('dicom file')
depth=image.GetDepth()
nda = sitk.GetArrayFromImage(image)
print(nda.shape)
for i in range(depth):
img = sitk.GetImageFromArray(nda[i])
writer = sitk.ImageFileWriter()
writer.SetFileName(os.path.join('out', str(i)+'.png' ))
writer.Execute(img)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDICOM Format についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by