# Bug in itk.image\_duplicator?

**URL:** https://discourse.itk.org/t/bug-in-itk-image-duplicator/4408
**Category:** Uncategorized
**Created:** [September 9, 2021, 1:03pm UTC](https://discourse.itk.org/t/bug-in-itk-image-duplicator/4408 "2021-09-09T13:03:53Z")
**Posts on this page:** 3
**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: [September 9, 2021, 1:03pm UTC](https://discourse.itk.org/t/bug-in-itk-image-duplicator/4408/1 "2021-09-09T13:03:53Z")

</div>

I load an image like

```auto
import itk
img = itk.imread("/path/to/image.nii.gz")
print(type(img))
print(img.shape)

```

The type is a `itk.itkImagePython.itkImageF3`.  
The shape is (310,310,310).

Then I duplicate the image: `img_t = image_duplicator(img)`  
The shape is (310,310) and the type `itk.itkPyBufferPython.NDArrayITKBase`.

Does this make sense? What am I doing wrong?

I also tried:

```auto
import copy
img_t = copy.deepcopy(img)

```

This leads to following error:

> File “i2i\translate\_image.py”, line 78, in translate  
> img\_t = copy.deepcopy(img)  
> File “C:\Python36\lib\copy.py”, line 180, in deepcopy  
> y = \_reconstruct(x, memo, \*rv)  
> File “C:\Python36\lib\copy.py”, line 280, in \_reconstruct  
> state = deepcopy(state, memo)  
> File “C:\Python36\lib\copy.py”, line 150, in deepcopy  
> y = copier(x, memo)  
> File “C:\Python36\lib\copy.py”, line 240, in \_deepcopy\_dict  
> y[deepcopy(key, memo)] = deepcopy(value, memo)  
> File “C:\Python36\lib\copy.py”, line 169, in deepcopy  
> rv = reductor(4)  
> TypeError: can’t pickle SwigPyObject objects

and `img_t = itk.image_from_array(itk.array_view_from_image(img))`, leading to following error:

> File “i2i\translate\_image.py”, line 75, in translate  
> img\_t = itk.image\_from\_array(itk.array\_view\_from\_image(img))  
> File “E:\Develop\Segmania.venv\lib\site-packages\itk\support\extras.py”, line 325, in GetArrayViewFromImage  
> image\_or\_filter, “GetArrayViewFromImage”, keep\_axes, update, ttype  
> File “E:\Develop\Segmania.venv\lib\site-packages\itk\support\extras.py”, line 296, in \_GetArrayFromImage  
> raise RuntimeError(“No suitable template parameter can be found.”)  
> RuntimeError: No suitable template parameter can be found.

btw: I am using itk 5.2.0.post2, Python 3.6, Windows

---

<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: [September 9, 2021, 1:54pm UTC](https://discourse.itk.org/t/bug-in-itk-image-duplicator/4408/2 "2021-09-09T13:54:32Z")

</div>

sorry. it turned out to be a bug in my code (`translate` was calling itself recursively …)

---

<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: [September 9, 2021, 1:56pm UTC](https://discourse.itk.org/t/bug-in-itk-image-duplicator/4408/3 "2021-09-09T13:56:43Z")

</div>

I was just about to say I can’t reproduce it:

```nohighlight
C:\Users\Dzenan>python
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import itk
>>> itk. __version__'5.2.1'
>>> img = itk.imread("C:/a/cbct.nrrd")
>>> print(type(img))
<class 'itk.itkImagePython.itkImageSS3'>
>>> print(img.shape)
(433, 667, 667)
>>> img_t = itk.image_duplicator(img)
>>> print(img_t.shape)
(433, 667, 667)

```
