[Insight-users] RequestedRegion (ImageToImageFilter)

Torsten Schröer torsten.schroeer at igd.fraunhofer.de
Wed May 25 04:42:13 EDT 2005


Hello ITK friends,

I subclassed ImageToImageFilter to write an region growing based filter. 
Now I try to limit the region growing to a defined portion of the input 
image. I recognized the DataObjects SetRequestedRegion method as well as 
EnlargeOutputRequestedRegion, GenerateOutputRequestedRegion and 
GenerateInputRequestedRegion. But I don't understand how this works.

Examlpe:
// --- EXAMPLE BEGIN ---
// READING THE INPUT IMAGE:
   typedef unsigned short InputPixelType;
   typedef itk::Image< InputPixelType, 2 > InputImageType;
   typedef itk::ImageFileReader< InputImageType > ReaderType;

   ReaderType::Pointer reader = ReaderType::New();
   reader->SetFileName( av[1] );

   try {
     reader->Update();
   } catch (itk::ExceptionObject & e) {
     std::cerr << "exception in file reader " << std::endl;
     std::cerr << e.GetDescription() << std::endl;
     std::cerr << e.GetLocation() << std::endl;
     return EXIT_FAILURE;
   }

// PROCESSING THE IMAGE:
   InputImageType::Pointer image = reader->GetOutput();

// REQUESTED REGION:
   typedef InputImageType::IndexType IndexType;
   typedef InputImageType::SizeType SizeType;
   typedef InputImageType::RegionType RegionType;
   RegionType region;
   SizeType size;
   IndexType origin;

   origin[0] = 25;
   origin[1] = 25;
   size[0]   = 50;
   size[1]   = 50;

   image->SetRequestedRegion( region );
   image->PropagateRequestedRegion();

   typedef unsigned char OutputPixelType;
   typedef itk::Image< OutputPixelType, 2 > OutputImageType;
   typedef itk::MyRegionGrowingFilter< InputImageType, OutputImageType > 
MyRegionGrowingFilterType;
   MyRegionGrowingFilterType::Pointer filterRG = 
RegionGrowingHojjaFilterType::New();

   filterRG->SetInput( image );
   filterRG->Update( );

// SOME VISUALIZATION CODE (VTK)
...
// --- EXAMPLE END ---

Now, at the filters GenerateData method, I try to evaluate the 
RequestedRegionsSize:

typename Superclass::InputImageConstPointer inputImage  = this->GetInput();
SizeType size = inputImage->GetRequestedRegion().GetSize();

Determiated size at this point is always the entire image size and not 
the portion of the image set by SetRequestedRegion().

Any Ideas appreciated!

BTW: Is there a generic technique setting up specialized Neighborhoods 
(N4, N8 in 2D-data and N6, N18, N26 in 3D-data and so on)? 
RadiusType.Fill(1) always uses the entire Neighborhood (N8, N26 ...) and 
OffsetType is specific to image's dimension, which is bad for a generic 
filter programming. I need something like generic cross neighborhood.

Thanks a lot,
Torsten.



More information about the Insight-users mailing list