Because you only return true if centerX1 is 247 or 227, not anything in between.
You might go about using the values in between something like this:
Code:
return Math.abs( centerX1 - 237 ) < 10;
What this does is
1) finds the difference between 237 and centerX1
2) gets the absolute value of that
3) compares it to 10. Increasing or decreasing 10 will result in a larger or smaller error margin.