[Insight-users] a question about boundary points extraction

Luis Ibanez luis.ibanez@kitware.com
Wed, 11 Sep 2002 13:50:07 -0400


Hi Zhao,

Currently there is no API for extracting boundary points.
I assume that you have in mind something like a Freeman string
for representing a contour in 2D.

However, (as you mentioned), you could use the neigborhood iterator
in order to walk through the contour. The only difficulty is that
when you get the neighbor pixels they are not ordered clock or
counter clock wise.

http://www.itk.org/Doxygen/html/classitk_1_1NeighborhoodIterator.html

The order problem can be easily solved knowing that the
NeighborhoodIterator use a lexicographic order. If you have a
3x3 neighborhood (x radius =1 and y radius =1) the order in which
surrounding pixels are accessed is:

   0  1  2
   3  4  5
   6  7  8

Hence, you can take advantage of the GetPixel(int) method and
get the pixels clock-wise order { 0 1 2 5 8 7 6 3 } or counter
clock-wise { 0 3 6 7 8 5 2 1 }

Notice that when you are walking through the contour, the starting
direction for testing neighbors has to be related with the previous
step you made along the contour.  The most efficient way to implement
a contourVisitor is to use a State Machine model. You can do this
with a Matrix (transition matrix with (state,input) pairs mapped to
a next state). and a switch statemente inside a while loop.

It will look like:

 while( state != endstate )
  {
  state = TransitionMatrix[state][input];
  switch( state )
   {
   case 3:
     currentIndex[0]--;
     break;
   case 6:
     currentIndex[0]--;
     currentIndex[1]--;
     break;
// etc....
   }
  }

Please let us know if you find any problems implementing this
contourVisitor.


  Thanks


   Luis



===============================================

zhao wrote:

> Hi Luis,
> 	
> 	How to extract the boundary points sequentially from a labeled region. Is there any API in ITK can do this?
> 	
> 	Does ITK have a Neighborhood class that allow users access neighborhood pixels clockwise(in 2-D image; either 4-N ro 8-N), which I think will be very useful for boundary extraction?
> 	
> 	In my program, I want to extract the boundary information from a segmented/labeled region to draw and to store for later use. 
> 	
> 	Thanks!
> 
> Zhao
> 
> Zhao ChenGuang
> P.O.Box:010,
> Dept. BME,
> Shanghai Jiao Tong University,
> 1954# Hua Shan Road,
> Shanghai,P.R.China,
> 200030
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>