Question: Problem Description: Task 1: For this task, you are going to complete two functions. One to label each blood cell (how is it defined?) with
Problem Description:

Task 1:
For this task, you are going to complete two functions. One to label each blood cell (how is it defined?) with a unique number and another to count the number of the unique blood cells.
1. The first function gets a 10x10 two-dimensional array of 0s and 1s, and labels each blood cell with a unique number. For example, if the given image (i.e., two-dimensional array) is something like the left picture below, one sample solution can be something like the right picture. It is not important how you choose the numbers for the cell, as long as it is not zero or a negative number. Also, the numbers do not need to be in a consecutive order. For example, one might label the cells in the example below with arbitrary numbers of 20, 3, 4, 8, 18, 7, 1. The signature of this function looks like below:
void color(int image[IMAGE_SIZE][IMAGE_SIZE]);
This function gets the 10x10 two-dimensional array (like the above picture) and label each group of 1s (a distinct cell) with a unique number (like the right picture).
Ansi-C Code:
#include
#include
#define IMAGE_SIZE 10
// this function prints the array
void printImgArray(int array[IMAGE_SIZE][IMAGE_SIZE])
{
printf("------ Image Contents ------- ");
int i, j;
for (i=0; i
{
for (j=0; j
printf("%02d, ",array[i][j]);
printf(" ");
}
printf("----------------------------- ");
}
/**
* This function counts the number of distinct
* number (i.e. the number of cells)
*
* feel free to add auxiliary data structures and helper functions
**/
int cellCount(int image[IMAGE_SIZE][IMAGE_SIZE]){
// insert your code for task1.2 here
// you may want to change the return value.
return 0;
}
/**
* This function colors each blood cell with a unique color
* (i.e. unique number)
* Hint: scan the array element by element, and explore each element as much as possible,
* when come to an already labelled one, relabell the array to form larger cell
*
* feel free to add auxiliary data structures and helper functions
**/
void color(int image[IMAGE_SIZE][IMAGE_SIZE]){
// insert your code for task 1.1 here
int i, j;
for (i=0; i
{
for (j=0; j
}
// ...
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
