Can someone please help solve this with details/explanations An 8x8 image is giv
ID: 2266100 • Letter: C
Question
Can someone please help solve this with details/explanations
An 8x8 image is given below:
THIS IS A MATH BASED PROBLEM AND NOT MATLAB CODING BASED
a) Apply thresholding on the given image to create a binary image. Use as the threshold value 50. Draw the binary image with pixel values after the thresholding.
b) If 4-connectivity is assumed, how many connected components are there in the binary image? Mark them on the binary image. You don’t have to apply the algorithm if you can determine the number by visual inspection.
c) What is the area of each of the connected components?
d) If 8-connectivity is assumed, how many connected components are there in the binary image? Draw a new figure of binary image to mark these. You don’t have to apply the algorithm if you can determine the number by visual inspection.
e) What is the largest connected component area and centroid of connected component with the smallest area? Assume that spatial coordinates of image pixels are (x,y) where x represents the row and y the column. Assume that the top left pixel has the spatial coordinates (1,1).
f) How many passes of the dilation operator are necessary before the whole image is a single connected component? Show the filtered image after every pass. Assume small image is padded with 1s and that structuring element is a 3x3 box filter.
g) How many passes of the erosion operator are necessary before the whole image is a single connected component? Show the filtered image after every pass. Assume small image is padded with 1s and that structuring element is a 3x3 box filter.
215 159 123 80 10 5 8 8 205 208 12710 95 117 215 91 117 823 91 103 22215 17 35 105 236 15 2117 5 10 810 46 215 117 117 74 91 2155 16 40 15 13 126 10 91 415 10 18 47 101 183 918 91 91 2115Explanation / Answer
Given image in a table form for explanations. Matlab code is not required for understanding the concept of threshold, connected component, area, centroid, erosion and dilation operations.
a) Apply thresholding with the threshold value = 50.
Every pixel value is checked against the threshold value. If the pixel value of a pixel is greater than the threshold value, then the pixel value is set to 1, else 0. For example, top left pixel has value 215, after thresholding, the pixel value is set 1. Similarly, for the bottom right pixel, the pixel value is 15, after thresholding, the pixel value is set 0. A binary image has only two pixel values either 1 or 0.
The output of thresholding operation, which is a binary image shown below.
----------------------------------------------------------------------------------------------------------------------------
b) 4-connectivity means you take a step from a pixel with value '1' in only 4 directions such as north, south, each, west or top, bottom, left right to reach any neighbor pixel with value '1'. Use top, bottom, left, right which is more appropriate. All the pixels which can be reached with the four directions form a connected component.
Let us mark individual connected components by numbering them in increasing order from top left corner. We move the horizontally for labelling the connected components. We take step from previous row last column to next row first column while labelling.
The labelled image using 4-connectivity for the binary image is shown below,
There are 4 connected components in the binary image.
-------------------------------------------------------------------------------------------------
c) The actual number of pixels in each connected components is considered as the area of the connected components. The list is below
First - 8 pixels
Second - 11 pixels
Third - 8 pixels
Fourth - 2 pixels
---------------------------------------------------------------------------------------------------------------
d) 8-connectivity means you take a step from a pixel with value '1' in any directions to reach any neighbor pixel with value '1'. All the pixels which can be reached with any directions form a connected component.
The labelled image using 8-connectivity for the binary image is shown below,
Here, we can observe that there are only 4 connected components for 8-connectivity.
--------------------------------------------------------------------------------------------------------
e) We need to find the area of connected components
First - 8 pixels
Second - 11 pixels
Third - 8 pixels
Fourth - 2 pixels
The largest connected component is the second connected component and the smallest connected component is the fourth connected component.
We need to calculate the centroid, to perform centroid calculation, we require pixel positions
Let's take smallest component for analysis. As mentioned in the question, the pixel spatial coordinates are labelled from the top left corner as (1,1). So, the spatial coordinates for the pixels which belong to the fourth connected components are {(8,5), (8,6)}. I got the values (8,5) and (8,6) by counting the number of rows and then the number of columns from the top left corner. Due to 2 pixels in the connected component, we have two spatial coordinates in the set. Now, we need to average them to find the centroid along each axis.
The centroid of the smallest connected component is {(8,5.5)}. Sometimes, the real value is converted to integer for find the centroid pixel. In this case, it will be {(8,6)}. I have rounded 0.5 to next integer.
Similarly, the pixel in the largest connected components are
{(2,6),(2,7),(2,8),(3,5),(3,6),(3,8),(4,5),(4,8),(5,6),(5,7),(5,8)}
The centroid of the largest connected component is {(38/11,74/11)} = {(3.4545,6.7272)}. Rounding of the nearest integer, we get {(3,7)}
--------------------------------------------------------------------------------------------------------------------------------------
f) For dilation operation, we consider only pixels with value '0', which are termed as background pixels. If any neighborhood pixel has value '1', which are considered as foreground pixels, then the pixel value is set '1', else left as it is.
Assumption of padding 1's is also provided in the problem. This assumption is used for the edge pixels or boundary pixels. Since 3x3 box filter do not cover all the pixels and some portion is left empty. The unfilled portion of the filter is considered as '1' for dilation operation.
First pass of dilation
In only one pass, all the pixel values are set to '1' and making the image as a single connected component.
---------------------------------------------------------------------------------------------------------------------------------
g) For erosion operation, we consider only pixels with value '1', which are termed as foreground pixels. If any neighborhood pixel has value '0', which are considered as background pixels, then the pixel value is set '0', else left as it is.
Assumption of padding 1's is also provided in the problem. This assumption is used for the edge pixels or boundary pixels. Since 3x3 box filter do not cover all the pixels and some portion is left empty. The unfilled portion of the filter is considered as '1' for erosion operation.
First pass of erosion
Still there are two pixels with value '1'. We need to perform erosion again to make the image with the pixels of same value.
Second pass of erosion
Now, all the pixels have same value and hence the single connected component is obtained after two times erosion operation.
-----------------------------------------------------------------------------------------
215 159 123 80 10 5 8 8 205 208 12 7 10 95 117 215 91 117 8 23 91 103 22 215 17 35 10 5 236 15 2 117 5 10 8 10 46 215 117 117 74 91 215 5 16 40 15 13 126 10 91 41 5 10 18 47 101 183 91 8 91 91 21 15