R&D
CENTER

Rule-Based Dimensional Measurement: Turning Pixels into Millimeters

For inspections where the tolerance is a number, measurement fits better than AI. This lesson explains how to measure diameter, thickness and roundness with calibration, contour extraction and circle fitting, and how to combine them with AI judgment.

Core4 min1 views
Key points
  1. When the criterion is a number, such as thickness of 1.8 mm or more, rule-based measurement is explainable and accurate.
  2. The calibration value that converts pixels to mm (mm/pixel) is the starting point of measurement accuracy.
  3. Extract the contour stably (blur, morphology, Canny) and exclude protrusions such as ears before fitting the circle. Then you get sub-pixel precision.
  4. In the field, run AI (appearance) + YOLO (known defects) + dimensions (tolerance) together so each covers the gaps of the others.

AI answers "is there something wrong with the appearance?" well. But for "is the inner diameter at least 51.2 mm?", measuring with a ruler fits better than AI. You can keep the result as a number, explain why a part failed, and you need no training data. This lesson follows the process of measuring dimensions from an image, using a round part as the example.

Thickness tInner dia. DEar — excluded from circle fit Measurement items Inner DiameterCircumferenceThickness (mean over angles)RoundnessEar Angle L·R Example: Dia 51.39 mm · Thickness 1.88 mm · Roundness 93.76 %
Items that fineAi Dimensional Measurement Tool measures on a round band product. The example result is from a real measurement screen.

1. Calibration: How Many mm Is One Pixel?

Distances in an image are in pixels. To convert them to mm you need the mm/pixel value. Image a reference object of known size (gauge block, calibration plate) at the same position, then divide the real length by the pixel count. For example, the EB line setting is 0.041 mm/pixel. A 1-pixel error then becomes a 0.041 mm error.

You must recalibrate when the camera height, lens focus or resolution changes. If you switch to a 5MP (2448×2108) camera, mm/pixel gets smaller for the same field of view, so precision improves, but you must find the value again.

2. Contour Extraction: Finding the Boundary Stably

Measurement comes down to handling points on the boundary line. If the boundary jitters, the measurement jitters.

  1. Gaussian blur — Reduce noise to remove false boundaries.
  2. Binarization — Separate the part from the background. If lighting is uneven, use an adaptive threshold that changes the reference per region.
  3. Morphology — Fill small holes and remove small spurs.
  4. Canny edge — Extract the lines where brightness changes sharply as the boundary.

3. Circle Fitting: Sub-Pixel Precision

If you fit a circle to the boundary points by least squares, hundreds of points average out. You can then get the center and radius in units smaller than one pixel. The key is to leave out the parts that are not circular. If a protrusion such as a band ear is included, the circle is pulled toward it. Multi-Inspector EB excludes the ear region when fitting the circle and aims for sub-pixel precision. Hough circle detection is fast but less precise, so it is used only for on-screen display.

4. Measuring Each Item

  • Thickness — Draw several measurement lines across a set angle range and measure the distance between the inner and outer boundaries. Choose the top N and drop outliers, so a single speck of dust does not change the thickness.
  • Roundness — The ratio of how close the contour is to a perfect circle. A distorted part scores lower.
  • Circumference and inner diameter — Computed from the fitted circle and the actual contour.

5. Judging with Rules

In Multi-Inspector, you attach rules to the measurement mode (circularity). For example, specify roundness, thickness, circumference as rules and set an allowed range for each item (such as roundness of 0.931 or more). If a value is out of range, the result records which dimension caused the failure, as in NG-Dim-THICKNESS.

Using It with AI: Triple Judgment

Multi-Inspector EB v2.3 judges one part three ways at the same time.

Mode Method What it catches
mode1 · AI model Anomaly detection after alignment (rotation-fix2) Appearance anomalies never seen before
mode2 · YOLO Object detection after alignment (yolo_align) Defects with a defined name
mode3 · Dimensions Circle-fit measurement (circularity) Dimensions out of tolerance

AI does not know whether a numeric tolerance is met, and measurement does not know about scratches on a surface. Running the three judgments together covers each one's gaps. The aligned image is made only once and shared with the measurement mode, so processing time does not grow much as judgments are added.