[Insight-users] Pointer to itk image or filter of any type

Miller, James V (Research) millerjv at crd.ge.com
Mon Jun 20 13:50:12 EDT 2005


This is not possible with ITK.  All filters and images must be explictly
typed at compile time.

You can structure your program to provide an algorithm with any datatype
using a switch statement that instantiates an algorithm with the
various datatypes you want to support.

Jim


-----Original Message-----
From: insight-users-bounces+millerjv=crd.ge.com at itk.org
[mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of
Weiguang Guan
Sent: Monday, June 20, 2005 1:34 PM
To: Karthik Krishnan
Cc: insight-users at itk.org
Subject: Re: [Insight-users] Pointer to itk image or filter of any type


Thank you, but this is not what I want. I want to define a generic
itk::Image type with unknown data type, MyGenericITKImageType.  Then,
typedef itk::ImageToImageFilter <MyGenericITKImageType,
MyGenericITKImageType> MyGenericITKFilterType.

Is it possible?

Weiguang
-- 
========================================================
Weiguang Guan, Research Engineer
RHPCS, McMaster University
========================================================

On Mon, 20 Jun 2005, Karthik Krishnan wrote:

> If you don't want the datatype exposed in your specific function. You 
> could dynamic_cast to its base class, ImageBase in this case:
> 
> void ProcessAnyGenericImage( DataObject *someDataObject )
> {
>   const ImageBase< 3 > *myGenericImage = dynamic_cast< const ImageBase< 
> 3 > * >( someDataObject );
>   if( !myGenericImage ) //throw exception
> 
>   // Process myGenericImage
> }
> 
> But if you have a stand alone application, at some point you will have 
> to explicitly instantiate the class.
> 
> -karthik
> 
> Weiguang Guan wrote:
> 
> >Hi ITK users,
> >
> >I wonder if I could define a Pointer type of "generic" itk image or 
> >filter. By "generic" I mean the data type of itk image or filter is 
> >unknown, and it could be anything c++ legal type, e.g., unsigned char, 
> >short, int, float ...
> >
> >I've tried (This is something I want)
> >	typedef itk::Image GenericITKImageType;
> >	typedef typename GenericITKImageType::Pointer 
> >GenericITKImagePointer;
> >and compiler complained "invalid use of template-name ...". I just want to 
> >get rid of "<float, 3>" in typedef itk::Image<float, 3> GenericITKImageType;
> >
> >Does anyone have find a way to work this out? This is actually a c++ 
> >question, I think.
> >
> >Thanks in advance.
> >
> >Weiguang
> >
> >  
> >
> 

_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list