Home > front end >  How to convert image in fast fourier transform signal?
How to convert image in fast fourier transform signal?

Time:09-21

I am trying to convert image into fast fourier transform signal and used the following peace of code:

fake_A1 = tf.signal.fft2d(fake_A1)

where input image type is: <class 'numpy.ndarray'> but I am getting following error:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Value for attr 'Tcomplex' of float is not in the list of allowed values: complex64, complex128
; NodeDef: {{node FFT2D}}; Op<name=FFT2D; signature=input:Tcomplex -> output:Tcomplex; attr=Tcomplex:type,default=DT_COMPLEX64,allowed=[DT_COMPLEX64, DT_COMPLEX128]> [Op:FFT2D]

How may I make it solve?

CodePudding user response:

P.S.: If you want to make edits then do it on your question, not as an answer.

Now coming to the topic: 2D FFT of an image. Firstly an image is of shape:

image.shape = (3,rows,columns)

Where 3 stands for 3 matrices which are of 2 dimensions, corresponding to RGB. Hence to carry out 2D FFT, we first need to flatten this by converting it to grayscale. I found a useful tutorial here on Grayscale and FFT plots

Hope this helps.

CodePudding user response:

Instead of tensorflow converter we can replace: fake_A1 = tf.signal.fft2d(fake_A1) to the following code that works for me:

fake_A1 = np.fft.fft2(fake_A1) 
  • Related