He looks at several pixels at the same time (center pixel and its neighbors). It is used to contrast in order to divide the group into light and dark pixels (think of it as a 1-bit bitmap). He then uses this to recognize the pattern that forms these pixels (for example, a diagonal line), and displays a predefined extended version of this pattern colored by the original pixels.
eg. if you notice that neighboring pixels form this shape:
X . . . X . . . X
then you can output its higher version:
xXXx...... ..xXXx.... ....xXXx.. ......xXXx
Pattern recognition areas overlap for continuity (or another way of thinking about it is that it looks at more pixels for context, for example, to distinguish a diagonal line from a rounded corner).
Due to pattern recognition, hq2x only works well on high-contrast cartoony images. With natural images, with a lot of blurry edges and smooth lines, the algorithm does not notice the patterns and finishes just interpolating the image.
Kornel
source share