Save binary image into .dcm
Afficher commentaires plus anciens
Hi
I have segmented an organ from a CT scan (original image given in DICOM) and I would like to save the segmented image (binary one) as .dcm due to I need to use it after in other software that only read .dcm. Could someone explain me how I can do that?
Thank you in advance.
7 commentaires
Geoff Hayes
le 19 Août 2014
dicomwrite(X, filename) writes the binary, grayscale, or truecolor image X to the file filename, where filename is a string specifying the name of the Digital Imaging and Communications in Medicine (DICOM) file to create.
Geoff Hayes
le 20 Août 2014
Isabel - what do you mean by flipped? Is the image transposed or flipped left to right? And is the origin different?
To avoid the warning message, you can probably just convert the data to 8-bit unsigned integers and multiply by 255 (since the binary data is just 0s or 1s). Something like
seg17 = 255*uint8(seg17);
Why are you doing the reshape, and so adding the extra dimension?
Isabel
le 22 Août 2014
Geoff Hayes
le 22 Août 2014
Isabel - I'm not sure why that would be happening. Out of curiosity, if you read the file back in to MATLAB (with dicomread) are the images upside down? Is the meta data (as obtained with dicominfo) the same as the original, or has it been changed too?
dicomwrite(flipud(reshape(seg17,[512 512 1 268])), 'ct_seg.dcm', info, 'CreateMode', 'copy');
You could also check the status of the dicomwrite as
status = dicomwrite(flipud(reshape(seg17,[512 512 1 268])), ...
'ct_seg.dcm', info, 'CreateMode', 'copy');
Isabel
le 26 Août 2014
Geoff Hayes
le 26 Août 2014
Glad that you were able to get everything working, Isabel!
Réponses (0)
Catégories
En savoir plus sur Read and Write Image Data from Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!