Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

use matlab Project 2: Connected components (4 connected and 8 connected) Instruc

ID: 3870136 • Letter: U

Question


use matlab

Project 2: Connected components (4 connected and 8 connected) Instructions: Read image of your choice by using imread function Convert it to grayscale if it is in RGB by using rgb2gray function Convert it to binary image by using im2bw function from matlab or take some threshold and make it to binary imageim bin apize . Define the size of the image . Take P as the center pixel and A and Bas the neighboring pixels .If both of the neighboring pixels are "O" give a new label to that corresponding pixel in the resulting image . If A=0 and B= 1 assign the label of B to P If A-1 and B-0 assign the label of A to 1A; 1 and B= 1 assign the label of either A or B and make a note that A=B After you assign all the labels go and scan the whole image and replace all the pixels of same object i.e. all pixels with the same label as A or all the pixels with same label as B Finally count the number of different labels in the image Plot your images by using the "imagesc" function to see different objects in the image with different colors Compare your result with "bwlabe" Please try to do 8-connected if you are done with 4-connected

Explanation / Answer

answres instruction wise:

1) A = imread(filename, fmt ) reads a greyscale or color image from the file specified by the string filename , where the string fmt specifies the format of the file. If the file is not in the current directory or in a directory in the MATLAB path, specify the full pathname of the location on your system.

example. A=imread(holo.jpg)

2) gray = rgb2gray ( rgb ) Convert RGB image or colormap to grayscale. In this case gray=rgb2gray(A).

3) BW = im2bw(I, level) converts the grayscale image I to a binary image. ... Therefore, a level value of 0.5 is midway between black and white, regardless of class. To compute the level argument, you can use the function graythresh . If you do not specify level , im2bw uses the value 0.5. In this case BW=im2bw(gray,0.5).

4) Reading the image size: [x1,y1,z1] = size(A);

5)