Hi all,
I’m trying to use the SplitComponentsImageFilter
class to split a 5D image (component + 3D spatial + time) by time, and I’m getting a compilation error when I try to build a very simple test.
For context, this is related to this work (adding sequence of 3D + component image IO support to 3D Slicer):
The code that compiles (based on this test):
constexpr unsigned int Dimension = 4;
using PixelType = signed short;
using FrameImageType = itk::Image<PixelType, Dimension>;
using VectorType = itk::Vector<PixelType, Dimension>;
using ImageType = itk::Image<VectorType, Dimension>;
using SplitComponentsFilterType = itk::SplitComponentsImageFilter<ImageType, FrameImageType>;
SplitComponentsFilterType::Pointer splitComponentsFilter = SplitComponentsFilterType::New();
The code that I’d need for my use case:
constexpr unsigned int Dimension = 4;
using PixelType = itk::RGBAPixel<unsigned short>;
using ImageType = itk::Image< PixelType, Dimension >;
using FrameImageType = itk::Image< PixelType, Dimension-1 >;
using SplitComponentsFilterType = itk::SplitComponentsImageFilter<ImageType, FrameImageType>;
SplitComponentsFilterType::Pointer splitComponentsFilter = SplitComponentsFilterType::New();
When building this latter (VS2022), I get this error:
7>C:\d\S5D\ITK\Modules\Remote\SplitComponents\include\itkSplitComponentsImageFilter.hxx(82,48): error C2665: 'slicer_itk::ImageRegionConstIterator<slicer_itk::Image<PixelType,4>>::ImageRegionConstIterator': no overloaded function could convert all the argument types
7>C:\d\S5D\ITK\Modules\Core\Common\include\itkImageRegionConstIterator.h(151,3): message : could be 'slicer_itk::ImageRegionConstIterator<slicer_itk::Image<PixelType,4>>::ImageRegionConstIterator(const TImage *,const slicer_itk::ImageRegion<4> &)'
7> with
7> [
7> TImage=slicer_itk::Image<PixelType,4>
7> ]
7>C:\d\S5D\ITK\Modules\Remote\SplitComponents\include\itkSplitComponentsImageFilter.hxx(82,48): message : 'slicer_itk::ImageRegionConstIterator<slicer_itk::Image<PixelType,4>>::ImageRegionConstIterator(const TImage *,const slicer_itk::ImageRegion<4> &)': cannot convert argument 2 from 'const slicer_itk::ImageRegion<3>' to 'const slicer_itk::ImageRegion<4> &'
7> with
7> [
7> TImage=slicer_itk::Image<PixelType,4>
7> ]
7>C:\d\S5D\ITK\Modules\Remote\SplitComponents\include\itkSplitComponentsImageFilter.hxx(82,56): message : Reason: cannot convert from 'const slicer_itk::ImageRegion<3>' to 'const slicer_itk::ImageRegion<4>'
7>C:\d\S5D\ITK\Modules\Remote\SplitComponents\include\itkSplitComponentsImageFilter.hxx(82,56): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
7>C:\d\S5D\ITK\Modules\Remote\SplitComponents\include\itkSplitComponentsImageFilter.hxx(82,48): message : while trying to match the argument list '(slicer_itk::SmartPointer<const slicer_itk::Image<PixelType,4>>, const slicer_itk::ImageRegion<3>)'
7>C:\d\S5D\ITK\Modules\Remote\SplitComponents\include\itkSplitComponentsImageFilter.hxx(76,1): message : while compiling class template member function 'void slicer_itk::SplitComponentsImageFilter<ImageType,FrameImageType,4>::DynamicThreadedGenerateData(const slicer_itk::ImageRegion<3> &)'
7>C:\d\Slicer\Libs\vtkITK\vtkITKImageSequenceReader.cxx(195,38): message : see reference to class template instantiation 'slicer_itk::SplitComponentsImageFilter<ImageType,FrameImageType,4>' being compiled
The line in question is this:
My quesion is whether this class is designed to be able to be used for such splitting, and if not, what should I use instead? Thank you!