# no itk.join\_image\_filter in ITK 5.1.2

**URL:** <https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671>\
**Category:** Beginner Questions\
**Created:** [December 3, 2020, 8:38am UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671 "2020-12-03T08:38:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyoll](https://discourse.itk.org/user_avatar/discourse.itk.org/dyoll/32/2311_2.png) [@dyoll](https://discourse.itk.org/u/dyoll)\
**Post date:** [December 3, 2020, 8:38am UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/1 "2020-12-03T08:38:33Z")

</div>

It seems the itk::JoinImageFilter is not wrapped to python (yet). I could not find it in the 5.1.2 release.  
Is there a list of filters which have been wrapped?

I would expect a class named `itk.join_image_filter`. The only filter in itk with `join` in the name, is join\_series\_image\_filter. I think that filter results in a different ordering of the data though.

I am trying to join components of a tensor image (stored as scalar images) and thought it a good task to start using the python interface instead of c++.

Is there an alternative or way to join the image components?

- I tried  
`join_filter = itk.JoinImageFilter[type(components[0]), itk.Image[itk.F, 6]].New()`  
but itk.JoinImageFilter also is not available.

- I also tried to stack the images with numpy:  
`tensor_image = np.stack([itk.array_view_from_image(c) for c in components], axis=3)` but  
`itk.image_view_from_array(tensor_image, is_vector=True)` fails (error pasted below)

Should I create an issue on github?

> Traceback (most recent call last):  
> File “E:\Develop\Scripts\MIDA\_dti.venv\lib\site-packages\itkTemplate.py”, line 336, in **getitem**  
> return(self. **template** [tuple(cleanParameters)])  
> KeyError: (, 4)
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “E:\Develop\Scripts\MIDA\_dti.venv\lib\site-packages\itkTemplate.py”, line 340, in **getitem**  
> return(self. **template** [tuple(cleanParameters)])  
> KeyError: (, 4)
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “make\_tensor\_image.py”, line 18, in   
> itk.image\_view\_from\_array(tensor\_image)  
> File “E:\Develop\Scripts\MIDA\_dti.venv\lib\site-packages\itkExtras.py”, line 299, in GetImageViewFromArray  
> return \_GetImageFromArray(arr, “GetImageViewFromArray”, is\_vector)  
> File “E:\Develop\Scripts\MIDA\_dti.venv\lib\site-packages\itkExtras.py”, line 272, in \_GetImageFromArray  
> ImageType = itk.Image[PixelType, Dimension]  
> File “E:\Develop\Scripts\MIDA\_dti.venv\lib\site-packages\itkTemplate.py”, line 342, in **getitem**  
> raise TemplateTypeError(self, tuple(cleanParameters))  
> itkTemplate.TemplateTypeError: itk.Image is not wrapped for input type `itk.F, int`.
> 
> To limit the size of the package, only a limited number of  
> types are available in ITK Python. To print the supported  
> types, run the following command in your python environment:
> 
> ```
> itk.Image.GetTypes()
> 
> ```
> 
> Possible solutions:
> 
> - If you are an application user:  
> \*\* Convert your input image into a supported format (see below).  
> \*\* Contact developer to report the issue.
> 
> - If you are an application developer, force input images to be  
> loaded in a supported pixel type.
> 
> - (Advanced) If you are an application developer, build ITK Python yourself and  
> turned to `ON` the corresponding CMake option to wrap the pixel type or image  
> dimension you need. When configuring ITK with CMake, you can set  
> `ITK_WRAP_${type}` (replace ${type} with appropriate pixel type such as  
> `double`). If you need to support images with 4 or 5 dimensions, you can add  
> these dimensions to the list of dimensions in the CMake variable  
> `ITK_WRAP_IMAGE_DIMS`.
> 
> Supported input types:
> 
> itk.RGBPixel[itk.UC]  
> itk.RGBAPixel[itk.UC]  
> itk.Vector[itk.F,2]  
> itk.Vector[itk.F,3]  
> itk.Vector[itk.F,4]  
> itk.CovariantVector[itk.F,2]  
> itk.CovariantVector[itk.F,3]  
> …

---

<div class="post-metadata">

**Author:** ![dyoll](https://discourse.itk.org/user_avatar/discourse.itk.org/dyoll/32/2311_2.png) [@dyoll](https://discourse.itk.org/u/dyoll)\
**Post date:** [December 3, 2020, 11:00am UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/2 "2020-12-03T11:00:50Z")

</div>

btw. I see in the list of supported pixel types that vector with 6 components are not listed. I think the only pixel type in that list that has 6 values is the 3d symmetric second rank tensor.  
However, the API of `image_view_from_array` and `image_from_array` doesn’t seem to allow to specify the pixel type explicitly.

---

<div class="post-metadata">

**Author:** ![dyoll](https://discourse.itk.org/user_avatar/discourse.itk.org/dyoll/32/2311_2.png) [@dyoll](https://discourse.itk.org/u/dyoll)\
**Post date:** [December 3, 2020, 11:13am UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/3 "2020-12-03T11:13:25Z")

</div>

it seems even if I get the components into a tensor image, the image writer is not wrapped for this type:

> itkTemplate.TemplateTypeError: itk.ImageFileWriter is not wrapped for input type `itk.Image[itk.SymmetricSecondRankTensor[itk.D,3],3]`.

While the pixel type is listed in the itk.Image.GetTypes(), it seems the image writer does not support the same set of image types.

---

<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:** [December 3, 2020, 6:15pm UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/4 "2020-12-03T18:15:43Z")

</div>

Have you tried compiling ITK yourself? That way you can turn on extra wrapping options.

---

<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:** [December 9, 2020, 4:55pm UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/5 "2020-12-09T16:55:58Z")

</div>

> [@dyoll](#):
>
> However, the API of `image_view_from_array` and `image_from_array` doesn’t seem to allow to specify the pixel type explicitly.

ITK 5.2, whose release candidate is coming up, has more support for vector pixel types in these functions and in an `image.astype` function.

> [@dyoll](#):
>
> I am trying to join components of a tensor image (stored as scalar images) and thought it a good task to start using the python interface instead of c++.

While we can add more wrapping for `join_image_filter`, but combining scalar images into a multi-component image is already supported with `itk.compose_image_filter`. For example,

```auto
arrays = [component1, component2, component3]
together = itk.compose_image_filter(*arrays)

# or
images = [itk.image_view_from_array(a) for a in arrays]
together = itk.compose_image_filter(*images)

```

---

<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 25, 2024, 5:19am UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/6 "2024-06-25T05:19:42Z")

</div>

Yes, I’ve noticed, for example, this files just fine:

```auto
itk.JoinSeriesImageFilter[itk.Image[itk.UC,2], itk.Image[itk.UC,3]]
<class 'itk.itkJoinSeriesImageFilterPython.itkJoinSeriesImageFilterIUC2IUC3'>

```

And then, this flops on it’s face:

```auto
itk.JoinSeriesImageFilter[itk.Image[itk.RGBPixel[itk.UC], 2], itk.Image[itk.RGBPixel[itk.UC], 3]]
Traceback (most recent call last):
...
itk.support.extras.TemplateTypeError: itk.JoinSeriesImageFilter is not wrapped for input type `itk.Image[itk.RGBPixel[itk.UC],2], itk.Image[itk.RGBPixel[itk.UC],3]`.

```

Is there an easy workaround in this case, I’m wondering, please?

Digging deeper, Dženan (@dzenanz) — are you saying this can be configured (in CMake) when compiling ITK with Python wrapping? … and then it would be possible to “install” the itk Python package locally?

---

<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 25, 2024, 12:39pm UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/7 "2024-06-25T12:39:03Z")

</div>

Yes.

---

<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 25, 2024, 12:41pm UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/8 "2024-06-25T12:41:26Z")

</div>

Uh, no. uchar RGB pixel is on by default, which means that `JoinSeriesImageFilter` is missing wrapping for it. It only [wraps](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/ImageCompose/wrapping/itkJoinSeriesImageFilter.wrap#L16) scalar images. That would need to be changed, to e.g. also include RGB images.

---

<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:** [July 2, 2024, 5:03am UTC](https://discourse.itk.org/t/no-itk-join-image-filter-in-itk-5-1-2/3671/9 "2024-07-02T05:03:49Z")

</div>

I see. Thank you. I’m just tinkering around with things, and have found a workaround for now.
