Bicubic resampling by Pixel Bender

August 25th, 2009  |  Published in Uncategorized  |  7 Comments

There is bilinear resampling by Pixel Bender already, why not bicubic too?

With the very helpful Java implementation, I can get bicubic resampling running in Pixel Bender in hours.

Here is my result, along with the resampling results in PhotoShop as a comparison:

Source image (4x4), scaled by your browser)

Source image (size 4x4, scaled by your browser)

Source image enlarged in PS (nearest neighbor)

Source image enlarged by PS (nearest neighbor)

Bicubic resampling by Pixel Bender

Bicubic resampling by Pixel Bender

There is some difference with PhotoShop’s versions (below), hope it’s not my mistake…

Bicubic resampling by PhotoShop.

Bicubic resampling by PhotoShop.

Bicubic smoother in PhotoShop

Bicubic smoother by PhotoShop

Bicubic sharper in PhotoShop

Bicubic sharper by PhotoShop

My codes can be downloaded below:
Bicubic resampling sample program source (with PB source)


Update:
Notified by author of the Java version, the Java code was wrong and has been updated. Here below is my updated code:
Bicubic resampling sample program source (with PB source)

updated output of PB

Tags: , ,

Responses

  1. Brian says:

    November 24th, 2009 at 9:13 am (#)

    This filter looks fantastic when upsampling an image, but it is really jagged when downsampling. Any thoughts?

  2. Andy says:

    November 24th, 2009 at 10:00 pm (#)

    The code I ported from is actually designed for up sampling only as the name bicubic interpolation suggests. It is because it takes the nearest four points to calculate the values in between.
    More pixels (>4) are needed for “correct” calculation in high ratio down sampling.

  3. How to resize an image with ActionScript at Jozef Chúťka's blog says:

    January 15th, 2010 at 5:38 pm (#)

    [...] BitmapData, Bitmap, ByteArray, read this article. Continue reading about bilinear resampling and bicubic resampling using pixel [...]

  4. Yoz says:

    January 16th, 2010 at 10:40 pm (#)

    Hi, I have just figured out smoother downscaling
    http://blog.yoz.sk/2010/01/how-to-resize-an-image-with-actionscript/

  5. Paul Breeuwsma says:

    February 26th, 2010 at 5:20 am (#)

    Hi, I wrote the Java implementation and made a mistake: the code didn’t do bicubic interpolation, sorry.
    I fixed it a few days ago. So this code for Pixel Blender is wrong too and also has to be fixed.

  6. Andy says:

    March 1st, 2010 at 2:55 am (#)

    @Paul Breeuwsma Thanks for the info! I’ve just updated the code according to your changes. :)

  7. Paul Breeuwsma says:

    June 21st, 2010 at 8:47 am (#)

    Hi, I changed my code again, already a while ago, the new formula is more smooth than the one used here now. But now, it should be perfect. :)

Leave a Response