Help with locating Blobs in C++

CODE

#include <iostream>
#include <fstream>
using namespace std;
// sets max row and colum size
const int MAXROW=22;
const int MAXCOL=72;
const int MAXLINESIZE =80;
// standered way of putting this
void cleararray( char ba[][MAXCOL]);


int main(void)
{
ifstream myfile;

char bigaarray[MAXROW][MAXCOL];
char inputline[MAXLINESIZE];
cleararray(bigaarray);
myfile.open("blob.txt");
for (int row=1; row<MAXROW-1; row++)
{
myfile.getline(inputline,MAXLINESIZE);
cout <<inputline << endl;
for (int col=1; col<MAXCOL-1; col++)
bigaarray[row][col]=inputline[col-1];

}
myfile.close();

return 0;

}

void cleararray(char ba[][MAXCOL])
{
for (int row=0; row<MAXROW; row++)
for (int col=0; col<MAXCOL; col++)
ba[row][col]=' ';
}

The assignment is to construct code that searches through the file and counts the number of blobs. It needs to search if there is any characters arround the current one. I need to write one more function called
void DestroyBlob(Blobarray,r,c) and in here i need to figure out if there is characters arroung the current one. There are 8 possible places (r ,c-1 )
(r ,c+1 ) (r+1, c)(r-1, c)(r+1, c+1)(r+1, c-1)(r-1, c-1)(r-1, c+1))

All the final output needs to be is the number of blobs.
Thank you
You've not said what a blob is. What counts as not-blob? Space? Different char values?

Either way, look into this: http://en.wikipedia.org/wiki/Connected-component_labeling
Last edited on
a blob is where there is any two characters in arow in the 8 possible places
ex:

xxxx
xxxx
xx

this is one blob
Last edited on
it needs to involve recursion
Have you found you how to do this yet? I'm in a similar situation (same class lol)
Topic archived. No new replies allowed.