WOLFRAM

ImageGraphics[image]

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

ImageGraphics[image,n]

uses up to n colors for the vector graphics.

ImageGraphics[image,colors]

creates vector graphics containing the specified colors.

Details and Options

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Convert a color image into vector graphics:

Out[1]=1

Convert a natural image to vector graphics using 8 colors:

Out[1]=1

Scope  (3)Survey of the scope of standard use cases

Convert a bitmap of a digit to vector graphics:

Out[1]=1

Convert a grayscale image to vector graphics:

Out[1]=1

By default, an automatic color quantization is performed:

Out[2]=2

Specify the number of colors to use:

Out[3]=3

Specify the explicit colors to use in the vector graphics:

Out[4]=4

Options  (3)Common values & functionality for each option

Method  (1)

Exact segment contours:

Out[3]=3

Simplified contours by connecting linearly separable segments:

Out[4]=4

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

Out[5]=5

Use marching squares:

Out[6]=6

Use dual marching squares:

Out[7]=7

MinColorDistance  (1)

By default, the minimum color distance is automatically chosen:

Out[2]=2

Specify a minimum color distance:

Out[3]=3

Smaller value for color distance results in more colors:

Out[4]=4

DistanceFunction  (1)

The color metric defined by DistanceFunction influences the image segmentation:

Out[3]=3
Out[4]=4

Applications  (4)Sample problems that can be solved with this function

Create an outline image:

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

Out[2]=2

Convert to vector graphics:

Out[3]=3

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

Out[2]=2
Out[3]=3

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

Out[1]=1

Delete county borders:

Out[2]=2

Convert colored elevation map into graphic contours:

Out[3]=3

Perform vector graphic operations introducing contour lines and changing colors:

Out[4]=4

Transform the map without altering line thickness:

Out[6]=6

Compare the result with the corresponding pixel-based transformation:

Out[7]=7

Creating a scalable icon of a kingfisher:

Obtain a rough mask:

Out[2]=2

Refine the mask with the grow-cut algorithm:

Out[3]=3

Regularize the color segments via curvature flow:

Out[4]=4

Cover the background with green:

Out[5]=5

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

Out[6]=6

Generate a vector graphic:

Out[7]=7

Remove the green background segment:

Out[8]=8

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

Out[9]=9

Properties & Relations  (3)Properties of the function, and connections to other functions

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

Out[3]=3
Out[3]=3

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

Out[2]=2
Out[3]=3
Out[4]=4

Segment and select shapes:

Colorize the segmented image:

Out[2]=2

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

Out[3]=3

Possible Issues  (6)Common pitfalls and unexpected behavior

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

Out[1]=1

Segment edges in the resulting graphic are not colored:

Out[2]=2

Colorize the edges by providing explicit FaceForm and EdgeForm specifications:

Out[3]=3

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

Out[2]=2

Make the lines thicker for a better conversion:

Out[3]=3

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

Out[1]=1

Lower the color distance:

Out[2]=2

Segments touching across pixel corners are connected:

Out[1]=1

Use Method"MarchingSquares" to keep segments separated:

Out[2]=2

A low-resolution image may cause some pixelation artifacts:

Out[1]=1

Some of that artifact may be removed after image upsampling:

Out[2]=2

Alternatively, use a high-resolution image:

Out[3]=3
Wolfram Research (2017), ImageGraphics, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageGraphics.html (updated 2018).
Wolfram Research (2017), ImageGraphics, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageGraphics.html (updated 2018).

Text

Wolfram Research (2017), ImageGraphics, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageGraphics.html (updated 2018).

Wolfram Research (2017), ImageGraphics, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageGraphics.html (updated 2018).

CMS

Wolfram Language. 2017. "ImageGraphics." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/ImageGraphics.html.

Wolfram Language. 2017. "ImageGraphics." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/ImageGraphics.html.

APA

Wolfram Language. (2017). ImageGraphics. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageGraphics.html

Wolfram Language. (2017). ImageGraphics. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageGraphics.html

BibTeX

@misc{reference.wolfram_2025_imagegraphics, author="Wolfram Research", title="{ImageGraphics}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/ImageGraphics.html}", note=[Accessed: 25-May-2025 ]}

@misc{reference.wolfram_2025_imagegraphics, author="Wolfram Research", title="{ImageGraphics}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/ImageGraphics.html}", note=[Accessed: 25-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_imagegraphics, organization={Wolfram Research}, title={ImageGraphics}, year={2018}, url={https://reference.wolfram.com/language/ref/ImageGraphics.html}, note=[Accessed: 25-May-2025 ]}

@online{reference.wolfram_2025_imagegraphics, organization={Wolfram Research}, title={ImageGraphics}, year={2018}, url={https://reference.wolfram.com/language/ref/ImageGraphics.html}, note=[Accessed: 25-May-2025 ]}