[Insight-users] Use of itk image in a function and return processed image

Melanie Uks meluks2010 at googlemail.com
Tue Feb 7 05:50:29 EST 2012


Hi,
I try to use a extract an image slice of a 3D dataset in a function in c++.
I read this site<http://www.itk.org/pipermail/insight-users/2004-November/011095.html>where
Luis describes how to use an image in a function but I was not able
to write my function...
I define the 3D dataset in the main program and want to extract the slice
in a function and return this slice somehow back to the main program.
At the moment my code looks like

*main program:*
    ....
    typedef itk::Image<PixelType, 2> OutputImageType;
    OutputImageType::Pointer outimage;
    void * pimg = &outimage;
    extractSlice(pimg, dim);**
     .....


*void extractSlice(void * pimg, int dim)*

    typedef itk::Image<PixelType, 2> OutputImageType;
    typedef itk::ExtractImageFilter<ImageType, OutputImageType>
ExtractFilterType;
    ExtractFilterType::Pointer extractFilter = ExtractFilterType::New();

    ...

    OutputImageType::Pointer outimage = OutputImageType::New();

    try
    {
        extractFilter->Update();
        outimage = extractFilter->GetOutput();
        ImageType::Pointer *kimg = (ImageType::Pointer *)pimg;
       * kimg = outimage.GetPointer();* * //NOT WORKING*
    }
    catch(itk::ExceptionObject &err)
    {
       ...
    }

Does one of you know how to solve my problem?
Thanks a lot for your help!

Best regards
melanie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120207/e01425a2/attachment.htm>


More information about the Insight-users mailing list