[Insight-users] 'Marching squares' -- Need to go from 2D binary images <-> 2D 'meshes'

Luis Ibanez luis.ibanez at kitware.com
Thu Dec 1 11:49:00 EST 2005


Hi Zach,



Thanks for your detailed email.


Here are some thoughts:



1) The Bresenham line iterator is already in ITK.
    It was contributed by Benjamin King on June 2005

  http://www.itk.org/Insight/Doxygen/html/classitk_1_1LineConstIterator.html
http://www.itk.org/Insight/Doxygen/html/classitk_1_1LineIterator.html




2) This iterator is used by the PolylineMask2DImageFilter
    in order to rasterize Polylines into 2D binary mask images.

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

    a natural input for this filter is the

                  itkPolyLineParametricPath

    as illustrated in the test:

           Insight/Testing/Code/BasicFilters/
               itkPolylineMask2DImageFilterTest.cxx



3) Since you seem to have nicely defined 2D contours and
    you don't seems to need to perform dynamic operations
    on the contour (e.g. node insertion or removal,  or
    contour deformation), the Mesh does not really provide
    interesting functionalities for solving your problem.

    You probably will find an easier solution by using
    the PolyLyineParametricPath and the PolyLineMask2DImageFilter.


4) What we seem to be missing from your list of desired
    functionalities is a filter for taking a 2D image mask and
    extracting the contours in the form of a PolyLineParametricPath.

    However, such filter can easily be written by modifying the
    SimpleContourExtractorImageFilter

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

    and of course, if you do so, we will be happy to help you put
    this new filter back into the toolkit.




Please let us know if you find that the approach suggested above
does not quite solve the problem that you are interested in.




   Thanks


      Luis




---------------------
Zachary Pincus wrote:
> Hi folks,
> 
> I'm working on a 2D application right now (might be 3D in the future)  
> where I'll need to convert between:
> (a) 2D binary masks of simple shapes (with no "holes")
> (b) some sort of geometric representation of the same, e.g. a '2d  mesh' 
> which is I think just a closed poly-line.
> (c) rasterized outlines (not filled) of the same
> 
> I'm wondering if anyone has any recommendations for the best way to  do 
> this in ITK.
> 
> Specifically:
> First, what would be the best data structure to represent 2D shapes  
> geometrically within ITK? With itk::Mesh or  
> itk::PolyLineParametricPath? What are the benefits/drawbacks of each?
> 
> Second, what's the best approach for the following conversions:
> (a to b: mask to mesh) I presume I'd need some sort of "marching  
> squares" algorithm to do this right. Is there anything of the sort in  
> ITK (or another way)? All I see is the BinaryMask3DMeshSource, which  
> is, obviously, just for 3D.
> 
> (a to c: mask to outline) Either go through an itk::ParametricPath  
> intermediate and use the Breshenham line iterator (which I hope to be  
> in ITK soon) or similar, or pre-process the binary image and use the  
> itk::ZeroCrossingImageFilter to get the appropriate contour. Which  
> seems best?
> 
> (b to a: mesh to mask) If I'm using a 2D mesh, presumably the  existing 
> ITK mesh to image filters would work? Or is there a better  2D polygon 
> rasterizer to use? On the other hand, is there a simple  way to do this 
> from the parametric path representation?
> 
> (b to c: mesh to outline) If I'm using the parametric path, this  seems 
> easy (as above with the iterator), but hard if using a mesh.  Are there 
> mesh-to-surface (rather than mesh to volume) filters in ITK?
> 
> 
> Any thoughts on how best to approach this with ITK?
> 
> Thanks,
> 
> Zach Pincus
> 
> Program in Biomedical Informatics and Department of Biochemistry
> Stanford University School of Medicine
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 



More information about the Insight-users mailing list