[Insight-developers] Writing filters : GenerateInputRequested Region() GenerateOutputInformation()

Miller, James V (CRD) millerjv@crd.ge.com
Mon, 19 Feb 2001 08:17:42 -0500


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

-----Original Message-----
From: Luis Ibanez [mailto:ibanez@cs.unc.edu]
Sent: Sunday, February 18, 2001 10:06 PM
To: Insight toolkit
Subject: [Insight-developers] Writing filters :
GenerateInputRequestedRegion() GenerateOutputInformation()



Hi,

For those of us writing filters, it 
is important to note that methods:

GenerateOutputInformation() I

and

GenerateInputRequestedRegion() 

should in general be overloaded.


The default version of them existing in itkProcessObject 
implicitly assumes that inputs and outputs are images,
and that doesn't support ImageAdaptors.

For example:

ProcessObject::GenerateOutputInformation() 

will call CopyInputInformation() in an output.
if the output is an itkImage, the CopyInputInformation()
implicitly assumes thate the input is also an image
of the SAME type. That causes an erroneous down casting
and a subsequent seg fault if the input object is not
really an image.

itkUnaryImageFilter
itkBinaryImageFilter
itkTernaryImageFilter

have been updated to provide these two additional methods.



Luis





_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers