ScaleNx

Scale2x and Scale3x image scaling in Python

Scale2x and Scale3x algorithms (sometimes referred to as AdvMAME2x and AdvMAME3x) were initially developed by Andrea Mazzoleni for scaling up graphics like game sprites and icons without introducing new colors and blurring contrast edges. That's what it was invented for, and nothing else.

However, I came up with idea that Scale2x and Scale3x may be successfully misused for absolutely different task: scaling up low-res text scans before OCR, and drawings before tracing them to vectors.

So I created pure Python implementation of Scale2x and Scale3x, which can be downloaded from GitHub. By saying «pure Python» I mean it - it doesn't even use bytearrays, only lists of lists of lists. Consider it a spiritual practice or whatever. You can download it as «IncScaleNx.py» module to import into other software and/or just to laugh at it. Anyway, below is the illustration of Scale3x interpolation of small black and white text, twice. As you can see, Scale3x interpolation is quite unusual and absolutely different from nearest neighbour, bilinear and bicubic you know from Photoshop - it tries to keep image sharp and pays attention to diagonals.

Downloadable pack at GitHub includes Python sources for Scale2x and Scale3x command line versions, GUI versions thereof, and batch-processing GUI programs for scaling up all PNG files in a directory (recursively) with either Scale2x or Scale3x. If you want Scale4x or even bigger X, just run Scale2x twice in a row, and so on.


Upd: - Batch Scale2x and Scale3x programs turned to multiprocessing. On my 4 logical, i. e. 2 real CPU notebook it approximately halves total processing time. There is a price though - at 100 % CPU load interface becomes somewhat unresponsive and program looks like hung up (not responding and eating all the power) - don't worry, it is not, it just tries to run as fast as possible and have no time to talk about it. So it makes sense to download updated exe from most recent release.


Proceed to ScaleNx at GitHub for downloads.


Move back to main page.