[ITK-users] Fwd: SimpleITK FFTConvolution

Gaetan Lehmann gaetan.lehmann at gmail.com
Wed Apr 8 09:45:11 EDT 2015


Sorry, forgot to keep the list in copy.

Gaëtan



2015-04-02 15:54 GMT+02:00 Bradley Lowekamp <blowekamp at mail.nih.gov>:

> Gaetan,
>
> Nice to see you taking SimpleITK for a spin :)
>
> You need to inspect the input image types a little. It's reading them an
> RGB images into a VectorImage type. Implicit types can be a pain.
>
> You can utilize the second argument of the ReadImage method to specify the
> desired pixel type, say "sitk.sitkFloat32".
>

Thanks, it works a lot better that way :-)


>
> Brad
>
> BTW,
> I have been wanting to pick you brain about way to make the LabelMaps more
> extendible. I did some classes [1] where the parents was a template
> argument, so that you could compose different label map objects, and
> similarly filters. The usage got a little complicated though[2].
>
> [1] https://github.com/blowekamp/itkOBBLabelMap/tree/master/include
> [2]
> https://github.com/blowekamp/itkOBBLabelMap/blob/master/test/itkOrientedBoundingBoxImageLabelMapFilterTest1.cxx#L42
>
>

I think your approach is quite good actually. I'm not sure it can be
simpler with a static implementation.

The the label type and image dimension in the type declaration repetition
could be avoided - they could be taken from the superclass passed in
parameter, but then it wouldn't be possible to provide a default superclass.

  typedef itk::OrientedBoundingBoxLabelObject< LabelPixelType,
ImageDimension > OBBLabelObjectType;
  typedef itk::AttributeImageLabelObject< LabelPixelType,
ImageDimension, ImageType, OBBLabelObjectType > LabelObjectType;

would be

   typedef itk::AttributeImageLabelObject<ImageType,
    itk::OrientedBoundingBoxLabelObject<
      itk::ShapeLabelObject<LabelPixelType, ImageDimension > > >
LabelObjectType;

Not sure that's any better.

My main concern is that it would be quite hard to wrap.

I thought about something to add attributes but at runtime — that would be
a lot easier to wrap — using a mechanism similar to what is done in the
metadata dictionary.
I've never completed the implementation, mainly because of the negative
comments I've heard on the metadata dictionary implementation.
This would also have some API and performance impact because the attribute
must be retrieved with a string and the value casted to its actual type.

  ImageType* img = lo->GetAttribute< ImageType* >("FeatureImage);

instead of

  ImageType * img = lo->GetFeatureImage();

Gaëtan



>
> On Apr 2, 2015, at 9:47 AM, Gaetan Lehmann <gaetan.lehmann at gmail.com>
> wrote:
>
> > Hi Brad,
> >
> > I'm trying to use SimpleITK's FFTConvolution from python:
> >
> >   import SimpleITK as sitk
> >   img = sitk.ReadImage("/tmp/cthead1.png")
> >   kernel = sitk.ReadImage("/tmp/kernel2.png")
> >   conv = sitk.FFTConvolution(img, kernel)
> >
> > the last line fails with the error:
> >
> > Traceback (most recent call last):
> >   File "/tmp/test.py", line 5, in <module>
> >     conv = sitk.FFTConvolution(img, kernel)
> >   File
> "/Users/glehmann/Library/Python/2.7/lib/python/site-packages/SimpleITK/SimpleITK.py",
> line 17771, in FFTConvolution
> >     return _SimpleITK.FFTConvolution(*args, **kwargs)
> > RuntimeError: Exception thrown in SimpleITK FFTConvolution:
> /scratch/dashboards/SimpleITK-OSX10.7-intel-pkg/SimpleITK/Code/Common/include/sitkMemberFunctionFactory.hxx:193:
> > sitk::ERROR: Pixel type: vector of 8-bit unsigned integer is not
> supported in 2D byN3itk6simple25FFTConvolutionImageFilterE
> >
> > I get the same error when building from source and when installing
> SimpleITK with
> >
> >   pip install --user SimpleITK
> >
> > This is on a mac running yosemite.
> >
> > Would you have an idea of what is wrong?
> >
> > Thanks,
> >
> > Gaëtan
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150408/b2f25ed3/attachment.html>


More information about the Insight-users mailing list