Hello everybody,
i wrote a program which find every pixel and check their around. I want to write every checked pixel to 2d array. For this reason i initialized struct and with help of struct 2d array. But when i want to fill 2d array with checked pixels after x=167, the program can not terminate its operation. What is problem?
In advance thank you very much!
typedef unsigned char buftype;
#define NBUF 4104
#define MAXCLU 10000
#define MAXPIX 6000
struct tpix {
unsigned char x,y;
unsigned short z;
};
tpix cluster[MAXCLU][MAXPIX];
void fillcluster(int x, int y) {
const int ncluster=34;
int np[ncluster];
int nn=np[ncluster];
cluster[ncluster][nn].x=x;
cluster[ncluster][nn].y=y;
cluster[ncluster][nn].z=frame[x][y];
printf("%d %d %d \n", cluster[ncluster][nn].x, cluster[ncluster][nn].y, cluster[ncluster][nn].z);
frame[x][y]=0;
np[ncluster]++;
}
void clust(int x, int y) {
int i,j,m;
for (i=-1;i<2;i++) {
for (j=-1;j<2;j++) {
if (frame[x+i][y+j]>0) {
fillcluster(x+i,y+j);
clust(x+i,y+j);
}
}
}
}
analyze_clusters() {
int i,j;
int k,l;
for (i=0;i<258;i++) {
for (j=0;j<258;j++) {
if (frame[i][j]>0) {
clust(i,j);
}
}
}
}
