Error using RGBPixel with TileImageFilter

Hi,

I am getting a mutex error when using the following piece of code:

using RGBPixelType = itk::RGBPixel< unsigned char >;
using FinalOutputImageType = itk::Image< RGBPixelType, 2 >;
using TileFilterType = itk::TileImageFilter< FinalOutputImageType, FinalOutputImageType >;
auto tileFilter = TileFilterType::New();

This is the call stack from VS:

Cheers,
Sarthak

The program runs fine for me with or without the commented line:

#include "itkTileImageFilter.h"

int
main(int argc, char * argv[])
{
  //itk::MultiThreaderBase::SetGlobalDefaultThreader(itk::MultiThreaderBase::ThreaderEnum::Pool);
  using RGBPixelType = itk::RGBPixel<unsigned char>;
  using FinalOutputImageType = itk::Image<RGBPixelType, 2>;
  using TileFilterType = itk::TileImageFilter<FinalOutputImageType, FinalOutputImageType>;
  auto tileFilter = TileFilterType::New();
  return EXIT_SUCCESS;
}

I have ITK compiled with TBB multi-threader, so it is the default.

Ah, got it, thanks.

I was trying to initialize this as a global variable and ran into the aforementioned issue.

1 Like

You can not create most ITK objects before entering the main of the application. This can occur if you have global static variables.

You can find more information about static variable initialization here:
https://isocpp.org/wiki/faq/ctors#static-init-order

2 Likes