[Insight-developers] How to return an itk::Image correctly?

Michael Xanadu xanadu.michael at googlemail.com
Mon Oct 12 11:08:53 EDT 2009


Hi my friends,

I have a class called FilterManager which uses templates and is derivated
from ProcessObject. This class has a method getAnything() which shall return
the pointer of an itk:Image. I looked at the example "VTKImageToImageFilter"
and what they did was something like that:


    template <class TImage>
    const typename FilterManager<TImage>::ImageType *
FilterManager<TImage>::getAnything(int anyParameter) const
    {
        // any code
        return anyItkFilter->GetOutput();
    }

Now I want to call the method in this way:

    typedef itk::GremlinDetector<Short3DType> GremlinDetectorType;
    GremlinDetectorType::popUpImage(filterManager->getAnything(number));

where "popUpImage" (a static method) is declared in this way:

    template <class TImage>
    void GremlinDetector<TImage>::popUpImage(ImageType *image) //ImageType
is defined in the header as: typedef TImage ImageType;
    {
        //do anything with the image
    }


It seems that I have a problem with "const" in the method header. Of course
the compiler complains:

    error C2664: 'itk::GremlinDetector<TImage>::popUpAllImages' : cannot
convert parameter 1 from 'const itk::Image<TPixel,VImageDimension> *' to
'itk::Image<TPixel,VImageDimension> *'

But I don't know how to fix that problem. If I remove the "const"
expressions from the getAnything()-header the application crashes and I
can't make popUpImage() to a const method, because I may not change that
code. Can somebody help me please?


Regards, Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20091012/f905a9d1/attachment.htm>


More information about the Insight-developers mailing list