1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20""" Example script showing Fast Fourier Transform convolution in SimpleITK """
21
22import sys
23import os
24import math
25import SimpleITK as sitk
26
27if len(sys.argv) < 4:
28 print("Usage: FFTConvolution <input> <kernel> <output>")
29 sys.exit(1)
30
31inputFileName = sys.argv[1]
32kernelFileName = sys.argv[2]
33outputFileName = sys.argv[3]
34
35
36
38
39
40
41pixelID = img.GetPixelID()
42
43
45size = img.GetSize()
46
47
49
50
51
53
54
56
57
59stats.Execute(kernel)
60kernel =
sitk.Cast(kernel / stats.GetSum(), sitk.sitkFloat32)
61
62upadding = [0] * 2
63upadding[0] = int(math.floor((size[0] - kernel.GetSize()[0]) / 2.0))
64upadding[1] = int(math.floor((size[1] - kernel.GetSize()[1]) / 2.0))
65
66lpadding = [0] * 2
67lpadding[0] = int(math.ceil((size[0] - kernel.GetSize()[0]) / 2.0))
68lpadding[1] = int(math.ceil((size[1] - kernel.GetSize()[1]) / 2.0))
69
70
72
73
75
76
77fftkernel.SetSpacing(fftimg.GetSpacing())
78fftkernel.SetOrigin(fftimg.GetOrigin())
79fftkernel.SetDirection(fftimg.GetDirection())
80
81
82
84
85
87
88
89
91
92if "SITK_NOSHOW" not in os.environ:
Compute min, max, variance and mean of an Image .
Image Crop(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 InverseFFT(const Image &image1)
Base class for inverse Fast Fourier Transform .
Image FFTShift(const Image &image1, bool inverse=false)
Shift the zero-frequency components of a Fourier transform to the center of the image.
Image ForwardFFT(const Image &image1)
Base class for forward Fast Fourier Transform .
SITKIO_EXPORT Image ReadImage(const PathType &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
Image Flip(const Image &image1, std::vector< bool > flipAxes=std::vector< bool >(3, false), bool flipAboutOrigin=false)
Flips an image across user specified axes.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
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.
SITKIO_EXPORT void WriteImage(const Image &image, const PathType &fileName, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageFileWriter. class which is convenient for many image...
Image Cast(const Image &image, PixelIDValueEnum pixelID)
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.