Public: Technology Reviews : Tracing Color Layers
This page last changed on Oct 09, 2006 by scytacki.
This page explains how to use potrace to trace a color raster image.
First the antialiasing is removed using the technique on this page:
Then the image is color quantized using the instructions at the the bottom of this page:
Here is the resulting image that we'll start with:
Here is what it looks like after being traced with stack off. The color regions have also been broken apart.
Notice that in the paths above there is still a lot of redundancy. Every edge between the regions is represented twice: once by the black outline and again by the color. Not only does this cause an increase in size, it also causes gaps in the images. For example here is a zoom in on the lines of the fin after they have been traced:
The solution that Inkscape uses is to layer the colors on top of one another. This elimnates gaps, but when it is done in a random order it actually increases the redunancy. Here are the layers that Inkscape makes when "stack" is on:
Each layer includes the colors from above it. In this way there will never be any gaps. Because there is always an overlap between two color areas. This could cause something like gaps but with colors. For example when the black layer is put on top of the green layer there might be some spots where the green shows up behind the black where it is not supposed to. I have not found an example of this yet.
How did Inksacpe create these layers? The image below attempts to describe the algorithm with pictures. Here it is in words:
The layering or stacking that Inkscape uses is not ideal, so we need more control over that process. Here is a how to do the stacking from the commandline using netpbm commands. It assumes you know the hex format of the colors in the image.
Inkscape uses the potrace command to do the tracing. potrace only traces black and white images, so once the images above have been created they can be traced with potrace.
|Document generated by Confluence on Jan 27, 2014 16:56|