Linear Interpolation with Multichannel Pitched Memory ... Do I need cuArray?

Hi,

I have a three channel 24 bit RGB Image, which is stored in simple pitched memory.

My question: Is it possible to do linear interpolation only between R or G or B pixels? Or do I have to use a three channel cuArray for that?

Regards,

Kwyjibo

P.S.: Is it better to use 4 channels instead of 3 for performance? Any experiences?

I understand that you want to find the value of a pixel RGB_i between two other pixels RGB_{i-1}, RGB_{i+1}, depending on the space (x,y) position of RGB_i. Hence the result depends on the 5 values <r,g,b,x,y> for each pixel (indexed i, i-1, i+1).

It depends on how you implement the interpolation. If you use textures and ask the interpolated value with tex2D, you want to use 3 layers (1D array or pitched (2D) array), and ask for each layer the interpolated value and rebuild the resulting pixel (RGB). The computation is done as float (FP32), but you can create half (FP16) textures and use the same tex2D; the computation will be automatically done in float, and then the result back in half. The benefit with half textures is to use twice less memory.

https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#texture-object-api

There is no benefit using RGBA if A is empty or constant; on the contrary, it will use more memory.

You also can use a single array (RGBRGBRGB…), but you need to implement your own interpolation function.