CUDA图像旋转

Jam*_*ter 2 cuda image

我在CUDA中实现图像旋转时遇到问题.我有一个非常简单的Rotate函数,其工作方式如下:

__device__ float readPixVal( float* ImgSrc,int ImgWidth,int x,int y)
{
    return (float)ImgSrc[y*ImgWidth+x];
}
__device__ void putPixVal( float* ImgSrc,int ImgWidth,int x,int y, float floatVal)
{
    ImgSrc[y*ImgWidth+x] = floatVal;
}

__global__ void Rotate(float* Source, float* Destination, int sizeX, int sizeY, float deg)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;// Kernel definition
    int j = blockIdx.y * blockDim.y + threadIdx.y;

    if(i < sizeX && j < sizeY)
    {
        putPixVal(Destination, sizeX, ((float)i)*cos(deg) - ((float)j)*sin(deg), ((float)i)*sin(deg) + ((float)j)*cos(deg)), readPixVal(Source, sizeX, i, j));
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是,我不知道如何进行任何插值.利用上述内容,由于整数舍入而跳过许多像素.任何人都知道如何解决这个问题,还是有任何免费/开源实现的图像旋转?我找不到任何CUDA.

Mar*_*ett 5

通常在这种图像处理中,您遍历所有目标像素位置,计算源图像中的相应像素(或插值像素组).

这可以确保您均匀均匀地填充生成的图像,这通常是您关心的.