I'm trying to run the following example as part of the SimpleElastix library:
import SimpleITK as sitk
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(sitk.ReadImage('1.jpg', sitk.sitkFloat32))
elastixImageFilter.SetMovingImage(sitk.ReadImage('2.jpg', sitk.sitkFloat32))
elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap('rigid'))
elastixImageFilter.Execute()
sitk.WriteImage(elastixImageFilter.GetResultImage())
When I try to run the above code, I get the following error (I'm showing part of the output):
Traceback (most recent call last):
File "rigid_transform.py", line 8, in <module>
sitk.WriteImage(elastixImageFilter.GetResultImage())
File "/usr/local/lib/python2.7/dist-packages/SimpleElastix-1.0.1rc1.dev331+gd756f-py2.7-linux-x86_64.egg/SimpleITK/SimpleITK.py", line 8015, in WriteImage
return _SimpleITK.WriteImage(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'WriteImage'.
Possible C/C++ prototypes are:
itk::simple::WriteImage(itk::simple::Image const &,std::string const &,bool)
itk::simple::WriteImage(itk::simple::Image const &,std::vector< std::string,std::allocator< std::string > > const &,bool)
How can I solve this issue?
EDIT: As per @Dženan's answer, I got the following:
Traceback (most recent call last):
File "rigid_transform.py", line 8, in <module>
sitk.WriteImage(elastixImageFilter.GetResultImage(), 'result.jpg')
File "/usr/local/lib/python2.7/dist-packages/SimpleElastix-1.0.1rc1.dev331+gd756f-py2.7-linux-x86_64.egg/SimpleITK/SimpleITK.py", line 8015, in WriteImage
return _SimpleITK.WriteImage(*args)
RuntimeError: Exception thrown in SimpleITK WriteImage: /home/me/Desktop/SimpleElastix/build/ITK/Modules/IO/JPEG/src/itkJPEGImageIO.cxx:454:
itk::ERROR: JPEGImageIO(0x1a5daa0): JPEG supports unsigned char/int only
Thanks.
You are missing a file name. Try this:
sitk.WriteImage(elastixImageFilter.GetResultImage(), 'result.jpg')
Edit: you can try other file extensions: result.png
, result.tif
, result.nrrd
, result.mha
etc.