我已经尝试了这两种方法的许多不同变体,但无法将其对数组求和。它作为指针传递给函数,需要计算平均值并返回。
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;
}