# Error using RGBPixel with TileImageFilter

**URL:** https://discourse.itk.org/t/error-using-rgbpixel-with-tileimagefilter/3082
**Category:** Uncategorized
**Created:** [May 17, 2020, 2:04am UTC](https://discourse.itk.org/t/error-using-rgbpixel-with-tileimagefilter/3082 "2020-05-17T02:04:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sarthakpati](https://discourse.itk.org/user_avatar/discourse.itk.org/sarthakpati/32/383_2.png) [@sarthakpati](https://discourse.itk.org/u/sarthakpati)
#### Post date: [May 17, 2020, 2:04am UTC](https://discourse.itk.org/t/error-using-rgbpixel-with-tileimagefilter/3082/1 "2020-05-17T02:04:00Z")

</div>

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:

 ![image](https://discourse.itk.org/uploads/default/original/2X/3/3b735e9b7b8e0723ccc4e89d103032283d1dc917.png)

Cheers,  
Sarthak

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 17, 2020, 5:19pm UTC](https://discourse.itk.org/t/error-using-rgbpixel-with-tileimagefilter/3082/2 "2020-05-17T17:19:17Z")

</div>

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

```cpp
#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.

---

<div class="post-metadata">

### Author: ![sarthakpati](https://discourse.itk.org/user_avatar/discourse.itk.org/sarthakpati/32/383_2.png) [@sarthakpati](https://discourse.itk.org/u/sarthakpati)
#### Post date: [May 17, 2020, 5:35pm UTC](https://discourse.itk.org/t/error-using-rgbpixel-with-tileimagefilter/3082/3 "2020-05-17T17:35:58Z")

</div>

Ah, got it, thanks.

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

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [May 18, 2020, 11:52am UTC](https://discourse.itk.org/t/error-using-rgbpixel-with-tileimagefilter/3082/4 "2020-05-18T11:52:06Z")

</div>

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](https://isocpp.org/wiki/faq/ctors#static-init-order)
