我在CUDA中實現圖像旋轉時遇到了問題。我有一個非常簡單的旋轉功能的工作如下:CUDA Image Rotation
__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));
}
}
的問題是,我不知道該怎麼做任何的插值。通過以上,由於整數舍入,許多像素被跳過。任何人都知道如何解決這個問題,或者是否有任何圖像旋轉的免費/開源實現?我找不到任何CUDA。
請記住,該顯卡擁有圖形管線做旋轉和其它線性變換快速的硬件。爲了利用它,使用CUDA來實現OpenGL或DirectX互操作性。 – 2012-03-23 03:43:34