# Simple Blob Detector: How is a blob measured?

**URL:** <https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157>\
**Category:** Python\
**Tags:** features2d\
**Created:** [July 16, 2025, 2:08pm UTC](https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157 "2025-07-16T14:08:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CCN](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@CCN](https://forum.opencv.org/u/CCN)\
**Post date:** [July 16, 2025, 2:08pm UTC](https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157/1 "2025-07-16T14:08:55Z")

</div>

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](https://docs.opencv.org/4.x/d2/d29/classcv_1_1KeyPoint.html) 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:

```basic
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.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 16, 2025, 2:27pm UTC](https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157/2 "2025-07-16T14:27:35Z")

</div>

“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.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 16, 2025, 2:37pm UTC](https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157/3 "2025-07-16T14:37:39Z")

</div>

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:

> <https://github.com/opencv/opencv/blob/4813d1cd3245013df505af2e036c075562187bc2/modules/features2d/src/blobdetector.cpp#L469C74-L469C80>

> <https://github.com/opencv/opencv/blob/4813d1cd3245013df505af2e036c075562187bc2/modules/features2d/src/blobdetector.cpp#L325-L325>

> <https://github.com/opencv/opencv/blob/4813d1cd3245013df505af2e036c075562187bc2/modules/features2d/src/blobdetector.cpp#L333-L345>

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.

---

<div class="post-metadata">

**Author:** ![CCN](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@CCN](https://forum.opencv.org/u/CCN)\
**Post date:** [July 16, 2025, 2:44pm UTC](https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157/4 "2025-07-16T14:44:08Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 16, 2025, 7:35pm UTC](https://forum.opencv.org/t/simple-blob-detector-how-is-a-blob-measured/23157/5 "2025-07-16T19:35:08Z")

</div>

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.
