[Insight-users] Submission: FullyConnectedImageFilter to comp lement ConnectedComponentImageFilter

Miller, James V (Research) millerjv at crd.ge.com
Mon, 22 Mar 2004 15:55:53 -0500


Zach, 

I finally got around modifying the ConnectedComponentImageFilter to
allow the user to select between fully connected neighbors and face
connected neighbors.  As usual with ITK, once I thought about it awhile, 
a simple and elegant solution appeared.  I was able to use the 
ShapeNeighborhoods for both algorithms (though I had to expose an API from
ShapeNeighborhood's superclass).

ConnectedComponentImageFilter can now be controlled via methods 
SetFullyConnected(bool), or FullyConnectedOn()/FullyConnectedOff().  The
default behavior is FullyConnectedOff.

I modified Testing/Code/BasicFilters/itkConnectedComponentImageFilterTest to
take
an optional argument to control the connectivity.  

The test names itkConnectedComponentImageFilterTest2 and
itkConnectedComponentImageFilterTest3 operate on the new input file
Testing/Data/Input/Shapes.png.  The baseline regression images are in
Testing/Data/Baseline/BasicFilters/ConnectedComponentImageFilterTest2.png
and Testing/Data/Baseline/BasicFilter/ConnectedComponentImageFilterTest3.png

http://www.itk.org/cgi-bin/viewcvs.cgi/Testing/Data/Baseline/BasicFilters/Co
nnectedComponentImageFilterTest2.png?rev=1.1&cvsroot=Insight&content-type=te
xt/vnd.viewcvs-markup

http://www.itk.org/cgi-bin/viewcvs.cgi/Testing/Data/Baseline/BasicFilters/Co
nnectedComponentImageFilterTest3.png?rev=1.1&cvsroot=Insight&content-type=te
xt/vnd.viewcvs-markup

If you get a chance, could you run your data through the new algorithm?

Jim


-----Original Message-----
From: Zachary Pincus [mailto:zpincus at stanford.edu]
Sent: Sunday, February 15, 2004 11:10 PM
To: insight-users at itk.org
Subject: [Insight-users] Submission: FullyConnectedImageFilter to
complement ConnectedComponentImageFilter


Hello,

Here is an image filter that labels thin contours in binary images.

While ITK includes a ConnectedComponentImageFilter, this filter only 
works for face-connected objects (in 2-d, that's 4-connected), such as 
blobs. For single-pixel-thick contours, one needs to trace all the 
diagonal connections too (in 2-d, that's 8-connected), so this filter 
is not sufficient.

I have modified itkConnectedComponentImageFilter to trace contours 
across diagonals and faces in n dimensions. (It was a simple, but not 
totally trivial modification.) Here is my code, in case anyone needs 
it, or the ITK maintainers feel that it would be worth including in the 
repository.

(Note that I tried to integrate this into the original 
itkConnectedComponentImageFilter code to avoid excess code duplication, 
but that became really kludgy and unworkable due to the interface 
differences between ShapedNeighborhoodIterator::Iterator and 
Neighborhood::Iterator -- this is a bit of a pain, really.)

Also, in the future, what is the preferred method of code submission?

Zach Pincus

Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine