[Insight-users] runtime error in itk::ConstNeighborhoodIterator
Miller, James V (Research)
millerjv at crd.ge.com
Thu Mar 31 09:18:18 EST 2005
Aaron,
The ExtractImageFilter needs to be Update()'d before you can walk its output with an interator.
Jim
-----Original Message-----
From: insight-users-bounces at itk.org on behalf of Aaron Skewes
Sent: Wed 3/30/2005 2:48 PM
To: insight-users at itk.org
Cc:
Subject: [Insight-users] runtime error in itk::ConstNeighborhoodIterator
Dear Sirs,
I am attempting to extract a slice normal to the z-axis from a 3d image, and create a ConstNeighborhoodIterator with a scaleable radius to perform some calculations. When the code executes the conditions in the for loop (boundaries of the neighborhood) I receive a runtime error. Any ideas why this may occur?
typedef float FilterPixelType;
typedef float ItPixelType;
// Define the image type, dimensions
typedef itk::Image< FilterPixelType, DIMENSION > FilterImageType;
typedef itk::Image< ItPixelType, 2 > ItImageType;
typedef itk::ImageFileReader< FilterImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( inputFileName );
reader->SetFileName(inputFileName );
try
{
reader->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Problem reading the input file" << std::endl;
std::cerr << excp << std::endl;
return -1;
}
//!Extract a slice from the image
typedef itk::ExtractImageFilter< FilterImageType, ItImageType > ExtractFilterType;
ExtractFilterType::Pointer extractfilter = ExtractFilterType::New();
FilterImageType::RegionType inputRegion = reader->GetOutput()->GetLargestPossibleRegion();
FilterImageType::SizeType size = inputRegion.GetSize();
size[2] = 0;
FilterImageType::IndexType start = inputRegion.GetIndex();
start[2] = 0;
FilterImageType::RegionType desiredRegion;
desiredRegion.SetIndex( start );
desiredRegion.SetSize( size );
extractfilter->SetExtractionRegion( desiredRegion );
extractfilter->SetInput( reader->GetOutput() );
//set-up an iterator to preform convolution
typedef itk::ConstNeighborhoodIterator< ItImageType > NeighborhoodIteratorType;
NeighborhoodIteratorType::RadiusType radius;
for (float sigma=sigmaMin; sigma<sigmaMax; sigma+=step_size)
{
//set scalable filter width
radius.Fill(sigma);
NeighborhoodIteratorType it( radius, extractfilter->GetOutput(), extractfilter->GetOutput()->GetRequestedRegion());
for (it.GoToBegin(); !it.IsAtEnd(); ++it) !!!!!!!!!!!!!!!! RUNTINE ERROR HERE
{
DO SOMETHING
}
}
Thanks,
Aaron
More information about the Insight-users
mailing list