A robot collects golf balls. It knows what a ball looks like in its camera: a small template, a bright dot on grass, 3 × 3 pixels. Write match(window, template): given a window of the photo the same size as the template, say how well it matches: the higher, the more it looks like the ball. The robot will go to the windows that score highest, so every ball should score high, wherever it lies.
The robot’s photo of the driving range, each pixel a brightness drawn as its grey, and the ball it looks for. It slides the ball over the photo and scores every window, drawn under the photo as a score map. The brightest spot is the sand; comparing pixel by pixel loses the balls in the shadow and the mist. The goal is a map like the one it ends on. Your match(window, template) scores one window.
match(window, template)| window | a 3x3 patch of the photo (a numpy array), brightness 0 to 24 | e.g. [[4, 8, 4], [8, 24, 8], [4, 8, 4]] |
| template | the 3x3 ball the robot looks for (a numpy array), the same size | e.g. [[4, 8, 4], [8, 24, 8], [4, 8, 4]] |
| returns | how well the window matches the template: the higher, the better | |