Graphic STI
logo EPFL
Text EPFL
english only
Biomedical Imaging Group
IP-LAB: Image Processing Laboratories
BIG > Teaching > IP-LAB > Morphological operators 19

Morphological operators

1. Study of the dilation operator

Understand the morphological operator that performs dilation. The code is provided in the method dilate(), only the structuring element "Unknown" is coded.

Apply the dilation operator on pattern and impulse with the structuring element "Unknown" using the plugin Dilate. Give the structuring element "Unknown 9" of size 9 and the resulting image. Fill the report.

Important note: To make the connection with the course notes, we are in the special case of graylevel morphology with b[y] = 0 and we are drawing Ωb. we only consider symmetric structuring element b = bs.

2. Structuring element


Cross 3

Square 7

Disk 9

Here, we propose to implement three different shapes for the structuring element of size NxN where N is odd, 0 < N < half size of the input image. The three shapes with different size are shown at the figure on the right.

Code the method createStructuringElement(Shape shape, int size) that returns a 2D boolean array containing the structuring element for a specified shape and a specified size.

Give the results of dilation operator on bar with the structuring element Square 7, Cross 3, and Disk 9. Insert the resulting images in the report.

3. Morphological operators

We propose to implement a series of morphological operators with the three structuring elements defined in Question 2.

Operator Operation Method in Code.java Name of the plugin
Dilation f ⊕ b dilate() Dilate
Erosion f ⊖ b erode() Erode
Open f ο b = (f Θ b) ⊕ b open() Open
Close f • b = (f ⊕ b) Θ b close() Close
Gradient b(f) = (f ⊕ b) - (f Θ b) gradient() Gradient
TopHat f - (f ο b) topHat() Top Hat
BottomHat (f • b) - f bottomHat() Bottom Hat

Write these operators in the corresponding Java methods and test your code on bar. The plugins are also able to process RGB images by independently applying the operator on every color channels. Insert in the report the resulting images of Gradient(Disk 7) on sunrise, Bottom Hat(Square 3) on pattern.

4. Understand the morphological operators

4.1 Comparison

Apply the following morphological operators on pattern. When the image content is the same, explain why in the report.

  1. Compare the results of Erosion(Square 9) with Erosion(Disk 9).
  2. Compare the results of 3 successive Erosion(Square 3) with Erosion(Square 3).
  3. Compare the results of 3 successive Erosion(Square 3) with Erosion(Square 7).
  4. Compare the results of 3 successive Closing(Square 3) with Closing(Square 3).
  5. Compare the results of TopHat(Square 5) with BottomHat(Square 5).

4.2 Check duality

Check the two following duality relations in the case of an image range from 0 to 255:

Write the methods checkDualityErodeDilate() and checkDualityOpenClose() that displays the two images of the relation of duality. The method image.show("Title") allows to display an image. Apply on doisneau with the structuring element Disk 7. Fill the report.

5. Simple applications


a. objects

b. miro

For each application, give a sequence of few morphological operators and their parameters to complete the required task. You can combine the morphological operators (different shapes, different sizes). Fill the report.

  1. Fill the black holes inside the white objects and keep objects not in contact in the binary image objects.
  2. Suppress as much as possible everything from the image miro, expect the thin lines.

6. Median filter

Write the routine median() that returns a median-filtered image using only the Square(3) as structuring element. To find the median value, an easy way is to sort a 1D array and finally take the central value of the sorted array as the output value. In Java, the sort procedure is achieved by the command: double array[]; Arrays.sort(array);

Test your code on the images doisneau-noise using the plugin Median. Fill the report.

7. Distance map from border

We propose to estimate the distance from the border of objects by iteratively eroding (structuring element Cross 3) objects until all the object pixels vanish. The input image is a binary image, objects are white (pixel value:255) and background is black (pixel value: 0). At each iteration, the eroded area (1 pixel band) is accumulated in a map M stored in an ImageAccess object with the index of the current iteration. The process runs until the current eroded image is zero everywhere.

Write the code that implements this algorithm in the method distanceBorderMap() that returns the map M defined above.

Test your code using the image Hela using the plugin Distance Border Map. Propose a "noise tolerance" of the Find Maxima command (Menu ImageJ » Process) to draw a yellow cross on every local maximum that corresponds to a HeLa cell (your results do not have to be perfect). Fill the report.

Christmas Question (not graded): Compute the distance map of the christmas-tree image.


webmaster.big@epfl.ch • 06.12.2018