First of all, sorry if this topic already exists (I think this is a common task, but couldn\'t find anything).
The point, is that I have an image who shows different
Since you already know the colors you are looking for, I would segment the image based on color. The steps I would follow are:
red_dot_count = 0
yellow_dot_count = 0
green_dot_count = 0
For each pixel in the image:
if pixel color is red:
floodfill using this pixel as seed pixel and target_color as black
red_dot_count++
if pixel color is green:
floodfill using this pixel as seed pixel and target_color as black
green_dot_count++
if pixel is yellow:
floodfill using this pixel as seed pixel and target_color as black
yellow_dot_count++
Your image would have to be a PNG image though as @Mark pointed out.
Also, this assumes that the colors in the red, green and yellow dots do not appear anywhere else in the image.