[Insight-users] Submission: FullyConnectedImageFilter to comp lement ConnectedComponentImageFilter
Zachary Pincus
zpincus at stanford.edu
Mon, 22 Mar 2004 13:34:37 -0800
James,
Oh dear, this is almost funny. A few days ago I also sat down to figure
out a clean N-dimensional way of doing this. I was just writing up test
cases and getting ready to email the ITK list when I saw your message!
Amazingly, we wrote identical code, except that I had an extra line to
get around the un-exposed GetCenterNeighborhoodIndex() call. (
offset.Fill(0); unsigned int centerIndex =
nit.GetNeighborhoodIndex(offset); does the same...)
Anyhow, suffice to say that this method works perfectly on my data.
Thanks, and sorry for any duplication of effort. At least we can be
more sure that this is in fact the appropriate solution.
Zach Pincus
Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine
On Mar 22, 2004, at 12:55 PM, Miller, James V (Research) wrote:
> 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
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>