问题描述
我想用CUDA对2D图像进行FFT - >斜坡滤波 - > iFFT。首先,作为一个测试,我试图做FFT和iFFt没有任何过滤器。在FFT和iFFT之后,图像看起来是相同的,但是在操作之前,图像像素值在0-255之间,并且在FFT和iFFT之后,图像包含〜10 ^ 7个值。
I'm trying to preform an FFT -> ramp filtering -> iFFT on a 2D image with CUDA. First, as a test I tried to do FFT and iFFt without any filters. After the FFT andthe iFFT the image seems the same, but before the operation the image pixel values were between 0-255 and after the FFT and iFFT the image contains ~10^7 values.
测试图像包含浮点数,尺寸为512 x 360.我使用cuffSinogram函数创建fft,使用cuInversefftSinogram函数创建iFFT。这是我写的两个函数:
The test image contains float numbers, and the dimensions are 512 x 360. I preform the fft with my "cuffSinogram" function, and the iFFT with the "cuInversefftSinogram" function. These are the two function what I wrote:
#define NX 512
#define NY 360
void cufftSinogram(cufftComplex* d_complex_Sinogram, float* d_real_sinogram){
cufftHandle plan;
/* Create a 2D FFT plan. */
if (cufftPlan2d(&plan, NX, NY, CUFFT_R2C) != CUFFT_SUCCESS){
fprintf(stderr, "CUFFT Error: Unable to create plan\n"); return;
}
if (cufftExecR2C(plan, (cufftReal*)d_real_sinogram, d_complex_Sinogram) != CUFFT_SUCCESS){
fprintf(stderr, "CUFFT Error: Unable to execute plan\n"); return;
}
if (cudaDeviceSynchronize() != cudaSuccess){
fprintf(stderr, "Cuda error: Failed to synchronize\n"); return;
}
cufftDestroy(plan);}
void cuInversefftSinogram(float* d_real_sinogram, cufftComplex* d_complex_Sinogram){
cufftHandle plan;
/* Create a 2D FFT plan. */
if (cufftPlan2d(&plan, NX, NY, CUFFT_C2R) != CUFFT_SUCCESS){
fprintf(stderr, "CUFFT Error: Unable to create plan\n"); return;
}
if (cufftExecC2R(plan, d_complex_Sinogram, d_real_sinogram) != CUFFT_SUCCESS){
fprintf(stderr, "CUFFT Error: Unable to execute plan\n"); return;
}
if (cudaDeviceSynchronize() != cudaSuccess){
fprintf(stderr, "Cuda error: Failed to synchronize\n"); return;
}
cufftDestroy(plan);}
和修改的tiff图片可以在找到(我建议,打开与image)
One original and modified tiff image can be found here (I suggest, to open with imageJ)
推荐答案
CUDA FFT-> IFFT序列要求将结果值除以变换中的元素数,if您想要返回原始数据。
CUDA FFT->IFFT sequences require that you divide the resultant values by the number of elements in the transform, if you want to return back to the original data.
从:
这篇关于不同于cuda FFT和iFFT后的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!