[Insight-users] WrapITK python bindings and GradientAnisotropicDiffusion with 3D float input

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Tue Apr 18 08:58:01 EDT 2006


Hi Kalle,

The type you are using is not the right one: vtktoitk will give you an  
image with unsigned char pixel, while diff requires an image with float  
pixel.

you can convert the image from vtktoitk with a CastImageFilter:

cast = itk.CastImageFilter.IUC3IUF3.New(vtktoitk)
diff.SetInput(cast.GetOutput())

or you can convert your vtk image directly to an image with float pixel  
type:

vtktoitk=ItkVtkGlue.VTKImageToImageFilter.IUF3.New()

Gaetan


PS: Note that you should import itkvtk rather than ItkVtkGlue: it add the  
VTKImageToImageFilter and ImageToVTKImageFilter in the itk module, so it's  
more simple to use :-)

vtktoitk=itk.VTKImageToImageFilter[itk.Image.UC3].New()

instead of

vtktoitk=ItkVtkGlue.VTKImageToImageFilter[itk.Image.UC3].New()

PS2: Your usage of itk types is quite strange: we generally use the dict  
notation or the short name notation, but not both at the same time:

dim = 3
PixelType = itk.UC
ImageType = itk.Image[PixelType, dim]
vtktoitk=itk.VTKImageToImageFilter[ImageType].New()

or

vtktoitk=itk.VTKImageToImageFilter.IUC3.New()

The first one will let you define only in one place the image type for a  
pipeline, but is longer than the second one.
The second one is shorter, but less flexible, and thus more adapted for  
prototyping in interperter



On Tue, 18 Apr 2006 14:35:16 +0200, Kalle Pahajoki <kalpaha at st.jyu.fi>  
wrote:

> Hi
>
> I'm using the WrapITK python bindings for ITK and am currently trying to
> do very basic Watershed segmentation.
>
> My setup is part of a larger program so I've distilled the problem to a
> simple script (attached), but basically I'm reading 3D data on VTK side,
> then switching it over to ITK for watershed segmentation.
>
> The error message I get is:
>
> Traceback (most recent call last):
>   File "test_itk.py", line 24, in ?
>     diff.SetInput(vtktoitk.GetOutput())
>   File
> "/usr/local/Python-SWIG/itkGradientAnisotropicDiffusionImageFilter.py",
> line 334, in SetInput
>     def SetInput(*args): return
> _itkGradientAnisotropicDiffusionImageFilter.itkGradientAnisotropicDiffusionImageFilterIF3IF3_Pointer_SetInput(*args)
> TypeError: No matching function for overloaded
> 'itkGradientAnisotropicDiffusionImageFilterIF3IF3_Pointer_SetInput'
>
> Here's what I'm wrapping:
>
> WRAP_ITK_DIMS:STRING=2;3
> WRAP_ITK_JAVA:BOOL=OFF
> WRAP_ITK_PYTHON:BOOL=ON
> WRAP_ITK_TCL:BOOL=OFF
> WRAP_covariant_vector_double:BOOL=OFF
> WRAP_covariant_vector_float:BOOL=ON
> WRAP_double:BOOL=OFF
> WRAP_float:BOOL=ON
> WRAP_rgb_unsigned_char:BOOL=ON
> WRAP_rgb_unsigned_short:BOOL=OFF
> WRAP_signed_char:BOOL=OFF
> WRAP_signed_long:BOOL=OFF
> WRAP_signed_short:BOOL=OFF
> WRAP_unsigned_char:BOOL=ON
> WRAP_unsigned_long:BOOL=OFF
> WRAP_unsigned_short:BOOL=ON
> WRAP_vector_double:BOOL=OFF
> WRAP_vector_float:BOOL=ON
> WRAP_rgb_unsigned_short-MODIFIED:INTERNAL=1
> WRAP_unsigned_short-MODIFIED:INTERNAL=1
>
> Any suggestions?
>
> Kalle
>



-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr


More information about the Insight-users mailing list