title: OpenCV gpu::dft distorted image after inverse transform
body: <p>I'm working on GPU implementation of frequency filtering of an image. 
  My code works great on CPU (I used something like <a href="https://stackoverflow.com/questions/10269456/inverse-fourier-transformation-in-opencv">this</a>) but I have spent whole day trying to make the same work on GPU - without success. I want to apply a filter in the frequency domain hence I need the full (complex) result of the forward transform.
  I have read that I need to pass two complex matrices (src and dst) to forward dft to obtain full spectrum (32FC2). However, I fail to obtain the same image after inverse transform (the returned image is very distorted).</p>
  
  <p>My code (with the closest result):</p>
  
  <pre><code>gpu.img1 = gpu::GpuMat(vrH, imgWidth, CV_32FC2);
  gpu.img2 = gpu::GpuMat(vrH, imgWidth, CV_32FC2);
  gpu.img4 = gpu::GpuMat(vrH, imgWidth, CV_32FC1);
  gpu.img5 = gpu::GpuMat(vrH, imgWidth, CV_8UC1);
  
  Mat planes[] = {imageIn, Mat::zeros(imageIn.size(), CV_32FC1)};
  merge(planes, 2, imageIn);
  
  gpu::Stream stream; 
  gpu.img1.upload(imageIn);
  
  gpu::dft(gpu.img1, gpu.img2, gpu.img1.size(), 0, stream);
  gpu::dft(gpu.img2, gpu.img4, gpu.img1.size(), DFT_INVERSE | DFT_REAL_OUTPUT | DFT_SCALE, stream);
  stream.enqueueConvert(gpu.img4, gpu.img5, CV_8U);
  
  stream.waitForCompletion();
  gpu.img5.download(imageOut);  
  namedWindow("processed",1); imshow("processed", imageOut); waitKey(1000);
  </code></pre>
  
  <p>Your help and suggestions are much appreciated.</p>