Question: Perform using MATLAB ! 2. Suppose that you have a matrix consisting of 1s and Os that represent the pixels of a black & white

Perform using MATLAB !

Perform using MATLAB ! 2. Suppose that you have a matrix consisting

of 1s and Os that represent the pixels of a black &

2. Suppose that you have a matrix consisting of 1s and Os that represent the pixels of a black & white image where is and Os correspond to black and white pixels, respectively. Two black pixels are said to be in the same black region if they share a common edge or corner. Note that a black pixel surrounded by white pixels is assumed to be a black region itself by definition. You objective is to write a function numberofRegions(X) that returns the number of regions consisting of ls in the matrix X (i.e., the number of black regions in the image) and the number of is in the largest region (i.e., the number of black pixels in the largest black region). The following table shows a possible list of images, corresponding matrices and the outputs of the function. Image nRegs maxReg O O 0 O O O O O 0 2: 0 0 0 0 0 0 O O 6 15 0 0 O 0 O . O 0 O 0 0 1 0 0 O . 5 17 O 1 1 1 1 1 1 1 O O O O O O 0 0 0 0 O Input 1 1 O O O O O O O O O 1 1 O O 1 O 1 1 1 1 O O O 1 1 O 1 1 O 1 1 O 1 1 O O O O O 1 1 O 1 O 1 1 O O O O 1 1 O O O 1 1 1 1 O O O O 1 1 O 1 1 0 1 1 O O 1 1 1 O O 1 O O 1 1 O 1 1 1 O O 1 1 1 1 1 1 1 O O 1 1 1 O O 1 1 1 0 O O O O O 0 0 0 1 1 0 O 0 0 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 O 1 1 1 11 0 0 1 O 1 1 1 1 1 O O O O O O 1 1 1 0 0 1 1 1 1 1 1 O O O O O 1 O 1 O O O 11 1 1 O O O O O O 1 1 O 1 O O O O O O O O O O 1 1 1 1 1 O O O 1 O O O O O O O O O O 1 1 O 1 1 1 1 O O O O O O O O 1 1 1 O 1 1 1 1 1 O 1 1 O O 1 1 O O O O O 1 1 1 1 1 0 O O 1 1 O O O O 1 1 1 O O O O 1 11 O O 1 1 O O O O 1 1 1 O 1 1 1 O O O O 1 1 1 1 0 O 1 1 O O O O O 1 11 O O O O O O O O 1 1 O O O 1 O O O 0 1 1 1 1 1 1 O O O 11 1 O O 1 O O O 1 11 1 O O 1 O 1 1 1 1 1 1 1 1 O O 1 O 1 11 1 1 1 1 1 O 1 1 O 0 0 0 O O 0 0 0 1 1 1 O O O O 0 0 0 O O O 1 1 1 1 1 1 1 1 0 O O 1 0 0 1 11 O 1 1 O 0 0 0 O O O 0 O O 0 0 0 . T AT: 0 . O O 7 42 0 0 0 O . O . Table 2: A list of possible outputs of the function numberofRegions 2. Suppose that you have a matrix consisting of 1s and Os that represent the pixels of a black & white image where is and Os correspond to black and white pixels, respectively. Two black pixels are said to be in the same black region if they share a common edge or corner. Note that a black pixel surrounded by white pixels is assumed to be a black region itself by definition. You objective is to write a function numberofRegions(X) that returns the number of regions consisting of ls in the matrix X (i.e., the number of black regions in the image) and the number of is in the largest region (i.e., the number of black pixels in the largest black region). The following table shows a possible list of images, corresponding matrices and the outputs of the function. Image nRegs maxReg O O 0 O O O O O 0 2: 0 0 0 0 0 0 O O 6 15 0 0 O 0 O . O 0 O 0 0 1 0 0 O . 5 17 O 1 1 1 1 1 1 1 O O O O O O 0 0 0 0 O Input 1 1 O O O O O O O O O 1 1 O O 1 O 1 1 1 1 O O O 1 1 O 1 1 O 1 1 O 1 1 O O O O O 1 1 O 1 O 1 1 O O O O 1 1 O O O 1 1 1 1 O O O O 1 1 O 1 1 0 1 1 O O 1 1 1 O O 1 O O 1 1 O 1 1 1 O O 1 1 1 1 1 1 1 O O 1 1 1 O O 1 1 1 0 O O O O O 0 0 0 1 1 0 O 0 0 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 O 1 1 1 11 0 0 1 O 1 1 1 1 1 O O O O O O 1 1 1 0 0 1 1 1 1 1 1 O O O O O 1 O 1 O O O 11 1 1 O O O O O O 1 1 O 1 O O O O O O O O O O 1 1 1 1 1 O O O 1 O O O O O O O O O O 1 1 O 1 1 1 1 O O O O O O O O 1 1 1 O 1 1 1 1 1 O 1 1 O O 1 1 O O O O O 1 1 1 1 1 0 O O 1 1 O O O O 1 1 1 O O O O 1 11 O O 1 1 O O O O 1 1 1 O 1 1 1 O O O O 1 1 1 1 0 O 1 1 O O O O O 1 11 O O O O O O O O 1 1 O O O 1 O O O 0 1 1 1 1 1 1 O O O 11 1 O O 1 O O O 1 11 1 O O 1 O 1 1 1 1 1 1 1 1 O O 1 O 1 11 1 1 1 1 1 O 1 1 O 0 0 0 O O 0 0 0 1 1 1 O O O O 0 0 0 O O O 1 1 1 1 1 1 1 1 0 O O 1 0 0 1 11 O 1 1 O 0 0 0 O O O 0 O O 0 0 0 . T AT: 0 . O O 7 42 0 0 0 O . O . Table 2: A list of possible outputs of the function numberofRegions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!