The first part of this three-part series covered the principles that allow machine vision to make high-accuracy measurements. This second part examines challenges that the measurement environment imposes on machine vision and gives approaches to mitigate the effects and retain much of the high-accuracy capability.
Machine Vision Measurements v. Conventional Measurements
Measuring to an edge with a caliper will measure to the high point (see Figure 1) giving an error between the manually measured value and the measurement value from the machine vision system. Similarly, measuring the diameter of a hole with machine vision usually gives the average diameter. If the hole is just slightly elliptical, then measuring its diameter with a pin gage will give a different diameter than the machine vision measurement.
There are software tools in many machine vision programs to emulate conventional measurement tools. For example, a tool to find the smallest inside diameter simulates checking a hole with a pin gage. These tools may give better correlation to conventional measurement approaches but with likely less precision than a hole fitting tool that makes use of statistical averaging over all points around the hole.
Lighting
The purpose of lighting is to create contrast. The higher the contrast between an edge and its background, the better results sub-pixel measurement techniques provide due to better edge profile data. Higher contrast also improves the signal-to-noise ratio further improving results. Use as much of the camera’s gray-scale range as practical.
When setting lighting and camera exposure time, it is considered best practice to ensure there is no saturation or black level clipping in the image around the area where measurements are made. When using gray-scale analysis of the edge profile, slight clipping of the bright or the dark areas will not affect the precision of the measurement. The challenge with saturation is that there is no way to tell from image data how much of the edge amplitude is lost.
If there is a risk of saturation or clipping, you must ensure it is only a small amount that won’t distort the edge profile in the area of the inflexion. There is little data to suggest that saturation or clipping has any benefit for measurement accuracy.
Risk in Fitting to a Model
Since all sub-pixel precision techniques in machine vision rely on fitting to a model, the approach comes with the risk the physical reality may not match the model to an acceptable degree. Fitting to a straight edge that isn’t straight gives an estimate of an equivalent straight edge.
Fortunately, a statistical fit can also provide a goodness of fit measurement. There are many such metrics including R-squared and Pearson’s chi-squared test. If the goodness-of-fit result is unsatisfactory, it indicates either the edge doesn’t match the model well enough or the vision system is suffering from too much noise, or the system calibration didn’t adequately correct for lens distortion.
As discussed above, achieving sub-pixel precision relies on fitting the data to a model. What if the real world does not conform to the model as illustrated in Figure 2? For example, if the data from the edge is fit to a straight line, but the edge is not straight, there will not be a gain in precision or the resulting accuracy.
The quality of fit to a straight edge, or any other model, would be a statistical test such as R-squared. A test’s value out of some defined, acceptable range indicates a deviation of data points from the fit model.
The same reasoning applies to finding the true edge position from a gray-scale edge profile. There is an assumption of symmetry about the inflection point. If the edge profile is not symmetric, then the calculated edge position will be in error.
Outliers
In any set of data, there are bound to be a few outliers – data points that deviate rather significantly from the model as shown in Figure 3. It is valid to detect outliers and delete them from the data set to achieve the highest precision. This is due to noise or perhaps random artifacts in the scene.
Because most fitting algorithms use the least squares approach which minimizes the square of the error between data points and the result, an outlier with high error has a stronger effect on the fit to the data than points close to the fit. Eliminating those few outliers and refitting the remaining data points to a line gives improved precision. Hopefully, your machine vision software gives you the option of deleting outliners.
Burrs
An edge with burrs produces outliners (see Figure 4). If the burr extends only along a very short portion of the measured edge, then eliminating outliers will likely cause the burr to be ignored. Otherwise, if the burr is irregular, the use of a statistical test such as R-squared will give evidence of a problematic fit. In the second case where the burr extends for much of the edge, a precision measurement is likely not possible.
Chamfer or Deburring
Many machined parts and even molded parts have a chamfer or radius on the edge due to the design of the mold or due to deburring. This chamfer results in a distortion of the gray-scale edge profile as shown in Figure 5 and Figure 6. This often leads to errors in determining the true edge position.
In Figure 5, the light is coming from the chamfered edge. This results in two edges on either side of the chamfer. Most vision software systems can be set up to pick the correct edge.
In Figure 6, the light is coming from the opposite direction of the radius. The edge brightness fades to dark. Vision software cannot find the correct edge.
When chamfered or radiused edges are present, lighting and software setup becomes extremely important to achieve accurate measurements.
Motion Blur
The blurring of an image due to motion reduces the accuracy of measurements – both trueness and precision. Motion blurs the edge profile that is parallel to the motion direction making the inflection point less distinct as shown in Figure 7. You can notice that the first derivative has a flat top rather than a defined peak. The second derivative has a flat between the opposing spikes rather than a clean zero crossing.
Most algorithms extracting the edge from the edge profile will give greatly degraded trueness and precision in reporting the edge position or possibly fail to report an edge position when dealing with motion blur. Even algorithms anticipating the edge profile distortion will still not give the best precision and trueness.
When making measurements on moving parts, a short exposure is essential. While the typical best practice is an exposure time giving only one pixel of blur, for precision measurements, the exposure time should be reduced to give a blur of just a small fraction of a pixel – much less than the sub-pixel precision target. This usually requires a strobed light source, with overdrive when using LED illumination.
Conclusion
The operating environment critically affects measurement performance. One common challenge is a difference between manual measurement methods and machine vision measurement techniques. Machine vision software has made progress in better emulating manual inspection techniques.
There are problems created by edge artifacts such as burrs, edge conformance to an expectation, chamfers, and radii that can confuse the vision system’s software. Lighting and using statistical principles provide methods to deal with these challenges.
The third part of this series covers some challenges that are part of the vision system design and components.