c++ - Inverse FFT in OpenCV gives different result than Matlab -


using opencv, want same result of matlab's ifft2 function. in matlab get:

a = [1 2 0; 4 5 0; 7 8 9; 10 11 12]; inverse = ifft2(a);  inverse =     5.7500 + 0.0000i  -0.1250 + 0.3608i  -0.1250 - 0.3608i   -1.7500 - 2.0000i  -0.3080 + 0.4665i   0.5580 + 0.0335i   -1.2500 + 0.0000i  -0.1250 - 0.2165i  -0.1250 + 0.2165i   -1.7500 + 2.0000i   0.5580 - 0.0335i  -0.3080 - 0.4665i 

in opencv, when do:

cv::mat paddeda; int m = cv::getoptimaldftsize(a.rows); int n = cv::getoptimaldftsize(a.cols);  cv::copymakeborder(a, paddeda, 0, m - a.rows, 0, n - a.cols, cv::border_constant, cv::scalar::all(0)); cv::mat planes[] = { cv::mat_<float>(paddeda), cv::mat::zeros(paddeda.size(), cv_32f) }; cv::mat complexa; cv::merge(planes, 2, complexa);  cv::mat inverse; cv::idft(complexa, inverse, cv::dft_scale | cv::dft_complex_output); 

this gives me:

inverse = [1, -0, 2, -0, 0, -0;      4, -0, 5, -0, 0, -0;      7, -0, 8, -8, 9, 0;      10, -0, 11, -0, 12, -0] 

and type of a cv_32f. how can same result of matlab?

you using 2 different functions. fft optimized version of dft. should use step function in matlab compare results.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -