You are here: Start » AVL.NET » Adaptive Vision Library .NET Usage » Blob Analysis Example

Blob Analysis Example

Following example thresholds a loaded image into the region with ThresholdToRegion function and then splits it into blobs with SplitRegionIntoBlobs function. Blobs, that don't met specific area condition, are bounded with red circle. Circles, determined with RegionBoundingCircle function are drawn with DrawCircle function. The region area is calculated using RegionArea function.

To have the example work, a single form with PictureBox control and a mounts.jpg file located in the application directory are needed.

using System.Linq;

using AvlNet;

    public partial class Form1 : Form
        public Form1()


        private void Inspect()
            Image mountsImage;
            Region mountsRegion;
            Region[] mounts;

            AVL.LoadImage("mounts.jpg", false, out mountsImage);
            AVL.ThresholdToRegion(mountsImage, null, null, 128.0f, 0.0f, out mountsRegion);
            AVL.SplitRegionIntoBlobs(mountsRegion, RegionConnectivity.FourDirections, 1, false, out mounts);

            //display invalid mounts
            DrawingStyle style = new DrawingStyle() { Thickness = 2.0f, DrawingMode = DrawingMode.HighQuality, Opacity = 1.0f };
            Pixel red = new Pixel(255.0f, 0.0f, 0.0f, 0.0f);
            foreach (Region mount in mounts)
                int area;
                AVL.RegionArea(mount, out area);
                if (area < 2000)
                    Circle2D circle;
                    AVL.RegionBoundingCircle(mount, out circle);
                    AVL.DrawCircle(ref mountsImage, circle, red, style);
            pictureBox1.Image = mountsImage.CreateBitmap();

            //dispose objects
            foreach (Region r in mounts)

Previous: Basic Template Matching Next: AvlNet Designers example