Converting Segmentation to Volume automatically w/ Python or Matlab

You can load the segmentation and export to volume file. If you want the segmentation to have a particular geometry (origin, spacing, axis directions, and extents) then specify the CT volume as reference volume when you export to volume file (when you call ExportSegmentsBinaryLabelmapRepresentationToFiles).

See complete example here: