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
172 new CommandButton refresh
173 set refresh.Label "Refresh (to be used once at start time)"
174 connect refresh.Widget buttonLayout.Widget3
176 new LayoutLine layout2D
177 set layout2D.Orientation H
178 connect layout2D.Widget splitUp.Widget2
180 new Viewer2D viewer2DImageOriginal
181 connect viewer2DImageOriginal.Widget layout2D.Widget1
183 new Viewer2D viewer2DImageSegmented
184 connect viewer2DImageSegmented.Widget layout2D.Widget2
186 new Viewer2D viewer2DImageSmooth
187 connect viewer2DImageSmooth.Widget layout2D.Widget3
189 new LayoutSplit layout3D
190 set layout3D.Orientation H
191 set layout3D.Proportion 90
192 connect layout3D.Widget mainSplit.Widget2
194 new LayoutSplit layoutSurfaces
195 set layoutSurfaces.Orientation H
196 set layoutSurfaces.Proportion 50
197 connect layoutSurfaces.Widget layout3D.Widget1
199 new Viewer3D viewer3DSurfaceThreshold
200 connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
202 new Viewer3D viewer3DSurfaceSmooth
203 connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2
205 new LayoutLine vSliderLayout
206 connect vSliderLayout.Widget layout3D.Widget2
208 new Slider lowerOpacitySlider
209 set lowerOpacitySlider.Title "Opacity"
210 set lowerOpacitySlider.Min 1
211 set lowerOpacitySlider.Max 100
212 set lowerOpacitySlider.In 50
213 set lowerOpacitySlider.Orientation V
214 connect lowerOpacitySlider.Widget vSliderLayout.Widget1
217 new Slider upperOpacitySlider
218 set upperOpacitySlider.Title "UpperOpacity"
219 set upperOpacitySlider.Max 100
220 set upperOpacitySlider.In 100
221 set upperOpacitySlider.Orientation V
222 connect upperOpacitySlider.Widget vSliderLayout.Widget2
226 // End of Graphical organization
227 // -----------------------------
230 // Processing pipeline
231 // -------------------
233 connect reader.Out viewer2DImageOriginal.In
234 connect sliceSlider.Out viewer2DImageOriginal.Slice
236 #Slider size is the number of planes
237 connect gveZ.Out sliceSlider.Max
238 #initial slice is the middle one
239 connect div2.Out sliceSlider.In
240 set sliceSlider.ChangeResolution 1
244 new BinaryThresholdImageFilter threshold
245 set threshold.InsideValue 255
246 set threshold.OutsideValue 0
248 connect upperThresholdSlider.Out threshold.UpperThreshold
249 connect lowerThresholdSlider.Out threshold.LowerThreshold
250 connect reader.Out threshold.In
252 connect threshold.Out viewer2DImageSegmented.In
253 connect sliceSlider.Out viewer2DImageSegmented.Slice
255 new ImageGaussianSmooth smooth
256 connect threshold.Out smooth.In
257 connect smoothSlider.Out smooth.StdDevX
258 connect smoothSlider.Out smooth.StdDevY
259 connect smoothSlider.Out smooth.StdDevZ
261 connect smooth.Out viewer2DImageSmooth.In
262 connect sliceSlider.Out viewer2DImageSmooth.Slice
266 new ImagePlanes planes
267 connect reader.Out planes.In
268 connect planes.PlaneX viewer3DSurfaceSmooth.Obs1
269 connect planes.PlaneY viewer3DSurfaceSmooth.Obs2
270 connect planes.PlaneZ viewer3DSurfaceSmooth.Obs3
274 new IsoSurfaceExtractor isoextractorThreshold
275 connect threshold.Out isoextractorThreshold.In
276 set isoextractorThreshold.Opacity 1
277 set isoextractorThreshold.Isovalue 100
278 connect colourThreshold.Out isoextractorThreshold.Colour
279 connect isoextractorThreshold.Out viewer3DSurfaceThreshold.In1
282 connect lowerOpacitySlider.Out div3.In1
285 new IsoSurfaceExtractor isoextractorSmooth
286 connect smooth.Out isoextractorSmooth.In
287 connect div3.Out isoextractorSmooth.Opacity
288 set isoextractorSmooth.Isovalue 200
289 connect colourSmooth.Out isoextractorSmooth.Colour
290 connect isoextractorSmooth.Out viewer3DSurfaceSmooth.In2
294 new MultipleInputs multInForImageOriginal
295 connect sliceSlider.BoxChange multInForImageOriginal.In1
296 # connect refresh.BoxChange multInForImageOriginal.In2
299 new MultipleInputs multInForImageSegmented
300 connect lowerThresholdSlider.BoxChange multInForImageSegmented.In1
301 connect upperThresholdSlider.BoxChange multInForImageSegmented.In2
302 # connect refresh.BoxChange multInForImageSegmented.In3
303 connect sliceSlider.BoxChange multInForImageSegmented.In4
305 new MultipleInputs multInForImageSmooth
306 connect lowerThresholdSlider.BoxChange multInForImageSmooth.In1
307 connect upperThresholdSlider.BoxChange multInForImageSmooth.In2
308 connect smoothSlider.BoxChange multInForImageSmooth.In3
309 # connect refresh.BoxChange multInForImageSmooth.In4
310 connect sliceSlider.BoxChange multInForImageSmooth.In5
312 new MultipleInputs multInForSurfaceThreshold
313 # connect refresh.BoxChange multInForSurfaceThreshold.In1
314 connect colourThreshold.BoxChange multInForSurfaceThreshold.In2
315 connect lowerThresholdSlider.BoxChange multInForSurfaceThreshold.In3
316 connect upperThresholdSlider.BoxChange multInForSurfaceThreshold.In4
318 new MultipleInputs multInForSurfaceSmooth
319 # connect refresh.BoxChange multInForSurfaceSmooth.In1
320 connect lowerOpacitySlider.BoxChange multInForSurfaceSmooth.In1
321 connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
322 connect lowerThresholdSlider.BoxChange multInForSurfaceSmooth.In3
323 connect upperThresholdSlider.BoxChange multInForSurfaceSmooth.In4
324 connect smoothSlider.BoxChange multInForSurfaceSmooth.In5
326 connect multInForImageOriginal.BoxChange viewer2DImageOriginal.BoxExecute
327 connect multInForImageSegmented.BoxChange viewer2DImageSegmented.BoxExecute
328 connect multInForImageSmooth.BoxChange viewer2DImageSmooth.BoxExecute
330 connect multInForSurfaceThreshold.BoxChange viewer3DSurfaceThreshold.BoxExecute
331 connect multInForSurfaceSmooth.BoxChange viewer3DSurfaceSmooth.BoxExecute