Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fractal image scaling with Python

I am in a position where relatively low resolution images are provided (via an API, higher resolution images are not available) and high resolution images need to be generated.

I've taken a look at PIL and it's just great for about everything... Except scaling up images.

It has the common resizing algorithms:

  • Nearest Neighbor
  • Bilinear
  • Bicubic
  • Anti-aliased

I would like to use Fractal Resizing (as per jeff's post on coding horror), but alas, PIL has no support for this kind of resizing.

Further Google searches yield no alternative libraries to provide fractal image resizing either.

Does such a thing exist or do I really have to buckle down and write my own fractal resizing algorithm?

I'm no expert but from my current vantage point, that looks like a pretty steep learning curve :(

If no such library exists, maybe you have some advice where to learn about fractal compression algorithms?

like image 429
Jiaaro Avatar asked Nov 17 '09 17:11

Jiaaro


3 Answers

There are algorithms, and you're definitely not going to find them in Python. To start with, you can take this paper :

Daniel Glasner, Shai Bagon, and Michal Irani, "Super-Resolution from a Single Image," in Proceedings of the IEEE International Conference on Computer Vision, Kyoto, Japan, 2009.

It is very much state of the art, highly sophisticated, and producing promising results. If you ever make it into a python implementation please release it to the public :)

like image 60
Paul Avatar answered Nov 20 '22 09:11

Paul


Fractal-based image scaling is still quite unusual and hasn't settled down onto one accepted-best algorithm yet. I'm afraid you aren't going to find it in standard image processing libraries yet.

It's also not invariably preferable to bicubic. It can have artefacts which will be undesirable for some kinds of images. For me, Jeff's example image looks a bit weird and unnatural around the sharp edges like the right-hand-side of the nose. Better for some values of ‘better’, sure, but I wouldn't blanket-apply it to all my images.

(This is the case with other ‘advanced’ upscaling techniques, too, including the better-known and more widely-implemented Lanczos/Sinc method.)

like image 2
bobince Avatar answered Nov 20 '22 09:11

bobince


Check out this solution using Residual Dense Networks: https://github.com/idealo/image-super-resolution

Good documentation and rather easy to implement. They even have docker builds and google collab notebooks available. See the docs

like image 1
Createdd Avatar answered Nov 20 '22 10:11

Createdd