waifu2x-caffe icon indicating copy to clipboard operation
waifu2x-caffe copied to clipboard

Pixel offset/shift when using scaling?

Open cyaoeu opened this issue 5 years ago • 2 comments

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

cyaoeu avatar Mar 25 '19 18:03 cyaoeu

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.

lux-perpetua avatar Aug 12 '19 12:08 lux-perpetua

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.

nagadomi avatar Aug 12 '19 17:08 nagadomi