Changed sum formula
This commit is contained in:
parent
f82e141315
commit
feefe1b0a6
|
@ -4,4 +4,9 @@ Settings::Settings( void )
|
|||
{
|
||||
colorThreshold[0] = 100;
|
||||
colorThreshold[1] = 1000;
|
||||
|
||||
ul.x = bl.x = ul.y = ur.y = 30;
|
||||
ur.x = br.x = 610;
|
||||
br.y = bl.y = 450;
|
||||
|
||||
}
|
||||
|
|
|
@ -42,16 +42,16 @@ State State::generateState (SDL_Surface *boardImg, Settings settings)
|
|||
int i, j, x, y, r, sum;
|
||||
point p;
|
||||
r = 10; //what kind of magic number is this?
|
||||
for (i = 0; i < size; i++) {
|
||||
for (j = 0; j < size; j++) { //for all points:
|
||||
for (i = 0; i < size; ++i) {
|
||||
for (j = 0; j < size; ++j) { //for all points:
|
||||
p = positionPoint(i, j, settings); //retrieve the estimated point
|
||||
sum = 0;
|
||||
|
||||
//TODO: this loop should be placed into its own function!
|
||||
for (y = p.y-r; y < p.y+r; y++) {
|
||||
for (x = p.x-r; x < p.x+r; x++) { //for -20 to 20 around the point
|
||||
for (y = p.y-r; y < p.y+r; ++y) {
|
||||
for (x = p.x-r; x < p.x+r; ++x) { //for -10 to 10 around the point
|
||||
uint32_t px = PX(boardImg, x, y);
|
||||
sum += (1024 -PXR(px) - PXG(px) + PXB(px)); //sum up the colors
|
||||
sum += (PXR(px) + PXG(px) + PXB(px)); //sum up the colors
|
||||
}
|
||||
}
|
||||
sum/=400;
|
||||
|
|
Reference in New Issue