[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.&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=090113917-12072002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp; I think we have found a 
  "feature" of the FloodFilledSpatialFunctionConditionalIterator.&nbsp; If you 
  recall, it iterates within some spatial function via a flood fill, beginning 
  at some seed point that is fed to the iterator.&nbsp; Well, what seems to 
  happen to that seed point is that it is visited twice.&nbsp; Here is an 
  example code snipped (from itkFloodFillIteratorTest.cxx)&nbsp;for filling a 
  sphere with radius&nbsp;2 centered at (10,10,10) with a seed point of 
  (9,10,10)</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial 
  size=2>---------------------------------------------------</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp; typedef 
  itk::SphereSpatialFunction&lt;dim&gt; TFunctionType;<BR>&nbsp; typedef 
  TFunctionType::InputType TFunctionPositionType;</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; // Create and initialize a new sphere 
  function</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; TFunctionType::Pointer spatialFunc = 
  TFunctionType::New();<BR>&nbsp; spatialFunc-&gt;SetRadius( 2 );</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; TFunctionPositionType center;<BR>&nbsp; 
  center[0]=10;<BR>&nbsp; center[1]=10;<BR>&nbsp; center[2]=10;<BR>&nbsp; 
  spatialFunc-&gt;SetCenter(center);</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; std::cout &lt;&lt; "Sphere spatial 
  function created" &lt;&lt; std::endl;</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; //---------Create and initialize a spatial 
  function iterator-----------<BR>&nbsp; TImageType::IndexType 
  seedPos;<BR>&nbsp; const TImageType::IndexValueType pos[] = 
  {9,10,10};<BR>&nbsp; seedPos.SetIndex(pos);</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; typedef 
  itk::FloodFilledSpatialFunctionConditionalIterator<BR>&nbsp;&nbsp;&nbsp; 
  &lt;TImageType, TFunctionType&gt; TItType;<BR>&nbsp; TItType sfi = 
  TItType(sourceImage, spatialFunc, seedPos);</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; // Iterate through the entire image and 
  set interior pixels to 255<BR>&nbsp; for( ; !( sfi.IsAtEnd() 
  );++sfi)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; 
  sfi.GetIndex() &lt;&lt; ": " &lt;&lt; sfi.Get() &lt;&lt; 
  std::endl;<BR>&nbsp;&nbsp;&nbsp; sfi.Set(255);<BR>&nbsp;&nbsp;&nbsp; 
  }</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial 
  size=2>-------------------------------------------------</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>As you might notice, the first index [9,10,10] is 
  repeated.&nbsp; This is the seed point.&nbsp; Currently, to get around this 
  bug, we increment the iterator before it is used the first time.&nbsp; Of 
  course, this hack is not a fix.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Has anybody else noticed this bug?&nbsp; 
  </FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>wilson</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C229CB.07EECA93--