returns the content of image in the form of scalable vector graphics.


uses up to n colors for the vector graphics.


creates vector graphics containing the specified colors.

Details and Options

  • ImageGraphics is also known as image vectorization or auto tracing.
  • ImageGraphics works with arbitrary 2D images and returns a Graphics object.
  • ImageGraphics has the same options as Graphics, with the following changes and additions:
  • DistanceFunctionAutomaticany distance supported in ColorDistance
    MethodAutomaticmethod to determine color segment contours
    MinColorDistanceAutomaticminimum color distance
  • Possible settings for Method include:
  • "Exact"exact representation of the contour
    "LinearSeparable"approximate contour by local linear separation
    {"LinearSeparable",α}merge and smooth segments with direction changes smaller than α
    "MarchingSquares"contour computed using marching squares
    "DualMarchingSquares"contour computed using dual marching squares


open allclose all

Basic Examples  (2)

Convert a color image into vector graphics:

Convert a natural image to vector graphics using 8 colors:

Scope  (3)

Convert a bitmap of a digit to vector graphics:

Convert a grayscale image to vector graphics:

By default, an automatic color quantization is performed:

Specify the number of colors to use:

Specify the explicit colors to use in the vector graphics:

Options  (3)

Method  (1)

Exact segment contours:

Simplified contours by connecting linearly separable segments:

Smooth contours by rounding corners of less than 90° with Bézier splines:

Use marching squares:

Use dual marching squares:

MinColorDistance  (1)

By default, the minimum color distance is automatically chosen:

Specify a minimum color distance:

Smaller value for color distance results in more colors:

DistanceFunction  (1)

The color metric defined by DistanceFunction influences the image segmentation:

Applications  (4)

Create an outline image:

Simplify color regions using mean-shift and smooth outlines via curvature flow filter:

Convert to vector graphics:

Successively simplify the color regions of an image with a mean-shift filter:

Generate vector graphic maps. Import a pixel-based map of the Rocky Mountains near Denver:

Delete county borders:

Convert colored elevation map into graphic contours:

Perform vector graphic operations introducing contour lines and changing colors:

Transform the map without altering line thickness:

Compare the result with the corresponding pixel-based transformation:

Creating a scalable icon of a kingfisher:

Obtain a rough mask:

Refine the mask with the grow-cut algorithm:

Regularize the color segments via curvature flow:

Cover the background with green:

Select the dominant colors of the bird and add green as the background color:

Generate a vector graphic:

Remove the green background segment:

Insert the expression into a larger graphic to obtain a scalable icon:

Properties & Relations  (3)

Typically, the scalable graphics version of the image is much smaller in byte count:

ImageGraphics returns color segments similar to color quantization in the LAB color space:

Segment and select shapes:

Colorize the segmented image:

Convert the image into vector graphics. Double-click to select and move a segment

Possible Issues  (6)

"MarchingSquares" and "DualMarchingSquares" introduce gaps at T-junctions:

Segment edges in the resulting graphic are not colored:

Colorize the edges by providing explicit FaceForm and EdgeForm specifications:

Lines and curves of one-pixel thickness may not be detected correctly:

Make the lines thicker for a better conversion:

If the minimum color distance is larger than the image color variation, the output may be of a single color:

Lower the color distance:

Segments touching across pixel corners are connected:

Use Method"MarchingSquares" to keep segments separated:

A low-resolution image may cause some pixelation artifacts:

Some of that artifact may be removed after image upsampling:

Alternatively, use a high-resolution image:

Wolfram Research (2017), ImageGraphics, Wolfram Language function, (updated 2018).


Wolfram Research (2017), ImageGraphics, Wolfram Language function, (updated 2018).


@misc{reference.wolfram_2020_imagegraphics, author="Wolfram Research", title="{ImageGraphics}", year="2018", howpublished="\url{}", note=[Accessed: 15-January-2021 ]}


@online{reference.wolfram_2020_imagegraphics, organization={Wolfram Research}, title={ImageGraphics}, year={2018}, url={}, note=[Accessed: 15-January-2021 ]}


Wolfram Language. 2017. "ImageGraphics." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018.


Wolfram Language. (2017). ImageGraphics. Wolfram Language & System Documentation Center. Retrieved from