I am new in OpenCV and image processing algorithms. I need to do inverse discrete fourier transformation in OpenCV in C++, but I don't know how. I searched over internet and I didn't find answer. I am doing fourier transformation in my program with this code from this page: http://opencv.itseez.com/doc/tutorials/core/discrete_fourier_transform/discrete_fourier_transform.html. I have tried to do inverse to that code, but I don't know where I am doing wrong. My code is here (I think that whole code is wrong):
void doFourierInverse(const Mat &src, Mat &dst) {
normalize(src, dst, 0, -1, CV_MINMAX);
int cx = dst.cols/2;
int cy = dst.rows/2;
Mat q0(dst, Rect(0, 0, cx, cy));
Mat q1(dst, Rect(cx, 0, cx, cy));
Mat q2(dst, Rect(0, cy, cx, cy));
Mat q3(dst, Rect(cx, cy, cx, cy));
Mat tmp;
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp);
q2.copyTo(q1);
tmp.copyTo(q2);
dst = dst(Rect(0, 0, dst.cols & -2, dst.rows & -2));
exp(dst, dst);
dst -= Scalar::all(1);
Mat planes[2];
polarToCart(dst, Mat::zeros(dst.rows, dst.cols, dst.type()), planes[0], planes[1]);
merge(planes, 2, dst);
idft(dst, dst, DFT_INVERSE | DFT_SCALE);
split(dst, planes);
dst = planes[0];
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…