[Insight-developers] extra iteration in FloodFilledSpatialFun
ctionConditionalIterator
Miller, James V (Research)
millerjv at crd . ge . com
Fri, 12 Jul 2002 13:39:30 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C229CB.07EECA93
Content-Type: text/plain;
charset="iso-8859-1"
yep.
noticed it the first time we used it.
-----Original Message-----
From: Wilson Chang [mailto:wmcst6+@pitt.edu]
Sent: Friday, July 12, 2002 1:01 PM
To: Insight Developers
Subject: [Insight-developers] extra iteration in FloodFilledSpatialFunctionConditionalIterator
hi
I think we have found a "feature" of the FloodFilledSpatialFunctionConditionalIterator. If you
recall, it iterates within some spatial function via a flood fill, beginning at some seed point that
is fed to the iterator. Well, what seems to happen to that seed point is that it is visited twice.
Here is an example code snipped (from itkFloodFillIteratorTest.cxx) for filling a sphere with radius
2 centered at (10,10,10) with a seed point of (9,10,10)
---------------------------------------------------
typedef itk::SphereSpatialFunction<dim> TFunctionType;
typedef TFunctionType::InputType TFunctionPositionType;
// Create and initialize a new sphere function
TFunctionType::Pointer spatialFunc = TFunctionType::New();
spatialFunc->SetRadius( 2 );
TFunctionPositionType center;
center[0]=10;
center[1]=10;
center[2]=10;
spatialFunc->SetCenter(center);
std::cout << "Sphere spatial function created" << std::endl;
//---------Create and initialize a spatial function iterator-----------
TImageType::IndexType seedPos;
const TImageType::IndexValueType pos[] = {9,10,10};
seedPos.SetIndex(pos);
typedef itk::FloodFilledSpatialFunctionConditionalIterator
<TImageType, TFunctionType> TItType;
TItType sfi = TItType(sourceImage, spatialFunc, seedPos);
// Iterate through the entire image and set interior pixels to 255
for( ; !( sfi.IsAtEnd() );++sfi)
{
std::cout << sfi.GetIndex() << ": " << sfi.Get() << std::endl;
sfi.Set(255);
}
-------------------------------------------------
and the output listing the pixel indices (and their values) as they are visited by the iterator:
[9, 10, 10]: 0
[9, 10, 10]: 255
[8, 10, 10]: 0
[8, 9, 10]: 0
[9, 9, 10]: 0
[10, 9, 10]: 0
[11, 10, 10]: 0
[10, 11, 10]: 0
[9, 11, 10]: 0
[9, 11, 9]: 0
[10, 11, 9]: 0
[10, 10, 9]: 0
[9, 10, 9]: 0
[8, 10, 9]: 0
[8, 9, 9]: 0
[9, 9, 9]: 0
[10, 9, 9]: 0
[11, 10, 9]: 0
[11, 9, 10]: 0
[11, 9, 9]: 0
[10, 8, 10]: 0
[9, 8, 10]: 0
[9, 8, 9]: 0
[10, 8, 9]: 0
[10, 9, 8]: 0
[9, 10, 8]: 0
[10, 10, 8]: 0
[9, 9, 8]: 0
[10, 10, 10]: 0
[10, 10, 11]: 0
[9, 10, 11]: 0
[9, 9, 11]: 0
[10, 9, 11]: 0
As you might notice, the first index [9,10,10] is repeated. This is the seed point. Currently, to
get around this bug, we increment the iterator before it is used the first time. Of course, this
hack is not a fix.
Has anybody else noticed this bug?
wilson
------_=_NextPart_001_01C229CB.07EECA93
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2715.400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=090113917-12072002><FONT color=#0000ff
size=2>yep. </FONT></SPAN></DIV>
<DIV><SPAN class=090113917-12072002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=090113917-12072002><FONT color=#0000ff size=2>noticed it the
first time we used it.</FONT></SPAN></DIV>
<DIV><SPAN class=090113917-12072002></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Wilson Chang
[mailto:wmcst6+@pitt.edu]<BR><B>Sent:</B> Friday, July 12, 2002 1:01
PM<BR><B>To:</B> Insight Developers<BR><B>Subject:</B> [Insight-developers]
extra iteration in
FloodFilledSpatialFunctionConditionalIterator<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>hi</FONT></DIV>
<DIV><FONT face=Arial size=2> I think we have found a
"feature" of the FloodFilledSpatialFunctionConditionalIterator. If you
recall, it iterates within some spatial function via a flood fill, beginning
at some seed point that is fed to the iterator. Well, what seems to
happen to that seed point is that it is visited twice. Here is an
example code snipped (from itkFloodFillIteratorTest.cxx) for filling a
sphere with radius 2 centered at (10,10,10) with a seed point of
(9,10,10)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>---------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2> typedef
itk::SphereSpatialFunction<dim> TFunctionType;<BR> typedef
TFunctionType::InputType TFunctionPositionType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Create and initialize a new sphere
function</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> TFunctionType::Pointer spatialFunc =
TFunctionType::New();<BR> spatialFunc->SetRadius( 2 );</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> TFunctionPositionType center;<BR>
center[0]=10;<BR> center[1]=10;<BR> center[2]=10;<BR>
spatialFunc->SetCenter(center);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> std::cout << "Sphere spatial
function created" << std::endl;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> //---------Create and initialize a spatial
function iterator-----------<BR> TImageType::IndexType
seedPos;<BR> const TImageType::IndexValueType pos[] =
{9,10,10};<BR> seedPos.SetIndex(pos);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef
itk::FloodFilledSpatialFunctionConditionalIterator<BR>
<TImageType, TFunctionType> TItType;<BR> TItType sfi =
TItType(sourceImage, spatialFunc, seedPos);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Iterate through the entire image and
set interior pixels to 255<BR> for( ; !( sfi.IsAtEnd()
);++sfi)<BR> {<BR> std::cout <<
sfi.GetIndex() << ": " << sfi.Get() <<
std::endl;<BR> sfi.Set(255);<BR>
}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>-------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>and the output listing the pixel indices (and
their values) as they are visited by the iterator:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[9, 10, 10]: 0<BR>[9, 10, 10]: 255<BR>[8, 10,
10]: 0<BR>[8, 9, 10]: 0<BR>[9, 9, 10]: 0<BR>[10, 9, 10]: 0<BR>[11, 10, 10]:
0<BR>[10, 11, 10]: 0<BR>[9, 11, 10]: 0<BR>[9, 11, 9]: 0<BR>[10, 11, 9]:
0<BR>[10, 10, 9]: 0<BR>[9, 10, 9]: 0<BR>[8, 10, 9]: 0<BR>[8, 9, 9]: 0<BR>[9,
9, 9]: 0<BR>[10, 9, 9]: 0<BR>[11, 10, 9]: 0<BR>[11, 9, 10]: 0<BR>[11, 9, 9]:
0<BR>[10, 8, 10]: 0<BR>[9, 8, 10]: 0<BR>[9, 8, 9]: 0<BR>[10, 8, 9]: 0<BR>[10,
9, 8]: 0<BR>[9, 10, 8]: 0<BR>[10, 10, 8]: 0<BR>[9, 9, 8]: 0<BR>[10, 10, 10]:
0<BR>[10, 10, 11]: 0<BR>[9, 10, 11]: 0<BR>[9, 9, 11]: 0<BR>[10, 9, 11]:
0</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>As you might notice, the first index [9,10,10] is
repeated. This is the seed point. Currently, to get around this
bug, we increment the iterator before it is used the first time. Of
course, this hack is not a fix.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Has anybody else noticed this bug?
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>wilson</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BLOCKQUOTE></BODY></HTML>
------_=_NextPart_001_01C229CB.07EECA93--