# Helper Function itk.tile\_image\_filter Correct Usage to Convert a 2D Slice to 3D Image

**URL:** https://discourse.itk.org/t/helper-function-itk-tile-image-filter-correct-usage-to-convert-a-2d-slice-to-3d-image/7586
**Category:** Beginner Questions
**Created:** [June 28, 2025, 4:16am UTC](https://discourse.itk.org/t/helper-function-itk-tile-image-filter-correct-usage-to-convert-a-2d-slice-to-3d-image/7586 "2025-06-28T04:16:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![constantine](https://discourse.itk.org/user_avatar/discourse.itk.org/constantine/32/3915_2.png) [@constantine](https://discourse.itk.org/u/constantine)
#### Post date: [June 28, 2025, 4:16am UTC](https://discourse.itk.org/t/helper-function-itk-tile-image-filter-correct-usage-to-convert-a-2d-slice-to-3d-image/7586/1 "2025-06-28T04:16:21Z")

</div>

I have used `itk::ImageFilter<itk::Image<unsigned char, 2>, itk::Image<unsigned char, 3>>` in C++ to convert a 2D slice to 3D volume in the past.

I’m trying to achieve the same ends with `itk.tile_image_filter` with ITK Python wrapper like this:

```auto
img_moving3d = itk.tile_image_filter(
    img_moving,
    layout=[1,1,0], # The docs say this is how we stack along the 3rd dim.
    default_pixel_value=0.0
)

```

Producing this:

```auto
  File "...\Lib\site-packages\itk\itkTileImageFilterPython.py", line 1957, in SetLayout
    return _itkTileImageFilterPython.itkTileImageFilterIUC2IUC2_SetLayout(self, _arg)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^
TypeError: Expecting an itkFixedArrayUI2, an int, a float, a sequence of int or a sequence of float.
python-BaseException

```

Which is telling the wrong template is selected: `itkTileImageFilterIUC2IUC2`, where I’d want this template: `itkTileImageFilterIUC2IUC3`.

And when I pass a list of images, as documentation suggests:

```auto
img_moving3d = itk.tile_image_filter(
    [img_moving],
    layout=[1,1,0], # The docs say this is how we stack along the 3rd dim.
    default_pixel_value=0.0
)

```

Further confusion ensures:

```auto
File "...\PhantomAs3_Displacements.py", line 99, in <module>
    img_moving3d = itk.tile_image_filter(
        [img_moving],
        layout=[1,1,0],
        default_pixel_value=0.0
    )
  File "...\Lib\site-packages\itk\support\helpers.py", line 194, in image_filter_wrapper
    return image_filter(*args, **kwargs)
  File "...\Lib\site-packages\itk\itkTileImageFilterPython.py", line 3153, in tile_image_filter
    instance = itk.TileImageFilter.New(*args, **kwargs)
  File "...\Lib\site-packages\itk\support\template_class.py", line 749, in New
    raise itk.TemplateTypeError(self, input_type)
itk.support.extras.TemplateTypeError: itk.TileImageFilter is not wrapped for input type `None`.

```

I know I could go about it like this:

```auto
tif = itk.TileImageFilter[itk.Image[itk.UC,2], itk.Image[itk.UC,2]].New(img_moving)...
tif.SetLayout([1,1,0])

```

But what is the correct way of calling `itk.tile_image_filter` for single 2D slice to 3D output?

---

<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: [June 30, 2025, 12:54pm UTC](https://discourse.itk.org/t/helper-function-itk-tile-image-filter-correct-usage-to-convert-a-2d-slice-to-3d-image/7586/2 "2025-06-30T12:54:02Z")

</div>

With that interface, the wrapper plumbing picks first available match for the input, which is 2D-\>2D, and not 2D-\>3D (what you want). I am not sure that you can get that with procedural interface. Wrapper specification is [here](https://github.com/InsightSoftwareConsortium/ITK/blob/main/Modules/Filtering/ImageGrid/wrapping/itkTileImageFilter.wrap), a simple combination of all the wrapped dimensions.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 30, 2025, 3:25pm UTC](https://discourse.itk.org/t/helper-function-itk-tile-image-filter-correct-usage-to-convert-a-2d-slice-to-3d-image/7586/3 "2025-06-30T15:25:45Z")

</div>

Hi,

To specify the type of the filter with the procedural interface, the [`ttype` kwarg can be used.](https://docs.itk.org/en/latest/learn/python_quick_start.html#filter-types)
