Save binary image into .dcm
Show older comments
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 Comments
Geoff Hayes
on 19 Aug 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
on 20 Aug 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
on 22 Aug 2014
Geoff Hayes
on 22 Aug 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
on 26 Aug 2014
Geoff Hayes
on 26 Aug 2014
Glad that you were able to get everything working, Isabel!
Answers (0)
Categories
Find more on Read and Write Image Data from Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!