1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20""" A SimpleITK example demonstrating various image grid manipulation
21 techniques. """
22
23import sys
24import SimpleITK as sitk
25
26if len(sys.argv) < 3:
27 print("Usage: " + sys.argv[0] + " <input-1> <input-2>")
28 sys.exit(1)
29
32
33
35joined_image = join.Execute(image_1, image_2)
36
37
39select.SetOutputPixelType(sitk.sitkUInt8)
40
41select.SetIndex(0)
42channel1_image = select.Execute(joined_image)
43select.SetIndex(1)
44channel2_image = select.Execute(joined_image)
45select.SetIndex(2)
46channel3_image = select.Execute(joined_image)
47
48
50composed_image = compose.Execute(channel1_image, channel2_image, channel3_image)
51
52
53sliced_image = composed_image[10:40, 10:40, 0]
54
55
57extract.SetSize([30, 30, 0])
58extract.SetIndex([10, 10, 0])
59extracted_image = extract.Execute(composed_image)
60
61
62
63
65crop.SetLowerBoundaryCropSize([10, 10, 0])
66crop.SetUpperBoundaryCropSize(
67 [composed_image.GetWidth() - 40, composed_image.GetHeight() - 40, 1]
68)
69cropped_image = crop.Execute(composed_image)
70
71
72print(f"Sliced image size: {sliced_image.GetWidth()}x{sliced_image.GetHeight()}x{sliced_image.GetDepth()}")
73print(f"Extracted image size: {extracted_image.GetWidth()}x{extracted_image.GetHeight()}x{extracted_image.GetDepth()}")
74print(f"Cropped image size: {cropped_image.GetWidth()}x{cropped_image.GetHeight()}x{cropped_image.GetDepth()}")
ComposeImageFilter combine several scalar images into a multicomponent image.
Decrease the image size by cropping the image by an itk::Size at both the upper and lower bounds of t...
Join N-D images into an (N+1)-D image.
Extracts the selected index of the vector that is the input pixel type.
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...