]> Creatis software - bbtk.git/blobdiff - packages/demo/bbs/appli/demoFiltering1.bbs
no message
[bbtk.git] / packages / demo / bbs / appli / demoFiltering1.bbs
index 1be94e23bf1d2608ee6e6c422f347ec3867c482c..8326a39804c5dc587ff65df9c57ff3cddcce63b3 100644 (file)
@@ -1,7 +1,7 @@
 
 
-description "Basic segmentation and filtering of an image : demoFiltering1-try.bbs"
+description "Basic segmentation and filtering of an image"
 author "jpr@creatis.insa-lyon.fr"
 author "jpr@creatis.insa-lyon.fr"
-category "demo"
+category "demo, filter"
 
 // 3 Slices, 2 volumes
 
 
 // 3 Slices, 2 volumes
 
@@ -17,12 +17,81 @@ include wxvtk
 // ----------------------------------------------------------
 
 # Here loads hola.mhd
 // ----------------------------------------------------------
 
 # Here loads hola.mhd
+# -------------------
+# Don't forget to comment out the following 2 lines
+# If you want to check someting else.
+
 include vtk/boxes/bbLoadHola
 new LoadHola reader
 include vtk/boxes/bbLoadHola
 new LoadHola reader
+
 # uncomment next lines to have a file selector
 # uncomment next lines to have a file selector
-#new FileSelector openFileDialog
-#new ImageReader reader
-#  connect openFileDialog.Out reader.In
+# --------------------------------------------
+/*
+new FileSelector openFileDialog
+new ImageReader reader
+  connect openFileDialog.Out reader.In
+*/
+
+# uncomment next lines to use Gimmick
+# -----------------------------------
+/*
+load creaImageIO
+new Gimmick reader
+*/
+
+# uncomment next lines to Read a MHD file (and nothing else !)
+# ------------------------------------------------------------
+/*
+new FileSelector openFileDialog
+new MetaImageReader reader
+   connect openFileDialog.Out reader.In
+*/
+
+# uncomment the following lines to read a 3D images stack
+# (only if file name order is meaningfull)
+# -------------------------------------------------------
+/*
+// To choose the directory
+new DirectorySelector ds
+// To get the image names into a vector
+new FilesFromDirectory fd
+// To read all the files, as a bbitk::ImagePointer
+new ImageSeriesReader reader
+// user choosen directory as input
+connect ds.Out fd.In
+set fd.Recursive false
+// list of files as input
+#print "Files found in $ds.Out$\n
+connect fd.Out reader.FileNames
+*/
+
+# uncomment the following lines to read a 3D images stack
+# (if the directory contains a 'XCoherent" Serie)
+# -------------------------------------------------------
+/*
+// To choose the directory
+new DirectorySelector ds
+// To get the image names into a vector
+new FilesFromDirectory fd
+// user choosen directory as input
+connect ds.Out fd.In 
+// order the files, computes an accurate ZSpacing
+new GetXCoherentInfoGdcmReader reader
+connect fd.Out reader.In
+*/
+
+# uncomment the following lines to read a 3D images stack
+# (with DICOMDirReader)
+# -------------------------------------------------------
+/*
+include itk/boxes/bbDICOMDirReader
+// To choose the directory
+new DirectorySelector ds
+new DICOMDirReader reader
+   connect ds.Out reader.In
+*/
+
+// We need that to set Sliders sizes
 
 #Get image dimensions, ...
 new ImageProperties mc
 
 #Get image dimensions, ...
 new ImageProperties mc
@@ -37,8 +106,8 @@ new GetVectorIntElement gveZ
 new Div div2
   connect   gveZ.Out div2.In1
   set div2.In2 2
 new Div div2
   connect   gveZ.Out div2.In1
   set div2.In2 2
-  
-//  
+
+//
 // Graphical organization
 // ----------------------
 
 // Graphical organization
 // ----------------------
 
