-description "Basic segmentation and filtering of an image"
+
+description "Basic segmentation and filtering of an image : demoFiltering1-try.bbs"
author "jpr@creatis.insa-lyon.fr"
category "demo"
include itkvtk
include wxvtk
+//
+// Get the image and determine Slice number, slider size, ...
+// ----------------------------------------------------------
+
# Here loads hola.mhd
include vtk/boxes/bbLoadHola
new LoadHola reader
#Get image dimensions, ...
new ImageProperties mc
connect reader.Out mc.In
-
+
#Get number of planes (Z)
new GetVectorIntElement gveZ
connect mc.Size gveZ.In
connect gveZ.Out div2.In1
set div2.In2 2
-#---------------------------------------------------------------------
+//
+// Graphical organization
+// ----------------------
-new Slider sliceSider
- set sliceSider.Title "Slice"
-
- #Slider size is the number of planes
- connect gveZ.Out sliceSider.Max
- #initial slice is the middle one
- connect div2.Out sliceSider.In
- set sliceSider.ChangeResolution 1
-
-new Slider lowerThresholdSlider
- set lowerThresholdSlider.Title "LowerThreshold"
- set lowerThresholdSlider.Max 50
- set lowerThresholdSlider.In 20
- set lowerThresholdSlider.ChangeResolution 1
-
-new Slider lowerOpacitySlider
- set lowerOpacitySlider.Title "LowerOpacity"
- set lowerOpacitySlider.Max 100
- set lowerOpacitySlider.In 20
- set lowerOpacitySlider.Orientation V
+new LayoutSplit mainSplit
+ set mainSplit.Proportion 50
+ set mainSplit.WinHeight 1200
+ set mainSplit.WinWidth 1600
+ set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1-try.bbs) "
-new Slider upperThresholdSlider
- set upperThresholdSlider.Title "UpperThreshold"
- set upperThresholdSlider.Max 50
- set upperThresholdSlider.In 500
- set upperThresholdSlider.ChangeResolution 1
-
-new Slider upperOpacitySlider
- set upperOpacitySlider.Title "UpperOpacity"
- set upperOpacitySlider.Max 100
- set upperOpacitySlider.In 100
- set upperOpacitySlider.Orientation V
-new Slider smoothSlider
- set smoothSlider.Title "Smooth"
- set smoothSlider.Max 10
- set smoothSlider.In 1
- set smoothSlider.ChangeResolution 1
-
-new CommandButton refresh
- set refresh.Label "Refresh"
- set refresh.In "exec isoextractorthreshold;exec isoextractorsmooth;exec viewer2DImageSegmented; exec viewer2DImageSmooth; exec viewer2DImageOriginal; exec mainSplit"
-
-new MultipleInputs refreshimages
- connect sliceSider.BoxChange refreshimages.In1
- connect upperThresholdSlider.BoxChange refreshimages.In2
- connect lowerThresholdSlider.BoxChange refreshimages.In3
- connect smoothSlider.BoxChange refreshimages.In4
+ 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 sliderLayout
+ set sliderLayout.Orientation V
+ connect sliderLayout.Widget toolLayout.Widget1
+
+ new Slider sliceSlider
+ set sliceSlider.Title "Slice"
+ connect sliceSlider.Widget sliderLayout.Widget1
+
+ new Slider lowerThresholdSlider
+ set lowerThresholdSlider.Title "LowerThreshold"
+ set lowerThresholdSlider.Max 50
+ set lowerThresholdSlider.In 20
+ set lowerThresholdSlider.ChangeResolution 1
+ connect lowerThresholdSlider.Widget sliderLayout.Widget2
+
+ new Slider upperThresholdSlider
+ set upperThresholdSlider.Title "UpperThreshold"
+ set upperThresholdSlider.Max 500
+ set upperThresholdSlider.In 500
+ set upperThresholdSlider.ChangeResolution 1
+ connect upperThresholdSlider.Widget sliderLayout.Widget3
+
+ new Slider smoothSlider
+ set smoothSlider.Title "Smooth"
+ set smoothSlider.Max 10
+ set smoothSlider.In 1
+ set smoothSlider.ChangeResolution 1
+ connect smoothSlider.Widget sliderLayout.Widget4
+
+ new LayoutLine buttonLayout
+ set buttonLayout.Orientation V
+ connect buttonLayout.Widget toolLayout.Widget2
+
+ new ColourSelectorButton colourLower
+ set colourLower.In "1 1 0"
+ connect colourLower.Widget buttonLayout.Widget1
+
+ new ColourSelectorButton colourUpper
+ set colourUpper.In "1 0 0"
+ connect colourUpper.Widget buttonLayout.Widget2
+
+ 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 Viewer2D viewer2DImageSegmented
+ connect viewer2DImageSegmented.Widget layout2D.Widget2
+
+ 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 layoutSurfaces
+ set layoutSurfaces.Orientation H
+ set layoutSurfaces.Proportion 50
+ connect layoutSurfaces.Widget layout3D.Widget1
+
+ new Viewer3D viewer3DSurfaceThreshold
+ connect viewer3DSurfaceThreshold.Widget layoutSurfaces.Widget1
+
+ new Viewer3D viewer3DSurfaceSmooth
+ connect viewer3DSurfaceSmooth.Widget layoutSurfaces.Widget2
+
+ new LayoutLine vSliderLayout
+ connect vSliderLayout.Widget layout3D.Widget2
+
+ new Slider lowerOpacitySlider
+ set lowerOpacitySlider.Title "LowerOpacity"
+ set lowerOpacitySlider.Min 1
+ set lowerOpacitySlider.Max 100
+ set lowerOpacitySlider.In 20
+ set lowerOpacitySlider.Orientation V
+ connect lowerOpacitySlider.Widget vSliderLayout.Widget1
+
+/*
+ new Slider upperOpacitySlider
+ set upperOpacitySlider.Title "UpperOpacity"
+ set upperOpacitySlider.Max 100
+ set upperOpacitySlider.In 100
+ set upperOpacitySlider.Orientation V
+ connect upperOpacitySlider.Widget vSliderLayout.Widget2
+*/
+
+//
+// End of Graphical organization
+// -----------------------------
+
+//
+// Processing pipeline
+// -------------------
-new Viewer2D viewer2DImageOriginal
connect reader.Out viewer2DImageOriginal.In
- connect sliceSider.Out viewer2DImageOriginal.Slice
- connect sliceSider.BoxChange viewer2DImageOriginal.BoxExecute
-
-#---------------------------------------------------------------------
+ connect sliceSlider.Out viewer2DImageOriginal.Slice
-new BinaryThresholdImageFilter threshold
- connect upperThresholdSlider.Out threshold.UpperThreshold
- connect lowerThresholdSlider.Out threshold.LowerThreshold
+ #Slider size is the number of planes
+ connect gveZ.Out sliceSlider.Max
+ #initial slice is the middle one
+ connect div2.Out sliceSlider.In
+ set sliceSlider.ChangeResolution 1
+
+// Images 2D
+
+ new BinaryThresholdImageFilter threshold
set threshold.InsideValue 255
set threshold.OutsideValue 0
+
+ connect upperThresholdSlider.Out threshold.UpperThreshold
+ connect lowerThresholdSlider.Out threshold.LowerThreshold
connect reader.Out threshold.In
-
-new Viewer2D viewer2DImageSegmented
+
connect threshold.Out viewer2DImageSegmented.In
- connect sliceSider.Out viewer2DImageSegmented.Slice
-// connect sliceSider.BoxChange viewer2DImageSegmented.BoxExecute
- connect refreshimages.Out viewer2DImageSegmented.BoxExecute
+ 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 Viewer2D viewer2DImageSmooth
- connect smooth.Out viewer2DImageSmooth.In
- connect sliceSider.Out viewer2DImageSmooth.Slice
- connect sliceSider.BoxChange viewer2DImageSmooth.BoxExecute
-
-
-#---------------------------------------------------------------------
-
-new LayoutLine upLayout
- set upLayout.Orientation H
- connect viewer2DImageOriginal.Widget upLayout.Widget1
- connect viewer2DImageSegmented.Widget upLayout.Widget2
- connect viewer2DImageSmooth.Widget upLayout.Widget3
-
-
-new ColourSelectorButton colourLower
- set colourLower.In "1 1 0"
-
-new ColourSelectorButton colourUpper
- set colourUpper.In "1 0 0"
-
-#---------------------------------------------------------------------
-
-new Viewer3D viewernvImagethreshold3D
-# set viewernvImagethreshold3D.nTypeView "5"
-
-new IsoSurfaceExtractor isoextractorthreshold
- connect threshold.Out isoextractorthreshold.In
- set isoextractorthreshold.Opacity 1
- #set isoextractorthreshold.Isovalue 10
-set isoextractorthreshold.Isovalue 100
- connect colourUpper.Out isoextractorthreshold.Colour
- connect viewernvImagethreshold3D.Renderer isoextractorthreshold.Renderer
-
-
-#---------------------------------------------------------------------
-new Viewer3D viewernvImageSmooth3D
-# set viewernvImageSmooth3D.nTypeView "5"
- //connect refreshimages.Out viewernvImageSmooth3D.BoxExecute
-
+
+ connect smooth.Out viewer2DImageSmooth.In
+ connect sliceSlider.Out viewer2DImageSmooth.Slice
+
+
+// Surfaces 3D
+
+new IsoSurfaceExtractor isoextractorThreshold
+ connect threshold.Out isoextractorThreshold.In
+ set isoextractorThreshold.Opacity 1
+ set isoextractorThreshold.Isovalue 100
+ connect colourUpper.Out isoextractorThreshold.Colour
+ connect isoextractorThreshold.Out viewer3DSurfaceThreshold.In1
+
new Div div3
connect lowerOpacitySlider.Out div3.In1
set div3.In2 100
-new IsoSurfaceExtractor isoextractorsmooth
- connect smooth.Out isoextractorsmooth.In
- connect div3.Out isoextractorsmooth.Opacity
- set isoextractorsmooth.Isovalue 200
- connect colourLower.Out isoextractorsmooth.Colour
- connect viewernvImageSmooth3D.Renderer isoextractorsmooth.Renderer
-
-
-#---------------------------------------------------------------------
-
-new LayoutSplit downLayout
- set downLayout.Orientation H
- set downLayout.Proportion 50
- connect viewernvImagethreshold3D.Widget downLayout.Widget1
- connect viewernvImageSmooth3D.Widget downLayout.Widget2
-
-new LayoutLine sliderLayout
- set sliderLayout.Orientation V
-
-new LayoutLine buttonLayout
- set buttonLayout.Orientation V
- connect colourLower.Widget buttonLayout.Widget1
- connect colourUpper.Widget buttonLayout.Widget2
- connect refresh.Widget buttonLayout.Widget3
-
-new LayoutLine toolLayout
- set toolLayout.Orientation H
- connect sliderLayout.Widget toolLayout.Widget1
- connect buttonLayout.Widget toolLayout.Widget2
-
-
-//new ImageWriter imw
-// connect smooth.Out imw.In
- connect refresh.BoxChange smooth.BoxExecute
+new IsoSurfaceExtractor isoextractorSmooth
+ connect smooth.Out isoextractorSmooth.In
+ connect div3.Out isoextractorSmooth.Opacity
+ set isoextractorSmooth.Isovalue 200
+ connect colourLower.Out isoextractorSmooth.Colour
+ connect isoextractorSmooth.Out viewer3DSurfaceSmooth.In2
+
+// Refresh issues
-new LayoutLine vSliderLayout
- connect lowerOpacitySlider.Widget vSliderLayout.Widget1
- connect upperOpacitySlider.Widget vSliderLayout.Widget2
+ new MultipleInputs multInForImageOriginal
+ connect sliceSlider.BoxChange multInForImageOriginal.In1
+ connect refresh.BoxChange multInForImageOriginal.In2
+
+ new MultipleInputs multInForImageSegmented
+ connect lowerThresholdSlider.BoxChange multInForImageSegmented.In1
+ connect upperThresholdSlider.BoxChange multInForImageSegmented.In2
+ connect refresh.BoxChange multInForImageSegmented.In3
-new LayoutSplit layout3D
- set layout3D.Orientation H
- set layout3D.Proportion 90
- connect downLayout.Widget layout3D.Widget1
- connect vSliderLayout.Widget layout3D.Widget2
-
-#---------------------------------------------------------------------
-new LayoutSplit splitUp
- set splitUp.Proportion 38
- connect toolLayout.Widget splitUp.Widget1
- connect upLayout.Widget splitUp.Widget2
-
- connect sliceSider.Widget sliderLayout.Widget1
- connect lowerThresholdSlider.Widget sliderLayout.Widget2
- connect upperThresholdSlider.Widget sliderLayout.Widget3
- connect smoothSlider.Widget sliderLayout.Widget4
+ new MultipleInputs multInForImageSmooth
+ connect lowerThresholdSlider.BoxChange multInForImageSmooth.In1
+ connect upperThresholdSlider.BoxChange multInForImageSmooth.In2
+ connect smoothSlider.BoxChange multInForImageSmooth.In3
+ connect lowerOpacitySlider.BoxChange multInForImageSmooth.In4
+ connect refresh.BoxChange multInForImageSmooth.In5
+
+ new MultipleInputs multInForSurfaceThreshold
+ connect refresh.BoxChange multInForSurfaceThreshold.In1
+ new MultipleInputs multInForSurfaceSmooth
+ connect refresh.BoxChange multInForSurfaceSmooth.In1
+
+ connect multInForImageOriginal.BoxChange viewer2DImageOriginal.BoxExecute
+ connect multInForImageSegmented.BoxChange viewer2DImageSegmented.BoxExecute
+ connect multInForImageSmooth.BoxChange viewer2DImageSmooth.BoxExecute
+
+ connect multInForSurfaceThreshold.BoxChange viewer3DSurfaceThreshold.BoxExecute
+ connect multInForSurfaceSmooth.BoxChange viewer3DSurfaceSmooth.BoxExecute
-new LayoutSplit mainSplit
- set mainSplit.Proportion 50
- set mainSplit.WinHeight 1200
- set mainSplit.WinWidth 1600
- set mainSplit.WinTitle "Processing / Viewing example (demoFiltering1.bbs) "
- connect splitUp.Widget mainSplit.Widget1
- connect layout3D.Widget mainSplit.Widget2
-
-#---------------------------------------------------------------------
-
-exec isoextractorthreshold
-exec isoextractorsmooth
+
+ exec mainSplit
-exec mainSplit