Skip to content

Instantly share code, notes, and snippets.

@cpinter
Created September 15, 2023 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpinter/c69e2f7860ed2053d1a38c965b930349 to your computer and use it in GitHub Desktop.
Save cpinter/c69e2f7860ed2053d1a38c965b930349 to your computer and use it in GitHub Desktop.
using PixelType = unsigned short;
constexpr unsigned int Dimension = 5;
using ImageType = itk::Image< PixelType, Dimension >;
using ReaderType = itk::ImageFileReader< ImageType >;
ReaderType::Pointer reader = ReaderType::New();
using InputImageType = itk::Image<PixelType, Dimension>;
reader->SetFileName("d:/pynrrd_test.nrrd");
reader->Update();
ImageType::ConstPointer image = reader->GetOutput();
using WriterType = itk::ImageFileWriter< ImageType >;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("d:/ith5DWriteTest.nrrd");
writer->SetInput(image);
writer->Update();
@cpinter
Copy link
Author

cpinter commented Sep 18, 2023

To keep the RGBA component, the first two rows need to be modified to:

using PixelType = itk::RGBAPixel<unsigned short>;
constexpr unsigned int Dimension = 4;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment