Completely black image after inverse DFT on GPU

asked 2014-05-25 20:12:05 -0500

CommanderDJ gravatar image

updated 2014-05-25 20:15:39 -0500

Hello,

I'm doing some image deconvolution using the OpenCV GPU libraries. I successfully perform DFTs on my image and my kernel and then use the mulSpectrums function for the deconvolution. I'm now attempting to recover the deconvolved image so I can write it back out to a file, but the result of doing an inverse DFT on the deconvolved image gives me a completely black image. I've had a look at this question and tried the solutions in there, but alas with no results. The relevant part of my code is as below. If anyone could take a look and help me figure out what I'm doing wrong, that'd be great!

//DFT the image
cout << filepath << ": performing DFT" << endl;
GpuMat dftImageG = GpuMat(Mat::zeros(complexImageG.size(), CV_32FC2));
gpu::dft(complexImageG, dftImageG, dftImageG.size());
complexImageG.release();

GpuMat newKernelG;
newKernelG.upload(tempKernel);

//Perform the deconvolution.
cout << filepath << ": deconvolving" << endl;
gpu::mulSpectrums(dftImageG, newKernelG, dftImageG, 0);
newKernelG.release();

//Perform an inverse DFT to get an image back.
cout << filepath << ": performing inverse DFT" << endl;
GpuMat inverseDFT = GpuMat(Mat::zeros(dftImageG.size(), CV_32FC1));
gpu::dft(dftImageG, inverseDFT, inverseDFT.size(), DFT_REAL_OUTPUT | DFT_SCALE | DFT_INVERSE);
dftImageG.release();

Edit: The kernel is already DFTed, even if it's not shown here.

edit retag flag offensive close merge delete