2

I'm attempting to trace the following bitmap:

A real chill penguin

Image by ACStewart from the web comic "Behind the GIFs"

As humans, we can clearly see this was originally a vector, and should trace well. The problem is, the JPEG artifacting is causing Inkscape's "Trace Bitmap" code to think the clear black line against the white background as having a gray strip and even a bit of blue running around it.

Zoomed in result of Trace Bitmap in Inkscape

Are there any settings to tweak or any way to trick Inkscape into seeing the lossy JPEG as the vector image it really is?

1
  • 1
    It's not the most complicated illustration in the world. Could you not trace it by hand using the pen tool? Jun 6, 2016 at 13:39

2 Answers 2

8

The bad news: With automatic tracing algorithms alone, you won't be able to get a clean result. There will always be noise.

The good news: If you're willing to invest just a bit of effort in manual cleanup, you can get a very decent vectorized reconstruction. This is what I was able to get in roughly 5 minutes:

Original and Reconstructed

(Click on the image for a high-res version or jump straight to the SVG at the bottom.)

Here's what I did:

  1. Run "Trace Bitmap" on the original twice, once using "Brightness Cutoff" at 0.45 and once using "Multiple scans: Colors" with 6 scans.

In the "Mode" tab, make sure the fields "Smooth", "Stack scans" and "Remove background" are all unchecked. These were my "Options" for both traces:

  1. Put the result of the "Brightness Cutoff" on the side. It is actually really good and gives you all the blacks (as pointed out by Juancho). So all that's missing is the colored areas.

  2. Separate the 6 color layers, delete the ones that contain just noise, clean the remaining layers until you're left with the missing big colored patches:

Hint: To delete the noise, enter "Node selection mode" (F2), select a bunch of noisy nodes by dragging a box around them and delete them with Ctrl+Del.

  1. Align the patches. If some patches seem to have been "thinned out" slightly during tracing, you can "fatten them up" again with "Path" > "Outset" (or Ctrl+)). Finally, group the result.

And there you have your reconstructed SVG:

reconstructed SVG

Right-click and "Save image as..." on the above image or click here to download the standalone SVG file.

4
  • 1
    I have been using just plain DEL for years, and often I get these "wacky" curves when I delete nodes. I am so happy you showed me CTRL+DEL: delete without preserving shape
    – IQAndreas
    Jun 6, 2016 at 21:58
  • @IQAndreas Yep, Ctrl+Del is a pretty essential one ;-) If my answer solves your question, do you mind accepting it? Jun 6, 2016 at 23:40
  • Excellent answer! Do you think you could note which other settings you used? (for instance, it looks like "Stack Scans" is disabled based on the results)
    – IQAndreas
    Jun 12, 2016 at 17:48
  • @IQAndreas Thanks for pointing that out, I just added the missing checkbox states to the answer. "Stack Scans" was in fact disabled. I just realized that with "Stack Scans" enabled, it is possibly even simpler to separate the colored patches. Oh, well - works either way ;-). Jun 12, 2016 at 18:11
1

If you trace the bitmap with the Brightness Cutoff algorithm and threshold 0.3, you will get a nice rendering of the black strokes only.

This will get most of the job done.

Another trace with a higher cutoff will get you the whole head included. You can colour this second trace grey and layer it below the first black trace.

1
  • The first step got the blacks perfectly! Unfortunately, when I increased the brightness cutoff threshold, inkscape decided to include "the fuzzy JPEG border" outside of the black, so I still ended up with similar results to using multiple scans with 4/5 colors.
    – IQAndreas
    Jun 6, 2016 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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