@@ -47,16 +116,15 @@ new LayoutSplit mainSplit
   set mainSplit.WinHeight  1000
   set mainSplit.WinWidth   1400
   set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
   set mainSplit.WinHeight  1000
   set mainSplit.WinWidth   1400
   set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
-  
-  
+
    new LayoutSplit splitUp
      set splitUp.Proportion 38
      connect splitUp.Widget  mainSplit.Widget1
    new LayoutSplit splitUp
      set splitUp.Proportion 38
      connect splitUp.Widget  mainSplit.Widget1
-     
+
       new LayoutLine toolLayout
         set toolLayout.Orientation H
         connect toolLayout.Widget splitUp.Widget1
       new LayoutLine toolLayout
         set toolLayout.Orientation H
         connect toolLayout.Widget splitUp.Widget1
-       
+
           new LayoutLine sliderLayout
               set sliderLayout.Orientation V
              connect sliderLayout.Widget toolLayout.Widget1
           new LayoutLine sliderLayout
               set sliderLayout.Orientation V
              connect sliderLayout.Widget toolLayout.Widget1
@@ -65,19 +133,19 @@ new LayoutSplit mainSplit
                     set sliceSlider.Title "Slice"
                     set sliceSlider.ReactiveOnTrack true
                    connect sliceSlider.Widget sliderLayout.Widget1
                     set sliceSlider.Title "Slice"
                     set sliceSlider.ReactiveOnTrack true
                    connect sliceSlider.Widget sliderLayout.Widget1
-                   
+
                  new Slider lowerThresholdSlider
                     set lowerThresholdSlider.Title "LowerThreshold"
                     set lowerThresholdSlider.Max       200
                     set lowerThresholdSlider.In        10
                     set lowerThresholdSlider.ChangeResolution 1
                    connect lowerThresholdSlider.Widget sliderLayout.Widget2
                  new Slider lowerThresholdSlider
                     set lowerThresholdSlider.Title "LowerThreshold"
                     set lowerThresholdSlider.Max       200
                     set lowerThresholdSlider.In        10
                     set lowerThresholdSlider.ChangeResolution 1
                    connect lowerThresholdSlider.Widget sliderLayout.Widget2
-               
+
                  new Slider upperThresholdSlider
                     set upperThresholdSlider.Title "UpperThreshold"
                     set upperThresholdSlider.Max       500
                     set upperThresholdSlider.In        150
                  new Slider upperThresholdSlider
                     set upperThresholdSlider.Title "UpperThreshold"
                     set upperThresholdSlider.Max       500
                     set upperThresholdSlider.In        150
-                    set upperThresholdSlider.ChangeResolution 1     
+                    set upperThresholdSlider.ChangeResolution 1
                    connect upperThresholdSlider.Widget sliderLayout.Widget3
 
                  new Slider smoothSlider
                    connect upperThresholdSlider.Widget sliderLayout.Widget3
 
                  new Slider smoothSlider
@@ -86,77 +154,76 @@ new LayoutSplit mainSplit
                     set smoothSlider.In        3
                     set smoothSlider.ChangeResolution 1
                    connect  smoothSlider.Widget sliderLayout.Widget4
                     set smoothSlider.In        3
                     set smoothSlider.ChangeResolution 1
                    connect  smoothSlider.Widget sliderLayout.Widget4
-                                                                             
+
            new LayoutLine buttonLayout
            new LayoutLine buttonLayout
-              set buttonLayout.Orientation H         
+              set buttonLayout.Orientation H
              connect buttonLayout.Widget toolLayout.Widget2
              connect buttonLayout.Widget toolLayout.Widget2
-             
-              new ColourSelectorButton colourThreshold  
-                 set colourThreshold.In "1 0 0"              
+
+              new ColourSelectorButton colourThreshold
+                 set colourThreshold.In "1 0 0"
                 connect colourThreshold.Widget buttonLayout.Widget1
 
               new ColourSelectorButton colourSmooth
                  set colourSmooth.In "1 1 0"
                 connect colourThreshold.Widget buttonLayout.Widget1
 
               new ColourSelectorButton colourSmooth
                  set colourSmooth.In "1 1 0"
