Vectorizing Photos: Finding an Adapted Algorithm [

2019-05-19 01:30发布

问题:

As a little project, I've decided I want to write a small raster to vector converter. Lots and lots of resources are available online, but many fewer actual implementations can give me any kind of starting point. I haven't decided which language I'm going to do this in, but Python seems to be pretty adapted.

The first issue is that most papers are directed at vectorizing either logos or grayscale images, neither of which I'm too interested in. potrace, whose algorithm is described here, is one of those libraries. Are the same techniques applicable to photo bitmaps ?

I was discouraged by my findings until I stumbled upon Vector Magic. The results are astonishing ! However, they don't provide any information concerning their algorithm. A method that produces similar quality results is described here: http://eprints.gla.ac.uk/47879/1/ID47879.pdf. The strategy is to remove the contours and process them, before drawing them as vectors.

But there is no mention of how they do this. I can extract contours with openCV, but then what ? I have trouble understanding the creation of the vector, or anything that happens after contour extraction.

So, to conclude, here are my questions: which language or library do you recommend for this project ? And do you have any tips on implementing an algorithm that can produce satisfactory results ?

回答1:

Here are a couple of approaches:

  • ARDECO: http://alice.loria.fr/index.php/publications.html?Paper=EGSR_Ardeco@2006
    it casts the problem as an energy minimization problem, that is solved via a Voronoi-like approach

  • http://www.cs.northwestern.edu/~sco590/npar2011.pdf
    it is much more similar in spirit to the portrace you mentioned

  • Using gradient meshes: https://www.cct.lsu.edu/~fharhad/ganbatte/siggraph2007/CD2/content/papers/011-sun.pdf
    that represent the gradients in the image with a mesh

  • Using diffusion curves:
    http://hal.archives-ouvertes.fr/docs/00/27/47/68/PDF/diffusion_curves.pdf
    Mostly used to create art by drawing gradients, they also propose the inverse problem of vectorizing an image with their primitives.