Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I see the problem. You need to put in a second channel of 0. When you have a one channel matrix, I thinks it's in a packed CSS format. You need to specify that the imaginary components are zero. So here's the altered code. Change CV_32FC1 to CV_32FC2 and it works.

N=32;
Mat idealLow=Mat::zeros(1,N,CV_32FC2);
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;