Local RLEImage compiling errors with ITK5.4

Hi @dzenanz,

I’m compiling ITK-SNAP with ITK 5.4-rc.2 and start getting following errors from this line.

Similar errors also occur when using ImageFileWriter and ImageAlgorithm etc. with RLEImage. The project is still using the local version of the RLEImage code instead of the itkRLEImage module. Are there any changes I can make to fix this or do you recommend we start using the remote RLE module instead. Any suggestions are appreciated!

In file included from /Users/jileihao/dev/itksnap-dev/itksnap/Logic/Mesh/MultiLabelMeshPipeline.cxx:50:
In file included from /Users/jileihao/tk/itk/installed/include/ITK-5.4/itkBinaryThresholdImageFilter.h:21:
In file included from /Users/jileihao/tk/itk/installed/include/ITK-5.4/itkUnaryFunctorImageFilter.h:145:
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkUnaryFunctorImageFilter.hxx:88:30: error: no viable constructor or deduction guide for deduction of template arguments of 'ImageScanlineConstIterator'
  ImageScanlineConstIterator inputIt(inputPtr, inputRegionForThread);
                             ^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkBinaryThresholdImageFilter.h:221:3: note: in instantiation of member function 'itk::UnaryFunctorImageFilter<RLEImage<unsigned short, 3>, itk::Image<float, 3>, itk::Functor::BinaryThreshold<unsigned short, float>>::DynamicThreadedGenerateData' requested here
  BinaryThresholdImageFilter();
  ^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkBinaryThresholdImageFilter.h:150:15: note: in instantiation of member function 'itk::BinaryThresholdImageFilter<RLEImage<unsigned short, 3>, itk::Image<float, 3>>::BinaryThresholdImageFilter' requested here
  itkNewMacro(Self);
              ^
/Users/jileihao/dev/itksnap-dev/itksnap/Logic/Mesh/MultiLabelMeshPipeline.cxx:63:40: note: in instantiation of member function 'itk::BinaryThresholdImageFilter<RLEImage<unsigned short, 3>, itk::Image<float, 3>>::New' requested here
  m_ThrehsoldFilter = ThresholdFilter::New();
                                       ^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkImageScanlineConstIterator.h:106:3: note: candidate template ignored: substitution failure [with TImage = RLEImage<unsigned short, 3>]: cannot reference member of primary template because deduced class template specialization 'ImageScanlineConstIterator<RLEImage<unsigned short, 3>>' is instantiated from a partial specialization
  ImageScanlineConstIterator(const TImage * ptr, const RegionType & region)
  ^                                                    ~~~~~~~~~~
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkImageScanlineConstIterator.h:267:1: note: candidate template ignored: could not match 'SmartPointer<type-parameter-0-0>' against 'const RLEImage<unsigned short, 3> *'
ImageScanlineConstIterator(SmartPointer<TImage>, const typename TImage::RegionType &)
^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkImageScanlineConstIterator.h:119:3: note: candidate function template not viable: requires single argument 'it', but 2 arguments were provided
  ImageScanlineConstIterator(const ImageIterator<TImage> & it)
  ^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkImageScanlineConstIterator.h:135:3: note: candidate function template not viable: requires single argument 'it', but 2 arguments were provided
  ImageScanlineConstIterator(const ImageConstIterator<TImage> & it)
  ^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkImageScanlineConstIterator.h:64:27: note: candidate function template not viable: requires 1 argument, but 2 were provided
class ITK_TEMPLATE_EXPORT ImageScanlineConstIterator : public ImageConstIterator<TImage>
                          ^
/Users/jileihao/tk/itk/installed/include/ITK-5.4/itkImageScanlineConstIterator.h:97:3: note: candidate function template not viable: requires 0 arguments, but 2 were provided
  ImageScanlineConstIterator()
  ^
1 error generated.

I suggest using the remote module. Otherwise you should backport changes done there to SNAP’s fork.

Thanks for the reply!

