Here you go:
using Stemmer.Cvb;
using Stemmer.Cvb.Foundation;
using System.Linq;
namespace FBlob_ExtractBlobImage_CS
{
class Program
{
static void Main(string[] args)
{
var img = Image.FromFile(@"%CVB%\Tutorial\Foundation\Images\Blob\Microswitch.bmp");
BlobFilter filter = new BlobFilter();
filter.RangeFilters.Add(RangeFilter.Size, new ValueRange<int>(100, 100000));
var blobResult = Blob.BinarizeAndSearch(img.Planes[0], new ValueRange<int>(0, 62), filter);
foreach (var blob in blobResult.Select((value, index) => ( value, index )))
{
var blobCropImage = img.Map(blob.value.BoundingBox);
blobCropImage.Save($"blobCropImage{blob.index}.bmp");
}
}
}
}
By the way, if you prefer C#/.Net, you could have posted this question in that particular sub forum. I’ve only replied with C++, because we are here in the C-style API sub forum.
You are right, this simply crops the bounding box of the a given blob.
If you only want the very area of the blob, you will have to use the binary image as a mask for the source image.