1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20""" An example script showing how to modify the tags of a DICOM image with SimpleITK. """
21
22import sys
23import time
24import SimpleITK as sitk
25
26if len(sys.argv) < 3:
27 print("Usage: python " + __file__ + " <input_image> <output_image>")
28 sys.exit(1)
29
30
32
33
35
36
37
38
39
40
41
42
43
44
45
46
47all_keys = image.GetMetaDataKeys()
48for key in all_keys:
49 mean_image.SetMetaData(key, image.GetMetaData(key))
50mean_image.SetMetaData("0008|0008", "DERIVED\\SECONDARY")
51modification_time = time.strftime("%H%M%S")
52modification_date = time.strftime("%Y%m%d")
53mean_image.SetMetaData("0008|0031", modification_time)
54mean_image.SetMetaData("0008|0021", modification_date)
55
57
58
59
60
61
62
63
65if (
66 modified_image.GetMetaData("0008|0008").replace(" ", "") != "DERIVED\\SECONDARY"
67 or modified_image.GetMetaData("0008|0031") != modification_time
68 or modified_image.GetMetaData("0008|0021") != modification_date
69):
70 sys.exit(1)
71
72sys.exit(0)
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 BoxMean(const Image &image1, std::vector< unsigned int > radius=std::vector< unsigned int >(3, 1))
Implements a fast rectangular mean filter using the accumulator approach.
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...