Saving 3D image

Hi,
I have a series of CT image slices that I've uploaded into MATLAB and are stacked in one variable. How do I save it out as a 3D image?

回答 (2 件)

Sean de Wolski
Sean de Wolski 2011 年 12 月 7 日

0 投票

Does it need to be accessible from another program?
doc save
I would just use save and save it as a matfile. If it has to be readable from another program (or someone without MATLAB) use fopen/fwrite
doc fopen
doc fwrite

11 件のコメント

Ka Zhang
Ka Zhang 2011 年 12 月 7 日
Yes, I'm using another program called elastix for image registration. It's ran from a command line, so I don't think fopen/fwrite will work. Thanks!
Sean de Wolski
Sean de Wolski 2011 年 12 月 7 日
fopen/fwrite will write it to binary. What format does elastix require? You're going to have to write to that format if elastix doesn't except raw binary.
Ka Zhang
Ka Zhang 2011 年 12 月 12 日
For elastix TIFF, JPEG, PNG, BMP, and DICOM seem to be common. Is there any way I could save my variable with all the slices as one of those formats?
Walter Roberson
Walter Roberson 2011 年 12 月 12 日
DICOM could do that for sure, in a format that elastix would be likely to understand.
The TIFF format does allow multiple images per file, but you would have to know exactly how elastix wanted the images named (or numbered)... and considering that JPEG and PNG and BMP files cannot handle multiple images per file, I would think it likely that elastix is not designed to look for the possibility of all of the slices being stored in the one TIFF file.
Ka Zhang
Ka Zhang 2011 年 12 月 12 日
Is there anything special I need to specify with dicomwrite for a 3D variable? I'm getting errors when using dicomwrite.
Sean de Wolski
Sean de Wolski 2011 年 12 月 12 日
How are you calling dicomwrite and what are the _full_ error messages?
Ka Zhang
Ka Zhang 2011 年 12 月 12 日
>> dicomwrite('images','027_3D.dcm');
??? Error using ==> dicom_prep_ImagePixel>getPixelStorage at 168
Invalid datatype for image pixels.
Error in ==> dicom_prep_ImagePixel at 14
[ba, bs, hb, pr] = getPixelStorage(X, txfr);
Error in ==> dicom_prep_metadata at 40
metadata = dicom_prep_ImagePixel(metadata, X, map, txfr);
Error in ==> dicom_create_IOD at 30
metadata = dicom_prep_metadata(IOD_UID, metadata, X, map, options.txfr);
Error in ==> dicomwrite>write_message at 236
[attrs, msg, status] = dicom_create_IOD(SOP_UID, X(:,:,:,p), map, ...
Error in ==> dicomwrite at 195
status = write_message(X, filename, map, metadata, options);
Sean de Wolski
Sean de Wolski 2011 年 12 月 12 日
You're calling dicomwrite with 'images' which is a 1x6 string (typo, probably).
dicomwrite(images,'027_3D.dcm');
Ka Zhang
Ka Zhang 2011 年 12 月 12 日
oops that was silly. But it seems it is not the problem:
>> dicomwrite(image027,'027_3D.dcm');
??? Error using ==> dicom_prep_ImagePixel>getPhotometricInterp at 98
Cannot determine photometric interpretation.
Error in ==> dicom_prep_ImagePixel at 10
metadata.(dicom_name_lookup('0028', '0004')) = getPhotometricInterp(X, map, txfr);
Error in ==> dicom_prep_metadata at 40
metadata = dicom_prep_ImagePixel(metadata, X, map, txfr);
Error in ==> dicom_create_IOD at 30
metadata = dicom_prep_metadata(IOD_UID, metadata, X, map, options.txfr);
Error in ==> dicomwrite>write_message at 236
[attrs, msg, status] = dicom_create_IOD(SOP_UID, X(:,:,:,p), map, ...
Error in ==> dicomwrite at 195
status = write_message(X, filename, map, metadata, options);
Sean de Wolski
Sean de Wolski 2011 年 12 月 12 日
what does
whos images
return?
Ka Zhang
Ka Zhang 2011 年 12 月 12 日
it's
Name Size Bytes Class Attributes
image027 512x512x99 207618048 double

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

Walter Roberson
Walter Roberson 2011 年 12 月 12 日

0 投票

1 件のコメント

Ka Zhang
Ka Zhang 2011 年 12 月 12 日
unfortunately that writes out the 3D MATLAB variable into 2D slices with each slice as an individual dicom file. Thanks though

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

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

タグ

質問済み:

2011 年 12 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by