7

I was trying to vectorize a .png. I found a utility (which is incorporated into InkScape), the potrace. If any of you knows how to use potrace, kindly teach me the right way to get sharp output.

Consider this input (png).

enter image description here

To use potrace, the picture must be in bitmap format. So I converted it by using imagemagick.

convert image.png image.bmp

Then I proceeded with potrace.

potrace --svg falcon.bmp -o falcon.svg

But unfortunately, the output looks obviously dull.

enter image description here

I don't really understand the options (potrace -h). Or if there's a better alternative other than potrace, just tell me.

  • Do you own illustrator? – Rosenthal Sep 9 '14 at 5:01
  • As with most auto-trace software, the larger the original image the better the final output in most cases. – Scott Sep 9 '14 at 6:27
  • There is a program which I mentioned in my answer that may increase the quality of the "vectorization". – Rosenthal Sep 9 '14 at 18:34
  • @Neo I do have illustrator. I tried (auto-tracing) with Adobe Illustrator. This is how I did. And when I compared the one generated by potrace and the one traced by Ai (as shown above), the potrace traced the outline better. – Aizan Fahri Sep 9 '14 at 18:55
1

Tracing with BirdFont

The potrace algorithm is good but no autotrace algorithm is perfect.

I had a similar problem when I tried to auto trace letters with potrace. Small details are not preserved and the result seems to be a little bit smoother than I wanted it to be. I solved this by implementing my own autotrace functionality in BirdFont. It seems to work a little bit better but it is not as fast as the potrace algorithm.

The image looks like this when converted to black and white: Image before tracing it

And the traced result looks like this: Vector graphics automatically generated from the raster image.

This image was generated with the following settings:

  • Cubic Beziér paths
  • Contrast: 0.59
  • Amount of details: 3.0
  • Simplification: 0.1

BirdFont is a font editor and TTF is the most common font format fonts but you can export the generated image as SVG.

Edit->Export Glyph as SVG

You can find more instructions on the autotrace functionality at the BirdFont website.

| improve this answer | |
6

Potracegui

I recommend you to download the GUI interface for potrace and autotrace, which contains two algorithms for tracing bitmapped images. It collects informations in an easy way (hopefully) and then it launches potrace or autotrace with all the relevant options. Using a GUI sometimes is more comfortable that using command line, it is more interactive, and it will easy for you to try different the settings.

Screenshot:

enter image description here

How can I improve the quality of the output of Potrace?

The most effective way to do so is to improve the quality of the input!. Scan your image at a higher resolution. Scan your image in greyscale, and use a program such as mkbitmap to generate a high-resolution bitmap to trace.

In some cases, it also helps to decrease the resolution of the input image. If the resolution of your input file is incredibly high, the output generated by Potrace might be larger than necessary. This also sometimes happens if the input is speckly or noisy. Rather than trying to simplify the vector image, it often helps to just downscale the input bitmap.

Update:

There is an utility called mkbitmap which converts color or greyscale images into a format suitable as input for other programs, particularly the tracing program Potrace. It is particularly useful for converting scanned line art, such as cartoons, handwritten text, etc., to high-resolution bilevel images.

In this website you can find some examples of the operation of mkbitmap.

| improve this answer | |
  • I had as just as Aizan Fahri some trouble generating a sharp image with potrace. Can you provide example settings for a good balance between smooth curves and preserved details with potrace? – Johan Sep 9 '14 at 12:51
  • @Johan, important information added – Rosenthal Sep 9 '14 at 18:28
  • @Johan it is okay. I also asked for alternative, which he did. Cheers. – Aizan Fahri Sep 9 '14 at 18:50
  • 2
    Yes, I think it is a very good answer. Thanks. – Johan Sep 9 '14 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.