ImageEn, unit iexHelperFunctions

TIEBitmapHelper.DetectBlobs

TIEBitmapHelper.DetectBlobs


Declaration

function DetectBlobs(MinThreshold: Double = 50;
                     MaxThreshold: Double = 220;
                     ThresholdStep: Double = 10;
                     MinBlobDistance: Double = 10;
                     GrayFilterEnabled: Boolean = True;
                     GrayLevel: Integer = 0;
                     AreaFilterEnabled: Boolean = True;
                     MinArea: Double = 25;
                     MaxArea: Double = 5000;
                     CircularityFilterEnabled: Boolean = False;
                     MinCircularity: Double = 0.8;
                     MaxCircularity: Double = 3.4e+38;
                     InertiaFilterEnabled: Boolean = False;
                     MinInertia: Double = 0.1;
                     MaxInertia: Double = 3.4e+38;
                     ConvexityFilterEnabled: Boolean = False;
                     MinConvexity: Double = 0.95;
                     MaxConvexity: Double = 3.4e+38): TIERectArray;


Description

A shortcut method that creates a TIEVisionBlobDetector object and calls detect.

For more information on the parameters:
  setFilterByArea
  setFilterByCircularity
  setFilterByConvexity
  setFilterByGrayLevel
  setFilterByInertia
  setMinDistBetweenBlobs
  setThreshold



Note:
 You must add the iexHelperFunctions unit to your uses clause
 You can draw the rects to a canvas using DrawRects
 Blob detection requires IEVision. You will need to register it before calling the method


Method Behaviour

The following call:

rects := ImageEnView1.IEBitmap.DetectBlobs( 50, 220, 10, 150 );

Is the same as calling:

blobDetector := IEVisionLib().createBlobDetector();
blobDetector.setThreshold( 50, 220, 10 );
blobDetector.setMinDistBetweenBlobs( 150 );
blobDetector.setFilterByInertia( False, 0.8, 3.4e+38 );
blobDetector.setFilterByConvexity( False, 0.95, 3.4e+38 );
keyPoints := blobDetector.detect( ImageEnView1.IEBitmap.GetIEVisionImage() );


Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr


Example

// Detect blobs in image
rects := ImageEnView1.IEBitmap.DetectBlobs( 50, 220, 10, 150 );
// Draw rects to image
for i := 0 to Length(rects) - 1 do
begin
  r := rects[i];
  with ImageEnView1.IEBitmap.Canvas do
  begin
    Pen.Width := 2;
    Pen.Color := clRed;
    Brush.Style := bsClear;
    Rectangle( r.x, r.y, r.x + r.width, r.y + r.width );
  end;
end;
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Found: %d', [ Length(rects) ]), 'Arial', 12, Text_Color, [fsBold] );
ImageEnView1.Update();