1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20""" An example script using SimpleITK's ExtractImageFilter to extact a slice from a 3D image. """
21
22import sys
23import os
24import SimpleITK as sitk
25
26if len(sys.argv) != 4:
27 print(f"Usage: {sys.argv[0]} inputImage sliceNumber outputImage")
28 sys.exit(1)
29
30zslice = int(sys.argv[2])
31
33
34size = list(inputImage.GetSize())
35size[2] = 0
36
37index = [0, 0, zslice]
38
40Extractor.SetSize(size)
41Extractor.SetIndex(index)
42
44
45if "SITK_NOSHOW" not in os.environ:
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...
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
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...