[Insight-developers] Adding Consistency check to itk::BinaryFunctorImageFilter : Design Question

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 2 15:12:27 EST 2009


The Bug 9893:

            http://www.itk.org/Bug/view.php?id=9893

calls for adding a check of consistency between the two input
images of filters that derive from itkBinaryFunctorImageFilter.

The example, is the AddImageFilter, in which we implicitly
assume that the two images passed as input have:

    1) The same number of pixels along each dimension
    2) The same origin
    3) The same spacing
    4) The same direction


Currently there is no check for these assumption,
and therefore, a user can pass two images of different
sizes, and get a segmentation fault at run time.

---

The proposed fix is to add the following methods:

>   /** These method verify if the two input images have the same
>    *  size, origin, spacing and orientation. It is intended to be
>    *  called from some derived filters, when they require the two
>    *  inputs to be consistent. The method throws and exception if
>    *  the two input images are not consistent. */
>   void CheckInputImagesConsistency();
>   void CheckInputImagesConsistencyInSize();
>   void CheckInputImagesConsistencyInOrigin();
>   void CheckInputImagesConsistencyInSpacing();
>   void CheckInputImagesConsistencyInDirection();


to the protected section of the itkBinaryFunctorImageFilter.


Then, most of its derived classes will call the method:

            CheckInputImagesConsistency()


(which internally will call all the other methods, each one
of which could throw an exception if the consistency check
fails).


Particular filters that do not require all checks, could call
only those that apply.

The suggested place to make these calls is the method

                 BeforeThreadedGenerateData();


---

An alternative approach is to set these calls in the
itkBinaryFunctorImageFilter, and add a boolean that
sets whether the check should be performed or not.

Derived filters could then set that boolean in their
constructors.

----


Any preferences between the two approaches above ?

Any objections ?

or Backward Compatibility concerns ?


     Thanks


          Luis


More information about the Insight-developers mailing list