1package require vtk
2
3# A script to test the threshold filter.
4# Values above 2000 are set to 255.
5# Values below 2000 are set to 0.
6
7# Image pipeline
8
9vtkImageCanvasSource2D imageCanvas
10imageCanvas SetScalarTypeToUnsignedChar
11imageCanvas SetExtent 0 339 0 339 0 0
12# background black
13imageCanvas SetDrawColor 0
14imageCanvas FillBox 0 511 0 511
15
16# thick box
17imageCanvas SetDrawColor 255
18imageCanvas FillBox 10 110 10 110
19imageCanvas SetDrawColor 0
20imageCanvas FillBox 30 90 30 90
21
22
23# put a stop sign in the box
24imageCanvas SetDrawColor 255
25imageCanvas DrawSegment 52 80 68 80
26imageCanvas DrawSegment 68 80 80 68
27imageCanvas DrawSegment 80 68 80 52
28imageCanvas DrawSegment 80 52 68 40
29imageCanvas DrawSegment 68 40 52 40
30imageCanvas DrawSegment 52 40 40 52
31imageCanvas DrawSegment 40 52 40 68
32imageCanvas DrawSegment 40 68 52 80
33imageCanvas FillPixel 60 60
34
35# diamond
36imageCanvas SetDrawColor 255
37imageCanvas FillTube 145 145 195 195 34
38imageCanvas SetDrawColor 0
39imageCanvas FillTube 165 165 175 175 7
40
41# H
42imageCanvas SetDrawColor 255
43imageCanvas FillBox 230 250 230 330
44imageCanvas FillBox 310 330 230 330
45imageCanvas FillBox 230 330 270 290
46
47# circle
48imageCanvas SetDrawColor 255
49imageCanvas DrawCircle 280 170  50.0
50
51# point as center of circle
52imageCanvas SetDrawColor 255
53imageCanvas DrawPoint 280 170
54
55# lines +
56imageCanvas DrawSegment 60 120 60 220
57imageCanvas DrawSegment 10 170 110 170
58
59# lines X
60imageCanvas DrawSegment 10 230 110 330
61imageCanvas DrawSegment 110 230 10 330
62
63# sloped lines
64imageCanvas DrawSegment 120 230 220 230
65imageCanvas DrawSegment 120 230 220 250
66imageCanvas DrawSegment 120 230 220 270
67imageCanvas DrawSegment 120 230 220 290
68imageCanvas DrawSegment 120 230 220 310
69imageCanvas DrawSegment 120 230 220 330
70imageCanvas DrawSegment 120 230 200 330
71imageCanvas DrawSegment 120 230 180 330
72imageCanvas DrawSegment 120 230 160 330
73imageCanvas DrawSegment 120 230 140 330
74imageCanvas DrawSegment 120 230 120 330
75
76# double thickness lines +
77imageCanvas DrawSegment 120 60 220 60
78imageCanvas DrawSegment 120 61 220 61
79imageCanvas DrawSegment 170 10 170 110
80imageCanvas DrawSegment 171 10 171 110
81
82# lines X
83imageCanvas DrawSegment 230 10 330 110
84imageCanvas DrawSegment 231 10 331 110
85imageCanvas DrawSegment 230 110 330 10
86imageCanvas DrawSegment 231 110 331 10
87
88
89vtkImageSkeleton2D skeleton1
90#skeleton1 BypassOn
91skeleton1 SetInputConnection [imageCanvas GetOutputPort]
92skeleton1 SetPrune 0
93skeleton1 SetNumberOfIterations 20
94skeleton1 ReleaseDataFlagOff
95
96vtkImageClip clip
97clip SetInputConnection [skeleton1 GetOutputPort]
98clip SetOutputWholeExtent 0 120 0 120 0 0
99
100vtkImageMagnify magnify
101magnify SetInputConnection [clip GetOutputPort]
102magnify SetMagnificationFactors 5 5 1
103magnify InterpolateOff
104magnify ReleaseDataFlagOff
105
106vtkImageViewer viewer1
107viewer1 SetInputConnection [imageCanvas GetOutputPort]
108viewer1 SetColorWindow 5
109viewer1 SetColorLevel 1
110
111vtkImageViewer viewer
112#viewer SetInputConnection [magnify GetOutputPort]
113viewer SetInputConnection [skeleton1  GetOutputPort]
114viewer SetColorWindow 5
115viewer SetColorLevel 1
116
117viewer Render
118
119
120
121
122
123
124
125
126