It should be simple enough by using an image processing library, I'm going to show you AForge.net since you asked in the C# forum
The first step is to filter out the background since the image already has a lot of circles by design, and running any old circle detection on it isn't going to work because it's going to register the target as a circle too.
The green background behind the bullet holes gives us an ideal colour to isolate, since it's quite far off from the other colours. We are going to make every colour in the image black except for colours that are close to green. I used these settings in my test:
Code:
EuclideanColorFiltering filter = new EuclideanColorFiltering();
filter.CenterColor = new RGB(99, 170, 94);
filter.Radius = 35;
filter.ApplyInPlace(bmp);
Which gave me this:
Now that the background is gone and just the holes are remaining, the finish line is in sight. AForge has a class called BlobCounter which will detect standalone objects in an image (in our case these green dots). It also gives you a class that will let you identify the shapes of these blobs.
Code:
BlobCounter counter = new BlobCounter();
counter.FilterBlobs = true;
counter.MinHeight = 5;
counter.MinWidth = 5;
counter.ProcessImage(bmpData);
Blob[] blobs = counter.GetObjectsInformation();
bmp.UnlockBits(bmpData);
SimpleShapeChecker checker = new SimpleShapeChecker();
checker.RelativeDistortionLimit = 0.2f;
It's important to set the distortion limit on the shape checker, because more often than not these holes are going to be imperfect circles.
The last step is to just iterate through the blobs and do what you want with the data
Code:
for (int i = 0; i < blobs.Length; i++)
{
List<IntPoint> edges = counter.GetBlobsEdgePoints(blobs[i]);
AForge.Point center;
float radius;
if (checker.IsCircle(edges, out center, out radius))
{
graphics.DrawEllipse(Pens.Red,
(float)(center.X - radius), (float)(center.Y - radius),
(float)(radius * 2), (float)(radius * 2));
}
}
Not bad for a first attempt
On the middle left hand side it detected two of the holes as a single blob, this is probably because they are just about overlapping. You need to have a look into further filtering and refine those edges more, or just make it a
feature in your system.
Here's the code I used (minus the designer junk), but it should be enough to get you started
http://pastebin.com/zCbpDy99