Ask Your Question

polycarbonate's profile - activity

2019-10-09 06:36:04 -0600 received badge  Popular Question (source)
2015-12-24 07:15:06 -0600 commented answer Meaning of cv::idft() with DFT_REAL_OUTPUT option

My example also uses 2ch mat like you. i.e. notSym is 2ch.

In your example, idft(im,imx) is equal to idft(im,imx, cv::DFT_COMPLEX_OUTPUT);. And no wonder the result has complex component, because I can get the same result by following a basic signal textbook.

My question is about the result of idft(im, imx, cv::DFT_REAL_OUTPUT). the result has only real component: [17, 15, 1, -1; 16, 16, 0, -0; -1, 1, -1, 1; 0, -0, 0, -0]

I would like to know the meaning of this and how to reproduce the result.

2015-12-23 17:33:50 -0600 received badge  Editor (source)
2015-12-23 10:21:10 -0600 received badge  Student (source)
2015-12-23 05:22:50 -0600 asked a question Meaning of cv::idft() with DFT_REAL_OUTPUT option

I would like to ask about cv::idft() with DFT_REAL_OUTPUT for non-symmetric matrix. Let me explain in detail.

If an input matrix in time domain has only real component, dft of the input matrix has some kind of symmetric structure. For example,

const int width = 4;
const int height = 4;
cv::Mat in1ch = (cv::Mat_<double>(width, height)
    << 1.0, 0.2, 0.4, 0.5,
    0.4, 0.3, 0.2, 0.1,
    0.5, 0.7, 0.3, 0.8,
    0.2, 0.9, 0.8, 0.1
    );

// dfted: dft result of in1ch
// [7.4      0.4-0.6i  0.2       0.4+0.6i;
//  -0.2+i   1-0.6i    1.4-0.2i  -0.2-i;
//  1.4      1.2+1.4i  -0.2      1.2-1.4i;
//  -0.2-i   -0.2+i    1.4+0.2i  1+0.6i]
cv::Mat dfted;
cv::dft(in1ch, dfted, DFT_COMPLEX_OUTPUT);

And the idft result of the symmetric matrix will have only real component.

// idfted: idft result of dfted
// it is the same with in1ch
cv::Mat idfted;
cv::idft(dfted, idfted, DFT_REAL_OUTPUT | DFT_SCALE);

On the contrary, the idft result of a non-symmetric matrix will have real and imaginary component. However, if I give a non-symmetric matrix to cv::idft() with DFT_REAL_OUTPUT, I get a matrix having only real component.

// notSym: non-symmetric matrix which is almost the same with dfted
// [7.4      1.3+0.2i  0.2       0.4+0.6i;
//  -0.2+i   1-0.6i    1.4-0.2i  -0.2-i;
//  1.4      1.2+1.4i  -0.2      0.4+i;
//  -0.2-i   -0.2+i    1.4+0.2i  1+0.6i]
cv::Mat notSym = dfted.clone();
notSym.at<cv::Vec2f>(0, 1) = cv::Vec2f(1.3, 0.2);
notSym.at<cv::Vec2f>(2, 3) = cv::Vec2f(0.4, 1.0);

// idfted2:
// [1.1125  0.1  0.2875  0.6
//  0.5125  0.2  0.0875  0.2
//  0.6125  0.6  0.1875  0.9
//  0.3125  0.8  0.6875  0.2]
cv::Mat idfted2;
cv::idft(notSym, idfted2, DFT_REAL_OUTPUT | DFT_SCALE);

Here are the questions:

  • Q1. To apply cv::idft() for non-symmetric matrix Is a meaningful procedure? If so, what is the meaning of the result?
  • Q2. What is an implementation of cv::idft() with DFT_REAL_OUTPUT? Is there some reference?