Blob analysis is the workhorse behind counting, presence checks and area measurement in machine vision: it reduces an image to connected regions of similar intensity and turns each region into numbers you can judge against a tolerance. This guide walks the pipeline end to end — threshold, connectivity, morphological cleaning, feature extraction, classification — with the formulas and the pixel-to-millimetre arithmetic in one place. You will see which blob features matter, how many pixels the smallest feature needs, where the method should run, and where it stops working. If you specify cameras, lights or vision sensors for presence detection, counting or pad measurement, this gives you the numbers to specify the check — and to argue for or against a rule-based blob tool.
What is blob analysis in machine vision?
Blob analysis is a four-step pipeline: segment the image with a threshold, connect the foreground pixels into regions, clean those regions, then measure and classify each one. A single connected region of 1200 px at a scale of 0.05 mm/px is a 3.0 mm² feature — that is the whole method.
The name says what it treats. A blob is any connected set of pixels that passed the segmentation test: a solder pad, a missing cap, a knot in lumber, a capsule on a conveyor. Each stage answers one question. Segmentation asks which pixels belong; connectivity asks which pixels belong together; cleaning asks which regions are real; feature extraction asks how big, where and what shape; classification asks pass or fail.
The jobs it wins are presence and absence, counting — such as verifying electrode pairs by counting connected regions — sorting by size or pose, and area tolerances like glue coverage or fill level. Everything after thresholding runs on a binary image, so the computation is simple enough to keep up with the line.
How do you threshold an image so blobs separate from the background?
Pick one gray limit in the empty valley between the histogram's two peaks: pixels on the object's side of the limit become foreground, the rest background. With 8-bit data that limit is a value between 0 and 255, and a gap of 40 to 60 gray levels between part and background keeps it stable when lamps age or parts vary.
Lighting, not software, creates that gap. Backlighting turns parts into dark silhouettes on a bright, uniform field, and a flat illuminator from the bar lights family behind a translucent belt is the simplest way to get there:
- Size
- 200-400 mm
- Type
- Standard
- Voltage
- 24 V
When you cannot backlight, light from a low angle so defects scatter toward the camera while sound surface stays dark, and keep factory ambient out of the lens — blocking ambient light with a bandpass filter matched to a red LED is the standard fix. An object that is mid-gray against both darker and lighter surroundings needs two limits, a gray band, with pixels inside the band as foreground. On color images, threshold in a color space instead of raw gray; segmenting white objects by S and V rather than gray level is the worked case.
How do thresholded pixels become clean, countable objects?
Pixels join into one blob under a connectivity rule — 4-connectivity counts only the four edge neighbours, 8-connectivity the diagonals too — after which opening removes specks and closing fills pinholes before any feature is extracted.
Count 8-connected neighbours as one region for round parts that can touch; choose 4-connectivity when a thin diagonal bridge would merge two objects that are separate in reality — 4- or 8-connectivity for circular markers works the case in detail. Then clean the binary mask with two operators. Opening, erosion followed by dilation, deletes specks smaller than the structuring element: a 3×3 opening removes 1-2 px noise without moving real boundaries. Closing, dilation followed by erosion, fills pinholes and hairline gaps of the same size. Both shift measurements — a 3×3 closing can move a boundary by 1 px, which is 0.04 mm in the station worked below — so keep the structuring element smaller than the smallest true feature.
Which features can you measure on a blob?
Every blob tool returns the same core set: area in pixels, centroid, bounding box, perimeter, equivalent diameter, orientation, and circularity 4πA/P² — 1.00 for a perfect disk, under 0.2 for a thin scratch.
| Feature | Definition | Typical inspection use |
|---|---|---|
| Area | foreground pixel count | presence, fill level, size tolerance |
| Centroid | mean x and y of the pixels | pick point, position tolerance |
| Bounding box | min and max extent in x and y | sorting, coarse size |
| Equivalent diameter | 2√(A/π) | round features against a diameter spec |
| Perimeter | boundary length | chipping, wear, edge defects |
| Circularity | 4πA/P² | shape: separates disks from scratches |
| Orientation | principal-axis angle | rotation checks, sorting by pose |
Area is a literal pixel count — measuring blob area by counting pixels — so its accuracy is set by how cleanly the boundary was drawn. The bounding box suits tolerances on a part's extent; object area suits tolerances on its material — bounding box area versus object area settles which to report. Circularity doubles as a filter: dropping linear background features by compactness keeps the blobs that look like parts. Orientation drives counting and sorting glass by pose.
How do you convert pixel measurements into millimetres?
Divide the field of view by the pixel count across it to get the scale, then multiply pixel area by the square of that scale: a 1200 px blob at 0.04 mm/px measures 1200 × 0.0016 = 1.92 mm².
Calibrate on a known length imaged in the plane of the feature — a machined gauge, a dot target, or the part with measured references — and re-check after any change of lens or distance. A part sitting out of that plane is imaged at a different magnification, and the scale no longer applies to it.
The worked numbers come from one camera, the LS-CMR-0166, a 12 MP USB3 area scan camera with 4000 × 3000 resolution:
- Sensor format
- 1/1.7"
- Interface
- USB3
- Resolution
- 12 MP
- Shutter
- Rolling
Give the station a 160 mm field of view across the 4000 px width. The scale is 160 mm ÷ 4000 px = 0.04 mm/px. A solder-pad blob of 1200 px then measures 1200 × 0.04² = 1200 × 0.0016 = 1.92 mm². As a round pad that is a diameter of 2√(1.92 ÷ π) = 2 × 0.78 = 1.56 mm. The drawing calls out 1.5 mm ±0.2 mm, so the window is 1.3 to 1.7 mm: this pad passes.
A scratch in the same image segments to 250 px: 250 × 0.0016 = 0.40 mm², with a measured perimeter of 6.0 mm. Its circularity is 4π × 0.40 ÷ 6.0² = 5.03 ÷ 36.0 = 0.14, far below a shape floor of 0.4, so the station rejects it as a defect despite its small area. Two features, two numbers, one decision each.
How many pixels does the smallest feature need?
Give the smallest feature you must detect at least 3 pixels across its narrowest dimension, and any feature judged against a tolerance at least 10 pixels — that ratio fixes camera resolution before anything else is chosen.
Work it backwards from the defect. A 0.20 mm flaw that must be measured, not just seen, needs 10 px across: 0.20 mm ÷ 10 px = 0.02 mm/px. A 4000 px sensor width then covers 4000 × 0.02 = 80 mm of field of view; if the part is wider, either accept detection-only on the small flaws or move to more pixels.
Motion sets a second budget. On a belt running 100 mm/s at 0.04 mm/px, one pixel of travel takes 0.04 mm ÷ 100 mm/s = 0.0004 s, so hold exposure at or under 0.4 ms or freeze the part with a strobed light. Depth of field sets a third: stopping the lens down from f/4 to f/8 doubles the depth of field and costs two stops — four times the exposure or four times the light output. Buy depth of field with the iris, and buy the light back with the driver rather than with camera gain.
Below about 10 px across, whole pixels flipping at the boundary swing the area reading by tens of percent; treat those blobs as detections, not measurements.
Should blob analysis run on a smart camera or a PC?
Put blob analysis on a vision sensor or smart camera when the check is fixed and the result leaves as pass/fail over I/O; put it on a PC with an area scan camera when the logic changes, images must be archived, or several checks share one view.
The sensor route keeps the whole station in one housing. A 1.6 MP vision sensor with a 12 mm lens and Fast Ethernet thresholds and counts on the device:
- Interface
- Fast Ethernet
- Resolution
- Up to 3 MP
- Sensor format
- 1/2.9"
- Shutter
- Global
When the PLC wants the numbers rather than the verdict, sending blob results out over serial covers it. On the PC side, a 20 MP USB3 mono camera resolves fine features, and an 8.8 MP smart camera on an x86 platform runs your own code:
- Sensor format
- 1"
- Lens mount
- C-mount
- Interface
- USB 2.0
- Resolution
- 6-10 MP
Choose smart cameras for many identical headless stations; choose area scan cameras plus a PC when one view feeds several checks or images must be stored for audits. Past about three checks per view, the shared camera and the PC justify their cabling.
When is blob analysis the wrong tool?
Blobs stop working when parts overlap in a pile, when object and background share a gray range with no stable threshold, or when you need volume instead of projected area — those call for 3D sensing, learned classifiers, or height data.
Overlapping parts leave no background between them, so no threshold can separate them; when to choose a 3D machine vision system over 2D is that decision written out. Natural appearance — wood grain, food, textiles — defeats a fixed threshold the same way; the trade between an AI model and rule-based smart camera inspection covers it. Projected area is not volume: a flat blob cannot tell a deep dent from a shallow stain, and 2.5D blob volume measurement explains why motion and height data are needed.
For tight dimensional tolerances, prefer edge tools: a caliper interpolates edge position to a fraction of a pixel, while blob area moves in whole-pixel steps. Use blobs to find, count and classify; use edges to measure a diameter whose tolerance is tighter than about ±2 %.
What should you check before ordering camera and light?
Check the gray gap, the pixel budget, the blur budget, the connectivity rule and the calibration plane before ordering hardware — five numbers, ten minutes, and they prevent the most common blob-station rebuilds.
- Gray gap: at least 40 gray levels between object and background on the worst-case part, under the light you will actually install.
- Pixel budget: smallest detected feature at least 3 px, smallest measured feature at least 10 px, at the chosen field of view.
- Blur budget: exposure at or under pixel size ÷ line speed — 0.4 ms at 100 mm/s and 0.04 mm/px.
- Connectivity: 8-connected for round parts that touch, 4-connected where diagonal bridges would merge neighbours.
- Morphology: structuring element smaller than the smallest true feature, so cleaning cannot delete a real defect.
- Calibration: scale taken from a target in the feature plane, re-checked after any lens or distance change.
With those fixed, the camera finder and the system configurator turn the pixel budget into hardware, and the rest of the pipeline is software. More building blocks sit under the systems topic.
Perguntas
Is blob analysis the same as connected component labelling?
Labelling is one step of the whole. Connected component labelling assigns an identity to every 4- or 8-connected foreground region so regions can be counted; blob analysis is the full pipeline — threshold, label, clean, measure, classify. A tool that only labels tells you how many regions exist, not whether any of them meets spec.
Can blob analysis measure holes inside a part?
Yes. A hole is a background region fully enclosed by foreground, and blob tools report it separately from the outer boundary: hole count, hole area, and often hole centroid. At the 0.04 mm/px scale of the worked example, an enclosed void of 250 px reads 0.40 mm² and can carry its own tolerance.
How fast can a blob analysis run?
On a vision sensor it runs at the camera's frame rate; the binary operations are simple enough for the on-board processor. On a PC, two-pass labelling of a multi-megapixel binary image takes single-digit milliseconds, so a 30 fps inspection loop spends its time on acquisition and lighting, not on the blob step.
Does blob analysis work on color images?
Yes, but threshold in a color space rather than raw gray. White objects separate with low saturation and high value channels, because gray conversion merges them with bright metal and specular highlights. Once the threshold produces a binary mask, the connect, clean and measure steps are identical to the grayscale case.
What accuracy can a blob area measurement hold?
About ±2 % of the reading with stable lighting, 10 or more pixels across the feature, and calibration in the feature plane. Below 10 pixels, boundary pixels flipping move the area by tens of percent, so count those blobs rather than measure them. For tighter dimensional tolerances, use edge-based measurement.




