Ask Your Question

Revision history [back]

You have to use a Mat with two channels like this :

int main(int ac, char** av) 
{
    Mat im(4,4,CV_32FC2);
    im.at<Vec2f>(0, 0) = Vec2f(4,0);
    im.at<Vec2f>(0, 1) = Vec2f(2,-2);
    im.at<Vec2f>(0, 2) = Vec2f(0,0);
    im.at<Vec2f>(0, 3) = Vec2f(2,2);

    im.at<Vec2f>(1, 0) = Vec2f(2,-2);
    im.at<Vec2f>(1, 1) = Vec2f(0,-2);
    im.at<Vec2f>(1, 2) = Vec2f(0,0);
    im.at<Vec2f>(1, 3) = Vec2f(2,0);

    im.at<Vec2f>(2, 0) = Vec2f(0,0);
    im.at<Vec2f>(2, 1) = Vec2f(0,0);
    im.at<Vec2f>(2, 2) = Vec2f(0,0);
    im.at<Vec2f>(2, 3) = Vec2f(0,0);

    im.at<Vec2f>(3, 0) = Vec2f(2,2);
    im.at<Vec2f>(3, 1) = Vec2f(2,0);
    im.at<Vec2f>(3, 2) = Vec2f(1,0);
    im.at<Vec2f>(3, 3) = Vec2f(0,3);

cout<<im<<endl;

Mat imx;
idft(im,imx);
cout<<imx<<endl;
return 0;
}

You have to use a Mat with two channels like this :: non hermitian symmetric

4.          2. - 2.i    0     2. + 2.i  
2. - 2.i  - 2.i         0     2.        
0           0           0     0         
2. + 2.i    2.          1.    3.i       


17. + i      16.    1. - i    - 2.   
17. - i      16.  - 1. - i      2.i  
- 1. - i       0    - 1. + i      2.   
- 1. + i       0      1. + i    - 2.i

and program is

int main(int ac, char** av) 
{
    Mat im(4,4,CV_32FC2);
    im.at<Vec2f>(0, 0) = Vec2f(4,0);
    im.at<Vec2f>(0, 1) = Vec2f(2,-2);
    im.at<Vec2f>(0, 2) = Vec2f(0,0);
    im.at<Vec2f>(0, 3) = Vec2f(2,2);

    im.at<Vec2f>(1, 0) = Vec2f(2,-2);
    im.at<Vec2f>(1, 1) = Vec2f(0,-2);
    im.at<Vec2f>(1, 2) = Vec2f(0,0);
    im.at<Vec2f>(1, 3) = Vec2f(2,0);

    im.at<Vec2f>(2, 0) = Vec2f(0,0);
    im.at<Vec2f>(2, 1) = Vec2f(0,0);
    im.at<Vec2f>(2, 2) = Vec2f(0,0);
    im.at<Vec2f>(2, 3) = Vec2f(0,0);

    im.at<Vec2f>(3, 0) = Vec2f(2,2);
    im.at<Vec2f>(3, 1) = Vec2f(2,0);
    im.at<Vec2f>(3, 2) = Vec2f(1,0);
    im.at<Vec2f>(3, 3) = Vec2f(0,3);

cout<<im<<endl;

Mat imx;
idft(im,imx);
cout<<imx<<endl;
return 0;
}