Question: Please help I have no idea how to start this. Your task is to complete the labelComponents() method and implement this program, using either Depth

Please help I have no idea how to start this.

Your task is to complete the labelComponents() method and implement this program, using either Depth First Search or Breadth First Search. Submit source code and output corresponding to the given input

// componentLabeling .cpp

// image component labeling

#include

#include "make2dArray.h"

#include "arrayQueue.h"

#include "position.h"

using namespace std;

// global variables

int **pixel;

int size; // number of rows and columns in the image

// functions

void welcome()

{// Not yet implemented.

}

void inputImage()

{// Input the image.

cout << "Enter image size" << endl;

cin >> size;

// create and input the pixel array

make2dArray(pixel, size + 2, size + 2);

cout << "Enter the pixel array in row-major order" << endl;

for (int i = 1; i <= size; i++)

for (int j = 1; j <= size; j++)

cin >> pixel[i][j];

}

void labelComponents()

{// Label the components.

//

// Add Your Code Here

//

}

void outputImage()

{// Output labeled image.

cout << "The labeled image is" << endl;

for (int i = 1; i <= size; i++)

{

for (int j = 1; j <= size; j++)

cout << pixel[i][j] << " ";

cout << endl;

}

}

void main()

{

welcome();

inputImage();

labelComponents();

outputImage();

}

//componentLabeling.input.txt

7

0 0 1 0 0 0 0

0 0 1 1 0 0 0

0 0 0 0 1 0 0

0 0 0 1 1 0 0

1 0 0 0 1 0 0

1 1 1 0 0 0 0

1 1 1 0 0 0 0

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!