简体   繁体   English

袖口图像处理

[英]cufft image processing

I inherited an image processing application. 我继承了图像处理应用程序。 Trying to figure things out here. 试图在这里解决问题。 I have three questions. 我有三个问题。 1) Do I have the sequence correct F2C, C2C, C2F? 1)我的序列正确吗?F2C,C2C,C2F? 2) Should I run C2C in one direction once? 2)我应该一次在一个方向上运行C2C吗? 3) Which direction should I use (forward or backward)? 3)我应该使用哪个方向(向前或向后)?

Background: 背景:

The input and output is a 2D image. 输入和输出是2D图像。

First a R2C is done using cufftF2C (cuda off the shelf) Then a C2C is done. 首先使用cufftF2C(现成的cuda)完成R2C,然后完成C2C。 This was hand coded by original developer. 这是由原始开发人员手工编码的。 Finally C2R is done using cufftC2F (cuda off the shelf) 最后,使用cufftC2F(现成的cuda)完成C2R

The result is a great picture only unsightly zig-zag lines appear. 结果是只出现难看的锯齿形线条的好照片。 The original developer used 1D plans (nx = x and batch = y). 原始开发人员使用一维计划(nx = x和批处理= y)。 I want to replace these with 2D plans (nx = x and ny = y). 我想将它们替换为2D计划(nx = x和ny = y)。 I also want to replace the home grown C2C with the cuda off the shelf cufftC2C. 我还想用现成的cuda代替自产的C2C cufftC2C。

1) Do I have the sequence correct [R2C], C2C, [C2R]? 1)我的序列是否正确[R2C],C2C,[C2R]? No, there are two domains in Fourier transform: space and frequency. 不,傅立叶变换有两个域:空间和频率。 A transform goes from space to frequency with CUFFT_FORWARD and frequency to space with CUFFT_INVERSE . 变换从太空进入频率CUFFT_FORWARD和频率与空间CUFFT_INVERSE

2) Should I run C2C in one direction once ? 2)我应该一次在一个方向上运行C2C吗? Depending on the usage of Hermitian symmetry you dont necessarily need C2C (see below). 根据Hermitian对称的用法,您不一定需要C2C (请参阅下文)。

3) Which direction should I use (forward or backward)? 3)我应该使用哪个方向(向前或向后)? If you want to apply an image processing filter, your output is most likely in the same space as your input, hence you have to apply as one forward transformation and one inverse transformation. 如果要应用图像处理滤镜,则输出很可能与输入在同一空间中,因此您必须应用一个正向变换和一个逆向变换。

Notes on data layout and R2C / C2R optimizations 有关数据布局和R2C / C2R优化的说明

When using C2R or R2C transforms, cufft is making use of the Hermitian symmetry of the frequency-space vector, hence solely storing the first half of the vector (the remaining part is not even touched): 当使用C2RR2C转换时, cufft 利用频率空间向量的Hermitian对称性 ,因此仅存储向量的前半部分(其余部分甚至不被触摸):

Apart from the general complex-to-complex (C2C) transform, cuFFT implements efficiently two other types: real-to-complex (R2C) and complex-to-real (C2R). 除了一般的复杂到复杂(C2C)转换之外,cuFFT还有效地实现了另外两种类型:实到复杂(R2C)和复杂到实(C2R)。 In many practical applications the input vector is real-valued. 在许多实际应用中,输入向量是实值。 It can be easily shown that in this case the output satisfies Hermitian symmetry ( X k = XN − k ∗ , where the star denotes complex conjugation). 可以很容易地看出,在这种情况下,输出满足厄米对称性(X k = XN-k ∗,其中星号表示复共轭)。 The converse is also true: for complex-Hermitian input the inverse transform will be purely real-valued. 反之亦然:对于复杂的Hermitian输入,逆变换将是纯实值。 cuFFT takes advantage of this redundancy and works only on the first half of the Hermitian vector. cuFFT利用了这种冗余,仅在Hermitian向量的前半部分起作用。

If the operation you are performing in frequency domain does not have the same Hermitian symmetry, the optimization is not true anymore, and the C2R operation would not provide you the the expected result. 如果您在频域中执行的操作没有相同的Hermitian对称性,那么优化就不再正确,并且C2R操作将无法为您提供预期的结果。

Also note the data requirements and layout of the approach which is a bit different than the one for C2C . 另请注意,此方法的数据要求和布局与C2C的数据要求和布局有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM