image thumbnail

Im2mesh (2D image to triangular meshes)

version 1.76 (121 KB) by Jiexian Ma
Convert 2d multi-phase image to FEM meshes, with poly-line simplification feature.


Updated 16 Dec 2020

View License

This tool consists of a few functions, like, im2Bounds (image to polygonal boundaries), getCtrlPnts (mark intersecting vertex between polygons, serving as fixed point for polygon simplification and meshing), simplifyBounds (simplify polygon), poly2mesh (polygon to triangular meshes, printInp (export as Inp file), and printBdf (export as Bdf file).

- Exactly reserve the contact detail between different phases.
- Able to avoid sharp corners when simplifying polyline.
- Support phase selection before meshing (see demo7.m)
- Generated mesh can be exported as inp file (Abaqus), bdf file (Nastran bulk data), and .node/.ele file.
- 7 examples are presented in demo1.m ~ demo7.m.

Note: To make this code run (especially for poly2mesh), you need to download MESH2D from, and add the folder (mesh2d-master) to your path. After that, you can start with demo1.m~demo7.m in im2mesh. Check the images in the folder (im2mesh\images\...).

If you have any questions or suggestions, feel free to send me an email., Nov 2020.

Great thanks Dr. Yang Lu providing valuable advice on this tool.  

Cite As

Jiexian Ma (2021). Im2mesh (2D image to triangular meshes) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!