Did ITK can read a directory of one serial that of many files, and write into one dcm file of multi frames.

Now I have a CT serial in a directory, now I want to read all the serial files and write it into one single dcm file.

You can write it into a one .dcm file. Example:

#include "itkImageFileWriter.h"
#include "itkRandomImageSource.h"

  using ImageType = itk::Image<unsigned short, 3>;
  using RS = itk::RandomImageSource<ImageType>;
  RS::Pointer rs = RS::New();
  itk::WriteImage(rs->GetOutput(), "C:/a/testOut.dcm");

  return 1;

produces this file:
testOut.dcm (517 KB)

If you want to carry over metadata from the source series, you might need something like:

itk::WriteImage(image, "C:/a/testOut.dcm");

You should also take a look at Dicom ChangeHeader example.

Thank you very much! I got it.

1 Like