1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20""" An example script demonstrating boarder segmentation in SimpleITK. """
21
22import sys
23import os
24import SimpleITK as sitk
25
26
27if len(sys.argv) != 5:
28 sys.stderr.write("Usage: {sys.argv[0]} inputFile outputFile replaceValue upperThreshold\n")
29 sys.exit(1)
30
31
32inputFileName = sys.argv[1]
33outputFileName = sys.argv[2]
34replaceValue = int(sys.argv[3])
35upperThreshold = float(sys.argv[4])
36
37
39
40
42
44
45
47
48boundary =
sitk.Cast(boundary, image.GetPixelID())
49
50
51
52
53image = image * ~boundary
54
55
56image = image + (boundary * replaceValue)
57
58if "SITK_NOSHOW" not in os.environ:
Image BinaryMorphologicalClosing(const Image &image1, std::vector< unsigned int > kernelRadius=std::vector< uint32_t >(3, 1), KernelEnum kernelType=itk::simple::sitkBall, double foregroundValue=1.0, bool safeBorder=true)
binary morphological closing of an image.
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 BinaryGrindPeak(const Image &image1, bool fullyConnected=false, double foregroundValue=1.0, double backgroundValue=0)
Remove the objects not connected to the boundary of the image.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
Image BinaryThreshold(Image &&image1, double lowerThreshold=0.0, double upperThreshold=255.0, uint8_t insideValue=1u, uint8_t outsideValue=0u)
Binarize an input image by thresholding.
Image Cast(const Image &image, PixelIDValueEnum pixelID)