]> Creatis software - bbtk.git/blob - packages/demo/bbs/appli/demoFiltering1.bbs
3da9435a9ba1f759b32343b6093883ff98b21909
[bbtk.git] / packages / demo / bbs / appli / demoFiltering1.bbs
1
2 description "Basic segmentation and filtering of an image : demoFiltering1-try.bbs"
3 author "jpr@creatis.insa-lyon.fr"
4 category "demo"
5
6 // 3 Slices, 2 volumes
7
8 include std
9 include vtk
10 include wx
11 include itk
12 include itkvtk
13 include wxvtk
14
15 //
16 // Get the image and determine Slice number, slider size, ...
17 // ----------------------------------------------------------
18
19 # Here loads hola.mhd
20 include vtk/boxes/bbLoadHola
21 new LoadHola reader
22 # uncomment next lines to have a file selector
23 #new FileSelector openFileDialog
24 #new ImageReader reader
25 #  connect openFileDialog.Out reader.In
26
27 #Get image dimensions, ...
28 new ImageProperties mc
29    connect reader.Out mc.In
30
31 #Get number of planes  (Z)
32 new GetVectorIntElement gveZ
33    connect mc.Size gveZ.In
34    set gveZ.I 2
35    
36 #Compute the number of the 'middle' slice on Z axis
37 new Div div2
38   connect   gveZ.Out div2.In1
39   set div2.In2 2
40   
41 //  
42 // Graphical organization
43 // ----------------------
44
45 new LayoutSplit mainSplit
46   set mainSplit.Proportion 50
47   set mainSplit.WinHeight  1000
48   set mainSplit.WinWidth   1400
49   set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
50   
51   
52    new LayoutSplit splitUp
53      set splitUp.Proportion 38
54      connect splitUp.Widget  mainSplit.Widget1
55      
56       new LayoutLine toolLayout
57         set toolLayout.Orientation H
58         connect toolLayout.Widget splitUp.Widget1
59         
60            new LayoutLine sliderLayout
61               set sliderLayout.Orientation V
62               connect sliderLayout.Widget toolLayout.Widget1
63
64                  new Slider sliceSlider
65                     set sliceSlider.Title "Slice"
66                     connect sliceSlider.Widget sliderLayout.Widget1
67                     
68                  new Slider lowerThresholdSlider
69                     set lowerThresholdSlider.Title "LowerThreshold"
70                     set lowerThresholdSlider.Max        50
71                     set lowerThresholdSlider.In         20
72                     set lowerThresholdSlider.ChangeResolution 1
73                     connect lowerThresholdSlider.Widget sliderLayout.Widget2
74                 
75                  new Slider upperThresholdSlider
76                     set upperThresholdSlider.Title "UpperThreshold"
77                     set upperThresholdSlider.Max        500
78                     set upperThresholdSlider.In         500
79                     set upperThresholdSlider.ChangeResolution 1     
80                     connect upperThresholdSlider.Widget sliderLayout.Widget3
81
82                  new Slider smoothSlider
83                     set smoothSlider.Title "Smooth"
84                     set smoothSlider.Max        10
85                     set smoothSlider.In         1
86                     set smoothSlider.ChangeResolution 1
87                     connect  smoothSlider.Widget sliderLayout.Widget4
88                                                                               
89            new LayoutLine buttonLayout
90               set buttonLayout.Orientation V          
91               connect buttonLayout.Widget toolLayout.Widget2
92               
93               new ColourSelectorButton colourSmooth
94                  set colourSmooth.In "1 1 0"
95                  connect colourSmooth.Widget buttonLayout.Widget1                
96    
97               new ColourSelectorButton colourThreshold  
98                  set colourThreshold.In "1 0 0"       
99                  connect colourThreshold.Widget buttonLayout.Widget2
100                  
101               new CommandButton refresh
102                  set refresh.Label "Refresh (to be used once at start time)"
103                  connect refresh.Widget buttonLayout.Widget3
104                                                 
105       new LayoutLine layout2D
106          set layout2D.Orientation H
107          connect layout2D.Widget splitUp.Widget2
108
109          new Viewer2D viewer2DImageOriginal
110             connect viewer2DImageOriginal.Widget layout2D.Widget1
111          
112          new Viewer2D viewer2DImageSegmented             
113             connect viewer2DImageSegmented.Widget layout2D.Widget2
114
115          new Viewer2D viewer2DImageSmooth           
116             connect viewer2DImageSmooth.Widget layout2D.Widget3                             
117   
118    new LayoutSplit layout3D
119      set layout3D.Orientation H
120      set layout3D.Proportion 90
121      connect layout3D.Widget  mainSplit.Widget2
122      
123         new LayoutSplit layoutSurfaces
124            set layoutSurfaces.Orientation H
125            set layoutSurfaces.Proportion 50
126            connect layoutSurfaces.Widget layout3D.Widget1
127            
128            new Viewer3D  viewer3DSurfaceThreshold
129            connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
130            
131            new Viewer3D  viewer3DSurfaceSmooth
132            connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2                  
133      
134         new LayoutLine vSliderLayout
135            connect vSliderLayout.Widget layout3D.Widget2
136         
137            new Slider lowerOpacitySlider
138               set lowerOpacitySlider.Title "Opacity"
139               set lowerOpacitySlider.Min        1  
140               set lowerOpacitySlider.Max        100
141               set lowerOpacitySlider.In         20
142               set lowerOpacitySlider.Orientation V
143               connect lowerOpacitySlider.Widget vSliderLayout.Widget1
144
145 /*            
146            new Slider upperOpacitySlider
147               set upperOpacitySlider.Title "UpperOpacity"
148               set upperOpacitySlider.Max        100
149               set upperOpacitySlider.In         100  
150               set upperOpacitySlider.Orientation V                    
151               connect upperOpacitySlider.Widget vSliderLayout.Widget2
152 */
153
154 //  
155 // End of Graphical organization
156 // ----------------------------- 
157
158 //
159 // Processing pipeline
160 // -------------------
161
162   connect reader.Out                    viewer2DImageOriginal.In
163   connect sliceSlider.Out               viewer2DImageOriginal.Slice
164
165   #Slider size is the number of planes
166   connect gveZ.Out     sliceSlider.Max
167   #initial slice is the middle one
168   connect div2.Out sliceSlider.In
169   set sliceSlider.ChangeResolution 1
170   
171 // Images 2D
172       
173  new BinaryThresholdImageFilter threshold
174   set threshold.InsideValue 255
175   set threshold.OutsideValue 0
176    
177   connect upperThresholdSlider.Out threshold.UpperThreshold
178   connect lowerThresholdSlider.Out threshold.LowerThreshold  
179   connect reader.Out threshold.In
180   
181   connect threshold.Out                 viewer2DImageSegmented.In
182   connect sliceSlider.Out               viewer2DImageSegmented.Slice
183   
184 new ImageGaussianSmooth smooth
185   connect threshold.Out smooth.In
186   connect smoothSlider.Out smooth.StdDevX
187   connect smoothSlider.Out smooth.StdDevY
188   connect smoothSlider.Out smooth.StdDevZ
189   
190   connect smooth.Out            viewer2DImageSmooth.In
191   connect sliceSlider.Out       viewer2DImageSmooth.Slice
192  
193  
194 // Surfaces 3D 
195  
196 new IsoSurfaceExtractor  isoextractorThreshold
197   connect threshold.Out isoextractorThreshold.In
198   set isoextractorThreshold.Opacity 1  
199   set isoextractorThreshold.Isovalue 100
200   connect colourThreshold.Out isoextractorThreshold.Colour  
201   connect isoextractorThreshold.Out  viewer3DSurfaceThreshold.In1
202       
203 new Div div3
204    connect lowerOpacitySlider.Out div3.In1
205    set div3.In2 100
206
207 new IsoSurfaceExtractor  isoextractorSmooth
208   connect smooth.Out isoextractorSmooth.In
209   connect div3.Out isoextractorSmooth.Opacity
210   set isoextractorSmooth.Isovalue 200
211   connect colourSmooth.Out isoextractorSmooth.Colour 
212   connect isoextractorSmooth.Out  viewer3DSurfaceSmooth.In2
213   
214 // Refresh issues  
215
216  new MultipleInputs multInForImageOriginal
217   connect sliceSlider.BoxChange multInForImageOriginal.In1  
218   connect refresh.BoxChange     multInForImageOriginal.In2
219   
220  new MultipleInputs multInForImageSegmented
221   connect lowerThresholdSlider.BoxChange multInForImageSegmented.In1
222   connect upperThresholdSlider.BoxChange multInForImageSegmented.In2
223   connect refresh.BoxChange              multInForImageSegmented.In3
224     
225  new MultipleInputs multInForImageSmooth
226   connect lowerThresholdSlider.BoxChange multInForImageSmooth.In1
227   connect upperThresholdSlider.BoxChange multInForImageSmooth.In2 
228   connect smoothSlider.BoxChange         multInForImageSmooth.In3
229   connect lowerOpacitySlider.BoxChange   multInForImageSmooth.In4  
230   connect refresh.BoxChange              multInForImageSmooth.In5
231
232  new MultipleInputs multInForSurfaceThreshold
233   connect refresh.BoxChange multInForSurfaceThreshold.In1
234   connect colourThreshold.BoxChange multInForSurfaceThreshold.In2
235
236  new MultipleInputs multInForSurfaceSmooth
237   connect refresh.BoxChange multInForSurfaceSmooth.In1  
238   connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
239     
240   connect multInForImageOriginal.BoxChange     viewer2DImageOriginal.BoxExecute  
241   connect multInForImageSegmented.BoxChange    viewer2DImageSegmented.BoxExecute
242   connect multInForImageSmooth.BoxChange       viewer2DImageSmooth.BoxExecute
243    
244   connect multInForSurfaceThreshold.BoxChange  viewer3DSurfaceThreshold.BoxExecute  
245   connect multInForSurfaceSmooth.BoxChange     viewer3DSurfaceSmooth.BoxExecute 
246
247  
248
249   exec mainSplit