2 description "Basic segmentation and filtering of an image"
3 author "jpr@creatis.insa-lyon.fr"
4 category "demo, filter"
16 // Get the image and determine Slice number, slider size, ...
17 // ----------------------------------------------------------
21 # Don't forget to comment out the following 2 lines
22 # If you want to check someting else.
24 include vtk/boxes/bbLoadHola
27 # uncomment next lines to have a file selector
28 # --------------------------------------------
30 new FileSelector openFileDialog
31 new ImageReader reader
32 connect openFileDialog.Out reader.In
35 # uncomment next lines to use Gimmick
36 # -----------------------------------
42 # uncomment next lines to Read a MHD file (and nothing else !)
43 # ------------------------------------------------------------
45 new FileSelector openFileDialog
46 new MetaImageReader reader
47 connect openFileDialog.Out reader.In
50 # uncomment the following lines to read a 3D images stack
51 # (only if file name order is meaningfull)
52 # -------------------------------------------------------
54 // To choose the directory
55 new DirectorySelector ds
56 // To get the image names into a vector
57 new FilesFromDirectory fd
58 // To read all the files, as a bbitk::ImagePointer
59 new ImageSeriesReader reader
60 // user choosen directory as input
62 set fd.Recursive false
63 // list of files as input
64 #print "Files found in $ds.Out$\n
65 connect fd.Out reader.FileNames
68 # uncomment the following lines to read a 3D images stack
69 # (if the directory contains a 'XCoherent" Serie)
70 # -------------------------------------------------------
72 // To choose the directory
73 new DirectorySelector ds
74 // To get the image names into a vector
75 new FilesFromDirectory fd
76 // user choosen directory as input
78 // order the files, computes an accurate ZSpacing
79 new GetXCoherentInfoGdcmReader reader
80 connect fd.Out reader.In
83 # uncomment the following lines to read a 3D images stack
84 # (with DICOMDirReader)
85 # -------------------------------------------------------
87 include itk/boxes/bbDICOMDirReader
88 // To choose the directory
89 new DirectorySelector ds
90 new DICOMDirReader reader
91 connect ds.Out reader.In
94 // We need that to set Sliders sizes
96 #Get image dimensions, ...
97 new ImageProperties mc
98 connect reader.Out mc.In
100 #Get number of planes (Z)
101 new GetVectorIntElement gveZ
102 connect mc.Size gveZ.In
105 #Compute the number of the 'middle' slice on Z axis
107 connect gveZ.Out div2.In1
111 // Graphical organization
112 // ----------------------
114 new LayoutSplit mainSplit
115 set mainSplit.Proportion 60
116 set mainSplit.WinHeight 1000
117 set mainSplit.WinWidth 1400
118 set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
120 new LayoutSplit splitUp
121 set splitUp.Proportion 38
122 connect splitUp.Widget mainSplit.Widget1
124 new LayoutLine toolLayout
125 set toolLayout.Orientation H
126 connect toolLayout.Widget splitUp.Widget1
128 new LayoutLine sliderLayout
129 set sliderLayout.Orientation V
130 connect sliderLayout.Widget toolLayout.Widget1
132 new Slider sliceSlider
133 set sliceSlider.Title "Slice"
134 set sliceSlider.ReactiveOnTrack true
135 connect sliceSlider.Widget sliderLayout.Widget1
137 new Slider lowerThresholdSlider
138 set lowerThresholdSlider.Title "LowerThreshold"
139 set lowerThresholdSlider.Max 200
140 set lowerThresholdSlider.In 10
141 set lowerThresholdSlider.ChangeResolution 1
142 connect lowerThresholdSlider.Widget sliderLayout.Widget2
144 new Slider upperThresholdSlider
145 set upperThresholdSlider.Title "UpperThreshold"
146 set upperThresholdSlider.Max 500
147 set upperThresholdSlider.In 150
148 set upperThresholdSlider.ChangeResolution 1
149 connect upperThresholdSlider.Widget sliderLayout.Widget3
151 new Slider smoothSlider
152 set smoothSlider.Title "Smooth"
153 set smoothSlider.Max 10
154 set smoothSlider.In 3
155 set smoothSlider.ChangeResolution 1
156 connect smoothSlider.Widget sliderLayout.Widget4
158 new LayoutLine buttonLayout
159 set buttonLayout.Orientation H
160 connect buttonLayout.Widget toolLayout.Widget2
162 new ColourSelectorButton colourThreshold
163 set colourThreshold.In "1 0 0"
164 connect colourThreshold.Widget buttonLayout.Widget1
166 new ColourSelectorButton colourSmooth
167 set colourSmooth.In "1 1 0"
168 connect colourSmooth.Widget buttonLayout.Widget2
171 new CommandButton refresh
172 set refresh.Label "Refresh (to be used once at start time)"
173 connect refresh.Widget buttonLayout.Widget3
175 new LayoutLine layout2D
176 set layout2D.Orientation H
177 connect layout2D.Widget splitUp.Widget2
179 new Viewer2D viewer2DImageOriginal
180 connect viewer2DImageOriginal.Widget layout2D.Widget1
182 new Viewer2D viewer2DImageSegmented
183 connect viewer2DImageSegmented.Widget layout2D.Widget2
185 new Viewer2D viewer2DImageSmooth
186 connect viewer2DImageSmooth.Widget layout2D.Widget3
188 new LayoutSplit layout3D
189 set layout3D.Orientation H
190 set layout3D.Proportion 90
191 connect layout3D.Widget mainSplit.Widget2
193 new LayoutSplit layoutSurfaces
194 set layoutSurfaces.Orientation H
195 set layoutSurfaces.Proportion 50
196 connect layoutSurfaces.Widget layout3D.Widget1
198 new Viewer3D viewer3DSurfaceThreshold
199 connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
201 new Viewer3D viewer3DSurfaceSmooth
202 connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2
204 new LayoutLine vSliderLayout
205 connect vSliderLayout.Widget layout3D.Widget2
207 new Slider lowerOpacitySlider
208 set lowerOpacitySlider.Title "Opacity"
209 set lowerOpacitySlider.Min 1
210 set lowerOpacitySlider.Max 100
211 set lowerOpacitySlider.In 50
212 set lowerOpacitySlider.Orientation V
213 connect lowerOpacitySlider.Widget vSliderLayout.Widget1
216 new Slider upperOpacitySlider
217 set upperOpacitySlider.Title "UpperOpacity"
218 set upperOpacitySlider.Max 100
219 set upperOpacitySlider.In 100
220 set upperOpacitySlider.Orientation V
221 connect upperOpacitySlider.Widget vSliderLayout.Widget2
225 // End of Graphical organization
226 // -----------------------------
229 // Processing pipeline
230 // -------------------
232 connect reader.Out viewer2DImageOriginal.In
233 connect sliceSlider.Out viewer2DImageOriginal.Slice
235 #Slider size is the number of planes
236 connect gveZ.Out sliceSlider.Max
237 #initial slice is the middle one
238 connect div2.Out sliceSlider.In
239 set sliceSlider.ChangeResolution 1
243 new BinaryThresholdImageFilter threshold
244 set threshold.InsideValue 255
245 set threshold.OutsideValue 0
247 connect upperThresholdSlider.Out threshold.UpperThreshold
248 connect lowerThresholdSlider.Out threshold.LowerThreshold
249 connect reader.Out threshold.In
251 connect threshold.Out viewer2DImageSegmented.In
252 connect sliceSlider.Out viewer2DImageSegmented.Slice
254 new ImageGaussianSmooth smooth
255 connect threshold.Out smooth.In
256 connect smoothSlider.Out smooth.StdDevX
257 connect smoothSlider.Out smooth.StdDevY
258 connect smoothSlider.Out smooth.StdDevZ
260 connect smooth.Out viewer2DImageSmooth.In
261 connect sliceSlider.Out viewer2DImageSmooth.Slice
265 new ImagePlanes planes
266 connect reader.Out planes.In
267 connect planes.PlaneX viewer3DSurfaceSmooth.Obs1
268 connect planes.PlaneY viewer3DSurfaceSmooth.Obs2
269 connect planes.PlaneZ viewer3DSurfaceSmooth.Obs3
273 new IsoSurfaceExtractor isoextractorThreshold
274 connect threshold.Out isoextractorThreshold.In
275 set isoextractorThreshold.Opacity 1
276 set isoextractorThreshold.Isovalue 100
277 connect colourThreshold.Out isoextractorThreshold.Colour
278 connect isoextractorThreshold.Out viewer3DSurfaceThreshold.In1
281 connect lowerOpacitySlider.Out div3.In1
284 new IsoSurfaceExtractor isoextractorSmooth
285 connect smooth.Out isoextractorSmooth.In
286 connect div3.Out isoextractorSmooth.Opacity
287 set isoextractorSmooth.Isovalue 200
288 connect colourSmooth.Out isoextractorSmooth.Colour
289 connect isoextractorSmooth.Out viewer3DSurfaceSmooth.In2
293 new MultipleInputs multInForImageOriginal
294 connect sliceSlider.BoxChange multInForImageOriginal.In1
295 # connect refresh.BoxChange multInForImageOriginal.In2
298 new MultipleInputs multInForImageSegmented
299 connect lowerThresholdSlider.BoxChange multInForImageSegmented.In1
300 connect upperThresholdSlider.BoxChange multInForImageSegmented.In2
301 # connect refresh.BoxChange multInForImageSegmented.In3
302 connect sliceSlider.BoxChange multInForImageSegmented.In4
304 new MultipleInputs multInForImageSmooth
305 connect lowerThresholdSlider.BoxChange multInForImageSmooth.In1
306 connect upperThresholdSlider.BoxChange multInForImageSmooth.In2
307 connect smoothSlider.BoxChange multInForImageSmooth.In3
308 # connect refresh.BoxChange multInForImageSmooth.In4
309 connect sliceSlider.BoxChange multInForImageSmooth.In5
311 new MultipleInputs multInForSurfaceThreshold
312 # connect refresh.BoxChange multInForSurfaceThreshold.In1
313 connect colourThreshold.BoxChange multInForSurfaceThreshold.In2
314 connect lowerThresholdSlider.BoxChange multInForSurfaceThreshold.In3
315 connect upperThresholdSlider.BoxChange multInForSurfaceThreshold.In4
317 new MultipleInputs multInForSurfaceSmooth
318 # connect refresh.BoxChange multInForSurfaceSmooth.In1
319 connect lowerOpacitySlider.BoxChange multInForSurfaceSmooth.In1
320 connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
321 connect lowerThresholdSlider.BoxChange multInForSurfaceSmooth.In3
322 connect upperThresholdSlider.BoxChange multInForSurfaceSmooth.In4
323 connect smoothSlider.BoxChange multInForSurfaceSmooth.In5
325 connect multInForImageOriginal.BoxChange viewer2DImageOriginal.BoxExecute
326 connect multInForImageSegmented.BoxChange viewer2DImageSegmented.BoxExecute
327 connect multInForImageSmooth.BoxChange viewer2DImageSmooth.BoxExecute
329 connect multInForSurfaceThreshold.BoxChange viewer3DSurfaceThreshold.BoxExecute
330 connect multInForSurfaceSmooth.BoxChange viewer3DSurfaceSmooth.BoxExecute