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

OMR - Get Circle (blob) Fullness / Partial fill problem

The forum is to discuss topics related to different areas of image processing and computer vision.

OMR - Get Circle (blob) Fullness / Partial fill problem

Postby costin_chivu » Tue Jul 19, 2016 9:42 pm


After trying many solutions I was able to find online I'm stuck on how to interpret if a circle from a scanned paper is filled or not and, in case of partial fill, to give me the correct fullness.
I do the following:

1 - convert PDF to Image (I'm using GhostScriptSharp for this task)
2 - convert image to unmanagedimage
3 - apply gray-scale
4 - apply invert
5 - apply threshold (10)
6 - scan through blobs
7 - find circles
8 - if circle, get blob fullness

The code I use top get the fullness (VB.NET) is the following:

Code: Select all
        Dim image As UnmanagedImage = UnmanagedImage.FromManagedImage(Me.PictureBox1.Image)
        'convert to grayscale
        Dim gr_filter As IFilter = New Grayscale(0.2125, 0.7154, 0.0721)
        image = gr_filter.Apply(image)
        'invert image
        Dim ifilter As New Invert()
        'apply threshold
        Dim thresholdFilter As New Threshold(10)
        'save image to see

        'define the blobcounter
        Dim blobCounter As New BlobCounter()
        'luam doar obiecte mari
        blobCounter.FilterBlobs = True
        blobCounter.MinHeight = 55
        blobCounter.MinWidth = 55
        Dim blobs As Blob() = blobCounter.GetObjectsInformation()

        ' searching for circles
        Dim shapeChecker As New SimpleShapeChecker()
        For Each blob As Blob In blobs
            Dim edgePoints As List(Of AForge.IntPoint) = blobCounter.GetBlobsEdgePoints(blob)
            Dim center As AForge.DoublePoint
            Dim radius As Double
            If shapeChecker.IsCircle(edgePoints, center, radius) Then
                If blob.Rectangle.Width > 55 And blob.Rectangle.Height > 55 Then
                    'get the fullness
                End If
            End If
    End Sub

It works well if the circle is correctly filled (full fill). However, in case the circle is partially filled, the section inside is recognized as another blob (circle) and the fullness is... as it would be blank. The processed image (filters applied / blob filtering applied) is the following:

In the second circle (bottom) there is another circle which is the actual fill (pencil was used). Could you please give me an idea on how to proceed?

Posts: 1
Joined: Tue Jul 19, 2016 9:24 pm

Re: OMR - Get Circle (blob) Fullness / Partial fill problem

Postby andrew.kirillov » Tue Jul 19, 2016 11:05 pm


Since you get coordinates and CoG for each blob, you may try checking if your circles have anoher blob inside them.
With best regards,

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

Return to Image Processing and Computer Vision