Bilinear upsampling shifts image slightly towards the top-left

  • 1
  • Problem
  • Updated 1 year ago
  • (Edited)
I noticed this while doing some reference testing in Photoshop to compare against my own resampling algorithm.

It appears that when you repeatedly downsample then upsample an image using a filter like bilinear, the image will slowly shift towards the top-left of the canvas. When resampling like this I would of course expect the image to get blurrier, but probably not to shift around, particularly if the contents are perfectly symmetrical. It doesn't occur with nearest neighbour resampling, and seems to be related to the upsample not the downsample.

It's quite easily reproducible (on Photoshop CC 20.0.2) by making a symmetrical image and using an action to repeatedly downsample then upsample to the original size:
  • Create a new 100x100px document
  • Fill the background with mid grey (or any color)
  • Then create a 20x20px white square in the center of the canvas
  • Then flatten so there's only a background layer. 
  • Then create a new action, and hit Record. 
  • Resize the image to 50%, using bilinear resampling. 
  • Resize the image to 200%, using bilinear resampling (should now be back to original size). 
  • Stop recording on that action.
  • Then press play on that action up to 10 times, and you'll see the image get blurrier, and also move further up into the top left of the canvas.
Here's a gif showing the above instructions, trying nearest neighbour first (which is fine), then showing bilinear.
https://imgur.com/a/gKUZwuk
(got a Bad Gateway error when trying to upload directly here)

I found a similar issue reported on another image library, which has apparently since been fixed, suggesting it's indeed a bug in Photoshop and not just something inherent in the upsampling.
https://github.com/python-pillow/Pillow/issues/986

Not really a major deal since no-one is really doing this again and again, but suggests that maybe upsampled images are very slightly shifted, so could be worth looking into for "correctness" reasons :)

Cheers,
Geordie
Photo of geordiemhall

geordiemhall

  • 3 Posts
  • 0 Reply Likes
  • amused

Posted 1 year ago

  • 1

Be the first to post a reply!