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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started