Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

How is ippDFT length specified?

missing__zlw
Beginner
550 Views
Hi,
In

IppStatus ippgDFTFwd_CToC_32fc(const Ipp32fc*pSrc, Ipp32fc*pDst, intlen, intflag);

IppStatus ippgDFTFwd_CToC_64fc(const Ipp64fc*pSrc, Ipp64fc*pDst, intlen, intflag);

it says :

supported value for : integer in the range [2, 64].


How should I specify the length and theIppsDFTSpec if I have a two dimention array such as 4096*4096?



Thanks.

0 Kudos
10 Replies
Ying_H_Intel
Employee
550 Views
Hello,

the lenmay be 12 (log2(4096)ifarrary is 4096. But the functions ippsDFT_* orippgDFT_* in ipps manual ippsman.pdf aresupposed for 1D signal.

Iffor two dimention array, you may try the function in ippiman.pdf, for example,
IppStatus ippiDFTFwd_CToC_32fc_C1R(). And on the manual, you may refer tothe example
Example 10-2 Fast Fourier Transform of a Complex Imagefor how to specify the DFTSpec. (the usage of FFTSpec and DFTSpecis almost same andit is not need to specify the length)

Regards,
Ying

The function flavors ippgDFTFwd_CToC and ippgDFTFwd_CToC_ compute the
forward DFT of the fixed length. They do not need the DFT specification structure. The length
of transform can be specified by the parameter len, or ...
0 Kudos
missing__zlw
Beginner
550 Views
Thanks for your response. But this is for FFT.
For DFT, what happens if the order of not 2^n. For example, if I want to do DFT on matrix 5*10 of complex numbers, how should I specify the length in both ippiDFTInitAlloc_c_32fc and ippiDFTFwd_CtoC_32fc ?
0 Kudos
missing__zlw
Beginner
550 Views
A follow-up question.
When I tried this, even with small arrays, I got 0 in output.
Did I get the settings wrong?
Ipp32fc* pSrc;
Ipp32fc* pDst;
pSrc = ippsMalloc_32fc(lexn*leny);
pDst = ippsMalloc_32fc(lenx*leny);
for (int i = 0; i < lenx*leny; i++) {
pSrc.re = i;
pSrc.im = 0.0f;
}
IppiDFTSpec_C_32fc *pDFTSpec;
IppStatus status;
IppiSize slen = {lenx, leny};
ippiDFTInitAlloc_C_32fc( &pDFTSpec, slen, IPP_FFT_NODIV_BY_ANY,ippAlgHintAccurate );
status = ippiDFTFwd_CToC_32fc_C1R(pSrc, leny, pDst, leny, pDFTSpec, 0 );
Please help.
0 Kudos
PaulF_IntelCorp
Employee
550 Views
Hello Laura,

I think you need to initialize your pDFTSpec buffer first using the ippiDFTInitAlloc() function. See this excerpt from the image processing documentation:

The function ippiDFTInitAlloc is declared in the ippi.h file. This function allocates memory and initializes the context structure pDFTSpec needed to compute the forward and inverse DFT of a two-dimensional image data.

The ippiDFTFwd and ippiDFTInv functions called with the pointer to the initialized pDFTSpec structure as an argument will compute the discrete Fourier transform for points in the ROI of size roiSize, with results normalization mode set according to flag (see Table Normalization Factors for Fourier Transform Results), and computation algorithm indicated by hint.


Paul
0 Kudos
Ying_H_Intel
Employee
550 Views

Hello zlw,

there are may be some tiny error in the code.

First, (a potentialerror):IppiSize slen = {lenx, leny};

let's suppose that you have 5x10 matrix. Then the "image" width is 10 and the height is 5.
then lenx=10, leny=5;

second, the srcSteps, dstSteps: Distance in bytes between starts of consecutive lines
in theimage.
So status = ippiDFTFwd_CToC_32fc_C1R(pSrc, leny, pDst, leny, pDFTSpec, 0 );
should beat least;
ippiDFTFwd_CToC_32fc_C1R(pSrc, leny*sizeof(Ipp32fc) , pDst, leny*(Ipp32fc), pDFTSpec, 0 );

Note, leny should be the image width, should be slen.width= lenx.

So you may take sure of the two things and make sure what is the input you hoped.

I did a small modification and then the program run ok.

//ippiDFT_test.cpp

#include
#include "ipp.h"

int main()
{

int lenx=5, leny=10; //5x10 matrix
Ipp32fc* pSrc;
Ipp32fc* pDst;
pSrc = ippsMalloc_32fc(lenx*leny);
pDst = ippsMalloc_32fc(lenx*leny);

for (int i = 0; i < lenx*leny; i++) {
pSrc.re = i;
pSrc.im = 0.0f;
}
IppiDFTSpec_C_32fc *pDFTSpec;
IppStatus status;
IppiSize slen = {leny, lenx};
ippiDFTInitAlloc_C_32fc( &pDFTSpec, slen, IPP_FFT_NODIV_BY_ANY, ippAlgHintAccurate );
status = ippiDFTFwd_CToC_32fc_C1R(pSrc, leny*sizeof(Ipp32fc), pDst, leny*sizeof(Ipp32fc), pDFTSpec, 0 );

printf("%d : %s\n", status, ippGetStatusString(status));
printf("%f, %f, %f, %f\n", pDst[0].re, pDst[0].im, pDst[1].re, pDst[1].im);

status = ippiDFTFree_C_32fc(pDFTSpec); // expect ippStsNoErr
printf("%d : %s\n", status, ippGetStatusString(status));
return 0;
}

run result:

0 : ippStsNoErr: No error, it's OK
1225.000000, 0.000000, -25.000000, 76.942093
0 : ippStsNoErr: No error, it's OK
Press any key to continue . . .

Hope it helps.
Ying

0 Kudos
brooke_s_
Beginner
550 Views

Hello,

I used this example to set up my 2D DFT.  It works great for small examples, but when I use it for a real image (1024x1024) I get a stack overflow.  Is there a work around?

Brooke

0 Kudos
SergeyKostrov
Valued Contributor II
550 Views
Try to increase Stack Reserve & Commit values in Linker Settings. Also, it would be nice to see more technical details about IPP version, your system & platform.
0 Kudos
brooke_s_
Beginner
550 Views

Hello,

I am using IPP 7.1 on a Windows 7 machine and using VS 2008 Pro. By updating the linker settings as suggested, I can now run the 2D fft test code in my debugger, but when I compile my image processing library as a dll and call it from my Application (C# GUI) , I still get a stack oferflow error (0xc00000fd) when I try the first 2Dfft.

0 Kudos
SergeyKostrov
Valued Contributor II
550 Views
>>...when I compile my image processing library as a dll and call it from my Application (C# GUI) , I still get a stack oferflow >>error (0xc00000fd) when I try the first 2Dfft... Please try to create a C/C++ test case for the IPP function(s) you use in order to verify that the Stack Overflow problem is Not related to .NET environment.
0 Kudos
SergeyKostrov
Valued Contributor II
550 Views
>>...When I compile that example code into a dll and then call it from my C# GUI... Did you test your function implemented in the DLL with a C/C++ console application ( Not a C# .NET GUI application )?
0 Kudos
Reply