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

Kalle Pahajoki kalpaha at st.jyu.fi
Tue Apr 18 10:39:44 EDT 2006


Gaetan Lehmann wrote:
>
> 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.
Oh course, how stupid of me!
>
> you can convert the image from vtktoitk with a CastImageFilter:
>
> cast = itk.CastImageFilter.IUC3IUF3.New(vtktoitk)
> diff.SetInput(cast.GetOutput())
I did use the vtkImageCast to give me floats, but used the wrong type of 
vtkImageToImage-filter.
>
> 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 :-)
Ok. Although I do that a lot, to try to cut down on the load time, i.e. 
import ITKBasicAlgorithmsA (or somethng like that) and then use 
ITKBasicAlgorithmsA.something instead of itk.something. If they all add 
the classes to the itk module, then it would indeed be cleaner to use that.

>
> 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()
Thanks for the pointer. I'm only just trying to get very basic stuff 
working  and I generally learn by trying stuff in the interpreter and 
just sticked with what works :-)

Thank you for the quick and  veyr useful answers!

Kalle



-- 
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition not smart enough to debug it.        -- Brian W. Kerninghan



More information about the Insight-users mailing list