Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1.     def forward_transform(self, matrix):
  2.         """Computes the forward Fourier transform of the input matrix
  3.        takes as input:
  4.        matrix: a 2d matrix
  5.        returns a complex matrix representing fourier transform"""
  6.         print(np.exp( -1*( pow(-1,0.5)*(2*np.pi)/2)*(0*1+0*1) ) )
  7.         width,height=matrix.shape
  8.  
  9.         newMatrix= np.zeros((height,width), dtype=complex)
  10.        
  11.  
  12.         for i in range(width):
  13.  
  14.             for j in range(height):
  15.            
  16.                 for u in range (width):
  17.  
  18.                     for v in range(height):
  19.                      
  20.                       multiple= (i*u+j*v)
  21.                       piPart=(2*np.pi)/width
  22.                       ePart=np.exp(-1j*piPart*multiple)
  23.  
  24.                       newMatrix[i,j]=newMatrix[i,j]+(matrix[u,v]*ePart)
  25.  
  26.         #print(newMatrix)
  27.         #matrix=np.fft.fft2(matrix)
  28.        
  29.        
  30.         return newMatrix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement