Error using RGBPixel with TileImageFilter


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:


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

#include "itkTileImageFilter.h"

main(int argc, char * argv[])
  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: