View Fourier Transform

Usage

giplt view_phase_difference.py <image1> <image2> 0

Description

This scripts displays the phase difference (in degrees) between corresponding pixels in the Fourier Transforms of the two input images, which must be of the same size. The Fourier Transforms honor the origin of the reference system, which is assumed to be at the center of the two images.

Script

import sys
import math

image1=LoadImage(sys.argv[1])
image2=LoadImage(sys.argv[2])
if image1.GetExtent != image2.GetExtent():
  print 'Error: The input images should have the same size.'
  print sys.exit(0)
image1.CenterSpatialOrigin()
image2.CenterSpatialOrigin()
image1.ApplyIP(alg.DFT())
image2.ApplyIP(alg.DFT())
ex_it=ExtentIterator(image1.GetExtent())
diff_image=CreateImage(image1.GetExtent())
for pixel in ex_it:
  phase1=Phase(image1.GetComplex(pixel))
  phase2=Phase(image2.GetComplex(pixel))
  phase_diff=phase1-phase2
  diff_image.SetReal(pixel,180.0*float(phase_diff)/math.pi)
v=Viewer(diff_image)
v.SetName("Phase difference (in degrees)")

Attachments