1 # ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 description "Basic segmentation and filtering of an image"
28 author "jpr@creatis.insa-lyon.fr"
29 category "demo, filter"
31 // 3 Slices, 2 volumes
41 // Get the image and determine Slice number, slider size, ...
42 // ----------------------------------------------------------
46 # Don't forget to comment out the following 2 lines
47 # If you want to check someting else.
49 include vtk/boxes/bbLoadHola
52 # uncomment next lines to have a file selector
53 # --------------------------------------------
55 new FileSelector openFileDialog
56 new ImageReader reader
57 connect openFileDialog.Out reader.In
60 # uncomment next lines to use Gimmick
61 # -----------------------------------
67 # uncomment next lines to Read a MHD file (and nothing else !)
68 # ------------------------------------------------------------
70 new FileSelector openFileDialog
71 new MetaImageReader reader
72 connect openFileDialog.Out reader.In
75 # uncomment the following lines to read a 3D images stack
76 # (only if file name order is meaningfull)
77 # -------------------------------------------------------
79 // To choose the directory
80 new DirectorySelector ds
81 // To get the image names into a vector
82 new FilesFromDirectory fd
83 // To read all the files, as a bbitk::ImagePointer
84 new ImageSeriesReader reader
85 // user choosen directory as input
87 set fd.Recursive false
88 // list of files as input
89 #print "Files found in $ds.Out$\n
90 connect fd.Out reader.FileNames
93 # uncomment the following lines to read a 3D images stack
94 # (if the directory contains a 'XCoherent" Serie)
95 # -------------------------------------------------------
97 // To choose the directory
98 new DirectorySelector ds
99 // To get the image names into a vector
100 new FilesFromDirectory fd
101 // user choosen directory as input
103 // order the files, computes an accurate ZSpacing
104 new GetXCoherentInfoGdcmReader reader
105 connect fd.Out reader.In
108 # uncomment the following lines to read a 3D images stack
109 # (with DICOMDirReader)
110 # -------------------------------------------------------
112 include itk/boxes/bbDICOMDirReader
113 // To choose the directory
114 new DirectorySelector ds
115 new DICOMDirReader reader
116 connect ds.Out reader.In
119 // We need that to set Sliders sizes
121 #Get image dimensions, ...
122 new ImageProperties mc
123 connect reader.Out mc.In
125 #Get number of planes (Z)
126 new GetVectorIntElement gveZ
127 connect mc.Size gveZ.In
130 #Compute the number of the 'middle' slice on Z axis
132 connect gveZ.Out div2.In1
136 // Graphical organization
137 // ----------------------
139 new LayoutSplit mainSplit
140 set mainSplit.Proportion 60
141 set mainSplit.WinHeight 1000
142 set mainSplit.WinWidth 1400
143 set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
145 new LayoutSplit splitUp
146 set splitUp.Proportion 38
147 connect splitUp.Widget mainSplit.Widget1
149 new LayoutLine toolLayout
150 set toolLayout.Orientation H
151 connect toolLayout.Widget splitUp.Widget1
153 new LayoutLine sliderLayout
154 set sliderLayout.Orientation V
155 connect sliderLayout.Widget toolLayout.Widget1
157 new Slider sliceSlider
158 set sliceSlider.Title "Slice"
159 set sliceSlider.ReactiveOnTrack true
160 connect sliceSlider.Widget sliderLayout.Widget1
162 new Slider lowerThresholdSlider
163 set lowerThresholdSlider.Title "LowerThreshold"
164 set lowerThresholdSlider.Max 200
165 set lowerThresholdSlider.In 10
166 set lowerThresholdSlider.ChangeResolution 1
167 connect lowerThresholdSlider.Widget sliderLayout.Widget2
169 new Slider upperThresholdSlider
170 set upperThresholdSlider.Title "UpperThreshold"
171 set upperThresholdSlider.Max 500
172 set upperThresholdSlider.In 150
173 set upperThresholdSlider.ChangeResolution 1
174 connect upperThresholdSlider.Widget sliderLayout.Widget3
176 new Slider smoothSlider
177 set smoothSlider.Title "Smooth"
178 set smoothSlider.Max 10
179 set smoothSlider.In 3
180 set smoothSlider.ChangeResolution 1
181 connect smoothSlider.Widget sliderLayout.Widget4
183 new LayoutLine buttonLayout
184 set buttonLayout.Orientation H
185 connect buttonLayout.Widget toolLayout.Widget2
187 new ColourSelectorButton colourThreshold
188 set colourThreshold.In "1 0 0"
189 connect colourThreshold.Widget buttonLayout.Widget1
191 new ColourSelectorButton colourSmooth
192 set colourSmooth.In "1 1 0"
193 connect colourSmooth.Widget buttonLayout.Widget2
196 new CommandButton refresh
197 set refresh.Label "Refresh (to be used once at start time)"
198 connect refresh.Widget buttonLayout.Widget3
200 new LayoutLine layout2D
201 set layout2D.Orientation H
202 connect layout2D.Widget splitUp.Widget2
204 new Viewer2D viewer2DImageOriginal
205 connect viewer2DImageOriginal.Widget layout2D.Widget1
207 new Viewer2D viewer2DImageSegmented
208 connect viewer2DImageSegmented.Widget layout2D.Widget2
210 new Viewer2D viewer2DImageSmooth
211 connect viewer2DImageSmooth.Widget layout2D.Widget3
213 new LayoutSplit layout3D
214 set layout3D.Orientation H
215 set layout3D.Proportion 90
216 connect layout3D.Widget mainSplit.Widget2
218 new LayoutSplit layoutSurfaces
219 set layoutSurfaces.Orientation H
220 set layoutSurfaces.Proportion 50
221 connect layoutSurfaces.Widget layout3D.Widget1
223 new Viewer3D viewer3DSurfaceThreshold
224 connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
226 new Viewer3D viewer3DSurfaceSmooth
227 connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2
229 new LayoutLine vSliderLayout
230 connect vSliderLayout.Widget layout3D.Widget2
232 new Slider lowerOpacitySlider
233 set lowerOpacitySlider.Title "Opacity"
234 set lowerOpacitySlider.Min 1
235 set lowerOpacitySlider.Max 100
236 set lowerOpacitySlider.In 50
237 set lowerOpacitySlider.Orientation V
238 connect lowerOpacitySlider.Widget vSliderLayout.Widget1
241 new Slider upperOpacitySlider
242 set upperOpacitySlider.Title "UpperOpacity"
243 set upperOpacitySlider.Max 100
244 set upperOpacitySlider.In 100
245 set upperOpacitySlider.Orientation V
246 connect upperOpacitySlider.Widget vSliderLayout.Widget2
250 // End of Graphical organization
251 // -----------------------------
254 // Processing pipeline
255 // -------------------
257 connect reader.Out viewer2DImageOriginal.In
258 connect sliceSlider.Out viewer2DImageOriginal.Slice
260 #Slider size is the number of planes
261 connect gveZ.Out sliceSlider.Max
262 #initial slice is the middle one
263 connect div2.Out sliceSlider.In
264 set sliceSlider.ChangeResolution 1
268 new BinaryThresholdImageFilter threshold
269 set threshold.InsideValue 255
270 set threshold.OutsideValue 0
272 connect upperThresholdSlider.Out threshold.UpperThreshold
273 connect lowerThresholdSlider.Out threshold.LowerThreshold
274 connect reader.Out threshold.In
276 connect threshold.Out viewer2DImageSegmented.In
277 connect sliceSlider.Out viewer2DImageSegmented.Slice
279 new ImageGaussianSmooth smooth
280 connect threshold.Out smooth.In
281 connect smoothSlider.Out smooth.StdDevX
282 connect smoothSlider.Out smooth.StdDevY
283 connect smoothSlider.Out smooth.StdDevZ
285 connect smooth.Out viewer2DImageSmooth.In
286 connect sliceSlider.Out viewer2DImageSmooth.Slice
290 new ImagePlanes planes
291 connect reader.Out planes.In
292 connect planes.PlaneX viewer3DSurfaceSmooth.Obs1
293 connect planes.PlaneY viewer3DSurfaceSmooth.Obs2
294 connect planes.PlaneZ viewer3DSurfaceSmooth.Obs3
298 new IsoSurfaceExtractor isoextractorThreshold
299 connect threshold.Out isoextractorThreshold.In
300 set isoextractorThreshold.Opacity 1
301 set isoextractorThreshold.Isovalue 100
302 connect colourThreshold.Out isoextractorThreshold.Colour
303 connect isoextractorThreshold.Out viewer3DSurfaceThreshold.In1
306 connect lowerOpacitySlider.Out div3.In1
309 new IsoSurfaceExtractor isoextractorSmooth
310 connect smooth.Out isoextractorSmooth.In
311 connect div3.Out isoextractorSmooth.Opacity
312 set isoextractorSmooth.Isovalue 200
313 connect colourSmooth.Out isoextractorSmooth.Colour
314 connect isoextractorSmooth.Out viewer3DSurfaceSmooth.In2
318 new MultipleInputs multInForImageOriginal
319 connect sliceSlider.BoxChange multInForImageOriginal.In1
320 # connect refresh.BoxChange multInForImageOriginal.In2
323 new MultipleInputs multInForImageSegmented
324 connect lowerThresholdSlider.BoxChange multInForImageSegmented.In1
325 connect upperThresholdSlider.BoxChange multInForImageSegmented.In2
326 # connect refresh.BoxChange multInForImageSegmented.In3
327 connect sliceSlider.BoxChange multInForImageSegmented.In4
329 new MultipleInputs multInForImageSmooth
330 connect lowerThresholdSlider.BoxChange multInForImageSmooth.In1
331 connect upperThresholdSlider.BoxChange multInForImageSmooth.In2
332 connect smoothSlider.BoxChange multInForImageSmooth.In3
333 # connect refresh.BoxChange multInForImageSmooth.In4
334 connect sliceSlider.BoxChange multInForImageSmooth.In5
336 new MultipleInputs multInForSurfaceThreshold
337 # connect refresh.BoxChange multInForSurfaceThreshold.In1
338 connect colourThreshold.BoxChange multInForSurfaceThreshold.In2
339 connect lowerThresholdSlider.BoxChange multInForSurfaceThreshold.In3
340 connect upperThresholdSlider.BoxChange multInForSurfaceThreshold.In4
342 new MultipleInputs multInForSurfaceSmooth
343 # connect refresh.BoxChange multInForSurfaceSmooth.In1
344 connect lowerOpacitySlider.BoxChange multInForSurfaceSmooth.In1
345 connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
346 connect lowerThresholdSlider.BoxChange multInForSurfaceSmooth.In3
347 connect upperThresholdSlider.BoxChange multInForSurfaceSmooth.In4
348 connect smoothSlider.BoxChange multInForSurfaceSmooth.In5
350 connect multInForImageOriginal.BoxChange viewer2DImageOriginal.BoxExecute
351 connect multInForImageSegmented.BoxChange viewer2DImageSegmented.BoxExecute
352 connect multInForImageSmooth.BoxChange viewer2DImageSmooth.BoxExecute
354 connect multInForSurfaceThreshold.BoxChange viewer3DSurfaceThreshold.BoxExecute
355 connect multInForSurfaceSmooth.BoxChange viewer3DSurfaceSmooth.BoxExecute