Blob detection is a computer vision technique that finds regions in an image that differ from their surroundings in brightness or colour, such as cells on a microscope slide, defects on a surface or stars in the sky. Each blob is returned with a position and a size, so software can count, measure or track it.
Key takeaways
- A blob is a connected region of pixels that is brighter or darker than its background. Detectors return a centre and a radius (or area) for each one.
- There are two families: scale-space detectors (LoG, DoG, DoH) that find blobs at several sizes, and threshold-and-contour detectors such as OpenCV's SimpleBlobDetector.
- Laplacian of Gaussian is the most accurate and the slowest; Difference of Gaussian approximates it faster; Determinant of Hessian is the fastest but misses blobs under about 3 pixels.
- Most real projects fail on lighting, noise and touching objects, not on the algorithm. Fix the image capture first, then tune parameters.
- Measure results with precision, recall and F1 on a labelled test set, plus processing time per frame if the system runs on a production line.
- Classical blob detectors still make sense when objects are simple and labelled data is scarce. Deep learning wins when shapes vary and backgrounds are cluttered.
What is a blob in image processing?
A blob is a group of connected pixels that share a property, usually intensity or colour, and stand out from the area around them. Think of a dark drop of oil on a bright metal sheet, or a bright cell nucleus on a dark stain.
The term covers both "bright on dark" and "dark on bright" regions. A detector does not know what the object is. It only reports where a region is, how big it is and, depending on the method, how round or elongated it is. That makes the technique useful as a first step: find candidate regions quickly, then measure or classify them.
Typical outputs per blob are:
- Centre (x, y coordinates)
- Size (radius, scale or pixel area)
- Shape descriptors such as circularity, convexity and inertia ratio
- Response strength, which you can threshold to drop weak detections
How does blob detection work?
Every method follows the same pattern: prepare the image, enhance regions of a given size or intensity, pick local maxima or connected components, then filter the candidates by size and shape.
- Capture and preprocess. Convert to greyscale, correct uneven lighting and reduce noise with a Gaussian, median or bilateral filter.
- Enhance or segment. Either convolve with a scale-space filter (LoG, DoG, DoH) or threshold the image into binary masks.
- Locate candidates. Find local maxima across position and scale, or extract connected components and their contours.
- Filter. Remove candidates that are too small, too large, not round enough or too weak.
- Use the result. Count objects, measure them, pass the regions to a classifier or track them across video frames.
LoG, DoG and DoH: which method should you use?
Use LoG when accuracy matters more than speed, DoG when you need a faster approximation, and DoH when you need speed and both bright and dark blobs. The scikit-image blob detection example compares all three on the same image and documents the trade-offs below.
Laplacian of Gaussian (LoG)
LoG smooths the image with Gaussians of increasing standard deviation (sigma), applies the Laplacian and stacks the results in a cube. Blobs are local maxima in that cube, and the scale where the maximum occurs gives the size. For a 2D blob the radius is roughly sigma times the square root of 2. The idea of normalising filter responses so that the right scale stands out comes from Tony Lindeberg's work on automatic scale selection in the 1990s.
Difference of Gaussian (DoG)
DoG blurs the image at several sigmas and subtracts neighbouring levels. The difference approximates the LoG at lower cost. David Lowe used a DoG pyramid to find keypoints in SIFT, described in his 2004 paper "Distinctive Image Features from Scale-Invariant Keypoints". Like LoG, it slows down for large blobs because the kernels grow.
Determinant of Hessian (DoH)
DoH looks for maxima in the determinant of the Hessian matrix of second derivatives. The scikit-image implementation uses box filters, so its speed does not depend on blob size, and it finds both bright and dark blobs. The cost is accuracy on very small objects. The same box-filter idea underlies the SURF feature detector.
| Method | Speed | Accuracy | Bright/dark | Best fit |
|---|---|---|---|---|
| Laplacian of Gaussian | Slowest, slower still for large blobs | Highest | Bright on dark (scikit-image) | Offline analysis, microscopy, astronomy |
| Difference of Gaussian | Faster than LoG | Close to LoG | Bright on dark (scikit-image) | Keypoint detection, larger image sets |
| Determinant of Hessian | Fastest, independent of blob size | Weak below about 3 px | Both | Near real-time use, mixed polarity |
| Threshold + contours (OpenCV) | Fast | Depends on lighting and thresholds | Set by blobColor | Controlled industrial scenes, round parts |
How OpenCV's SimpleBlobDetector works
SimpleBlobDetector does not use scale space. According to the OpenCV features2d source documentation, it thresholds the image at several levels, finds connected components in each binary image, groups centres that appear across levels and returns the final centres and radii as keypoints.
You then switch on filters for the candidates:
- Colour: blobColor = 0 keeps dark blobs, 255 keeps light blobs.
- Area: minArea and maxArea in pixels.
- Circularity: 4π × area / perimeter², where 1.0 is a perfect circle.
- Inertia ratio: how elongated the blob is. Low values mean line-like shapes.
- Convexity: area divided by the area of the convex hull. Dents and notches lower it.
Other parameters control the threshold range (minThreshold, maxThreshold, thresholdStep), how many threshold levels a blob must survive (minRepeatability) and how close two centres can be before they merge (minDistBetweenBlobs). The defaults are tuned for dark, circular blobs, which surprises many first-time users who expect bright spots to be found.
Which tools can you use?
For most teams the choice is between OpenCV and scikit-image in Python, with MATLAB as an option where a licence already exists.
- OpenCV (C++, Python, Java): SimpleBlobDetector, contour functions, watershed segmentation and a fast runtime for production systems.
- scikit-image (Python): blob_log, blob_dog and blob_doh return arrays of (row, column, sigma) and work directly on NumPy arrays. Good for research and prototyping.
- MATLAB Image Processing and Computer Vision toolboxes: blob analysis and region properties, common in academic and engineering teams.
A short scikit-image call looks like this: blob_log(gray, max_sigma=30, num_sigma=10, threshold=0.1). The three parameters set the largest blob size, how many scales to test and how strong a response must be.
Where is blob detection used?
It is used wherever the objects of interest are compact regions with clear contrast. Common examples:
- Manufacturing quality control: spotting pores, inclusions, scratches, solder balls, contamination or missing parts. See our guides to defect detection and industrial vision systems.
- Life sciences and medical imaging: counting cells and colonies, finding nuclei, and flagging candidate regions for a clinician or a second model to review.
- Astronomy: locating stars and galaxies in survey images. The scikit-image example uses the Hubble eXtreme Deep Field.
- Robotics and tracking: following coloured markers, LEDs or parts on a conveyor between frames.
- Traffic and surveillance: background subtraction followed by blob extraction to count moving objects.
Common problems and how to fix them
Most failures come from the image, not the algorithm. Plan for these issues early.
Uneven lighting and glare
A single global threshold breaks when one side of the part is brighter. Fix the lighting first (diffuse or backlight setups), then use background subtraction, top-hat filtering or adaptive thresholding.
Noise and texture
Sensor noise and surface texture create many tiny false blobs. Smooth before detection, set a minimum area or minimum sigma, and raise the response threshold until false positives drop on your test set.
Large range of sizes
If blobs range from a few pixels to hundreds, a single scale fails. Use a scale-space method with enough sigma levels, or run detection on an image pyramid.
Touching or overlapping objects
Two touching cells often merge into one blob. A distance transform followed by watershed segmentation is the usual way to split them. Scale-space detectors can also report overlap, and scikit-image prunes blobs that overlap more than a set fraction.
How do you measure detection quality?
Label a representative test set by hand, match detections to labels within a distance tolerance, then compute three numbers:
- Precision: of the blobs you reported, how many were real? Low precision means false alarms.
- Recall: of the real blobs, how many did you find? Low recall means missed defects.
- F1 score: the harmonic mean of the two, useful for comparing parameter sets.
Pick the balance based on cost. On a production line a missed defect may cost far more than a false reject, so you tune for recall and accept some manual re-checks. Also measure time per image on the target hardware, because a method that runs well on a workstation may not keep up with line speed on an edge device.
Classical detectors or deep learning?
Use a classical detector when objects are simple, contrast is good and you have little labelled data. Move to a trained model when shapes vary, backgrounds are cluttered or you need to tell defect types apart.
Many production systems combine both. A fast blob detector proposes candidate regions, and a small convolutional network classifies each crop. This keeps compute low and makes errors easier to explain. Once a model is involved you also need versioning, monitoring and retraining, which is where MLOps practices come in.
Practical tuning checklist
- Collect images under real production lighting, not lab conditions.
- Label at least a few hundred examples, including edge cases and "no defect" images.
- Start with defaults, then change one parameter at a time and record precision and recall.
- Set area or sigma limits from the physical size of the target and the camera resolution.
- Check results on images from different shifts, batches and cameras before go-live.
- Keep parameter sets in version control so you can trace a change in results back to a change in settings.
How Opsio helps
Opsio builds and runs visual inspection and computer vision systems, from camera and lighting choices to models deployed at the edge or in the cloud. If you are evaluating a blob-based or AI-based inspection setup, our computer vision consulting team can review your images, test detection methods on your data and estimate what accuracy is realistic before you invest in hardware.
Frequently asked questions
What is a blob in computer vision?
A blob is a connected region of pixels that is brighter or darker, or a different colour, than its surroundings. Detectors report its centre and size, and sometimes shape measures such as circularity.
What is the difference between LoG, DoG and DoH?
LoG is the most accurate and slowest. DoG approximates LoG by subtracting blurred images and runs faster. DoH uses the Hessian determinant with box filters, is the fastest and finds bright and dark blobs, but is less accurate for blobs smaller than about 3 pixels.
Why does OpenCV SimpleBlobDetector not find my bright blobs?
The default parameters are tuned for dark, circular blobs. Set filterByColor with blobColor = 255 for light blobs, and loosen the circularity, inertia and convexity filters if your objects are not round.
Is blob detection the same as object detection?
No. It finds regions that stand out by intensity or colour without knowing what they are. Object detection models are trained to locate and label specific classes, such as "scratch" or "person". Blobs are often used as candidate regions for a classifier.
How do you separate overlapping blobs?
Apply a distance transform to the binary mask and run watershed segmentation from the distance peaks. For round objects, scale-space detectors with overlap pruning also work well.
Related reading: Corrosion Detection.
Related reading: Contamination Detection.
Related Guides
Written By

Head of Innovation
Jacob leads innovation at Opsio, specialising in digital transformation, AI, IoT, and cloud-driven solutions that turn complex technology into measurable business value. With nearly 15 years of experience, he works closely with customers to design scalable AI and IoT solutions, streamline delivery processes, and create technology strategies that drive sustainable growth and long-term business impact.
Editorial standards: This article was written by the cloud practitioner named in the byline above. We revise it when the technology or regulation it covers changes; the dates on this page show the latest update. Opsio maintains editorial independence.