Page 1 of 1

Issue detecting multiple circles in black background

PostPosted: Tue Feb 20, 2018 5:29 am
by tgiardina
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 6706 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

Re: Issue detecting multiple circles in black background

PostPosted: Tue Feb 20, 2018 8:16 am
by andrew.kirillov
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.

Re: Issue detecting multiple circles in black background

PostPosted: Tue Feb 20, 2018 5:39 pm
by tgiardina
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

Re: Issue detecting multiple circles in black background

PostPosted: Tue Feb 20, 2018 6:25 pm
by andrew.kirillov
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.

Re: Issue detecting multiple circles in black background

PostPosted: Wed Feb 21, 2018 1:16 pm
by tgiardina
Thanks for the encouragement. I will give that a shot. :D