I've tried many different variants of both of the ways, and cannot get it to sum the array. It's passed into the function as a pointer and need to calc the mean and return.
unsigned char calcMean(unsigned char *buffer, int height, int width)
{
unsigned char mean, sum=0;
counter i, k;
int size;
size = width*height;
mean = 0;
for (i = 0; i < size; i++) {
sum += buffer[i];
}
/*
for(k=0;k<(width*height);k++)
{
mean = mean + *Buffer;
frameBuffer++;
printf("%d\n", mean);
}
*/
return sum;
}
summay be out of range ofunsigned chartype. Consider declaring is as a variable of larger data type likeint.buffer[i]when you run it under a debugger?