-                connect colourSmooth.Widget buttonLayout.Widget2                
-   
+                connect colourSmooth.Widget buttonLayout.Widget2
 
 
-/*              
+/*
               new CommandButton refresh
                  set refresh.Label "Refresh (to be used once at start time)"
                 connect refresh.Widget buttonLayout.Widget3
               new CommandButton refresh
                  set refresh.Label "Refresh (to be used once at start time)"
                 connect refresh.Widget buttonLayout.Widget3
-*/                                             
+*/
       new LayoutLine layout2D
          set layout2D.Orientation H
          connect layout2D.Widget splitUp.Widget2
 
          new Viewer2D viewer2DImageOriginal
            connect viewer2DImageOriginal.Widget layout2D.Widget1
       new LayoutLine layout2D
          set layout2D.Orientation H
          connect layout2D.Widget splitUp.Widget2
 
          new Viewer2D viewer2DImageOriginal
            connect viewer2DImageOriginal.Widget layout2D.Widget1
-        
-         new Viewer2D viewer2DImageSegmented            
+
+         new Viewer2D viewer2DImageSegmented
            connect viewer2DImageSegmented.Widget layout2D.Widget2
 
            connect viewer2DImageSegmented.Widget layout2D.Widget2
 
-         new Viewer2D viewer2DImageSmooth          
-           connect viewer2DImageSmooth.Widget layout2D.Widget3                             
-  
+         new Viewer2D viewer2DImageSmooth
+           connect viewer2DImageSmooth.Widget layout2D.Widget3
+
    new LayoutSplit layout3D
      set layout3D.Orientation H
      set layout3D.Proportion 90
      connect layout3D.Widget  mainSplit.Widget2
    new LayoutSplit layout3D
      set layout3D.Orientation H
      set layout3D.Proportion 90
      connect layout3D.Widget  mainSplit.Widget2
-     
+
         new LayoutSplit layoutSurfaces
            set layoutSurfaces.Orientation H
            set layoutSurfaces.Proportion 50
           connect layoutSurfaces.Widget layout3D.Widget1
         new LayoutSplit layoutSurfaces
            set layoutSurfaces.Orientation H
            set layoutSurfaces.Proportion 50
           connect layoutSurfaces.Widget layout3D.Widget1
-          
+
            new Viewer3D  viewer3DSurfaceThreshold
           connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
            new Viewer3D  viewer3DSurfaceThreshold
           connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
-          
+
           new Viewer3D  viewer3DSurfaceSmooth
           new Viewer3D  viewer3DSurfaceSmooth
-          connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2                  
-     
+          connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2
+
         new LayoutLine vSliderLayout
           connect vSliderLayout.Widget layout3D.Widget2
         new LayoutLine vSliderLayout
           connect vSliderLayout.Widget layout3D.Widget2
-       
+
            new Slider lowerOpacitySlider
               set lowerOpacitySlider.Title "Opacity"
            new Slider lowerOpacitySlider
               set lowerOpacitySlider.Title "Opacity"
-              set lowerOpacitySlider.Min       1  
+              set lowerOpacitySlider.Min       1
               set lowerOpacitySlider.Max       100
               set lowerOpacitySlider.In        50
               set lowerOpacitySlider.Orientation V
              connect lowerOpacitySlider.Widget vSliderLayout.Widget1
 
               set lowerOpacitySlider.Max       100
               set lowerOpacitySlider.In        50
               set lowerOpacitySlider.Orientation V
              connect lowerOpacitySlider.Widget vSliderLayout.Widget1
 
