System designGuide

Circle center color measurement in machine vision

Build a circle center color measurement workflow with calibrated coordinates, stable color sampling, clear rejection rules and practical sizing examples.

LumaSpec Vision11 min read Share on LinkedIn

On this page 10 sections
  1. 01Define the measurement before choosing an algorithm
  2. 02Size the camera, lens and lighting together
  3. 03Detect circles, then qualify the geometry
  4. 04Convert center pixels into physical coordinates
  5. 05Measure color from an interior region
  6. 06Work through a complete measurement example
  7. 07Separate repeatability, accuracy and color acceptance
  8. 08Know when the usual setup is wrong
  9. 09Check the complete workflow before ordering
  10. 10Questions

Detecting a circle gives you an image location, not yet a physical position or a dependable color name. A useful inspection must connect detection, calibration and color sampling without mixing coordinate systems or accepting glare as a surface color. This guide is for engineers locating several circular parts in one image. You will learn how to define the output, size the imaging setup, map centers into physical coordinates and reject uncertain color decisions.

Define the measurement before choosing an algorithm

For every accepted circle, return a structured record rather than drawing a center marker alone. A practical record contains:

  • Frame identifier and acquisition timestamp.
  • Center coordinates in the original image, expressed in pixels.
  • Fitted radius and a geometric quality indicator.
  • Center coordinates in a defined physical reference frame.
  • Color label, classification score and usable sample fraction.
  • Acceptance status and a specific rejection reason.

Pixel coordinates usually start at the upper-left image corner, with horizontal coordinates increasing rightward and vertical coordinates increasing downward. Physical coordinates need a separate definition: a fixture datum, axis directions, units and the measurement plane.

“Absolute position” is meaningful only relative to that reference. A camera cannot infer the fixture origin from an isolated circle without calibration or another known reference.

Keep acquisition separate from processing. Use a maintained camera interface and an image-processing binding compatible with your application runtime. Confirm image dimensions, pixel format, channel order and buffer ownership before implementing detection. Process a consistent frame snapshot, not a buffer that acquisition can overwrite midway through measurement.

Size the camera, lens and lighting together

Start with the required field of view and the smallest feature you must distinguish. Select area scan cameras through the camera finder only after estimating the required sampling.

For example, a feature width of 0.5 mm represented by 5 pixels requires a nominal object-space sampling of 0.1 mm per pixel. Across a 160 mm field, the horizontal requirement is:

Required horizontal pixels = field width × pixels per feature / feature width Required horizontal pixels = 160 mm × 5 / 0.5 mm = 1600 pixels

This is a sampling estimate, not a guarantee of feature recognition or measurement accuracy. Contrast, focus, noise and lens performance still matter.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

The MV-CU020-90GC is a color camera candidate with a global shutter and C-mount lens interface. Confirm its acquisition options against your timing and software requirements.

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
Up to 3 MP
$309.00View partBuild a system with it

Choose machine vision lenses using the lens finder. Field coverage depends on sensor dimensions, lens magnification and working distance; a matching thread alone does not establish optical suitability.

How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

The LS-FFL-0567 is a C-mount lens candidate. Verify focus range, image coverage and mechanical clearance for the intended installation before selecting it.

Machine vision lenses16 mm, 1.1", 20 MP, C-mount machine vision lens, F2.8-22, <0.3% distortion (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it

For surface color, begin with stable white illumination rather than a narrow-band source that removes useful color information. Bar lights offer adjustable illumination direction; use the lighting finder to compare arrangements.

The LS-BAR-1276 is a white diffused bar light candidate. Its suitability depends on whether the arrangement produces repeatable color without obscuring the circular boundary.

Bar lightsBar light, 372 x 28 mm, White (LS-BAR-1276)LS-BAR-1276
Size
200-400 mm
Type
Diffused
Voltage
24 V
$439.00View partBuild a system with it

Diffuse illumination does not automatically eliminate reflections. Test representative finishes, including the glossiest acceptable parts. For fine colored features, the explanation of color-camera spatial resolution describes why pixel count alone is insufficient.

Detect circles, then qualify the geometry

Use a grayscale or edge representation for geometry while preserving the original color image for sampling. Detection preprocessing may improve the boundary but can destroy information needed for color classification.

Choose the detection method according to how the circle appears:

Image condition Starting method Main check before accepting
Filled disc with strong background contrast Segment the region and analyze its contour Area, boundary fit and separation from neighbors
Visible circular rim with uneven interior Gradient-based circle search Edge support around the circumference
Partly hidden circular boundary Circle fit to selected edge points Visible arc coverage and fit stability
Tilted circular surface Ellipse or calibrated plane treatment Whether the reported center represents the required physical center

