-1

What I want

I want to transform a raster image into a vector image with minimum number of vertices. (Specifically, into a sticker for a messaging app, which is a gzipped lottie file, but that's irrelevant, I think.)

What I do

The best vectorization app I could find is Vector Magic. The results are great, however stacking of shapes on top of each other doesn't work (or I don't understand its options). It transforms the raster image on the left to the vector image on the right:

Shapes are touching each other. If there's a zig-zag line, it's present on both sides. 124 points in total, which is great compared to anything that Adobe Illustrator's built-in image tracing can produce. However, this can be optimized (shapes shifted to show the difference):

That's 72 points with no loss in quality. However, that's a lot of manual work.

What I need

Is there any way to do this sort of shape stacking automatically? I doubt I'm the first person to have this problem, but no matter what I search for, I find nothing.

0
1

You probably don't want to hear this, but auto tracing will never give you a result like that - especially not with an image like the example which has blurry edges. At best, you might be able to achieve some degree of stacking using software such as Adobe Illustrator or Inkscape which both have stacking settings that you can use when auto tracing.

To be honest with you, to get the result you want, I think it would be easier and quicker to simply redraw it manually using the Bézier/Pen tool in vector image editing software, where you can use the raster image as a guide to make the curves, rather than wasting your time trying to correct an auto trace.

An example made in a few minutes in Inkscape using the Bézier tool. The same is of course possible in Illustrator using the Pen tool.

enter image description here

4
  • Even if manual tracing is relatively fast, automatic tracing is much faster. If it was a one-off thing, I'd go for it, but I want to do this hundreds of times, so it becomes impractical. The image is also just an example to demonstrate the stacking issue. In more complex cases, especially when vectorizing images with shading and 30-50 stacked shapes, Vector Magic's results are much better than anything I can trace manually (mostly thanks to its segmentation) and optimal stacking becomes a complex mathematical problem which I find really hard to solve in my head (what goes on top of what).
    – Athari
    Oct 4 at 17:02
  • Sadly, this is exactly when I hit the size limits for vector animations allowed by the messaging app, so this is the time I need this sort of optimizartion the most. I assumed Inkscape to Illustrator is like GIMP to Photoshop, so haven't tried it.
    – Athari
    Oct 4 at 17:02
  • @Athari Sure, but when automatic tracing isn't doing what you want, then it's not really much use if it takes longer to fix than it would to redraw the images manually from scratch. Also you will find that the more complex the images are, the worse automatic tracing gets, and more fixing will be required. I do understand your problem, but unfortunately, current auto tracing software is no where near what a human can do. Maybe in the future some AI could improve things, for example if software could recognise shapes and know what they are supposed to be, like a human can.
    – Billy Kerr
    Oct 4 at 18:09
  • Well, I find removing unnecessary points easier than drawing new ones. Vector Magic plus Illustrator's Simlify produce almost perfect lines. It can't produce thick pen lines, but other than that, placement of points is very good. I can get to this i.stack.imgur.com/4OEAI.png (49 points) by only removing points. It's just 25% increase to what you did manually (39 points). The reason for my question is that the stacking problem is essentially the last one that I have and it looks like something which can be solved algorithmically. Well, hello StackOverflow and scripts, I guess.
    – Athari
    Oct 4 at 19:36
1

Since you're satisfied with the traced shapes, perhaps you could figure out a way to keep the bitmap stacked as transparent layers before tracing then?

This way the shapes below the yellow "squiggle" won't be cut out by it, for example, since you would be tracing one layer at a time.

The online sketchpad.app keeps each brush stroke in its own layer, so perhaps that type of tool could be used. Or something that can generate color separation layers like Photoshop for example.

I don't see many other options, as pointed out already in the Billy's answer.

6
  • Source raster images are drawn by artists who would never agree to put every single color on a separate layer just to make my job easier.
    – Athari
    Oct 11 at 23:19
  • @Athari I'm not saying the artists should do, but the drawing software. I assumed you had control over that.
    – Luciano
    Oct 13 at 8:16
  • It won't work for me, but let's assume for a second it's a proper collaborative work from the beginning and the artist doesn't have preferences on drawing software (which is a miracle by itself, from my experience). What application would perform this kind of granular layer separation without making the artist do this essentially manually (and suffering in the process enough to never do a collab with me ever again 😆)?
    – Athari
    Oct 13 at 10:46
  • @Athari I was thinking of some sort of color channel separation. This app keeps each stroke in its own layer, which sort of what I imagined would work well sketchpad.app
    – Luciano
    Oct 13 at 13:24
  • Hm, I guess this approach could work, in theory. Vector editors do have painting tools somewhat resembling raster brushes, so even if an artist completely ignores the vector nature of an image, shapes can be grouped by color and rearranged later with a relatively simple algorithm. Still, getting artists to use vector editors will be tough...
    – Athari
    Oct 13 at 13:51

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.