PixelArt fun

Written by sergio on July 12, 2011 Categories: programación

I recently stumbled upon this neat algorithm by Johannes Kopf and Dani Lischinski. In short, their algorithm takes a pixelart image, such as  those found in 8-bit video games, and produces a new image that somehow makes you think “hey, that looks like what the artist actually had in mind”. In other words, it tries to generate the ideal image for which the pixel art is only an imperfect representation. The results explain it better:

Mario - before, after

Mario from Super Mario Bros 3, using my own implementation. Click to zoom.

If you are interested in this kind of stuff, I really recommend you read their paper, it is well written, easy to understand even for people with no deep knowledge of computer graphics (like myself) or for people with no programming training. I partially implemented their algorithm using Common Lisp and Zach Beane’s Vecto library, here’s a very very short description, just to illustrate the different steps. Some eye-candy at the end!

Finding Vicinities

First, we find which regions of the original image are part of a single feature.

Different regions are found. Notice the blue cross near the center of the image, where we need to decide which diagonal should be kept as part of a single feature

Re-shaping Pixels

Once different regions have been found, pixels are re-shaped so that each region has a well defined contour.

Each pixel is re-shaped to a voronoi cell calculated using the center point of each cell and points defined by its vicinities

Smoothing Edges

Finally, edges are identified …

Edges are identified

Edges are identified

… and smoothed

Smoothing

Smooth edges. Have a look at Mario’s eyes.

Keep in mind that this is only a partial implementation, the original algorithm also re-shapes edges to make them look more natural, reducing zig-zag curves for example. (they also use a different type of curve, b-splines, which works better than what I’m using, catmull rom) and therefore produces much better results. Have a look at their examples in the linked article.

Some Examples!

Click on the images to enlarge

Spartan

Donkey Kong

zelda

karate champ

Captain America and the Avengers

mario kart

mario kart

sagat ftw

 Thanks to Javier Moreno, Norman Garcia and Angie Bloor for their comments.

14 Comments on PixelArt fun

14 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *