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

Karthik Krishnan Karthik.Krishnan at kitware.com
Mon Jun 20 13:15:59 EDT 2005


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
>
>  
>


More information about the Insight-users mailing list