[UPDATED]
What i should do is:
int width = 640;
int height = 480;
int average_x;
int average_y;
int count_x = 0;
int count_y = 0;
int count = 0;
for(int a = 0; a < width; a = a+1;){
for(int b = 0; a < height; b = b+1;){
if(pixel(a, b) == white)
{
count = count+1;
count_x = count_x+a;
count_y = count_y+b;
}
}
}
average_x = count_x/count;
average_y = count_y/count;
The average_x and average_y are the center axis you want.