[Solved] TDT4195-Assignment 3

$25

File Name: TDT4195_Assignment_3.zip
File Size: 188.4 KB

SKU: [Solved] TDT4195-Assignment 3 Category: Tag:
5/5 - (1 vote)

In this assignment, we will explore how we can segment an image into foreground and background by using basic segmentation algorithms, such as thresholding and region region growing. Then, you will explore how we can use binary morphological operations to manipulate the contents of a binary image.

Task 1: Theory

  • Define opening and closing in terms of erosion and dilation. What happens when open and closing are applied multiple times on the same image?
  • Smoothing of an image is often done before performing edge detection. What is the purpose of smoothing the image before edge detection?
  • The Canny edge detector uses a method called hysteresis thresholding. Shortly explain how hysteresis thresholding work.
  • Why do we use hysteresis thresholding instead of a single treshold?
  • Determine the dilation A B of the binary image in Figure 1a. Use the structuring element in Figure 1b.
0 1 0 1 0 0
0 1 0 1 1 0
0 1 1 1 0 0
0 0 0 0 0 0
0 0 1 0 0 0
0 0 0 0 0 1
1 1

(b) A 13 structuring element

(a) A 6 6 binary image.

Figure 1: A binary image and a structuring element. The foreground is colored white and given the symbol 1. The background has the symbol 0 and is colored black. The reference pixel in the structuring element (b) is indicated by a black circle.

Programming

Task 2: Segmentation

Segmentation by thresholding on pixel intensity is a intuitive, computational efficient, and simple way of implementing image segmentation. Selecting a good value for thresholding is a cumbersome process that is best left up to a threshold detection algorithm. One automatic algorithm for selecting a good threshold in a grayscale image is Otsus method. The algorithm finds a single threshold value that separates pixels into two classes, foreground and background. The basic idea is that a threshold giving the best separation between classes in terms of their intensity values would be the optimum threshold. In the assignment files we have included the file otsu-thresholding.pdf, scanned from the curriculum book [1], which describes the algorithm in detail.

(a)Implement a function in task2a.py/task2a.ipynb that implements Otsus algorithm for thresholding, and returns a single threshold value.

Segment the images thumbprint.png and polymercell.png, and include the results in your report.

  • X-ray image of a defective (b) Segmented using Otsus (c) Segmented using region growweld thresholding algorithm. ing with four manually selected

seed points.

Figure 2: Two different ways to segment the image in (a). Image source: [1]

Region growing is a region-based segmentation algorithm that uses a set of seed points and a homogeneity criteria H(Ri) to perform segmentation. For each seed point, a region is grown by inspecting neighboring pixels and evaluating whether or not to include them in region Ri using H(Ri). The neighboring pixels that are currently being evaluated are typically called candidate pixels. The growing of a region stops when there are no more candidate pixels to inspect. The simplest homogeneity criteria is a threshold, where the threshold defines the maximum absolute difference in intensity between the seed point and the current candidate pixel.

  • Implement a function in task2b.py/task2b.ipynb that segments a grayscale image using the region growing method outlined above. Use a Moore neighborhood (8-connectedness) to expand your set of candidate pixels around each seed point.

Apply it on the image defective-weld.png and show the result in your report. Use the 4 seed points given in the starter code and use a pixel intensity threshold of 50.

Hint: To make sure you implement the code correct, you should test your algorithm with a pixel intensity threshold of 90.

Task 3: Morphology

For the following tasks, you are allowed to use already implemented functions for opening, closing, erosion, and dilation. Skimage has several useful functions for this:

(a) A noisy binary image (b) An almost noise free version (c) A distance transform of the of (a) after morphological opera- binary image in (b) using chesstions. board distance.

Figure 3: Morphology operations on a binary image (a). Image source: [1]

  • Use what you know about erosion, dilation, opening, and closing to remove the noisy elements from the image in Figure 3. Implement this in the file py/task3a.ipynb. Your result should look something like the one in Figure 3b.

Include the resulting image in your report and shortly explain how you removed the noise.

The distance transform is an operation typically applied on a binary image and creates a grayscale image where each foreground pixel shows the distance to the closest boundary pixel. An example of this using chessboard distance can be seen in Figure 3c. The chessboard distance is the minimum number of moves a king has to perform to move from one square (or pixel in our case) to another square in the game of chess.

One inefficient way of calculating the distance transform is to use erosion. Intuitively, by using erosion the distance transform for a pixel is simply the number of erosion operations it took to remove it from the foreground of the original image.

  • Implement the distance transform using the erosion method explained above, in the file py/task3b.ipynb.ipynb. You can use a 3 3 structuring element of all ones to get chessboard distance.

Test the function on the noise free binary image you got from task (a) and show the result in your report.

Mathematical operations can be used for extracting boundary information from images. The operation for extracting the inner boundary extraction can be seen in Equation 1, where is erosion.

) (1)

  • Implement a function that extracts the boundary from a binary image, as defined in Equation 1, in the file py/task3c.ipynb. You can use a 3 3 structuring element of all ones.

Show the boundary on the image lincoln.png and include the result in your report.

Hole filling is a method to fill in holes in a segmentation, and is very useful for post-processing imperfect segmentations. Algorithm 1 outlines a basic algorithm that takes a binary image and fills all known holes indicated by a set of starting points.

Algorithm 1 A algorithm to fill holes in a binary image I. is the dilation operation, Ic is the complement of I, and is the union.

1: Input: Image I, number of iterations K, starting points S, and structuring element B.

2: Form an array, X0, of 0s (the same size as the Image I)

3: for row, column in S do 4: X0[row,column] 1

5: for k 1 to K do

6: Xk (Xk1 B) Ic

7: return Xk I

(d) Implement a function that takes in a binary image and a set of starting points indicating position of holes, and applies the hole filling algorithm outlined in Algorithm 1. Implement this in the file task3d.py/task3d.ipynb.

Apply the function on the image balls-with-reflection.png and include the resulting image in your report. The position of the holes are given in the starter code. Use 30 iterations (K = 30), and a 3 3 structuring element (B) of all 1s.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] TDT4195-Assignment 3[Solved] TDT4195-Assignment 3
$25