1. Basic erosion and dilation
1.1 Dilation operator
Understand the code of the dilation operator that is provided in the method dilateBasic() of the file Code.java. Find the structuring element from the Java code and fill the report. By using the plugin, describe how you would still be able to determine the structuring element without access to the source code. The name of the plugin is Basic Dilate.
1.2 Erosion operator
Write the method erodeBasic() that implements the erosion operator with the structuring element found in Question 1.1. The name of the plugin is Basic Erode.
Test your code on the images miretv and monarch.
2. Morphological operators with a user-defined structuring element
We want to implement the morphological operators the four following structuring elements.
2.1 Creation of structuring elements
A structuring element is a 2D boolean array containing true in the gray cells and false in the white cells.
Write the code for the methods block(n), diamond(n), line(n) and corner(n) to
build the "Block", "Diamond", "Line", and "Corner" structuring elements of size n.
We assume that the size n is always odd and is greater than 2.
The provided method show(boolean se) can display the structuring element as an image to help you check your results.
2.2 Implementation of the morphological operators
The task is to implement several operators that make use of the four structuring elements. The list of operations is provided in the box below. The user chooses the shape and the size of the structuring element through the dialog box. Test your code on the images miretv and monarch.
To make pixelwise arithmetic operations of ImageAccess objects, you can use the in-place methods as
You can first protect your input data by duplicating the content using
ImageAccess a = image.duplicate()
This class is documented at http://bigwww.epfl.ch/teaching/iplab/docs/index.html.
†Hint: To code the median filter, the method Arrays.sort() is useful to sort a one-dimensional array
2.3 Understanding of the morphological operators
3. Application: Detect black note heads
Propose an algorithm to detect only the black heads of the notes by doing any of the following steps (1) morphological operators of the Question 2.2, (2) the arithmetic operations of ImageJ and (3) a final thresholding.
The goal is to replace the black heads in the image notes by small squares (e.g., 7x7 pixel) and to remove everything else. Save the resulting image and briefly describe the steps and parameters of your algorithm.
4. Mouse tracking
We propose to build a program that can track the body of a mouse, excluding its tail.
a. Code the routine trackMouse() to segment the body of mouse using only the studied morphological operators and, as the last step, a threshold operation. The output body has to be white (value=255) over a black background (value=0) in the sequence of images stored as an array of ImageAccess objects. The sequence can be displayed using
// Show a sequence of images as a stack
ImageAccess out = new ImageAccess[n];
ImageAccess.Display display = new ImageAccess.Display(out, "Tracking");
b. Complete the routine trackMouse() to compute the center of gravity of the body in every binary images The trajectory can be displayed as a segmented line using 1 segment by frame transition.
// Draw a red line from point Fk (xa, ya) to point Fk+1 (xb, yb) display.overlayLine(xa, ya, xb, yb);