2 description "Basic segmentation and filtering of an image"
3 author "jpr@creatis.insa-lyon.fr"
16 // Get the image and determine Slice number, slider size, ...
17 // ----------------------------------------------------------
20 include vtk/boxes/bbLoadHola
22 # uncomment next lines to have a file selector
23 #new FileSelector openFileDialog
24 #new ImageReader reader
25 # connect openFileDialog.Out reader.In
27 #Get image dimensions, ...
28 new ImageProperties mc
29 connect reader.Out mc.In
31 #Get number of planes (Z)
32 new GetVectorIntElement gveZ
33 connect mc.Size gveZ.In
36 #Compute the number of the 'middle' slice on Z axis
38 connect gveZ.Out div2.In1
42 // Graphical organization
43 // ----------------------
45 new LayoutSplit mainSplit
46 set mainSplit.Proportion 60
47 set mainSplit.WinHeight 1000
48 set mainSplit.WinWidth 1400
49 set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
52 new LayoutSplit splitUp
53 set splitUp.Proportion 38
54 connect splitUp.Widget mainSplit.Widget1
56 new LayoutLine toolLayout
57 set toolLayout.Orientation H
58 connect toolLayout.Widget splitUp.Widget1
60 new LayoutLine sliderLayout
61 set sliderLayout.Orientation V
62 connect sliderLayout.Widget toolLayout.Widget1
64 new Slider sliceSlider
65 set sliceSlider.Title "Slice"
66 set sliceSlider.ReactiveOnTrack true
67 connect sliceSlider.Widget sliderLayout.Widget1
69 new Slider lowerThresholdSlider
70 set lowerThresholdSlider.Title "LowerThreshold"
71 set lowerThresholdSlider.Max 200
72 set lowerThresholdSlider.In 10
73 set lowerThresholdSlider.ChangeResolution 1
74 connect lowerThresholdSlider.Widget sliderLayout.Widget2
76 new Slider upperThresholdSlider
77 set upperThresholdSlider.Title "UpperThreshold"
78 set upperThresholdSlider.Max 500
79 set upperThresholdSlider.In 150
80 set upperThresholdSlider.ChangeResolution 1
81 connect upperThresholdSlider.Widget sliderLayout.Widget3
83 new Slider smoothSlider
84 set smoothSlider.Title "Smooth"
85 set smoothSlider.Max 10
87 set smoothSlider.ChangeResolution 1
88 connect smoothSlider.Widget sliderLayout.Widget4
90 new LayoutLine buttonLayout
91 set buttonLayout.Orientation H
92 connect buttonLayout.Widget toolLayout.Widget2
94 new ColourSelectorButton colourThreshold
95 set colourThreshold.In "1 0 0"
96 connect colourThreshold.Widget buttonLayout.Widget1
98 new ColourSelectorButton colourSmooth
99 set colourSmooth.In "1 1 0"
100 connect colourSmooth.Widget buttonLayout.Widget2
104 new CommandButton refresh
105 set refresh.Label "Refresh (to be used once at start time)"
106 connect refresh.Widget buttonLayout.Widget3
108 new LayoutLine layout2D
109 set layout2D.Orientation H
110 connect layout2D.Widget splitUp.Widget2
112 new Viewer2D viewer2DImageOriginal
113 connect viewer2DImageOriginal.Widget layout2D.Widget1
115 new Viewer2D viewer2DImageSegmented
116 connect viewer2DImageSegmented.Widget layout2D.Widget2
118 new Viewer2D viewer2DImageSmooth
119 connect viewer2DImageSmooth.Widget layout2D.Widget3
121 new LayoutSplit layout3D
122 set layout3D.Orientation H
123 set layout3D.Proportion 90
124 connect layout3D.Widget mainSplit.Widget2
126 new LayoutSplit layoutSurfaces
127 set layoutSurfaces.Orientation H
128 set layoutSurfaces.Proportion 50
129 connect layoutSurfaces.Widget layout3D.Widget1
131 new Viewer3D viewer3DSurfaceThreshold
132 connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
134 new Viewer3D viewer3DSurfaceSmooth
135 connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2
137 new LayoutLine vSliderLayout
138 connect vSliderLayout.Widget layout3D.Widget2
140 new Slider lowerOpacitySlider
141 set lowerOpacitySlider.Title "Opacity"
142 set lowerOpacitySlider.Min 1
143 set lowerOpacitySlider.Max 100
144 set lowerOpacitySlider.In 50
145 set lowerOpacitySlider.Orientation V
146 connect lowerOpacitySlider.Widget vSliderLayout.Widget1
149 new Slider upperOpacitySlider
150 set upperOpacitySlider.Title "UpperOpacity"
151 set upperOpacitySlider.Max 100
152 set upperOpacitySlider.In 100
153 set upperOpacitySlider.Orientation V
154 connect upperOpacitySlider.Widget vSliderLayout.Widget2
158 // End of Graphical organization
159 // -----------------------------
162 // Processing pipeline
163 // -------------------
165 connect reader.Out viewer2DImageOriginal.In
166 connect sliceSlider.Out viewer2DImageOriginal.Slice
168 #Slider size is the number of planes
169 connect gveZ.Out sliceSlider.Max
170 #initial slice is the middle one
171 connect div2.Out sliceSlider.In
172 set sliceSlider.ChangeResolution 1
176 new BinaryThresholdImageFilter threshold
177 set threshold.InsideValue 255
178 set threshold.OutsideValue 0
180 connect upperThresholdSlider.Out threshold.UpperThreshold
181 connect lowerThresholdSlider.Out threshold.LowerThreshold
182 connect reader.Out threshold.In
184 connect threshold.Out viewer2DImageSegmented.In
185 connect sliceSlider.Out viewer2DImageSegmented.Slice
187 new ImageGaussianSmooth smooth
188 connect threshold.Out smooth.In
189 connect smoothSlider.Out smooth.StdDevX
190 connect smoothSlider.Out smooth.StdDevY
191 connect smoothSlider.Out smooth.StdDevZ
193 connect smooth.Out viewer2DImageSmooth.In
194 connect sliceSlider.Out viewer2DImageSmooth.Slice
198 new ImagePlanes planes
199 connect reader.Out planes.In
200 connect planes.PlaneX viewer3DSurfaceSmooth.Obs1
201 connect planes.PlaneY viewer3DSurfaceSmooth.Obs2
202 connect planes.PlaneZ viewer3DSurfaceSmooth.Obs3
206 new IsoSurfaceExtractor isoextractorThreshold
207 connect threshold.Out isoextractorThreshold.In
208 set isoextractorThreshold.Opacity 1
209 set isoextractorThreshold.Isovalue 100
210 connect colourThreshold.Out isoextractorThreshold.Colour
211 connect isoextractorThreshold.Out viewer3DSurfaceThreshold.In1
214 connect lowerOpacitySlider.Out div3.In1
217 new IsoSurfaceExtractor isoextractorSmooth
218 connect smooth.Out isoextractorSmooth.In
219 connect div3.Out isoextractorSmooth.Opacity
220 set isoextractorSmooth.Isovalue 200
221 connect colourSmooth.Out isoextractorSmooth.Colour
222 connect isoextractorSmooth.Out viewer3DSurfaceSmooth.In2
226 new MultipleInputs multInForImageOriginal
227 connect sliceSlider.BoxChange multInForImageOriginal.In1
228 # connect refresh.BoxChange multInForImageOriginal.In2
231 new MultipleInputs multInForImageSegmented
232 connect lowerThresholdSlider.BoxChange multInForImageSegmented.In1
233 connect upperThresholdSlider.BoxChange multInForImageSegmented.In2
234 # connect refresh.BoxChange multInForImageSegmented.In3
235 connect sliceSlider.BoxChange multInForImageSegmented.In4
237 new MultipleInputs multInForImageSmooth
238 connect lowerThresholdSlider.BoxChange multInForImageSmooth.In1
239 connect upperThresholdSlider.BoxChange multInForImageSmooth.In2
240 connect smoothSlider.BoxChange multInForImageSmooth.In3
241 # connect refresh.BoxChange multInForImageSmooth.In4
242 connect sliceSlider.BoxChange multInForImageSmooth.In5
244 new MultipleInputs multInForSurfaceThreshold
245 # connect refresh.BoxChange multInForSurfaceThreshold.In1
246 connect colourThreshold.BoxChange multInForSurfaceThreshold.In2
247 connect lowerThresholdSlider.BoxChange multInForSurfaceThreshold.In3
248 connect upperThresholdSlider.BoxChange multInForSurfaceThreshold.In4
250 new MultipleInputs multInForSurfaceSmooth
251 # connect refresh.BoxChange multInForSurfaceSmooth.In1
252 connect lowerOpacitySlider.BoxChange multInForSurfaceSmooth.In1
253 connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
254 connect lowerThresholdSlider.BoxChange multInForSurfaceSmooth.In3
255 connect upperThresholdSlider.BoxChange multInForSurfaceSmooth.In4
256 connect smoothSlider.BoxChange multInForSurfaceSmooth.In5
258 connect multInForImageOriginal.BoxChange viewer2DImageOriginal.BoxExecute
259 connect multInForImageSegmented.BoxChange viewer2DImageSegmented.BoxExecute
260 connect multInForImageSmooth.BoxChange viewer2DImageSmooth.BoxExecute
262 connect multInForSurfaceThreshold.BoxChange viewer3DSurfaceThreshold.BoxExecute
263 connect multInForSurfaceSmooth.BoxChange viewer3DSurfaceSmooth.BoxExecute