[Insight-developers] Flood iterator ++ method

Damion Shelton dmsst59+@pitt.edu
Tue, 05 Jun 2001 18:07:41 -0400


Ok...

Jim's suggestion worked fine. The ++ method now executes one step of the
flood algorithm; more correctly, it executes the flood algorithm until a new
"interior" pixel is found or the algorithm terminates.

So, the usage syntax looks like:

  TImageType::IndexType seedPos;
  const unsigned long pos[] = {15,15,15};
  seedPos.SetIndex(pos);

  typedef itk::FloodFilledSpatialFunctionIterator<TImageType,
TSphereFunctionType> TSphereItType;
  TSphereItType sfi = TSphereItType(sourceImage, spatialFunc, seedPos);

  unsigned long int itCount = 0;

  // Iterate through the entire image and set interior pixels to 255
  for( ; !( sfi.IsAtEnd() ); ++sfi)
    {
    sfi.Get().SetScalar(255);
    itCount++;
    }

This code fragment iterates over a spherical region, with the sphere defined
earlier, and sets the pixels within the region to 255. The only remaining
memory issue is the stack that holds the list of indices generated during
the flood algorithm; I don't really see any way around this since it's
central to the algorithm.

Any other comments, pass them along. I appreciate the help...

-Damion-