I did some experiments with the remote module today. And the template deduction issue persists once I plug it in. Here’s a testing program, and it reports same error as mentioned above. Any thoughts on where could the issue be?

#include <itkRLEImageRegionIterator.h>
#include <itkRLERegionOfInterestImageFilter.h>
#include <iostream>
#include <string>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkTimeProbe.h>
#include "itkTestingComparisonImageFilter.h"
#include <itkBinaryThresholdImageFilter.h>

//using namespace std;

typedef itk::Image<short, 3> Seg3DImageType;
typedef itk::Image<short, 2> Seg2DImageType;
typedef itk::Image<float, 3> Float3DImageType;

typedef itk::RLEImage<short> shortRLEImage;
typedef itk::RegionOfInterestImageFilter<shortRLEImage, shortRLEImage> roiType;

Seg3DImageType::Pointer loadImage(const std::string filename)
{
    typedef itk::ImageFileReader<Seg3DImageType> SegReaderType;
    SegReaderType::Pointer sr = SegReaderType::New();
    sr->SetFileName(filename);
    sr->Update();
    return sr->GetOutput();
}

int main(int argc, char* argv[])
{
    itk::TimeProbe tp;
    std::cout << "Loading image: "; tp.Start();
    Seg3DImageType::Pointer inImage = loadImage(argv[1]);
    tp.Stop(); std::cout << tp.GetMean() * 1000 << " ms " << std::endl; tp.Reset();
        
    std::cout << "itk->RLE conversion: "; tp.Start();
    shortRLEImage::Pointer test = shortRLEImage::New();
    typedef itk::RegionOfInterestImageFilter<Seg3DImageType, shortRLEImage> inConverterType;
    inConverterType::Pointer inConv = inConverterType::New();
    inConv->SetInput(inImage);
    inConv->SetRegionOfInterest(inImage->GetLargestPossibleRegion());
    inConv->Update();
    test = inConv->GetOutput();
    tp.Stop(); std::cout << tp.GetMean() * 1000 << " ms " << std::endl; tp.Reset();

    auto fltThreshold = itk::BinaryThresholdImageFilter<shortRLEImage, Float3DImageType>::New();
    fltThreshold->SetInput(test);
    fltThreshold->SetLowerThreshold(0);
    fltThreshold->SetUpperThreshold(1);
    fltThreshold->SetInsideValue(1);
    fltThreshold->SetOutsideValue(0);
    fltThreshold->Update();

    auto out = fltThreshold->GetOutput();
    out->Print(std::cout);

    return 0;
}

Error Message:

