- Pixel art scaling algorithms
Pixel art scaling algorithms are
image scaling algorithms specifically designed toupsample (enlarge) low-resolution pixel andline art that contains thin lines, solid areas of colour rather than gradient fills or shading, and has not been anti-aliased.Motivation
Two standard scaling algorithms are bilinear and
bicubic interpolation . Since they work by interpolating pixel colour values, and usually set each pixel to a value interpolated between four input pixel values, they introduce some blur into the output (a form ofbox blur ). Although this is acceptable for continuous-tone images, it destroys contrast (sharp edges) and is often seen as ruining the appearance of line art.Nearest neighbour interpolation preserves these sharp edges, but it introducesjaggies (aliasing that makes diagonal lines and curves look blocky). Thus, the ideal algorithm for enlarging line art would be one that would interpolate areas of continuous tone, preserve the sharpness of orthogonal lines and smooth (ideally with anti-aliasing) diagonal lines and curves. Several attempts have been made to accomplish this.Efficiency
Since a typical application of this technology is improving the appearance of fourth-generation and earlier
video game s on arcade andconsole emulator s, many are designed to run in real time for sufficiently small input images.Many work only on specific scale factors: 2x is the most common, with 3x and 4x also present.
Algorithms
Eagle
Eagle is a library that generically enhances (scales) images, primarily pixel art from old games; the desired result being to make scaled pixel art less "jagged" and "blocky".
Eagle accomplished this as follows: for every in pixel we will generate 4 out pixels, first, set all 4 to the colour of the in pixel we are currently scaling (like nearest neighbor), next lets look at the pixels up and to the left, if they are the same colour as each other set the top right most pixel to that colour, continue doing the same for all four pixels, and then move to the next one [ [http://everything2.com/index.pl?node_id=1859453 Eagle (idea)@Everything2.com] ] .
Assume an in-matrix of 3x3 pixels where the center most pixel is the "current" pixel to be scaled, and an out matrix of 2x2 pixels (that is "this pixel after scaling")
Thus if we have a black pixel on a white background it will vanish. This is a bug in the Eagle algorithm, but is solved by its successors such as 2xSaI and HQ3x.first: |Then . . . -- CC |S T U -- 1 2. C . --/ CC |V C W --/ 3 4. . . |X Y Z
IF V=S=T => 1=S
IF T=U=W => 2=U
IF V=X=Y => 3=X
IF W=Z=Y => 4=Z2xSaI
2xSaI, short for 2x Scale and Interpolation engine, is a
digital image processing algorithm forcomputer graphics . It doubles the images both horizontally and vertically, resulting in a new image with four times as many pixels as the original one. The additional pixels are generated by detecting patterns such as lines and edges and interpolating additional pixels on that basis using techniques such asanti-aliasing and Wu lines.The 2xSaI algorithm was inspired by Eagle. It was designed by Derek Liauw Kie Fa, also known as Kreed, primarily for use in console and computer
emulator s, and it has remained fairly popular in this niche. Many of the most popular emulators, includingZSNES andVisualBoyAdvance , offer this scaling algorithm as a feature.Since Kreed released the source code under the
GNU General Public License , it is freely available to anyone wishing to utilize it in a project released under that license. Developers wishing to use it in a non-GPL project would be required to rewrite the algorithm without using any of Kreed's existing code.uper 2xSaI and Super Eagle
Several slightly different versions of the scaling algorithm are available, and these are often referred to as "Super 2xSaI", "2xSaI", and "Super Eagle".
Super Eagle which is also written by Kreed, is similar to the 2XSaI engine, but does more blending.
Super 2xSaI which is also written by Kreed is a filter which smoothes the graphics, but it blends more than the Super Eagle engine.
hq"n"x family
Maxim Stepin's hq2x, hq3x and hq4x are for scale factors of 2:1, 3:1 and 4:1 respectively. Each works by comparing the colour value of each pixel to those of its eight immediate neighbours, marking the neighbours as close or distant, and using a pregenerated lookup table to find the proper proportion of input pixels' values for each of the 4, 9 or 16 corresponding output pixels. The hq3x family will perfectly smooth any diagonal line whose slope is ±1:2, ±1:1 or ±2:1 and which is not anti-aliased in the input; one with any other slope will alternate between two slopes in the output. It will also smooth very tight curves. Unlike 2xSaI, it anti-aliases the output. [ cite web | last = Stepin | first = Maxim | url = http://www.hiend3d.com/hq3x.html | title = hq3x Magnification Filter | accessdate = 2007-07-03 ]
[
nearest neighbor interpolation ]
hq"n"x was initially created for the Super Nintendo emulatorZSNES .Others
Several similar interpolating graphics engines exist today. These include the open source family of Scale2x, Scale3x and Scale4x technologies (also referred to as AdvMame2x, AdvMame3x or AdvMame4x) developed in 2001 for use in the
AdvanceMAME emulator.Applications to arcade and console emulators
On sufficiently fast hardware, these algorithms allow resizing suitable for real-time applications such as games. These highly optimized algorithms provide sharp, crisp graphics while minimizing blur. Scaling art algorithms have been implemented in a wide range of emulators, 2D
game engine s andgame engine recreation s, for example inAdvanceMAME ,DOSBox andScummVM . They have gained wide recognition with gamers, with whom these technologies have encouraged a revival of the gaming experiences of the '80s and '90s.References
External links
* [http://bob.allegronetwork.com/projects.html Updated version of 2xSaI algorithm with 32bpp support]
* [http://scale2x.sourceforge.net/index.html Scale2x homepage]
* [http://www.hiend3d.com/hq3x.html hq3x project] (Windows utilities available)
Wikimedia Foundation. 2010.