[Insight-users] How to get & set the dimension of an itk::image dynamically?

Luis Ibanez luis.ibanez at kitware.com
Wed Sep 9 11:05:20 EDT 2009


Hi Michael,

You can't use the call to GetDimension() from an image
to set the dimension of another image.

This is because GetDimension() will act at run-time, while
you need something that will make the dimension available
at compilation time.


What you need is code of the sort:

*template <class TImage>
void MyClass<TImage>::writeImage(ImageType *image)
{
    typedef itk::Image<unsigned char, TImage::ImageDimension>
OutputImageType;*
}


and in some primitive compilers
like Visual Studio 6.0 and Borland 5.5,
you may have to do:

*
template <class TImage>
void MyClass<TImage>::writeImage(ImageType *image)
{*
*typedef itk::Image<unsigned char, *
:itk::GetImageDimension< TImage >::ImageDimension
*> OutputImageType;*
}


    Regards,


           Luis


------------------------------------------------------------
On Mon, Sep 7, 2009 at 4:17 AM, Michael Xanadu <
xanadu.michael at googlemail.com> wrote:

> Sorry, the error message in the mail I posted before is wrong. The compiler
> really says:
>
> error C2971: 'itk::Image' : template parameter 'VImageDimension' :
> 'dimension' : a local variable cannot be used as a non-type argument
>
>
> Regards, michael
>
>
> _____________________________________
> 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/20090909/2d52a3df/attachment.htm>


More information about the Insight-users mailing list