不同于cuda FFT和iFFT后的图像 [英] Not the same image after cuda FFT and iFFT

查看:357
本文介绍了不同于cuda FFT和iFFT后的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用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.

文档


cuFFT执行非归一化FFT;也就是说,对输入数据集合执行正向FFT,随后对结果集合进行逆FFT,产生等于输入的数据,由元素数量缩放。缩放要么通过数据集大小的倒数进行变换,要让用户按照适合的方式执行。

cuFFT performs un-normalized FFTs; that is, performing a forward FFT on an input data set followed by an inverse FFT on the resulting set yields data that is equal to the input, scaled by the number of elements. Scaling either transform by the reciprocal of the size of the data set is left for the user to perform as seen fit.

这篇关于不同于cuda FFT和iFFT后的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