Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your task is to count how many blobs exist in the image, and to label the pixels (entries in the array) corresponding to each blob

Your task is to count how many blobs exist in the image, and to label the pixels (entries in the array) corresponding to each blob with a unique numeric identifier.

Blobs are defined as sets of pixels that are connected. White pixels are connected to each other if either of their eight neighbours (top-left, top, top-right, right, bottom-right, bottom, left, and bottom-left) is also a white pixel.

You have to figure out how to carry out the counting and labelling process.

- The actual value of the labels for each blob does not matter, but:

* Labels should start at 2 (0 and 1 are already taken!)

* You will have as many distinct labels as there are cells in the image

* Blobs can be as tiny as 1 pixel, or as large as the whole image. We will test your

code on a different input image from the one you have in the starter code, so

you should test yourself, with different inputs, and make sure your code works.

ON THE BOTTOM, IS THE STARTER CODE IN C LANGUAGE:

#include #include

void printImgArray(int array[10][10]) { // Print out the contents of the array, it can be // used with the original array, or with the labeled // output after calling cell_count(). printf("------ Image Contents ------- "); for (int i=0; i<10; i++) { for (int j=0; j<10; j++) printf("%02d, ",array[i][j]); printf(" "); } printf("----------------------------- "); }

int cell_count(int image[10][10]) { // This function takes as input a binary array // (one which contains only ones and zeros) // representing a micrograph of blood cells. // The function must count the cells in the // array, and label them: the entries in the array // corresponding to each cell will have a // unique, different number, order does not // matter. // // Cells are represented by groups of 1's // that are connected vertically, horizontally, // or diagonally. // // Input arrays will be 10x10, and guaranteed to // be binary. // // Examples: // // Input: Labels: // // 0011010011 0022030044 // 0010010011 0020030044 // 0000000111 0000000444 // 1110000011 5550000044 // 1100011000 5500066000 // 0000111001 0000666007 // 0100011011 0800066077 // 0100000001 0800000007 // 1100110000 8800990000 // 0100010000 0800090000 // // And there are 8 cells in this image. // // Note: Labels start at 2, the upper limit is the // maximum number of cells you can pack in an image // of 10x10. // * As noted before - the order of labels does // not matter * // TO DO: Complete this function! // REMOVE any print statements you use for testing // BEFORE submitting! nothing should be printed here.

return 0; // <--- obviously it should not return zero }

#ifndef __testing int main() { // DO not change anything in main(), it will confuse the // auto-checker. int count; int cellImg[10][10]={{0,0,1,1,0,0,1,0,0,1},\ {1,0,1,1,0,0,1,1,0,1},\ {1,0,0,1,1,0,1,1,0,1},\ {1,1,0,0,0,0,0,0,0,0},\ {1,0,0,1,1,1,0,0,1,0},\ {0,0,0,0,1,0,0,1,1,0},\ {0,0,1,0,0,1,0,1,0,0},\ {0,0,1,1,0,0,1,0,0,0},\ {0,0,1,0,0,0,0,0,1,1}, {0,1,1,0,0,0,1,1,1,1}}; printImgArray(cellImg); count=cell_count(cellImg); printImgArray(cellImg); printf("Total number of cells in the image: %d ",count); return 0; } #endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

Discuss the goals of financial management.

Answered: 1 week ago