[Insight-users] passing itkImage to a function ...C++ template problem

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 14 17:30:34 EDT 2004



Hi Lagaffe,


Your class BasicTransformation seems to be ok,
however, you have to manage it as a templated class.

That is, it must be in a .txx file and it will only
get instantiated when you define the actual types.


Your code will be much simpler is you just create
BasicTransformation as a templated class, and use
the ImageType as the template parameter.

Something like



     template<class TImage>
     class BasicTransformation
       {
       public:
          void myFunction(const * TImage);
       };




You are *strongly* encouraged to look at the Tutorial
sessions:

      http://www.itk.org/HTML/Tutorials.htm

in particular to

http://www.itk.org/CourseWare/Training/GettingStarted-V.pdf

where the integration of ITK classes inside non-ITK
applications is discussed in detail.


Please let us know if you have further questions,


    Thanks


      Luis



----------------
Mr Gaffe wrote:

> Hello,
> I a new to itk and I try to create my own class which can do some basic 
> itk transformation with templated itk object, and I failed, I really 
> don't know how to do this.
>  
> In my .h declaration I did:
> 
> class BasicTransformation
> 
> {
> 
> public:
> 
> template<typename TPixel, typename VImageDimension> void 
> myFunction(itk::Image<TPixel, VImageDimension> imageData);
> 
> }
> 
> -> it doesn't compile, because I have to define all the template values 
> ? (so I don't understand how to use the template, since I had to specify 
> so early, my function have to work with different itkImage type ...).
> 
> If I specify the type it compile but it is not very interresting...
> 
> template<typename TPixel, typename VImageDimension> void 
> myFunction(itk::Image<unsigned short, 3> imageData);
> 
> -> What is very weard is that if I use an ImageSource, it compiles 
> without specify the type of ImageSource .... (at this time started to 
> begin mad :-)
> 
> template<typename TOutputImage> void 
> volumeRendering(itk::ImageSource<TOutputImage> imageSource);
> 
> So,
> 
> -> 1 - can someone could explain to me how to pass a itk object to a 
> function in another class, please .
> 
> ->2 - In my processing class is it better to have an itkImage to begin 
> the process or an ImageSource ?
> 
> 
> Thanks for help
> 
> Lagaffe
> 
> 
> _______________________________________________
> 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