[Insight-developers] inputs/outputs to basic image processing filters

Joshua Cates cates@sci.utah.edu
Wed, 11 Dec 2002 11:32:03 -0700 (MST)


Folks,

I am reworking some of the basic image processing filters to reduce 
confusion about acceptable input/output types.  New users tend to have 
trouble with this issue right now.

There are several ways to accomplish this and I want to get feedback as to
what the preferred way would be.  Also any ideas for other ways.


1) Cast the input and output images to match the type specified in the
template parameters.  Supply a third, optional parameter which indicates
the real-valued type to use in calculations (i.e. floats or doubles),
default type would be float.

Advantages: Easy to implement.  Can be set up to only cast if needed.  
Won't break existing applications.  Extra copies of data associated with
casting only sit around during filter execution (they are not cached in
the pipeline).

Disadvantages: Casting must be done each time the filter updates. (time
penalty).  Naive users may still get into trouble by constructing
casting nightmares such as:  Reader<uchar>->Diffusion<uchar,
uchar>->Gradient<uchar, vector<uchar>>, etc.


2) The input type becomes the only input parameter.  Cast from this input
image type to a real-valued type for processing.  Output is forced via
creative templating to always be a floating point image. See the
LevelSetSegmentation filters, for example.

Advantages: No data can be accidently cast away in the output image.
Reduces the number of template parameters seen by the user.

Disadvantages: Will break existing applications.


3) Enforce real-valued input and output types through itkConceptChecking.  
Default output type could be the input type, reducing required template
arguments to one.

Advantages: Enforces correct use of filters at compile time.  No ambiguity
or casting issues.  Will break existing applications not using the code
correctly.  Easiest to implement.

Disadvantages: Requires user to cast to correct type in the pipeline. This 
cached copy of the data persists in the pipeline.


I like options 3 and 1, in that order.  Any more opinions or ideas?

Thanks,

Josh.



______________________________
 Josh Cates			
 School of Computer Science	
 University of Utah
 Email: cates@sci.utah.edu
 Phone: (801) 587-7697
 URL:   www.cs.utk.edu/~cates