-/*           
+/*
            new Slider upperOpacitySlider
               set upperOpacitySlider.Title "UpperOpacity"
               set upperOpacitySlider.Max       100
            new Slider upperOpacitySlider
               set upperOpacitySlider.Title "UpperOpacity"
               set upperOpacitySlider.Max       100
-              set upperOpacitySlider.In        100  
-              set upperOpacitySlider.Orientation V                   
+              set upperOpacitySlider.In        100
+              set upperOpacitySlider.Orientation V
              connect upperOpacitySlider.Widget vSliderLayout.Widget2
 */
 
              connect upperOpacitySlider.Widget vSliderLayout.Widget2
 */
 
-//  
+//
 // End of Graphical organization
 // End of Graphical organization
-// ----------------------------- 
+// -----------------------------
 
 //
 // Processing pipeline
 
 //
 // Processing pipeline
@@ -172,27 +239,27 @@ new LayoutSplit mainSplit
   set sliceSlider.ChangeResolution 1
   
 // Images 2D
   set sliceSlider.ChangeResolution 1
   
 // Images 2D
-      
+
  new BinaryThresholdImageFilter threshold
   set threshold.InsideValue 255
   set threshold.OutsideValue 0
  new BinaryThresholdImageFilter threshold
   set threshold.InsideValue 255
   set threshold.OutsideValue 0
-   
+
   connect upperThresholdSlider.Out threshold.UpperThreshold
   connect upperThresholdSlider.Out threshold.UpperThreshold
-  connect lowerThresholdSlider.Out threshold.LowerThreshold  
+  connect lowerThresholdSlider.Out threshold.LowerThreshold
   connect reader.Out threshold.In
   connect reader.Out threshold.In
-  
+
   connect threshold.Out                        viewer2DImageSegmented.In
   connect sliceSlider.Out              viewer2DImageSegmented.Slice
   connect threshold.Out                        viewer2DImageSegmented.In
   connect sliceSlider.Out              viewer2DImageSegmented.Slice
-  
+
 new ImageGaussianSmooth smooth
   connect threshold.Out smooth.In
   connect smoothSlider.Out smooth.StdDevX
   connect smoothSlider.Out smooth.StdDevY
   connect smoothSlider.Out smooth.StdDevZ
 new ImageGaussianSmooth smooth
   connect threshold.Out smooth.In
   connect smoothSlider.Out smooth.StdDevX
   connect smoothSlider.Out smooth.StdDevY
   connect smoothSlider.Out smooth.StdDevZ
-  
+
   connect smooth.Out            viewer2DImageSmooth.In
   connect sliceSlider.Out       viewer2DImageSmooth.Slice
   connect smooth.Out            viewer2DImageSmooth.In
   connect sliceSlider.Out       viewer2DImageSmooth.Slice
+
 
 // Planes
 new ImagePlanes planes
 
 // Planes
 new ImagePlanes planes
@@ -200,16 +267,16 @@ new ImagePlanes planes
   connect planes.PlaneX viewer3DSurfaceSmooth.Obs1
   connect planes.PlaneY viewer3DSurfaceSmooth.Obs2
   connect planes.PlaneZ viewer3DSurfaceSmooth.Obs3
   connect planes.PlaneX viewer3DSurfaceSmooth.Obs1
   connect planes.PlaneY viewer3DSurfaceSmooth.Obs2
   connect planes.PlaneZ viewer3DSurfaceSmooth.Obs3
+
 // Surfaces 3D 
 // Surfaces 3D 
+
 new IsoSurfaceExtractor  isoextractorThreshold
   connect threshold.Out isoextractorThreshold.In
   set isoextractorThreshold.Opacity 1  
   set isoextractorThreshold.Isovalue 100
 new IsoSurfaceExtractor  isoextractorThreshold
   connect threshold.Out isoextractorThreshold.In
   set isoextractorThreshold.Opacity 1  
   set isoextractorThreshold.Isovalue 100
-  connect colourThreshold.Out isoextractorThreshold.Colour  
+  connect colourThreshold.Out isoextractorThreshold.Colour
   connect isoextractorThreshold.Out  viewer3DSurfaceThreshold.In1
   connect isoextractorThreshold.Out  viewer3DSurfaceThreshold.In1
