For faster write speeds in SAM tool, we wrote a custom function instead of using mitk::IOUtil::Save function.
The function:
template <typename TPixel, unsigned int VImageDimension> void mitk::SegmentAnythingPythonService::ITKWriter(const itk::Image<TPixel, VImageDimension> *image, std::string& outputFilename) { typedef itk::Image<TPixel, VImageDimension> ImageType; typedef itk::ImageFileWriter<ImageType> WriterType; typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputFilename); writer->SetInput(image); try { writer->Update(); } catch (const itk::ExceptionObject &error) { MITK_ERROR << "Error: " << error << std::endl; mitkThrow() << "Error: " << error; } }
However, the NRRD files it dumps seems 'corrupt' in Ubuntu. Those cannot be loaded by the SimpleITK in python wrapper.
But, it works fine in Windows OS!
What is going wrong?