Enforcing image dimension

Luis Ibanez ibanez at cs.unc.edu
Tue Apr 18 13:51:55 EDT 2000


Hi,

Can be first make a short summary of how
the ImageFilter is taking shape up to here ?

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

This is what I have understood from the code
please correct me if I'm missing something.


The hierarchy of itkFilterImageToImage looks like


 itkProcessObject
        |
 itkImageSource
        |
 itkFilterImageToImage




1)  itkProcessObject   has

- an array of pointers to inputs (itkDataObjects)
- an array of pointers to output (itkDataObjects)

This class is not templated. The number of inputs
and outputs can be modified at run time. The class
will take care of memory allocation for the arrays
and will copy the previous existing pointers
(to inputs and outputs) into the new allocated array.



2)  itkImageSource

It derives from itkProcesObject. It fixes the number
of outputs to 1 in the constructor, allocates one output
Image (in fact any itkDataObject) and link it in the
array of outputs managed by itkProcesObject.

The class is templated on the type of the output image.


3)  itkFilterImageToImage

It derives from itkImageSource. It is templated on the
type of the input and output images. (so it can have input
of type "char" and output of type "float) It fixes the
number of inputs to 1 in the constructor but doesn't
allocate any image (the user of the filter is expected to
provide a pointer to an input image using SetInput() method).

In fact, even though the names of the arguments templates
are called "image", any type deriving from itkDataObject
could be used.



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


An option for enforcing the dimension could be
to partialy specialize the filter in a derived
class, something like  :

template<class TInput, class TOutput, int N>
class itkSameDimensionFilter : public
  itkFilterImageToImage<
    itkImage<TInput,N>,
    itkImage<TOutput,N> >
{

};



This let open the choice for input and output
types, and any dimension, but fixes that the
dimension of both input and output images are
the same.  Additionaly it enforces to have "itkImages"
as input and output instead of allowing any
itkDataObject (as the itkFilterImageToImage does).

A particular version of this filter could be 
implemented as

template<class TInput, class TOutput>
class itkGaussian2D : public
itkSameDimensionFilter < TInput, TOutput, 2> {

};


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

A possible implementation is in the  attached files

itkSameDimensionFilter.h
itkGaussian2D.h
main.cxx

A traits mechanism will be a more elegant way to
define the types and standarize their names.

---

One open end with this is that the methods:

SetInput  and SetOutput from itkFilterImageToImage

are still visible...
so a user can still invoke them to set something that
is not an image or an image that has not the desired
dimension.

Changing the derivation of itkFilterImageToImage
to private could solve this, but will introduce
a lot of trouble with methods from classes higher
in the hierarchy that are called by default.


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


Another option is to template the filter class
using traits corresponding to the input or the
ouput class. In this way the dimension used by
default will be the one of the image.




Luis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkSameDimensionFilter.h.gz
Type: application/x-gzip
Size: 429 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20000418/35f4289a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkGaussian2D.h.gz
Type: application/x-gzip
Size: 304 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20000418/35f4289a/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cxx.gz
Type: application/x-gzip
Size: 314 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20000418/35f4289a/attachment-0002.bin>


More information about the Insight-developers mailing list