Jump to content

Hqx: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 6: Line 6:


==Algorithm==
==Algorithm==
First, the color of each of the 8 pixels around the source pixel is compared to the color of the source pixel. Shapes are detected by checking for [[pixel]]s of similar color according to a threshold. This gives total of 2<sup>8</sup>&nbsp;=&nbsp;256 combinations of similar or dissimilar neighbors. To expand the single pixel into a 2×2, 3×3 or 4×4 block of pixels, the arrangement of neighbors is looked up in a predefined table which contains the necessary interpolation patterns.
First, the color of each of the 8 pixels around the source pixel is compared to the color of the source pixel. Shapes are detected by checking for [[pixel]]s of similar color according to a threshold. This gives total of 2<sup>8</sup>&nbsp;=&nbsp;256 combinations of similar or dissimilar neighbors. To expand the single pixel into a 2×2, 3×3, or 4×4 block of pixels, the arrangement of neighbors is looked up in a predefined table which contains the necessary interpolation patterns.


The interpolation data in the lookup tables are constrained by the requirement that continuity of line segments must be preserved, while optimizing for smoothness. Generating these lookup tables is relatively slow, and is the major source of complexity in the algorithm: the render stage is very simple and fast, and designed to be capable of being performed in real time.
The interpolation data in the lookup tables are constrained by the requirement that continuity of line segments must be preserved, while optimizing for smoothness. Generating these lookup tables is relatively slow, and is the major source of complexity in the algorithm: the render stage is very simple and fast, and designed to be capable of being performed in real time.


==External links==
==External links==
*[http://web.archive.org/web/20070703061942/www.hiend3d.com/hq2x.html hq2x], [http://web.archive.org/web/20070703061942/www.hiend3d.com/hq3x.html hq3x] and [http://web.archive.org/web/20070703061942/www.hiend3d.com/hq4x.html hq4x] at HiEnd3D.com (archived copy)
*[http://web.archive.org/web/20070703061942/www.hiend3d.com/hq2x.html hq2x], [http://web.archive.org/web/20070703061942/www.hiend3d.com/hq3x.html hq3x], and [http://web.archive.org/web/20070703061942/www.hiend3d.com/hq4x.html hq4x] at HiEnd3D.com (archived copy)
* [http://code.google.com/p/hqx/ hqx project] at code.google.com
* [http://code.google.com/p/hqx/ hqx project] at code.google.com



Revision as of 02:17, 10 February 2011

In image processing, hqx ("hq" stands for "high quality" and "x" stands for magnification) is one of the pixel art scaling algorithms developed by Maxim Stepin, used in emulators such as Nestopia, bsnes, ZSNES, Snes9x, FCE Ultra and many more. There are 3 hqx filters: hq2x, hq3x, and hq4x, which magnify by factor of 2, 3, and 4 respectively. For other magnification factors, this filter is used with nearest-neighbor scaling. AGS supports hq2x and hq3x scaling filters.

Image enlarged 3× with the nearest-neighbor interpolation
Image enlarged in size by 3× with hq3x algorithm


Algorithm

First, the color of each of the 8 pixels around the source pixel is compared to the color of the source pixel. Shapes are detected by checking for pixels of similar color according to a threshold. This gives total of 28 = 256 combinations of similar or dissimilar neighbors. To expand the single pixel into a 2×2, 3×3, or 4×4 block of pixels, the arrangement of neighbors is looked up in a predefined table which contains the necessary interpolation patterns.

The interpolation data in the lookup tables are constrained by the requirement that continuity of line segments must be preserved, while optimizing for smoothness. Generating these lookup tables is relatively slow, and is the major source of complexity in the algorithm: the render stage is very simple and fast, and designed to be capable of being performed in real time.