[Insight-developers] A possible bug in neighborhood interator or filter?

Paul Yushkevich pauly at cognitica . com
Wed, 28 May 2003 11:36:04 -0400


The following code throws an exception in line 36 of 
itkZeroFluxNeumannBoundaryCondition.txx when filter->Update() is called.

#include "itkImageFileReader.h"
#include "itkImage.h"
#include "itkDiscreteGaussianImageFilter.h"

using namespace itk;

void main(int argc, char *argv[])
{

  // Typedefs
  typedef Image<float,3> ImageType;
  typedef ImageFileReader<ImageType> ReaderType;
  typedef DiscreteGaussianImageFilter<ImageType,ImageType> FilterType;

  // Load image
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName("MRIcrop-orig.gipl");
  reader->Update();
  ImageType::Pointer image = reader->GetOutput();

  // Create a requested region
  ImageRegion<3> region = image->GetLargestPossibleRegion();
  region.SetIndex(1,55);
  region.SetSize(1,1);

  // Create filter
  FilterType::Pointer filter = FilterType::New();
  filter->SetVariance(1.0f);
  filter->SetInput(image);
  filter->GetOutput()->SetRequestedRegion(region);
  filter->Update();
}

I didn't attach the image because it's a bit large for posting to the 
list.  However, it is of sufficient size (78x110x64). It seems that the 
neighborhood iterator jumps outside of bounds, causing the exception.  
The funny thing is that it works with

  region.SetIndex(0,55);
  region.SetSize(0,1);

but not with

  region.SetIndex(2,55);
  region.SetSize(2,1);

Paul.

-- 
--------------------------------
Paul A. Yushkevich, Ph.D.
President, Cognitica Corporation

17 Flemington Rd
Chapel Hill, NC 27517
Tel: 1-919-929-7652
--------------------------------