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
Usage:
dng view_phase_diff.py <image1> <image2>
6 image1=io.LoadImage(sys.argv[1])
7 image2=io.LoadImage(sys.argv[2])
9 image1=io.LoadImage(
'square.png')
10 image2=io.LoadImage(
'circle.png')
11 if image1.GetExtent() != image2.GetExtent():
12 raise RuntimeError(
'The input images should have the same size.')
13 image1.CenterSpatialOrigin()
14 image2.CenterSpatialOrigin()
17 ex_it=img.ExtentIterator(image1.GetExtent())
18 diff_image=img.CreateImage(image1.GetExtent())
20 phase1=img.Phase(image1.GetComplex(pixel))
21 phase2=img.Phase(image2.GetComplex(pixel))
22 phase_diff=phase1-phase2
23 diff_image.SetReal(pixel,180.0*float(phase_diff)/math.pi)
24 v=gui.CreateDataViewer(diff_image,
"Phase difference (in degrees)")