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

Zachary Pincus zpincus at stanford.edu
Tue Nov 29 03:33:15 EST 2005


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



More information about the Insight-users mailing list