[Insight-developers] spatial function updates

Damion Shelton dmshelto@andrew.cmu.edu
Fri, 24 May 2002 12:47:21 -0400


Hi,

I've made the modifications to 
FloodFilledSpatialFunctionConditionalIterator (and the const variant) 
mentioned in an earlier email. I'll be checking in an example shortly, but 
the example's output should explain things pretty well:

The output shown below illustrates the results of a flood fill on a circle 
of radius 1.0 centered at (2.5,2.5). The image is 5x5 bool, with an origin 
of (0,0) and spacing of (1.0,1.0). Prior to the modifications, the iterator 
behaved in what is now called the "origin" strategy.

Origin Inclusion Strategy
0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 1 1 0
0 0 0 0 0
Center Inclusion Strategy
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 0
0 0 0 0 0
Complete Inclusion Strategy
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
Intersect Inclusion Strategy
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0

Another note: subclasses of FloodFilledFunctionConditionalIterator had a 
bug/feature which I've modified slightly. The seed pixel did not have to 
pass the IsPixelIncluded() test, so it was included in the flood fill 
regardless of whether or not it was actually "in" the flood. This had the 
result that a randomly seeded flood fill would result in accessing at least 
one pixel, which was quite confusing for debugging.

I've modified GoToBegin() to test the seed pixel for inclusion and set 
m_IsAtEnd = true if the seed pixel is not included. This results in the 
iterator returning without accessing any pixels.

If this behavior is desired, the iterator syntax should look like (where 
sfi is the iterator):

for( sfi.GoToBegin(); !( sfi.IsAtEnd() ); ++sfi)

rather than

for( ; !( sfi.IsAtEnd() ); ++sfi)

If the latter form is used, the seed pixel will be included in the 
iterator's output regardless of its inclusion in the function.

Comments/suggestions/complaints welcome.

-Damion-