The existing guides to circle detection with contour analysis and live-feed circle detection cover those detection paths. Here, the critical step is validating their output before measurement.

Set expected radius limits from the part drawing and image scale. Reject candidates that touch an excluded image border, have insufficient edge support or overlap another candidate in an impossible way. Remove duplicate detections using center separation and radius similarity.

Do not assume detection order is stable between frames. If identity matters, associate circles using position, motion limits and other validated attributes. A list index is not a persistent part identifier.

Convert center pixels into physical coordinates

First correct lens distortion using a calibration appropriate to the imaging setup. Then map points from the corrected image into the measurement plane. The mapping and the detected centers must use the same image coordinate convention.

For a planar surface, a homography expresses the mapping in homogeneous coordinates:

[a, b, c]ᵀ = H × [u, v, 1]ᵀ X = a / c Y = b / c

Here, u and v are image coordinates, H is the calibrated mapping, and X and Y are coordinates in the selected physical frame. The units of X and Y follow the physical coordinates used during calibration.

Use more than the minimum number of calibration correspondences, distributed across the working area. Reserve independent reference positions for validation. A small fit error at the calibration points does not establish accuracy everywhere between them.

The guide to measuring planar distances with a calibrated camera explains the measurement assumptions. If you crop, resize or rectify images, also follow the coordinate bookkeeping in mapping points into a warped image.

Prefer transforming detected points rather than repeatedly resampling the color image. If image warping is necessary, account for interpolation and invalid border regions. The guide to antialiasing during image resizing and warping explains why resampling can change edge and color values.

A single scale factor works only when perspective and distortion are sufficiently controlled for the required tolerance. It is a useful special case, not a substitute for checking the complete field.

Measure color from an interior region

A center pixel can land on a highlight, printed mark, hole or noisy pixel. Instead, construct an interior sampling mask tied to the detected circle.

A useful starting experiment is an inner disc with a radius of 0.35 times the detected radius. This keeps sampling away from the boundary while retaining many pixels. It is not a universal setting: a center hole may require an annular mask instead.

Sample radius = 0.35 × detected radius Approximate sample area = π × sample radius²

For a detected radius of 100 pixels, the sample radius is 35 pixels. Its approximate area is π × 35² = 3848 pixels before masking exclusions and accounting for the pixel grid.

Exclude invalid pixels using documented rules, such as saturation, deep shadow, known holes or regions outside the part mask. Record the excluded fraction. If too little usable area remains, reject the color decision rather than silently averaging the remainder.

Calculate a median or trimmed mean from the retained samples in a defined color representation. A channel-wise median reduces sensitivity to isolated outliers, but it does not correct uneven illumination or mixed surface colors. Check spatial variation when a uniform finish is expected.

Before setting thresholds, stabilize exposure, gain, white balance and illumination. Automatic adjustments can move an unchanged part between color classes. The guide to automatic exposure and gain on color cameras explains how the selected image region affects those controls.

Use application-specific labels such as red, blue or unclassified. Build reference distributions from acceptable production samples under the intended illumination. Distance to a reference color is a score, not automatically a probability of correctness.

Work through a complete measurement example

Consider an illustrative image measuring 1600 × 1200 pixels across a planar field of 160 × 120 mm. These are application assumptions, not operating specifications for the example parts above.

After calibration and distortion correction, suppose validation supports an axis-aligned mapping with 0.1 mm per pixel. Place the physical origin at image coordinate (800, 600), with physical Y increasing upward.

A fitted circle center is (840.4, 620.2) pixels. The coordinate conversion is:

X = (u − 800) × 0.1 mm/pixel Y = (600 − v) × 0.1 mm/pixel X = (840.4 − 800) × 0.1 = 4.04 mm Y = (600 − 620.2) × 0.1 = −2.02 mm

A detected radius of 100 pixels corresponds to a nominal radius of 10 mm in this simplified mapping. With perspective present, do not apply the same scalar conversion indiscriminately to every radius; measure geometry in the calibrated plane instead.

Now apply the interior color mask. Suppose rasterization and geometric exclusions leave 3000 candidate samples. Saturation and shadow checks retain 2400 samples:

Usable sample fraction = retained samples / candidate samples Usable sample fraction = 2400 / 3000 = 0.80 = 80%

If application validation established a minimum usable fraction of 90%, this color decision must be rejected. A plausible median color does not override the failed quality gate.

For another circle that passes the sampling gate, compare its color statistic against the reference classes. Accept the nearest class only if its distance is sufficiently small and sufficiently separated from the next candidate. Otherwise, return unclassified while retaining the valid geometric measurement.

