Simple Blob Detector: How is a blob measured?

How is a blob measured in Simple Blob Detector? The equation for detecting the blob size seems to be as follows: Math.PI * (kp.Size / 2) ^ 2) . According to OpenCV: OpenCV: cv::KeyPoint Class Reference it seems kp.Size is keypoint size which seems to be the keypoint diameter? Why would a blob be measured based on diameter? Blobs are not a perfect circle and can have tentacles that stretch out or even stay connected via a few pixels. Is there a better way to determine blob size in pixels^2? Or just number of pixels would be fine.

I am working on a project where there is a MinArea input that should be a lower filter on the size of blob output. This is my current code:

Private Shared Sub FindColorBlobs(UseUDTempSettings As Boolean)
        Dim MinThreshold, MaxThreshold
        MinThreshold = 100
        MaxThreshold = 200

        Dim sbdParams As New SimpleBlobDetectorParams

        bAngleNaN = False
        bAngleInvalid = False
        bAnglePass = False
        dAngle = 0.0
        sAngle = ""

        sbdParams.MinThreshold = MinThreshold
        sbdParams.MaxThreshold = MaxThreshold
        sbdParams.ThresholdStep = 20
        sbdParams.FilterByArea = True
        If UseUDTempSettings Then
            sbdParams.MinArea = fSettings.RhtMinArea
        Else
            sbdParams.MinArea = AppSettings.GetInt("Rotation_Param_RhtMinArea")
        End If
        sbdParams.MaxArea = 100000
        sbdParams.FilterByCircularity = False
        sbdParams.MinCircularity = 0.1
        sbdParams.FilterByConvexity = False
        sbdParams.MinConvexity = 0.37
        sbdParams.FilterByInertia = False
        sbdParams.MinInertiaRatio = 0.01
        sbdParams.FilterByColor = False
        sbdParams.blobColor = 255

        Dim sbdR As New SimpleBlobDetector(sbdParams)
        kpRight = sbdR.Detect(RhtImage)
        FindTopBlob(MarkerTypes.Cross, kpRight, ptRTop)

        If UseUDTempSettings Then
            sbdParams.MinArea = fSettings.LftMinArea
        Else
            sbdParams.MinArea = AppSettings.GetInt("Rotation_Param_LftMinArea")
        End If
        Dim sbdL As New SimpleBlobDetector(sbdParams)
        kpLeft = sbdL.Detect(LftImage)
        FindTopBlob(MarkerTypes.Diamond, kpLeft, ptLTop)

        dX = ptRTop.X - ptLTop.X
        dY = ptRTop.Y - ptLTop.Y
        If UseUDTempSettings Then
            bDiffXPass = (dX >= fSettings.DiffXMin) And (dX <= fSettings.DiffXMax)
            bDiffYPass = (dY >= fSettings.DiffYMin) And (dY <= fSettings.DiffYMax)
        Else
            bDiffXPass = (dX >= AppSettings.GetInt("Rotation_Param_DiffXMin") And dX <= AppSettings.GetInt("Rotation_Param_DiffXMax"))
            bDiffYPass = (dY >= AppSettings.GetInt("Rotation_Param_DiffYMin") And dY <= AppSettings.GetInt("Rotation_Param_DiffYMax"))
        End If

        If kpRight.Count > 0 And kpLeft.Count > 0 Then
            If dX <> 0.0 Then
                Dim Min, Max As Double

                dAngle = Math.Atan(dY / dX) * 180.0 / Math.PI
                If dX < 0.0 Then
                    dAngle = dAngle + 180.0
                ElseIf dY < 0.0 Then
                    dAngle = dAngle + 360.0
                End If
                sAngle = dAngle.ToString("##0.0")
                If UseUDTempSettings Then
                    Min = fSettings.AngleMin
                    Max = fSettings.AngleMax
                Else
                    Min = AppSettings.GetInt("Rotation_Param_AngleMin")
                    Max = AppSettings.GetInt("Rotation_Param_AngleMax")
                End If
                If Min < 0 Then
                    Min = 360.0 + Min
                    bAnglePass = (dAngle >= Min Or dAngle <= Max)
                Else
                    bAnglePass = (dAngle >= Min And dAngle <= Max)
                End If
            Else
                sAngle = "Nan"
                bAngleNaN = True
            End If
        Else
            sAngle = "INV"
            bAngleInvalid = True
        End If

    End Sub

End Class

Why are the KeyPoint’s size (the output) less than the MinArea (input)?

What is MinArea and what is Size for Kp? Is there a difference in Units or is something else awry?

Thanks in advance.

“area” is literally the count of pixels for a blob, regardless of shape.

KeyPoint really doesn’t fit the “blob” concept very well. there is an unavoidable mismatch between keypoints and blobs.

I haven’t checked in OpenCV’s code but I would speculate that either the keypoint’s size is simply the area, or else assuming the blob to be a circle, it’s its diameter calculated from the area.

looks like the size of the KeyPoint (second argument, if the first is a Point) is set to be the “diameter”, which is twice the “radius”, and “radius” is calculated thusly:

that looks like it’s taking the barycenter (from moments calculation), then taking all the distances to all the contour points, and taking the median of that.

We set the MinArea to 1000 and are getting back sizes far less than that. Is there a better way to calculate blob size?

Thanks Again!

what values did you get for keypoint sizes, exactly?

what did you expect them to be instead?

if the area is 1000 pixels, and assuming circles, then

π·r² = 1000
r = 17.84
d = 2·r = 35.68

and the size is the diameter.