[Insight-users] Can't cast RescaleIntensityImageFilter to ImageToImageFilter ?

Luis Ibanez luis.ibanez at kitware.com
Sat Jun 20 20:48:04 EDT 2009


Hi Motes,

1) Please post the declaration of the function

           compare.getIntensityRescaler();

2)  You may want to try returning a raw pointer
      from the function instead of a SmartPointer
    unless the Filter is  being created in that function
    and it is not a member variable.


3) Just out of curiosity,.....
     why are you returning a filter from a function ?

     It doesn't seem to be a common use case.


    Regards,


          Luis



---------------------------------
On Sat, Jun 20, 2009 at 8:38 PM, motes motes <mort.motes at gmail.com> wrote:

> I am trying to cast a RescaleIntensityImageFilter to an ImageToImageFilter:
>
>     static const unsigned int Dimension = 2;
>     typedef float PixelType;
>     typedef itk::Image< PixelType, Dimension >
>                                                     FixedImageType;
>     typedef itk::Image< PixelType, Dimension >
>                                                     MovingImageType;
>     typedef unsigned char
>
> OutputPixelType;
>     typedef itk::Image< OutputPixelType, Dimension >
>                                             OutputImageType;
>     typedef itk::ImageToImageFilter<MovingImageType, FixedImageType>
>                           ImageToImageFilterType;
>     typedef itk::RescaleIntensityImageFilter<FixedImageType,
> OutputImageType >                RescalerType;
>
>     RescalerType::Pointer pp0 = compare.getIntensityRescaler();
>     ImageToImageFilterType::Pointer pp1 =
> static_cast<ImageToImageFilterType::Pointer>(pp0);
>
> where the function 'comare.getIntensityRescaler()' returns a
> RescalerType::Pointer. But the line:
>
>     ImageToImageFilterType::Pointer pp1 =
> static_cast<ImageToImageFilterType::Pointer>(pp0);
>
> gives the error:
>
> cannot convert from 'itk::SmartPointer<TObjectType>' to
> 'itk::SmartPointer<TObjectType>'
>
> But as I understand ImageToImageFilter is a base class for
> RescaleIntensityImageFilter so I don't see why I get this error, but maybe
> my C++ skills are a bit rusty.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090620/6d266e10/attachment-0001.htm>


More information about the Insight-users mailing list