Slicer3:Module:Binary Morphological Operations-Documentation

From Slicer Wiki
Jump to: navigation, search
Home < Slicer3:Module:Binary Morphological Operations-Documentation

Return to Slicer Documentation

Binary Morphological Operations


Module Type&Category

In order to implement morphological operations which are erosion and dilation, the four new modules have been integrated to Slicer 3 by using ITK commands which are explained in Module Description.The types of those modules are CLI and the category of them is Segmentation.

Authors, Collaborators & Contact

  • Author: Bike Kilic, MSc student in Northeastern University
  • Contact:

Module Description

The modules in this framework are used in order to segment a given image by morphological operations:

-The first step is to binarize given gray-level image. The inside of the object is white and the outside is black. In order to do binarization, in this project there are two modules integrated into Slicer 3. The one called "LabelBinaryImages" uses general thresholding which makes the inside pixel equal to 1 and outside pixels equal to 0 and then creates a labeled binary image. The other one called "BinaryThresholding" thresholds the gray-level image by given upper and lower values in order to binarize the image. However in this case, the inside pixels values are 255 and the ones which are in the outside of the object have the value 0.

-After having binary image, the second step is performing erode operation to this image in order to make the different objects separate with the module called "BinaryErodeOperations". For instance, in this project I have two intersected spheres which are already binary image. However in order to make them smooth, the spheres are thresholded by general thresholding firstly and then by binary erode operation the spheres are totally separated to specify two different labels. The label map is created by using Editor module of Slicer 3.

-As we have two separate images, the dilation operation is used in order to make them touch each other but not onto each other. The name of the module is "BinaryDilateOperations". The aim of this module is to make the totally separated objects touch each other but not overwritten.

-The final step is to create the label map and make 3D model of touching but different labeled objects. The Editor and Model Maker modules are used in order to achieve this goal.

The output of the algorithms is two different labeled binary image.


Examples, Use Cases & Tutorials

The "BinaryThresholding" module can be used in segmentation of foreground and background in an image. The problem might be stemmed from the values chosen for upper and lower threshold. In that case, the histogram equalization or some reconstruction methods can be used beforehand in order to enhance the image.

The "LabelBinaryImages" module is useful in order to find the connected pixels and label the image depending on the connectedness. After thresholding even we see different objects the program does not understand that they are different images so this module helps the program to label the objects in a binary image.

The morphological operations which are "BinaryErodeOperations" and "BinaryDilateOperations" can be used for several aspects such as segmentation, reconstruction, enhancement. What we have to be careful is choosing the best structuring element because both erosion and dilation depends on the structuring element. As I have seen in ITK documentation, there are three different structuring elements which are used for morphological operations. In this project, erosion is made by ball structuring element and the dilation uses neighborhood structuring element. The other included class for structuring element is binary cross structuring element. In addition to choosing structuring element, the properties of them have crucial role in the performance of these operations. For instance, if the radius of the binary ball structuring element is increased, the edge of the image has more square shape so it does not preserve the shape information. Therefore, in order to preserve the shape, some thresholding or smoothing algorithms can be performed.

Quick Tour of Features and Use

In the first step, the binary thresholding uses the gray level image as an input. In this project, our input is two intersected spheres with different radius sizes.

The second step, "BinaryErodeOperations", uses the output of binary thresholding which is a binary image as an input. This module should be repeated until we have two totally separate images because we need to create a label map and mark the different objects with different labels. The input for the repeated erosion is the eroded image from the previous one. User also identifies the radius size of structuring element.

The label map and label images are created by using Editor module. The input for label map is the last eroded image. After creating label map, the tools of Editor module help us to change the labels and create different labels. Then by using Model Maker, we can observe the separate images in 3D surface.

The next step is "BinaryDilateOperations". This module uses the last eroded image which is the output of BinaryErodeOperations as an input. Like erosion case, this module is also repeated until we get touched but not overwritten binary images. At the end of this method, what we want to see is to have different colored images which are touched each other.

The last step is again creating label map and 3D model by using Editor and Model Maker modules in order.

