20 from __future__
import print_function
21 from __future__
import division
23 import SimpleITK
as sitk
28 if len ( sys.argv ) < 4:
29 print(
"Usage: FFTConvolution <input> <kernel> <output>" )
33 inputFileName = sys.argv[1]
34 kernelFileName = sys.argv[2]
35 outputFileName = sys.argv[3]
43 pixelID = img.GetPixelID()
63 stats.Execute( kernel )
64 kernel =
sitk.Cast( kernel / stats.GetSum(), sitk.sitkFloat32 )
67 upadding[0] = int( math.floor( (size[0] - kernel.GetSize()[0])/2.0 ) )
68 upadding[1] = int( math.floor( (size[1] - kernel.GetSize()[1])/2.0 ) )
71 lpadding[0] = int( math.ceil( (size[0] - kernel.GetSize()[0])/2.0 ) )
72 lpadding[1] = int( math.ceil( (size[1] - kernel.GetSize()[1])/2.0 ) )
81 fftkernel.SetSpacing( fftimg.GetSpacing() )
82 fftkernel.SetOrigin( fftimg.GetOrigin() )
83 fftkernel.SetDirection( fftimg.GetDirection() )
99 if (
not "SITK_NOSHOW" in os.environ ):