Ball locate
  2    
To locate the ball precisely, the X, Y coordinates for centroid (geometric center) ar calculated, using formulas  Cx = ∑CixAi / ∑Ai  and  Cy = ∑CiyAi / ∑Ai,  where Cx, Cy are X, Y coordinates and A is the value of every pixel. As the background is predominantly black before this step, Cx, Cy will be in the center of the ball. Then the whole picture is moved so that the centroid is at coordinates 110,110, which is at the center of the frame. The center is marked with 2x2 red pixels.

Next, the averade diameter is measured, calculating the average pixel value for different diametres. The highest drop of average value (relative to the previous one) is considered as the ball diameter. Then, the background (every pixel which is outside of the diameter) is set to "white", or, more specifically, green (value 63).

Those two steps takes 38 ms. This is only the small microcontroller, so it is the good speed for 220*220 matrix. One part of credit for that goes to assembly language, and the other one to lookup tables which are used instead of trigonometric calculations.

 

    Back to projects 
0. Home
H. Hardware
L. Lighting
1. Frame fetch
2. Ball locate
3. Stretching
4. Unsharp mask
5. Component selection
6. Holes and scratches
7. Component shrink
8. Invert selection
9. Component list
10. Select best circle
11. Angle detection
12. Rotate selected
13. Select broad lines
14. Selected components list
15. Components scaling
16. Histogram
17. MSE and voting
C. Conclusion