-      
+
 new Div div3
    connect lowerOpacitySlider.Out div3.In1
    set div3.In2 100
 new Div div3
    connect lowerOpacitySlider.Out div3.In1
    set div3.In2 100
@@ -218,13 +285,13 @@ new IsoSurfaceExtractor  isoextractorSmooth
   connect smooth.Out isoextractorSmooth.In
   connect div3.Out isoextractorSmooth.Opacity
   set isoextractorSmooth.Isovalue 200
   connect smooth.Out isoextractorSmooth.In
   connect div3.Out isoextractorSmooth.Opacity
   set isoextractorSmooth.Isovalue 200
-  connect colourSmooth.Out isoextractorSmooth.Colour 
+  connect colourSmooth.Out isoextractorSmooth.Colour
   connect isoextractorSmooth.Out  viewer3DSurfaceSmooth.In2
   connect isoextractorSmooth.Out  viewer3DSurfaceSmooth.In2
-  
-// Refresh issues  
 
 
- new MultipleInputs multInForImageOriginal
-  connect sliceSlider.BoxChange multInForImageOriginal.In1  
+// Refresh issues
+
+new MultipleInputs multInForImageOriginal
+  connect sliceSlider.BoxChange multInForImageOriginal.In1
 #  connect refresh.BoxChange     multInForImageOriginal.In2
 
 
 #  connect refresh.BoxChange     multInForImageOriginal.In2
 
 
@@ -248,19 +315,19 @@ new IsoSurfaceExtractor  isoextractorSmooth
   connect upperThresholdSlider.BoxChange multInForSurfaceThreshold.In4 
 
  new MultipleInputs multInForSurfaceSmooth
   connect upperThresholdSlider.BoxChange multInForSurfaceThreshold.In4 
 
  new MultipleInputs multInForSurfaceSmooth
-#  connect refresh.BoxChange multInForSurfaceSmooth.In1  
-  connect lowerOpacitySlider.BoxChange multInForSurfaceSmooth.In1  
+#  connect refresh.BoxChange multInForSurfaceSmooth.In1
+  connect lowerOpacitySlider.BoxChange multInForSurfaceSmooth.In1
   connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
   connect lowerThresholdSlider.BoxChange multInForSurfaceSmooth.In3
   connect colourSmooth.BoxChange multInForSurfaceSmooth.In2
   connect lowerThresholdSlider.BoxChange multInForSurfaceSmooth.In3
-  connect upperThresholdSlider.BoxChange multInForSurfaceSmooth.In4 
+  connect upperThresholdSlider.BoxChange multInForSurfaceSmooth.In4
   connect smoothSlider.BoxChange         multInForSurfaceSmooth.In5
   connect smoothSlider.BoxChange         multInForSurfaceSmooth.In5
-    
-  connect multInForImageOriginal.BoxChange     viewer2DImageOriginal.BoxExecute  
+
+  connect multInForImageOriginal.BoxChange     viewer2DImageOriginal.BoxExecute
   connect multInForImageSegmented.BoxChange    viewer2DImageSegmented.BoxExecute
   connect multInForImageSmooth.BoxChange       viewer2DImageSmooth.BoxExecute
   connect multInForImageSegmented.BoxChange    viewer2DImageSegmented.BoxExecute
   connect multInForImageSmooth.BoxChange       viewer2DImageSmooth.BoxExecute
-   
-  connect multInForSurfaceThreshold.BoxChange  viewer3DSurfaceThreshold.BoxExecute  
-  connect multInForSurfaceSmooth.BoxChange     viewer3DSurfaceSmooth.BoxExecute 
+
+  connect multInForSurfaceThreshold.BoxChange  viewer3DSurfaceThreshold.BoxExecute
+  connect multInForSurfaceSmooth.BoxChange     viewer3DSurfaceSmooth.BoxExecute