[ 50%] Building CXX object CMakeFiles/RLETest.dir/main.cxx.o
In file included from /Users/jileihao/dev/sandbox/RLETest/main.cxx:9:
In file included from /Users/jileihao/dev/itk-dev/itk/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.h:21:
In file included from /Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkUnaryFunctorImageFilter.h:145:
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkUnaryFunctorImageFilter.hxx:88:30: error: no viable constructor or deduction guide for deduction of template arguments of ‘ImageScanlineConstIterator’
ImageScanlineConstIterator inputIt(inputPtr, inputRegionForThread);
^
/Users/jileihao/dev/itk-dev/itk/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.h:221:3: note: in instantiation of member function ‘itk::UnaryFunctorImageFilter<itk::RLEImage<short, 3>, itk::Image<float, 3>, itk::Functor::BinaryThreshold<short, float>>::DynamicThreadedGenerateData’ requested here
BinaryThresholdImageFilter();
^
/Users/jileihao/dev/itk-dev/itk/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.h:150:15: note: in instantiation of member function ‘itk::BinaryThresholdImageFilter<itk::RLEImage<short, 3>, itk::Image<float, 3>>::BinaryThresholdImageFilter’ requested here
itkNewMacro(Self);
^
/Users/jileihao/dev/sandbox/RLETest/main.cxx:78:91: note: in instantiation of member function ‘itk::BinaryThresholdImageFilter<itk::RLEImage<short, 3>, itk::Image<float, 3>>::New’ requested here
auto fltThreshold = itk::BinaryThresholdImageFilter<shortRLEImage, Float3DImageType>::New();
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:106:3: note: candidate template ignored: substitution failure [with TImage = itk::RLEImage<short, 3>]: cannot reference member of primary template because deduced class template specialization ‘ImageScanlineConstIterator<itk::RLEImage<short, 3>>’ is instantiated from a partial specialization
ImageScanlineConstIterator(const TImage * ptr, const RegionType & region)
^ ~~~~~~~~~~
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:267:1: note: candidate template ignored: could not match ‘SmartPointer’ against ‘const itk::RLEImage<short, 3> *’
ImageScanlineConstIterator(SmartPointer, const typename TImage::RegionType &)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:119:3: note: candidate function template not viable: requires single argument ‘it’, but 2 arguments were provided
ImageScanlineConstIterator(const ImageIterator & it)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:135:3: note: candidate function template not viable: requires single argument ‘it’, but 2 arguments were provided
ImageScanlineConstIterator(const ImageConstIterator & it)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:64:27: note: candidate function template not viable: requires 1 argument, but 2 were provided
class ITK_TEMPLATE_EXPORT ImageScanlineConstIterator : public ImageConstIterator
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:97:3: note: candidate function template not viable: requires 0 arguments, but 2 were provided
ImageScanlineConstIterator()
^
1 error generated.
make[2]: *** [CMakeFiles/RLETest.dir/main.cxx.o] Error 1
make[1]: *** [CMakeFiles/RLETest.dir/all] Error 2
make: *** [all] Error 2

It compiles for me:

Build started at 19:20...
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>1>Checking Build System
1>CMake is re-running because C:/Misc/Tester/CMakeFiles/generate.stamp is out-of-date.
1>  the file 'C:/Dev/ITK-vs22/ITKConfig.cmake'
1>  is newer than 'C:/Misc/Tester/CMakeFiles/generate.stamp.depend'
1>  result='-1'
1>-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19045.
1>-- ITK is setting tester's MSVC_RUNTIME_LIBRARY to dynamic
1>-- Configuring done (0.3s)
1>-- Generating done (0.1s)
1>-- Build files have been written to: C:/Misc/Tester
2>------ Build started: Project: tester, Configuration: Debug x64 ------
2>tester.cpp
2>tester.vcxproj -> C:\Misc\Tester\Debug\tester.exe
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
3>Project not selected to build for this solution configuration 
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========
========== Build completed at 19:21 and took 07.606 seconds ==========

Hmm. Which ITK commits are you building with? Are there any cmake flags I could try?

This was building ITK 5.4RC2, with Module_RLEImage turned ON.

It’s still happening for me on macOS build with Apple clang version 14.0.0 .

I was able to narrow down the issue a little.

So this block not working:

const shortRLEImage *constRLE = shortRLEImage::New();
itk::ImageScanlineConstIterator it(constRLE, constRLE->GetLargestPossibleRegion());

But this works:

const itk::Image<float, 3> *constFloat = itk::Image<float, 3>::New();
itk::ImageScanlineConstIterator it(constFloat, constFloat->GetLargestPossibleRegion());

I think the most important error message pointing to this line (which was newly added to 5.4): ITK/Modules/Core/Common/include/itkImageScanlineConstIterator.h at v5.4rc02 · InsightSoftwareConsortium/ITK · GitHub
with the message “candidate template ignored: could not match ‘SmartPointer’ against ‘const itk::RLEImage<short, 3> *’
ImageScanlineConstIterator(SmartPointer, const typename TImage::RegionType &)”

Is there any way to make this deduction guide work for RLEImages?

@Niels_Dekker any ideas?

Sorry for being late! Did ImageScanlineConstIterator support RLEImage before? I’m asking, because I just gave it a try, and got: itkImageConstIterator.h(117,43): error C2039: 'PixelContainer': is not a member of 'itk::RLEImage<unsigned short,3,unsigned short>'

There is a follow-up GitHub issue with more discussion:

1 Like