Changed sum formula
This commit is contained in:
parent
f82e141315
commit
feefe1b0a6
|
@ -4,4 +4,9 @@ Settings::Settings( void )
|
||||||
{
|
{
|
||||||
colorThreshold[0] = 100;
|
colorThreshold[0] = 100;
|
||||||
colorThreshold[1] = 1000;
|
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;
|
int i, j, x, y, r, sum;
|
||||||
point p;
|
point p;
|
||||||
r = 10; //what kind of magic number is this?
|
r = 10; //what kind of magic number is this?
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; ++i) {
|
||||||
for (j = 0; j < size; j++) { //for all points:
|
for (j = 0; j < size; ++j) { //for all points:
|
||||||
p = positionPoint(i, j, settings); //retrieve the estimated point
|
p = positionPoint(i, j, settings); //retrieve the estimated point
|
||||||
sum = 0;
|
sum = 0;
|
||||||
|
|
||||||
//TODO: this loop should be placed into its own function!
|
//TODO: this loop should be placed into its own function!
|
||||||
for (y = p.y-r; y < p.y+r; y++) {
|
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 (x = p.x-r; x < p.x+r; ++x) { //for -10 to 10 around the point
|
||||||
uint32_t px = PX(boardImg, x, y);
|
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;
|
sum/=400;
|
||||||
|
|
Reference in New Issue