[Insight-users] runtime error in itk::ConstNeighborhoodIterator

Aaron Skewes adskewes at bioinfo.uh.edu
Wed Mar 30 14:48:35 EST 2005


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050330/4377dfc3/attachment.htm


More information about the Insight-users mailing list