Hi,

I wrote code to use the CUDA bilinear interpolation to compute a tranlated version of an image (grayscale) with no integer shifts.

The problem is that the produced interpolated image is of poor quality and even worse when there is no shift

the resulting image is not the same with the initial! For example a pixel with the value 16 becomes 16.25 where it should remain the same.

Any help would be valuable.

My code (most significant part):

texture<float, 2, cudaReadModeElementType> my_tex;

void **global** shift(…,float dx,float dy)

{

…

output[i*Nx+j]=tex2D(texInput,j+dx,i+dy);

}

main()

{

…

Im = image_read(name);//image load

```
cudaArray *input; //2D cuda array to save the image on the device
cudaChannelFormatDesc tex_descriptor = cudaCreateChannelDesc<float>();
cudaMallocArray(&input, &, Nx, Ny);//2D array allocation
cudaMemcpyToArray(input, 0, 0, Im, Nx*Ny*sizeof(float), cudaMemcpyHostToDevice);//copy to image's array
texInput.filterMode = cudaFilterModeLinear;//use bilinear interpolation
texInput.normalized = false;
cudaBindTextureToArray(my_tex,input);
```

…

dim3 dimBlock2(64,64);

dim3 dimGrid2( (Nx + dimBlock2.x - 1) / dimBlock2.x,(Nx + dimBlock2.y - 1) / dimBlock2.y);

shift<<<dimGrid2,dimBlock2>>>(out_dev,Nx,Ny,dx,dy);//kernel execute

…

}