Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anyone who can explain the principle of hq2x algorithm?

I do not know the detail steps of hq2x algorithm. Although I have downloaded the source code from website, I still cannot understand the steps from the source code. Can anyone help me to explain how to do the algorithm step by step? Thank you!

like image 513
Xiao_ga Avatar asked Nov 24 '11 06:11

Xiao_ga


1 Answers

It looks at several pixels at once (a central pixel and its neighbors). Uses contrast to divide the group into light and dark pixels (think of it as 1-bit bitmap). Then it uses this to recognize a pattern that these pixels form (e.g. a diagonal line) and outputs a predefined, enlarged version of that pattern, colorized with source pixels.

e.g. if you notice that neighboring pixels form that shape:

X . .
. X .
. . X

then you can output higher-res version of it:

xXXx......
..xXXx....
....xXXx..
......xXXx

The areas for recognizing patterns are overlapping for continuity (or another way to think about it that it looks at more pixels for context, e.g. to distinguish diagonal line from rounded corner).

Because of pattern recognition, hq2x works well only on high-contrast cartoony images. With natural images, with lots of blurry edges and anti-aliased lines the algorithm fails to notice patterns and ends up simply interpolating the image.

like image 66
Kornel Avatar answered Nov 06 '22 17:11

Kornel