ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Count objects in image

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
xequte Posted - Jun 05 2018 : 17:27:04
Example code to find and count all blobs in this image:




// Show layer rects around objects
var
  rects: TList;
  i: integer;
  count: integer;
begin
  ImageEnView1.Proc.ConvertToBWThreshold(80);     // <= 80 = sensible parameter
  rects := ImageEnView1.Proc.SeparateObjects(4, false);
  ImageEnView1.Proc.Undo(); // Revert image

  count := 0;
  for i := 0 to rects.Count-1 do
  begin
    with PRect(rects[i])^ do
    begin
      if (Right-Left > 10) and (Bottom-Top > 10) then // Exclude small objects
      begin
        // Add Layers
        ImageEnView1.LayersAdd( iesRectangle, Rect( Left, Top, Right + 1, Bottom + 1), clRed, 2 );
        inc(count);
      end;
    end;
    dispose(PRect(rects[i]));
  end;
  rects.free;
  ImageEnView1.Update;

  ShowMessage('Found ' + IntToStr(count) + ' objects');
End;

// Draw red box onto image
var
  rects: TList;
  i: integer;
  count: integer;
begin
  ImageEnView1.Proc.ConvertToBWThreshold(80);     // <= 80 = sensible parameter
  rects := ImageEnView1.Proc.SeparateObjects(4, false);

  // Needed to draw red rectangles around found objects!
  ImageEnView1.Proc.ConvertTo24Bit();

  count := 0;
  for i := 0 to rects.Count-1 do
  begin
    with PRect(rects[i])^ do
    begin
      if (Right-Left > 10) and (Bottom-Top > 10) then // Exclude small objects
      begin
        // draw boxes
        with ImageEnView1.IEBitmap.Canvas do
        begin
          Pen.Color:=clRed;
          Brush.Style:=bsClear;
          Rectangle(Left,Top,Right+1,Bottom+1);
        end;

        inc(count);
      end;
    end;
    dispose(PRect(rects[i]));
  end;
  rects.free;
  ImageEnView1.Update;

  ShowMessage('Found ' + IntToStr(count) + ' objects');
End;




Nigel
Xequte Software
www.imageen.com
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 15 2018 : 00:22:55
Please wait for the release of IEVision v4.5.0 in about a week.

Nigel
Xequte Software
www.imageen.com
chouk Posted - Jun 14 2018 : 06:47:09
Hi,

Where is the link this demo for test ?

Thank's
xequte Posted - Jun 12 2018 : 23:07:17
Or with new IEVision Blob Detector:



Nigel
Xequte Software
www.imageen.com