The input and output images of above algorithms are given in the Screen shots part.



The modules for thresholding and morphological operations are taken from ITK website, [1].

For thresholding. itkBinaryThresholdImageFilter class is included. The user chooses lower and upper threshold values. The detailed information is given in BinaryThresholding

If the user wants to both binarize and label the image before morphological operations, the "LabelBinaryImages" module uses three ITK classes. itkBinaryThresholdImageFilter is for binary thresholding. itkConnectedComponentImageFilter and itkRelabelComponentImageFilter are for labeling the image. Please see the page LabelBinaryImages for more information.

For morphological operations, itkBinaryDilateImageFilter and itkBinaryErodeImageFilter classes are used. In order to create structuring element, ITK classes are also used. BinaryBallStructuringElement, BinaryCrossStructuringElement and Neighborhood classes are included in this project. The radius is given by the user. If user labels the image as 1 and 0 in the first step, the both erode and dilate value should be chosen as 1. Otherwise, if user wants to just threshold the image by using "BinaryThresholding" module, erode and dilate values should be the same as the upper value of the threshold. The reason is that these values represent the foreground value which is also the inner pixel value of the image. Please see the page BinaryErodeOperations for erosion and BinaryDilateOperations for dilation.

The problems

The problems I encountered with are stemmed from the values given by user in all sub-modules.

In the first step, the problems in binary thresholding are explained in the part BinaryThresholding. And if user wants to use labeling in addition to thresholding, the problems I had should be known and the detailed information is given in LabelBinaryImages.

In the second step, the problems in erosion are explained in the part BinaryErodeOperations.

In the third and last step, the problems in dilation are explained in the part BinaryDilateOperations.

Usability issues

Follow this link to the Slicer3 bug tracker. Please select the usability issue category when browsing or contributing.

Source code & documentation

Customize following links for your module.

Links to documentation generated by doxygen.

Screen shots

Input image for the module
The output of model maker before morphological operations after thresholding

The screen shot which show the input panel of binary thresholding operation can be shown in BinaryThresholding.

The screen shot which show the input and output of labeling binary images can be shown in LabelBinaryImages.

The screen shots which show the input and result of erode operation can be shown in BinaryErodeOperations.

The screen shots which show the input and result of dilate operation can be shown in BinaryDilateOperations.


Most of the development took place in the Surgical Planning Laboratory, Harvard Medical School and Brigham and Women's Hospital, under the supervision of Mr. Steve Pieper Ph.D.



In this project, the aim is to make the overwritten spheres separate by using erosion. After erosion, label them with different colors by using Editor module is the second goal. After having different labeled objects, dilation makes these objects touch together but not overwritten. At the end, we want to see different labeled objects which touch each other but not neither onto nor into each other.

Binary Thresholding, Binary Erosion worked very well. However, in binary dilation, I encountered with a problem. When I increased the iteration of dilation after the objects got closer, the objects became overwritten. And therefore, I could not label them differently. The problems and screen shots can be followed from BinaryDilateOperations.

The solution can be changing the algorithm in "BinaryDilateOperations" module. For instance, the input for the dilation could be labeled objects instead of binary eroded images. Another solution could be giving some constraints in growing forces of dilation.

Future work

For this project. in the future, the dilation algorithm should be improved. Instead of using binary eroded images, the binary labeled eroded images can be used as an input for dilation operation.For detailed information please look at LabelBinaryImages


  1. Gu L., Seminar Series on Advanced Medical Image Processing, Mathematical Morphology(1), 2002.
  2. Ibanez L.,ITK Architecture, ITK Basic Filters, 2006.
  3. Ibanez L.,ITK Arcitecture, ITK Segmentation Methods, 2000.
  4. Ibanez L., Schroeder W.,Ng L. & Cates J., The ITK Software Guide Second Edition Updated for ITK Version 2.4, 2005.
  5. Lehmann G., Binary Morphological closing and opening image filters, 2006.
  6. Lehmann G., Improving features and performance of binary erode and dilate filters, 2006.
  7. Vleeschouwer C., Morphology, 2007.[2]