CUDA bicubic or Lanczos image interpolation?

Hi,

do any of you know of implementations of bicubic or Lanczos image interpolation for CUDA? I only need downscaling, and at pretty small resolutions.

Thanks!

I don’t know of any CUDA implementations, but bicubic filtering is possible using just 4 bilinear texture lookups - see “Fast Third-Order Texture Filtering” in GPU Gems 2.

Awright, I’ll write it.

I think I’ll go for Lanczos, but beginning with a bicubic implementation. I’m thinking of doing an “in-place” separated convolution using shared memory, much like the convolutionSeparable sample. My images are small enough to be able to have each block handle one row / one column in each pass.

Here’s what I’m thinking a rescaling from a 4x4 down to 3x3 would look like in memory:

Legend:

I: Input data

_: Useless data

H: Horizontally convolved data

O: Output data, horizontally and vertically convolved

Input array - imgIn_4x4_D:

IIII

IIII

IIII

IIII

After "in-place" horizontal convolution - imgIn_4x4_D:

HHH_

HHH_

HHH_

HHH_

After vertical convolution from imgIn_4x4_D into imgOut_3x3_D:

OOO

OOO

OOO

As the kernel is small, I’m going to try precalculating it and putting it into a symbol, again like in convolutionSeparable.

Hey thanks, I didn’t see your answer until after I’d posted my updated plan. I’ll be checking out the book - thanks!

Edit: Nice, your reply helped with the Google queries. Seems this chapter is actually a published paper? Here’s a couple of articles I’ve found so far, for reference:

http://http.download.nvidia.com/developer/…s2_ch20_SDK.pdf

http://medvis.vrvis.at/fileadmin/publicati…is-2004-053.pdf

For the record, Lanczos interpolation is easy in CUDA and seems pretty efficient. I followed the code on the Wikipedia page about Lanczos resampling: [url=“Lanczos resampling - Wikipedia”]http://en.wikipedia.org/wiki/Lanczos_resampling[/url]

The code sample over at Wikipedia is a bit weird, and I’m not 100% sure it makes 100% sense, but roughly, it’s OK.

To get the same results as the ImageMagick resize function, it looks like you need to do a preblurring step of the source image, looks like a Gaussian blur of Sigma ~1.0-1.3.

I’ll post some code scraps when I’ve cleaned them.