20 """ Example script showing Fast Fourier Transform convolution in SimpleITK """
25 import SimpleITK
as sitk
28 print(
"Usage: FFTConvolution <input> <kernel> <output>")
31 inputFileName = sys.argv[1]
32 kernelFileName = sys.argv[2]
33 outputFileName = sys.argv[3]
41 pixelID = img.GetPixelID()
60 kernel =
sitk.Cast(kernel / stats.GetSum(), sitk.sitkFloat32)
63 upadding[0] = int(math.floor((size[0] - kernel.GetSize()[0]) / 2.0))
64 upadding[1] = int(math.floor((size[1] - kernel.GetSize()[1]) / 2.0))
67 lpadding[0] = int(math.ceil((size[0] - kernel.GetSize()[0]) / 2.0))
68 lpadding[1] = int(math.ceil((size[1] - kernel.GetSize()[1]) / 2.0))
77 fftkernel.SetSpacing(fftimg.GetSpacing())
78 fftkernel.SetOrigin(fftimg.GetOrigin())
79 fftkernel.SetDirection(fftimg.GetDirection())
86 img =
sitk.Crop(img, [128] * 2, [128] * 2)
92 if "SITK_NOSHOW" not in os.environ:
Compute min, max, variance and mean of an Image .
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
Image Cast(const Image &image, PixelIDValueEnum pixelID)
Image Crop(const Image &image1, std::vector< unsigned int > lowerBoundaryCropSize=std::vector< unsigned int >(3, 0), std::vector< unsigned int > upperBoundaryCropSize=std::vector< unsigned int >(3, 0))
Decrease the image size by cropping the image by an itk::Size at both the upper and lower bounds of t...
Image Flip(const Image &image1, std::vector< bool > flipAxes=std::vector< bool >(3, false), bool flipAboutOrigin=false)
Flips an image across user specified axes.
Image ForwardFFT(const Image &image1)
Base class for forward Fast Fourier Transform .
Image InverseFFT(const Image &image1)
Base class for inverse Fast Fourier Transform .
SITKIO_EXPORT void WriteImage(const Image &image, const std::vector< PathType > &fileNames, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageSeriesWriter. class which is convenient for many ima...
Image MirrorPad(const Image &image1, std::vector< unsigned int > padLowerBound=std::vector< unsigned int >(3, 0), std::vector< unsigned int > padUpperBound=std::vector< unsigned int >(3, 0), double decayBase=1.0)
Increase the image size by padding with replicants of the input image value.
Image ConstantPad(const Image &image1, std::vector< unsigned int > padLowerBound=std::vector< unsigned int >(3, 0), std::vector< unsigned int > padUpperBound=std::vector< unsigned int >(3, 0), double constant=0.0)
Increase the image size by padding with a constant value.
Image FFTShift(const Image &image1, bool inverse=false)
Shift the zero-frequency components of a Fourier transform to the center of the image.
SITKIO_EXPORT Image ReadImage(const std::vector< PathType > &fileNames, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image...