Starting from:
$35

$29

Homework Assignment 1: Binary Image Analysis Solution

The goal of this assignment is to gain familiarity with certain image enhancement tools that we covered in the class and you will use them for binary image analysis. You will use only MATLAB for this assignment. Please read the entire homework until the end before starting to implement anything or before sending an email. Not only your results but the quality and aesthetics of your report will affect your final grade. So please be careful with your submissions and pay attention to its format before submitting it. When asked to perform operations on images, you need to use the attached and corresponding images that are also sent to you alongside this homework description. Do not take screenshots of the images from this report to use with your code. Contact aydamir.mirzayev@bilkent.edu.tr if you have read the entire homework and if you still have questions.

    • Question (15 points)

Implement a function to generate histogram of a gray scale image. Your method should take an arbitrary gray scale image (a matrix) as an input and plot the histogram of pixel intensities. Your method should have the following declaration:

histogram ( source_image)

Your implementation should be generic for any given grayscale image. That is, it should be able to work with image of any size. Note that, you can use additional built-in functions or libraries to read an image as a matrix and for plotting histograms. However, your function should only take the image matrix as an input. No image processing libraries are to be used for the implementation of the histogram function. Please test your results on images provided in Figure 1(a) and 1(b). (HINT: compare your results with MATLAB’s built-in histogram function.)

    • Question (20 points)

Implement automated thresholding by Otsu’s Method. As in the first question, you must use your own implementation and avoid using any image processing libraries (except for reading and plotting images). Your function declaration should take a grayscale image (a 2D matrix) as an input and produce a binary image (also a 2D matrix) of the same dimensions as in the input image. Use the format below:

binary_image = otsu_threshold( source_image)

Separate the background from the foreground using your implementation of Otsu’s algorithm. Show your results on two different images shown in figure 2(a) and 2(b) (both of those images are also provided as a part of this homework). Discuss your results, are they always perfect? Why so, why not?

    • Question (25 points)

In this question, you will write your own implementations of two fundamental morphological operations:

namely dilation and erosion. You will write a separate function for each of those two operations. In each

1






















(b)


(a)

Figure 1: Grayscale images for the first question



























(a)    (b)

Figure 2: Grayscale images for the second question








2













(b) Plane lot

(a) Parking lot

Figure 3: Grayscale images for the fourth question


function, you will take two inputs (as matrices): (i) the input image as a matrix and (ii) a structuring element (also as a matrix), and produce a binary image (another matrix) as output. Note that the resulting image matrix should be of the same size as input image matrix. As before, your methods should be generic, that is it should work with grayscale image and structuring element of any size. Your method declaration should look as follows:

dilated_image = dilation ( source_image , struct_el )

eroded_image = erosion ( source_image , struct_el )

You should generate the structuring element as a binary image with an arbitrary shape. Given the structuring element, your code should implement the dilation and erosion operations using the definitions given in the course slides. Note that the structuring element should be created (as a matrix) outside and given as an input to the dilation/erosion codes so that your code can work with any kind of structuring element. You can assume that the origin is in the center, or get the coordinate of the origin as a separate input to your functions.

    • Question (40 points)

In this question, you will use functions implemented in Question 3. You are provided with 2 gray scale images as shown in Figure 3(a) and 3(b) and you are expected to apply a sequence of thresholding and/morphological operations to label distinct objects in the image

The first step is to find (by trial and error) or using Otsu’s method, a threshold that will produce a binary image that best separates objects from the background. Please, specify which method you are using and specify why.

The second problem is to use the morphological operators (dilation and erosion) you have written, to help separate objects that are connected together or to fill holes in the objects. Note that you might need to use inverse operation on the binary image of the planes as they are painted in white against black background. Once you have a decent binary image, use connected components labeling to produce a labeled image that has a distinct label (integer) for each region.

You MUST use the dilation, erosion and thresholding code from the third question. You CAN use other sources for arithmetic and logical operators, connected components labeling, and image I/O. Note that you are NOT allowed to use any operator other than the ones listed above.

Note that you will have to provide analytical justification for the specific sequence of operations performed and what each step achieves. Simply providing a working sequence is not enough. It is also possible that several different sequences achieve desired result, you are encouraged to find and compare them on your own. But report only one such sequence.



3
Submission Details: FOR EACH QUESTION in this assignment, you need to submit a report and an implementation (the asked function).

    1. A report (pdf file) that includes the results from all four questions, your discussions, generated plots and etc. Remember that slightly imperfect results are quite likely due to method limits. As long as you are able to provide analytical explanation for such results, and as long as these results are similar in quality to results from MATLAB libraries, you are OK. In fact you are encouraged to compare your implementation to that of MATLAB libraries, but please DO NOT INCLUDE these comparisons in your report! In parts of the assignment where you are allowed to use external libraries, specify the library and the method that you are using.

For the first question, provide resulting histograms for both images in Figure 1 and comment on your results. How, spatial intensity distribution of the image compares to that of generated histogram. Please label each histogram carefully as to indicate the image it belongs to i.e histogram of image 1(a) should correspond to histogram N(a) in corresponding figure N.

For the second question provide resulting binary images for the images in Figure 2. Include your comments on why a particular threshold occurred. For this purpose you may use the histograms of the images to help you understand results of thresholding.

For the third question you can briefly specify your implementation details. And include comments if you have some. This section does not have to be long, just a few sentences.

For the fourth question provide sequence of operations, and three results for each image in Figure 3. Three results being; result of thresholding, morphological operations (dilation, erosion and etc) and results of components labeling (total of 6 images). Note that you are expected to report the sequence used for each image and reason for that sequence. Also report all the structuring elements (as a binary image) used in each sequence and specify which sequence and step that structuring element belongs to. Also provide the reason for use of that specific structuring element. You are also expected to provide discussion of the results (e.g., which steps were easy and which were more difficult, what was possible and what was not). Submitting only the outputs will not deserve a full score.

    2. A script that contains the four functions you implemented and code for all parts of this assignment, with comments included. Omitting comments and submitting confusing script will result in grade reduction.

Send your homework to: aydamir.mirzayev@bilkent.edu.tr by 23:59 March 6th 2020, with the subject line CS_484_555_homework_1. Late submissions will not be graded. All the reports in your assignment should be submitted in a single PDF. Both the PDF file (your report) and your Matlab code must be submitted in a single compressed file. Use the format: HW1_YourName_YourID.zip. Not complying with the submission rules will result in 20 point penalty.
























4

More products