AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Issue detecting multiple circles in black background

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

Issue detecting multiple circles in black background

Postby tgiardina » Tue Feb 20, 2018 5:29 am

Hello! I have project where I am trying to detect the circles in a black and white image. I invert the image and use the BlobCpunter :
Code: Select all
         // create filter
         Invert filter = new Invert();
         // apply the filter
         filter.ApplyInPlace(bitmapData);

         // step 2 - locating objects
         BlobCounter blobCounter = new BlobCounter();

         blobCounter.FilterBlobs = true;
         blobCounter.MinHeight = 2;
         blobCounter.MinWidth = 2;

         blobCounter.ProcessImage(bitmapData);
         Blob[] blobs = blobCounter.GetObjectsInformation();
         bitmap.UnlockBits(bitmapData);


The image looks like this after it is inverted:
inverted.JPG
inverted.JPG (78.06 KiB) Viewed 4596 times


I have tried several different values for blobCounter.MinHeight and MinWidth. When it is small, like 2, it picks up artifacts. Larger values never seem to pick up the circles with the index numbers in them. I want to count the number of circles with the index numbers in them. I am new to AForge, so I am not sure what I am doing wrong.

Any help is appreciated!

Thanks
tgiardina
 
Posts: 3
Joined: Tue Feb 20, 2018 5:17 am

Re: Issue detecting multiple circles in black background

Postby andrew.kirillov » Tue Feb 20, 2018 8:16 am

Hello,

Looking at the image, it does not look like circles are isolated objects. Instead circles seem to be connected to lines, etc. And so blob counter will no be able to extract them.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Issue detecting multiple circles in black background

Postby tgiardina » Tue Feb 20, 2018 5:39 pm

Thank for the input, Andrew. Is there another part of the framework that could be used? Would Hough circle transformation work, or is that out of the question due to the lines connected to the circles?

Thanks
tgiardina
 
Posts: 3
Joined: Tue Feb 20, 2018 5:17 am

Re: Issue detecting multiple circles in black background

Postby andrew.kirillov » Tue Feb 20, 2018 6:25 pm

tgiardina wrote:Would Hough circle transformation work, or is that out of the question due to the lines connected to the circles?

No, lines is not an issue for Hough Circle Transformation. It will actually work, if you know radius of circles you want to detect. If it may vary slightly, you can run it several times with different radius values. It will cost performance though.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Issue detecting multiple circles in black background

Postby tgiardina » Wed Feb 21, 2018 1:16 pm

Thanks for the encouragement. I will give that a shot. :D
tgiardina
 
Posts: 3
Joined: Tue Feb 20, 2018 5:17 am




Return to AForge.NET Framework