Pixel-art scaling algorithms

This results in graphics that rely on a high amount of stylized visual cues to define complex shapes.

These specialized algorithms can improve the appearance of pixel-art graphics, but in doing so they introduce changes.

Since a typical application of this technology is improving the appearance of fourth-generation and earlier video games on arcade and console emulators, many pixel art scaling algorithms are designed to run in real-time for sufficiently small input images at 60-frames per second.

This places constraints on the type of programming techniques that can be used for this sort of real-time processing.

Eric's Pixel Expansion (EPX) is an algorithm developed by Eric Johnston at LucasArts around 1992, when porting the SCUMM engine games from the IBM PC (which ran at 320 × 200 × 256 colors) to the early color Macintosh computers, which ran at more or less double that resolution.

Later implementations of this same algorithm (as AdvMAME2× and Scale2×, developed around 2001) are slightly more efficient but functionally identical: AdvMAME2× is available in DOSBox via the scaler=advmame2x dosbox.conf option.

It was designed by Derek Liauw Kie Fa, also known as Kreed, primarily for use in console and computer emulators, and it has remained fairly popular in this niche.

Many of the most popular emulators, including ZSNES and VisualBoyAdvance, offer this scaling algorithm as a feature.

The constants colorMask, lowPixelMask, qColorMask, qLowPixelMask, redBlueMask, and greenMask are 16-bit masks.

The 2xSaI arbitrary scaler can enlarge any image to any resolution and uses bilinear filtering to interpolate pixels.

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.

[15] However, it goes further than HQx by using a 2-stage set of interpolation rules, which better handle more complex patterns such as anti-aliased lines and curves.

Scaled background textures keep the sharp characteristics of the original image, rather than becoming blurred like HQx (often ScaleHQ in practice) tends to do.

[17] It uses the same basic idea as xBR's pattern recognition and interpolation but with a different rule set designed to preserve fine image details as small as a few pixels.

xBRZ is optimized for multi-core CPUs and 64-bit architectures and shows 40–60% better performance than HQx even when running on a single CPU core only.

It works in two passes and can only scale an image by two (or multiples of two by reapplying it and also has an anti-ringing filter).

It produces far fewer artifacts than nearest-neighbor rotation algorithms, and like EPX, it does not introduce new colors into the image (unlike most interpolation systems).

It then (optionally) calculates what rotation offset to use by favoring sampled points that are not boundary pixels.

[25] Edge-directed interpolation (EDI) describes upscaling techniques that use statistical sampling to ensure the quality of an image as it is scaled up.

[26][27] There were several earlier methods that involved detecting edges to generate blending weights for linear interpolation or classifying pixels according to their neighbor conditions and using different otherwise isotropic interpolation schemes based on the classification.

[28] EDIUpsizer[29] is a resampling filter that resizes an image by a factor of two both horizontally and vertically using NEDI (new edge-directed interpolation).

These include condition number testing and adaptive window size,[30] as well as capping constraints.

Works by minimizing a cost function involving every pixel in a scan line.

It is intended for edge-directed interpolation for deinterlacing (i.e. not made for resizing a normal image, but can do that as well).

Both the size of the network and the neighborhood it examines can be tuned for a speed-quality tradeoff:[35]This is a quality vs speed option; however, differences are usually small between the number of neurons for a specific resize factor, however the performance difference between the count of neurons becomes larger as you quadruple the image size.

Sprite of a television set (center) resized using simple nearest-neighbor scaling (left) and the 2xSaI interpolation algorithm (right)
Comparison of common pixel art scaling algorithms. View in full resolution to see the differences.
EPX can be used to scale bitmap fonts. From top to bottom: a) original font size; b) nearest-neighbor 2× scaling; c) EPX 2× scaling; d) nearest-neighbor 3× scaling; e) EPX 3× scaling.
The matrix of surrounding pixels that Super2xSaI uses to scale a single pixel
Left: Original pixel art image
Middle: Image rotated using nearest-neighbor rotation algorithm
Right: Image rotated using RotSprite algorithm