how to use inverse 1D fft when input is real
Hi,
My program is
N=32;
Mat idealLow=Mat::zeros(1,N,CV_32FC1);
int kCutoff = static_cast<int>(N*0.125);
idealLow(Rect(0,0,kCutoff,1))=1;
Rect r(N-kCutoff+1,0,kCutoff-1,1);
idealLow(r)=1;
cout<<idealLow<<endl;
Mat hl,hh;
dft(idealLow,hl,DFT_REAL_OUTPUT|DFT_SCALE|DFT_INVERSE);
cout<<hl<<endl;
Results are
[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]
[0.25, 0.033356179, 0.22217911, -0.045528557, 0.15088835, -0.12785141, 0.066141248, -0.18034062, 0, -0.18034062, -0.029529601, -0.12785141, -0.025888346, -0.045528561, -0.0087907538, 0.033356179, 0, 0.082128763, -0.0087907612, 0.093363985, -0.025888346, 0.080015987, -0.029529598, 0.06485568, 0, 0.064855687, 0.066141255, 0.080015972, 0.15088835, 0.093363985, 0.22217911, 0.082128748]
Results should be 0.21875,0.2022584, 0.1571044,0.0949414 . Results display is inverse transform of [1. 0.9999999 + 0.9999999i 1.0000000 - 1.255D-08i - 2.282D-09 - 2.077D-08i...]. (my arrays but in complex)
In docs it is written :
When DFT_INVERSE is set and the input array is real, or it is complex but DFT_REAL_OUTPUT is set, the output is a real array of the same size as input. The function performs a 1D or 2D inverse transformation of the whole input array or each individual row, depending on the flags DFT_INVERSE and DFT_ROWS.
My question is : How to perfom an inverse dft with an array of real ?
Thanks for your answer
Is your input array actually real, or is it just a real representation of imaginary? IE:
[1,1,1,1,0, ..., 0,1,1,1] or is it
[1+1i, 1+1i, 0, ..., 0+1i, 1+1i]
It's a real array : H(0)=1 H(1)=1 H(2)=1 H(3)=1 H(4)=0... As I said result displayed is inverse transform of [1. 0.9999999 + 0.9999999i I have checked with matlab. But may be I don't understand doc..(Ps I'm not very good in english)