I have an image that I do some processing to in order to separate the background from the foreground, creating a binary (black/white) image.
Using AForge, I am able to detect all blobs from the processed image, and return them.
So, I take my original image, copy it to "SourceImg", do some filtering to separate the background and make it a binary image, and then I can do the blob extraction properly.
public static List<Bitmap> ApplyBlobExtractor(Bitmap SourceImg)
{
List<Bitmap> ImgLetters = new List<Bitmap>();
AForge.Imaging.BlobCounter blobCounter = new AForge.Imaging.BlobCounter();
// Sort order
blobCounter.ObjectsOrder = AForge.Imaging.ObjectsOrder.XY;
blobCounter.ProcessImage(SourceImg);
AForge.Imaging.Blob[] blobs = blobCounter.GetObjects(SourceImg, false);
// Adding images into the image list
AForge.Imaging.UnmanagedImage currentImg;
foreach (AForge.Imaging.Blob blob in blobs)
{
currentImg = blob.Image;
ImgLetters.Add(currentImg.ToManagedImage());
}
return ImgLetters;
}
What I really want to do is use those blobs' information to extract the locations from the original, unprocessed image.
Ideally, I want to use the blob like a cookie cutter and grab extract them from my initial unprocessed image file.
You can use the AForge.Imaging.Filters.Intersect class using your blob's image and your source image.