After casting the ImageType to a new data type, ConnectedComponentImageFilter still raising " error: conversion from ‘itk::Concept::IsInteger<float>"

I have defined the input ImageType as float and the OutputImageType for the ConnectedComponentImageFilter according to the link:

typedef float PixelType;
constexpr unsigned int Dimension=3;
using ImageType=itk::Image<PixelType ,Dimension>;
using ReaderType=itk::ImageFileReader<ImageType>;

using OutputImageType = itk::Image<unsigned short, Dimension>;  // Output type for ConnectedComponentImageFilter

However, I get the following error.
Then, according to this link, I created an intermediate image type (unsigned short same as output of CCFilter) for casting from input ImageType of ConnectedComponentImageFilter (CCFilter) to the OutputImageType.

 typedef itk::Image< unsigned short, 3> InternalImageType;
        typedef itk::CastImageFilter< ImageType, InternalImageType> CastingFilterType;
        CastingFilterType::Pointer castFilter = CastingFilterType::New();
        castFilter->SetInput( image );
        castFilter->Update();
        using ConnectedComponentImageFilterType = itk::ConnectedComponentImageFilter<InternalImageType, OutputImageType>;

        ConnectedComponentImageFilterType::Pointer connected = ConnectedComponentImageFilterType::New();
        connected->SetInput(castFilter->GetOutput());
        connected->Update();

I am still getting the error:

/usr/local/include/ITK-5.0/itkConceptChecking.h: In instantiation of ‘void itk::Concept::IsInteger<T>::Constraints::constraints() [with T = float]’:
/usr/local/include/ITK-5.0/itkConceptChecking.h:741:3:   required from ‘struct itk::Concept::IsInteger<float>’
/usr/local/include/ITK-5.0/itkConnectedComponentImageFilter.h:141:3:   required from ‘class itk::ConnectedComponentImageFilter<itk::Image<float, 3u>, itk::Image<float, 3u> >’
/home/user5/CLionProjects/VTK_examples/3-WritePLY/main.cpp:612:38:   required from here
/usr/local/include/ITK-5.0/itkConceptChecking.h:735:27: error: conversion from ‘itk::Concept::IsInteger<float>::Constraints::TrueT {aka itk::Concept::Detail::UniqueType_bool<true>}’ to non-scalar type ‘itk::Concept::IsInteger<float>::Constraints::IntegralT {aka itk::Concept::Detail::UniqueType_bool<false>}’ requested
       IntegralT a = TrueT();
                           ^

What could be the reason for this?
Thanks

Are you trying to instantiate ConnectedComponent filter using float image somewhere else (main.cpp, line 612, column 38)? That would explain the error.

1 Like