lltcggie / waifu2x-caffe

waifu2xのCaffe版
MIT License
8.06k stars 839 forks source link

Pixel offset/shift when using scaling? #160

Open cyaoeu opened 5 years ago

cyaoeu commented 5 years ago

I made a python script for resizing images (using pillow) then scaling them back again using waifu2x-caffe. I noticed when looping this (resize, waifu2x, resize, waifu2x and so on) that the more iterations there were the more the image would shift diagonally. It seems a bit weird, is this supposed to happen?

Gifs here: https://imgur.com/a/C101TAI

lux-perpetua commented 5 years ago

I've noticed the same behaviour with NGU-AA upscaling algorithm so I presume that it's because of neural-net is trying their best to perform anti-aliasing by detecting and adjusting the edges. Often when scaled back the difference is about ~1px so I suppose it's not a big issue.

nagadomi commented 5 years ago

It is also related to the implementation of the resizing algorithm used. waifu2x is trained with GraphcisMagick(fork of ImageMagick). As far as I remember, IrfanView's lanczos filter is shifted by 0.5px compared to ImageMagick's lanczos filter.