python - 2D fft - Null imaginary part -


i integrating python routine c++ code.

there computation of fft 2d of real matrix, using in python

f_blk=np.fft.fft2(blk) 

f_blk complex 512*24 matrix, coefficients complex real , imag part order of magnitude 10e5.

when compute fft2 of matrix in c++ complex matrix complex coefficients with real part order of magnitude 10e6 , null imaginary part.

  • what mean if fft2 has got null imaginary part ?
  • what possible sources such wrong results ?
  • would recommend 1 library in c++ computing fft2 ?

  1. if use real input fft

    • then not need have calculations ( c += r * c simpler c += c * c)
    • so if have fft c = f(r) coded such input data faster
    • then standard fft c= f(c)
    • and not need have allocated memory input imaginary part
    • also when input data real fft output symmetric
    • so can compute first half of output data , mirror rest
  2. the magnitude difference

    • either have wrong implementation of fft (in python or in c++)
    • or have different normalization coefficients
    • plot data , compare if difference constant scale factor
    • if not have bug in fft implementation somewhere or python fft not fft
    • also not forget data size fft must power of 2
    • if implementation expects cause of error
    • so try resize matrix 512x24 512x32 0 padding before fft
    • another thing can cause can overflow errors
    • if mix huge , small numbers accuracy lost
    • especially fft recursions output magnitude can 10e5 subresults can much bigger !!!
  3. 2d fft

    • look here 2d fft,dct 1d fft,dct
    • it contains slow 1d dft,idft implementations in c++ (r->c,c->r)
    • and algorithm how compute 2d transforms it
    • with correct results can check yours

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -