[Insight-users] segmentation boundary

Luis Ibanez luis . ibanez at kitware . com
Wed, 28 Aug 2002 10:28:56 -0400


Hi Alberto,

Once you have the extracted region, you can recover the
boundary of such region by using a filter like the
itkSobelEdgeDetectionImageFilter.
http://www.itk.org/Insight/Doxygen/html/classitk_1_1SobelEdgeDetectionImageFilter.html
(this is currently done in the RegionGrowingSegmentation2D
example). That will be ok for visualizing the countours.

If you want to make sure that the countours are 1 pixel
wide, you may have to do the following:

1) Take the image with the segmented region and apply a
    dilation (mathematical morphology operation) with the
    filter:

http://www.itk.org/Insight/Doxygen/html/classitk_1_1BinaryDilateImageFilter.html

2) Subtract the segmented image from the dilated image using
    the basic subtract filter:

http://www.itk.org/Insight/Doxygen/html/classitk_1_1SubtractImageFilter.html


This should left only the contours 1 pixel wide.

If you have concerns about the connectivity of the resulting contour,
That is, 26-connected, 6-connected... and so on. You may want to
chose an appropiate StructuringElement for the Dilate morphological
filter. This filter allow you to customize the structuring element.

A structuring element containing a central pixel and its 6 closest
neighbors will result in a 6-connected contour (after the subtraction).
A structuring element containing a central pixel and its 26 closest
neighbors will result in a 26 connected contour.

Once you have the image with only the contour, a piece of code like
the following will put this data in a file:

std::ofstream ofile("Contour.dat");
itk::ImageRegionIterator< ImageType > it( image,
                                           image->GetBufferedRegion() );
it.GoToBegin();
while( !it.IsAtEnd() )
   {
   if( it.Get() ) // if the pixel is not null
     {
     // print out the pixel position and value
     ofile << it.GetIndex() << " = " << it.Get() << std::endl;
     }
   ++it; // go to next pixel
   }
ofile.close();
	


Please let us know if you find any problem,


Thanks


Luis


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

Alberto Bert wrote:
> Hi all,
> 
> thaks to Luis for his patience...
> 
> I'm trying to segment a 3D image with a region growing algorithm.
> Actually I'm not very interested in the segmented region but in its
> boundary. More precisely I would like extract (and write to file, for 
> further processing) position and intensity of all "voxels" belonging 
> to the boundary (that is, the external part of the segmented region.)
> I don't know if something similar already exists in itk, and, if not,
> can tou give me some suggestion about it (where I've to start from?)
> 
> Thank you very much,
> Alberto.
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>