INFOIBVImage Processing

Assignment 2: Morphological filters

Use the provided framework and add the following functionality:
1. Erosion/dilation: implement two functions that take a grayscale image, a structuring element and a grayscale control image as input and output the geodesic eroded/dilated image with the mask as control image, respectively. You functions should also work for binary images. In this case, use only the values 0 and 1 in both image and control image. Check whether image and control image have the same size.(15 points)
2. Opening/closing: implement two functions that take a grayscale image, a structuring element and a grayscale control image as input and output the image after geodesic morphological opening and closing, respectively. You functions should also work for binary images. In this case, use only the values 0 and 1 in both image and control image. Check whether image and control image have the same size. For geodesic opening, first perform a "normal" erosion (no control image), followed by a geodesic dilation. (15 points)
3. Complement: implement a function that takes a (binary) grayscale image as input and outputs the complement of the image. (10 points)
4. AND/OR: implement two functions that take two (binary) grayscale images as input and output the AND and the OR of both images. Check the input arguments but only perform the AND/OR when the sizes of both images are the same. (10 points)
5. Value counting: implement a function that takes a grayscale image as input and outputs the number of distinct values. (10 points)
Choose what happens with boundary pixels. Make sure your code works with structuring elements of arbitrary size. Demonstrate your implementation by loading image B or C from assignment 1. Make sure it is a binary single channel image. We call this image W. Then:
1. dilate image W with a 3x3 square kernel. This is image X.
2. erode image W with a 3x3 square kernel. This is image Y.
3. take the AND of image X and the complement of Y. This is image Z.
4. use image A from assignment 1, convert it to grayscale and perform a series of dilations with increasing structuring element size. Choose the shape of the element (e.g. plus, square), but keep it fixed. The resulting images are E1...En.
5. for each image E1...En, count the number of distinct values F1..Fn.
Write a brief (2-page) report with:
1. the images X, Y and Z. Explain what result Z is. (10 points)
2. a graph with on the x-axis the size of the structuring element and on the y-axis the values F1...Fn. Explain what you see. How can this be explained? (10 points)

Submission
Submit (through http://www.cs.uu.nl/docs/submit, and select Image Processing Assignment 2):

1. your code (NO binaries/libs)
2. your 2-page report