Applying a Fourier Transform to an image
An image is Fourier-transformed using the alg.FFT() algorithm object:
#imports from ost.io import LoadImage from ost.img.alg import FFT from iplt.gui import Viewer #Load the image im=LoadImage("FILENAME.tif") # load the image # create an instance of the fft algorithm object fft=FFT() # do the actual Fourier transformation im_ft=im.Apply(fft) # back-transform im2 = im_ft.Apply(fft) # if this is run from within giplt, open viewers to look at the images Viewer(im) Viewer(im_ft) Viewer(im2)
It is not really necessary to create the fft instance, a temporary object can be used, since the alg.FFT algorithm object is stateless. In addition, the algorithm can be applied in-place to avoid the creation of a second image:
#imports from ost.io import LoadImage from ost.img.alg import FFT #Load the image im=LoadImage("FILENAME.tif") # load the image # do the actual Fourier transformation, in-place using temporary object im.ApplyIP(FFT()) # repeating this command will do the back-transform im.ApplyIP(FFT())
Please note that the FFT() algorithm does not require a direction to be given, this is implicitly determined by the underlying image state: a SPATIAL image will always be transformed to the FREQUENCY domain, and vice-versa.
back to Tutorials