Separate repeatability, accuracy and color acceptance

Test geometry with a fixed target before introducing motion or changing parts. Collect repeated frames and examine center variation in both pixels and physical units.

Suppose the standard deviation of a stationary center is 0.15 pixels. At 0.1 mm per pixel, that corresponds to 0.015 mm of positional repeatability. It does not include calibration bias, fixture movement or part-height changes.

If an independent calibration contribution has a standard uncertainty of 0.04 mm, an illustrative combination of independent contributions is:

Combined standard uncertainty = √(repeatability² + calibration uncertainty²) Combined standard uncertainty = √(0.015² + 0.04²) mm ≈ 0.043 mm

This calculation is appropriate only when the stated contributions and independence assumptions are justified. It is not a complete uncertainty budget or an acceptance tolerance. The guide to object-space pixel size helps distinguish sampling from physical accuracy.

Validate color separately using acceptable parts, borderline shades and known rejects. Include normal changes in position, orientation and surface finish. Track false acceptance, false rejection and unclassified outcomes rather than reporting one overall success rate.

Store representative failure images with their settings and masks. A rejected circle should reveal whether the cause was incomplete geometry, poor calibration coverage, insufficient color samples or ambiguous classification.

Know when the usual setup is wrong

A planar mapping is inappropriate when circle centers occur at materially different heights. Perspective makes image scale and position depend on depth. As a rough small-change estimate, relative scale change is approximately the height change divided by the camera-to-plane distance.

For example, 2 mm divided by 400 mm is 0.005, or 0.5%. At a nominal position 60 mm from the optical axis, that can produce a position difference of roughly 0.3 mm in a simplified front-facing arrangement. The actual error depends on the calibrated geometry.

If this exceeds your tolerance, control part height, use suitable optical geometry or measure depth. Do not compensate with a more aggressive circle detector.

Other cases need different handling:

  • A ring with a center hole needs a material-only sampling region.
  • A reflective disc may require a different lighting geometry before color classification is meaningful.
  • A multicolored disc needs region-specific labels or a color distribution, not one average name.
  • Closely touching circles may need segmentation that separates individual parts before fitting.
  • Moving parts need exposure and trigger settings that preserve boundary sharpness and frame identity.

For tilted parts, check that detection, plane correction and color-mask placement remain consistent. Rectifying geometry does not make illumination uniform or restore saturated color information.

Check the complete workflow before ordering

Use this acceptance checklist to turn the concept into a purchasing specification:

  • Reference frame: document the origin, axis directions, units and physical measurement plane.
  • Sampling: confirm the smallest feature has sufficient image support at the widest required field.
  • Optical fit: verify sensor coverage, mount, working distance, focus adjustment and mounting clearance.
  • Illumination: test the darkest and glossiest acceptable finishes, not only a convenient sample.
  • Acquisition: confirm pixel format, channel order, timing and access to the original color image.
  • Geometry: set radius limits, duplicate suppression and rejection rules for incomplete boundaries.
  • Calibration: validate independent positions across the field and repeat checks after mechanical changes.
  • Color: define the sampling mask, minimum usable area, class references and unclassified outcome.
  • Records: save frame identity, coordinates, quality scores and rejection reasons together.

Choose hardware around these acceptance tests rather than around a detection demonstration. Start with the camera configuration step, or send representative images, field dimensions, part-height variation and required tolerances through applications support for a coordinated camera, lens and lighting selection.

Questions

Does circle detection provide absolute physical coordinates?

No. A detected center initially describes a location in an image. Physical coordinates require a calibrated relationship to a defined datum and measurement plane. Distortion, perspective, cropping and image resizing must be accounted for before reporting positions in millimeters or another physical unit.

Should color be sampled at the center pixel or over a region?

A small interior region usually gives a more dependable estimate because a single pixel may contain glare, noise or a surface mark. Use a mask that samples actual material, exclude invalid pixels and reject the decision when insufficient usable area remains.

Can one image provide both circle position and color?

Yes, but the application must preserve the relationship between geometric coordinates and the original color frame. Detection can use a grayscale copy while color sampling uses the original image. Treat geometric validity and color validity as separate decisions, with independent rejection reasons.

How should uncertain color classifications be handled?

Return an unclassified label when a sample is too far from every reference class, too close to competing classes or supported by too few valid pixels. Establish these limits using representative production samples and borderline shades rather than assigning a color name to every detection.

When does the coordinate calibration need checking again?

Check calibration after changes to focus, working distance, camera mounting, lens mounting, image dimensions or the measurement plane. An independent reference target can reveal changes before production measurements are accepted. Recalibrate whenever the existing mapping no longer meets the required error limit.