[Insight-developers] ImageToImageFilter: dimension reductionp
roblem
Miller, James V (CRD)
millerjv@crd.ge.com
Thu, 4 Apr 2002 16:23:13 -0500
Yes it is doable. I am just deciding on an API. I don't want
to create too many methods that a filter writer HAS to override.
One stopgap is to add a method to ImageBase
virtual void SetRequestedRegion(const Region &) {};
Note the parameter is a Region not an ImageRegion or a RegionType.
Adding this method allows ImageToImageFilter::GenerateInputRequestedRegion()
to compile (although it would do nothing for the case where the input region
and output regions were different dimensions).
Then ExtractImageFilter can modify the regions appropriately in its
GenerateInputRequestedRegion() to take into account the reduction in dimension.
Long term, however, I do not want to have the dummy SetRequestedRegion()
method. I am looking at having ImageToImageFilter::GenerateInputRequestedRegion()
call one of two methods depending on whether the dimensions of the input and
output match or not.
-----Original Message-----
From: Wilson Chang [mailto:wmcst6+@pitt.edu]
Sent: Thursday, April 04, 2002 4:21 PM
To: Miller, James V (CRD)
Subject: Re: [Insight-developers] ImageToImageFilter: dimension
reductionproblem
Does it look like a fix to the base classes will be doable? If it isnt, I
could do what luis was suggesting by having the dimension reduction filter
inherit from process object.
thanks,
wilson
----- Original Message -----
From: "Miller, James V (CRD)" <millerjv@crd.ge.com>
To: "'Luis Ibanez'" <luis.ibanez@kitware.com>; "Wilson Chang"
<wmcst6@pitt.edu>
Cc: "Insight Developers" <Insight-developers@public.kitware.com>
Sent: Monday, April 01, 2002 8:36 AM
Subject: RE: [Insight-developers] ImageToImageFilter: dimension
reductionproblem
> 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
> >
>
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>