背景を前景から分離し、バイナリ (黒/白) 画像を作成するために何らかの処理を行う画像があります。
AForge を使用すると、処理された画像からすべてのブロブを検出して返すことができます。
そこで、元の画像を「SourceImg」にコピーし、フィルタリングを行って背景を分離し、バイナリ画像にすると、適切にブロブ抽出を行うことができます。
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;
}
私が本当にやりたいことは、これらのブロブの情報を使用して、元の未処理の画像から位置を抽出することです。
理想的には、ブロブをクッキー カッターのように使用して、最初の未処理の画像ファイルからそれらを抽出したいと考えています。