[Insight-developers] A possible bug in neighborhood interator
or filter?
Luis Ibanez
luis . ibanez at kitware . com
Wed, 28 May 2003 13:34:20 -0400
Hi Paul,
The methods
SetSize( component, value )
SetIndex( component, value )
set only one component of the Size/Index.
In the ImageRegion() default constructor
both m_Size and m_Index are filled up with
zeros.
In your example, since you are initializing
only the second component of the size, the
first one is still zero. So, you seem to be
asking for a region of size:
size = (0,1)
0 along X
1 along Y
Most iterators will be confused with this size.
They expect to have a value of at least 1 along
each dimension.
It is actually surprising that it works with
region.SetSize( 0, 1 );
You may want to call something like
region.SetSize(0, sizeX );
region.SetSize(1, sizeY );
region.SetSize(2, sizeZ );
region.SetIndex(0, indexX );
region.SetIndex(1, indexY );
region.SetIndex(2, indexZ );
Since your image is 3D
Luis
-----------------------
Paul Yushkevich wrote:
> 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.
>