[ITK-users] Setting tolerance is ignored

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Wed Sep 21 09:00:29 EDT 2016


Hello,

This is behaving as designed.

The “GlobalDefaultCoordinateTolerance” is the default value used when objects are constructed. Use case would be::

typedef itk::MaskImageFilter< ImageType, ImageType > FilterType;
FilterType::SetGlobalDefaultCoordinateTolerance(0.001);
FilterType::Pointer filter = FilterType::New();

This would set the default tolerance for ALL new ImageFilters.

What you may want to do is use SetCoordinateTolerance() on your constructed filter to set the value for just that one filter.

HTH,
Brad

> On Sep 21, 2016, at 5:05 AM, Chr. Rossmanith <cr at neuro.ma.uni-heidelberg.de> wrote:
> 
> Hi,
> 
> I have two images with slightly differing image origins:
> 
> InputImage Origin: [-7.9896713e+01, -7.0397179e+01, 0.0000000e+00]
> InputImage_1 Origin: [-7.9896706e+01, -7.0397186e+01, 0.0000000e+00]
> 
> which are used as input for MaskImageFilter. Processing fails with the error "Inputs do not occupy the same physical space!" and tolerance being reported as 4.6875000e-07 even if I set it to 0.001 by filter->SetGlobalDefaultCoordinateTolerance( 0.001 ).
> 
> If itkImageToImageFilter would call GetGlobalDefaultCoordinateTolerance() instead of using this->m_CoordinateTolerance in VerifyInputInformation() the user defined tolerance is used.
> 
> Is this a bug or is the current behaviour intended?
> 
> Regards,
> Christina Rossmanith
> --
> Dept. of Neurology
> University Medicine Mannheim
> University of Heidelberg
> 
> 
> --------------------------------------------- Code ----------------------------------------------------------------------------
> 
> #include "itkImageFileReader.h"
> #include "itkMaskImageFilter.h"
> 
> int main (int argc, char *argv[])
> {
>  const unsigned int Dimension = 3;
>  typedef short PixelType;
>  typedef itk::Image< PixelType, Dimension > ImageType;
> 
>  typedef itk::ImageFileReader< ImageType > ReaderType;
>  ReaderType::Pointer reader = ReaderType::New();
>  reader->SetFileName( argv[1] );
>  reader->Update();
>  ReaderType::Pointer mask = ReaderType::New();
>  mask->SetFileName( argv[2] );
>  mask->Update();
> 
>  typedef itk::MaskImageFilter< ImageType, ImageType > FilterType;
>  FilterType::Pointer filter = FilterType::New();
>  filter->SetGlobalDefaultCoordinateTolerance( 0.001 );
>  filter->SetInput1( reader->GetOutput() );
>  filter->SetInput2( mask->GetOutput() );
> 
>  try
>    {
>      filter->Update();
>    }
>  catch ( itk::ExceptionObject & e )
>    {
>      std::cout << "MaskImageFilter failed: " << e << std::endl;
>      return EXIT_FAILURE;
>    }
> 
>  return EXIT_SUCCESS;
> }
> 
> _____________________________________
> 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://www.kitware.com/products/protraining.php
> 
> 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://public.kitware.com/mailman/listinfo/insight-users



More information about the Insight-users mailing list