I load an image like
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:
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