Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
Fourier Transfrom ScriptThe below script is used to import an image or .fits file and produce the 2D Fourier Transformation.import pyfitsimport numpy as np import pylab as py import os from PIL import Image def imageImport() : #Function to call image files# #Changes current directory to one of users input# os.chdir('C:/Users/Ryan/Dropbox/Major Project/python/') #Imports a picture image# importImage = Image.open('sun.jpg').convert('L') imageArray = np.asarray(importImage) ''' #Import a fits file (requires pyfits)# image = pyfits.getdata('Dragonfly2_light.fit') ''' #functions for fourtier transform and plotting# iF = imageFourier(imageArray) plotTransform(iF, imageArray) def imageFourier(imageArray) : #Function to provide a Fourier Transform of inputted image file# #2d fourier transform# fourierTransform = np.fft.fft2(imageArray) #centre frequency spectrum# fourierShift = np.fft.fftshift(fourierTransform ) #take absolute values squared# fourierArray = np.abs(fourierShift)**2 #return the final array# return fourierArray def plotTransform(f, imageArray) : #Function to provide plots# py.figure(1) py.clf()
py.imshow(imageArray)
py.figure(2) py.clf() py.imshow(np.log(f)) py.show() imageImport()
Below is the sunflower galaxy, Image used from here
|