[Insight-developers] Writing filters : GenerateInputRequestedRegion() GenerateOutputInformation()

Luis Ibanez ibanez@cs.unc.edu
Mon, 19 Feb 2001 14:53:24 -0500


Hi Jim,

I totally agree,
It will be much better to keep the code
in a central place (a base class)
instead of replicating it over and over.

The basic conflict I encounter was in
itkImage.txx  (lines 147...) at  the
CopyInformation() method.

in line 153 it casts the input DataObject *
into an (Image *) of the same type of the
original image.

Which is general don't seems to be correct
as a filter can have a type of image as input
and another type of image as output.

Maybe it could be casted just as an (ImageBase *)  ?
because only its LargestPossibleRegion is taken.

--

On the other hand, my mistake is that Unary,
Binary and Ternary are not deriving from
ImageToImageFilter but from ImageSource.

I'll remove the added methods and derive these
three filters (and the RecursiveGaussians) from
ImageToImageFilter.

--

BTW this is one of the cases in which Doxygen diagrams
are much more useful that reading the code directrly

This is the diagram for ImageToImageFilter
http://public.kitware.com/Insight/Doxygen/html/class_itk__ImageToImageFilter.html

and this is the diagram for ImageSource
http://public.kitware.com/Insight/Doxygen/html/class_itk__ImageSource.html

Thanks


Luis

----------------------

"Miller, James V (CRD)" wrote:

> Our past experience has proven that it is very bad to copy code to subclasses.  The correct thing to
> do here is to rearchitect the calls in ProcessObject, Image, and ImageAdaptor so that they do they
> right thing.  I don't have a solution off the top of my head but one thing that may pan out is to add
> another try/catch block to the Image::CopyInformation that tries to cast the input parameter to some
> sort of ImageAdaptor.  The ImageAdaptor::CopyInformation routine would also have to have two
> try/catch blocks as well.
>
> The key is to handle these various cases up in Image, ImageAdaptor, and ProcessObject rather than
> having the same code strewn through all the filters. This may necessitate moving some of the code
> from ProcessObject down into ImageSource or ImageToImageFilter.
>
> So please hold off on adding these methods to all your filters.
>
> Jim
>