[Insight-developers] Adding Consistency check to itk::BinaryFunctorImageFilter : Design Question
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Wed Dec 2 16:08:53 EST 2009
Hi Luis,
I personally prefer your first approach. Don't you think that
CheckInputImagesConsistency() should be in
BeforeThreadedGenerateData() in BinaryFunctorImageFilter directly,
instead of its subclasses? The tests may be desactivated in the
subclasses if needed, by reimplementing BeforeThreadedGenerateData().
Also, this bug must also be in many other classes which are processing
several inputs - maybe those methods should be added in a more basic
class, so they can be reused in those filters as well?
Gaëtan
Le 2 déc. 09 à 21:12, Luis Ibanez a écrit :
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr http://www.itk.org
http://www.mandriva.org http://www.bepo.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20091202/601ed436/attachment.pgp>
More information about the Insight-developers
mailing list