returns the foreground region in image as a BoundaryMeshRegion object.

Details and Options

  • ImageMesh is also known as image-based meshing and converts 2D or 3D image data such as MRI or CT to a computer model. Constructed models can be used in a variety of ways, including the finite element method for solving PDEs.
  • ImageMesh works with arbitrary 2D and 3D images, taking the nonzero pixels of the image as foreground.
  • ImageMesh has the same options as BoundaryMeshRegion, with the following changes and additions:
  • CornerNeighbors Truewhether to connect foreground pixels diagonally across corners in 2D
    DataRangeAutomaticthe range of mesh coordinates to generate
    Method Automaticthe method to use
  • In 2D, possible settings for Method include:
  • "Exact"exact representation of the contour
    "LinearSeparable"approximate contour by local linear separation
    "MarchingSquares"contour computed using marching squares
    "DualMarchingSquares"contour computed using dual marching squares
  • In 3D, possible settings for Method include:
  • "Exact"exact representation of the surface
    "MarchingCubes"surface computed using marching cubes
    "DualMarchingCubes"surface computed using dual marching cubes


open allclose all

Basic Examples  (2)

Convert a 2D shape to a boundary mesh:

Convert a 3D image into mesh:

Options  (3)

CornerNeighbors  (1)

By default, 8-connectivity is assumed:

Assume 4-connectedness:

Method  (2)

Exact boundary:

Shape computed using marching squares:

Use the linear separable method:

By default, the exact method is used for 3D volumes:

Use marching cubes:

Use dual marching cubes:

Applications  (4)

Upsample an image by first approximating its smoothed shape and then rasterizing:

Compare with the magnified version of the image:

Segment a part of an image and convert it to a mesh:

Obtain an image of the Great Salt Lake:

Regularize the image with a mean shift filter:

Obtain a segmentation via region growing:

Create a mesh of the lake surface:

Compute the eigenfunctions of the wave equation on :

Display the oscillation modes:

Create 3D-printable objects from 2D images:

Properties & Relations  (1)

A shape typically has a more compact representation when converted to a mesh:

Even with exact representation, the shape is slightly simplified:

Wolfram Research (2016), ImageMesh, Wolfram Language function,


Wolfram Research (2016), ImageMesh, Wolfram Language function,


Wolfram Language. 2016. "ImageMesh." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2016). ImageMesh. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_imagemesh, author="Wolfram Research", title="{ImageMesh}", year="2016", howpublished="\url{}", note=[Accessed: 16-July-2024 ]}


@online{reference.wolfram_2024_imagemesh, organization={Wolfram Research}, title={ImageMesh}, year={2016}, url={}, note=[Accessed: 16-July-2024 ]}