[Insight-developers] ImageToImageFilter: dimension reduction problem

Miller, James V (CRD) millerjv@crd.ge.com
Mon, 1 Apr 2002 08:36:51 -0500


I think there are a few ways that we can handle this.

There already is a non-templated Region base class so that
may be an avenue.  Another option is to function overloading
to force a default implementation when the dimensions
match and require subclasses provided a method when the 
the dimensions do not.

I'll put together a fix.  Wilson, could you send me the 
snippet of your test program (or check in the test without
putting it in the TestDriver yest) that is causing this
error (just to save me from reinventing the wheel).



-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez@kitware.com]
Sent: Friday, March 29, 2002 5:15 PM
To: Wilson Chang
Cc: Insight Developers; Miller, James V (CRD)
Subject: Re: [Insight-developers] ImageToImageFilter: dimension
reduction problem



Hi Wilson,

The problem does not seem to be related with the
run-time behavior of the virtual functions.

What seems to happen is that regardless of how you overload
the method in your code, the code of ImageToImageFilter<TI,TO>
has to be compiled anyways and since the TInputImage
and TOutputImage that are being used are not compatible
the error will always appear at compilation time.

In fact, the streaming itself is built on the assumption
that dimension match.  (Jim, please correct me if I'm wrong here)
The only way around would be to have a RegionBase class, non
templated from which Region derives, and then do the dimension
checking at run time as opossed to compile time. The drawback
here is the we will lose the performace of inlining Region related
code and got the lower speed of virtual calls...

Another option could be to add another ImageToImageFilter
(with another name...) which just does not have methods
relying on matching dimensions between the input and
output.

This is similar to the problem we encounter when we
generalize the Transforms. Everything was fine until we
got to the Perspective transform where the dimension
of the output points do not match the dimension of the
input points.... The solution taken in that case was to
add the TransformBase (non-templated) class and
afford virtual calls each time a point is transformed.

One very short term solution for you could be to not derive
from ImageToImageFilter but from ProcessObject.....
but that may probably be only a temporary solution.


   Luis

====================================

Wilson Chang wrote:

> Hi, We have been working on a visualization project with itk and vtk 
> that requires having all of our images in 3-D or less.  Therefore, I 
> have been working on a filter that reduces the number of dimensions of 
> an image.  This filter inherits from the ImageToImageFilter class.  
> The snag that I have run into is the GenerateInputRequestedRegion 
> function in the ImageToImageFilter class:
>
>  
>
>  
>
> template<class TInputImage, class TOutputImage>
> void
> ImageToImageFilter<TInputImage,TOutputImage>
> ::GenerateInputRequestedRegion()
> {
> ...
>
>       input->SetRequestedRegion(this->GetOutput()->GetRequestedRegion());
> ...
>
>  
>
> This line of code basicly requires that the input and output image 
> have the same number of dimensions.  When I try to override this 
> GenerateInputRequestedRegion in my filter, I still get a compile error 
> saying:
>
>  
>
> cannot convert from 'const class itk::ImageRegion<2>' to 'const class 
> itk::ImageRegion<3>'
>
>  
>
> Is it possible that the superclass' definition of this function is 
> being called regardless of whether i've redefined this function?
>
>  
>
> ideas?
>
>  
>
> thanks,
>
> wilson
>