As I was shooting an archery 900 round earlier today (10 ends at 6 arrows an end, and 10 ends at 3 arrows an end, for a total of 90 arrows and a maximum score of 900), I thought of this challenge.
In archery (assuming that you are shooting on a FITA supplied target face [the piece of paper that you shoot at]), for each arrow you can claim a maximum score of 10. The target face contains 10 or 11 rings of decreasing diameter, nested inside one another. From the inner ring outward, these are counted from 10 points, to one point (and in the case of 11 rings, there is a secondary innermost ring that counts as 'X', which scores as 10 but is used in tie breaking cases as the higher value). Observe:
Of course, I am referring to the FITA Metric scoring, as seen in the above illustration. If you look closely, you may observe the innermost ring, which is a faded dotted line, whose score is not marked. That is the 'X' that I was referring to, but you will not have to pay heed to that unless competing for the bonus.
Create a function (or full program, if the language doesn't support functions), that receives a perfectly square image as input (or image filename, if need be), containing some number of green (HEX #00FF00, RGB(0, 255, 0)) dots of some size, and returns the score. The image may contain data other than the green dots, but the green will always be the exact same shade.
You may imagine that the square image represents the target face, with the outermost ring touching at 4 points (top center, bottom center, right center, left center). The represented target face will always be of the same proportion, with all of the rings having a width of exactly 1/20th of the input target image's width. As an example, given an input image of input dimensions 400px by 400px, you may assume that each ring has an inner width of 20px, as illustrated below:
- If touching two seperate rings, the higher of the two rings is counted
- You do not have to automatically account for misses or the 'x' case, unless trying for the bonus
- You may assume that no green circles are overlapping
- You may also assume that no other pixels of that shade of green are in the image
- The image will either be in a PNG, JPEG or PPM format (your choice)
- External image processing libraries are allowed, if authored before the posting of this question
- You may assume that all green circles on one target will have the same diameter
- If shooting (hah) for the overlapping circles bonus, you may assume that at least one circle in the image does not have another overlapping
- Standard loopholes are disallowed
The following two cases should each score 52 (or in the case of bonuses, 52 with 1 'x' and 1 miss):
And this last test case should score 25:
- -25 bytes if you also return the number of misses (outside any of the rings) as well
- -30 bytes if you also return the amount of Xs (assume that the innermost x is 3/100ths of the width of the image, and 10 is then 2/100ths of the width of the image. The 1-9 proportions remain unchanged)
- -35% byte count if you account for overlapping circles
This is code golf, so the least bytes wins. Have fun!