Example 3: Region Growing
Introduction
A very simple approach to segment parts of an image is the region growing method. A general explanation can be found here.
In this example, you will segment the brain of an image and show the segmentation results as an overlay on the original image.
Steps to do
Develop your network
Add a LocalImage
module to your workspace and select load $(DemoDataPath)/BrainMultiModal/ProbandT1.dcm. Add a View2D
module and connect both as seen below.
Add the RegionGrowing module
Add the RegionGrowing
module and connect the input with the LocalImage
module. You will see a message results invalid. The reason is, that a region growing always needs a starting point for getting similar pixels. The output of the module does not show a result in Output Inspector.
Add a SoView2DMarkerEditor
to your network and connect it with your RegionGrowing
and with the View2D
. Clicking into your viewer now creates markers which can be used for the region growing.
The region growing starts on manually clicking Update or automatically if Update Mode is set to Auto-Update. We recommend to set update mode to automatic update. Additionally you should set the Neighborhood Relation to 3D-6-Neighborhood (x,y,z), because then your segmentation will also affect the z-axis.
Set Threshold Computation to Automatic and define Interval Size as 1.600 % for relative, automatic threshold generation.
Clicking into your image in the View2D
now already generates a mask containing your segmentation. As you did not connect the output of the RegionGrowing
, you need to select the output of the module and use the Output Inspector to visualize your results.
In order to visualize your segmentation mask as an overlay in the View2D
, you need to add the SoView2DOverlay
module. Connect it as seen below.
Your segmentation is now shown in the View2D
. You can change the color and transparency of the overlay via SoView2DOverlay.
Close gaps
Scrolling through the slices, you will see that your segmentation is not closed. There are lots of gaps where the grey value of your image differs more than your threshold. You can simply add a CloseGap
module to resolve this issue. Configure Filter Mode as Binary Dilatation, Border Handling as Pad Src Fill and set KernelZ to 3.
The difference before and after closing the gaps can be seen in the Output Inspector.
You can play around with the different settings of the RegionGrowing
and CloseGap
modules to get a better result.
Visualize 2D and 3D
You can now also add a View3D
to show your segmentation in 3D. Your final result should look similar to this.
Summary
- The module
RegionGrowing
allows a very simple segmentation of similar grey values. - Gaps in a segmentation mask can be closed by using the
CloseGap
module. - Segmentation results can be visualized in 2D and 3D.