A digital image is a measurement before it is a photograph.
A camera sensor does not directly understand a scene. It converts photons arriving through the lens into electrical charge at small sensing elements called pixels. The analog signal is then digitized, assigning every pixel an intensity or color value. A grayscale image is one intensity matrix; a color image commonly combines three channels.
These numbers are not a pure recording of the surface. Illumination strength, angle of incidence, lens contrast transfer, sensor quantum efficiency, exposure time, and electronic noise all contribute to the value. A pixel does not say 'a scratch is present'; it only reports the light that reached the sensor under particular conditions.
The first task of an industrial system is therefore to turn the physical difference of interest into a dominant and repeatable signal. Only then does the algorithm's job become easier.
Good illumination amplifies the defect and suppresses variation.
Reflective metal, glass, and plastic form images not only through color but also through directional reflection. A small shift in camera or part angle can create a larger intensity change than the real defect. Changing a threshold in such a scene treats the symptom; it does not solve the measurement problem.
Diffuse dome or broad-area illumination makes reflections more uniform. Cross-polarization suppresses part of the surface glare, stabilizing color and texture. Low-angle dark-field light misses a smooth surface but scatters from scratch, ridge, and pit edges, making topographic defects bright. Backlight is powerful when silhouette matters more than color or texture.
The governing principle is simple: Make the physical feature optically visible before asking software to detect it.

Calibration turns pixels into comparable units.
Lenses do not transfer geometry perfectly. Straight lines can curve, especially with wider fields of view, and scale can vary across the image. Camera calibration estimates intrinsic parameters and distortion coefficients so these geometric effects can be corrected. Zhang's planar-pattern technique remains a practical foundation for common calibration workflows.
Dimensional inspection also requires a pixel-to-millimeter relationship. A fixed working distance, rigid mechanical mounting, and telecentric optics when appropriate help reduce perspective error. Color inspection requires locked white balance, exposure, gamma, and color references; flat-field correction can compensate for intensity variation across the field.
Calibration is not a one-time setup ritual. When focus, camera position, illumination, or mechanics change, measurement validity must be verified again.
Classical image processing remains powerful.
When the scene is controlled, many problems do not need deep learning. A region of interest is defined first; the image is converted to grayscale or a task-appropriate space such as Lab or HSV. Noise is filtered, the background is normalized, and thresholding separates candidate regions.
Morphological opening can remove small noise, while closing can bridge gaps inside a defect. Connected-component analysis measures candidate area, perimeter, and shape. Edge detection supports dimensional inspection; histograms, GLCM, or Local Binary Patterns can distinguish surface texture.
The greatest advantage of these methods is explainability. It is possible to trace why a pixel was classified as defective. As product geometry, texture, and defect appearance become more variable, however, fixed rules can become brittle.
When does AI create real value?
Supervised classification predicts a defect class; object detection provides an approximate location; segmentation identifies defective pixels. In production settings where defective samples are scarce and their forms unpredictable, anomaly-detection methods that learn only normal appearance may be useful. The MVTec AD dataset is an influential research reference for this real-world problem.
High laboratory accuracy does not guarantee production reliability. A new supplier surface, different lot color, aging illumination, camera replacement, or acceptable process variation can create domain shift. The model may have learned the background instead of the product or a reflection instead of the defect.
AI is therefore not an alternative to optical design. Better images reduce data requirements, simplify training, and make failures easier to understand.
The correct metric follows the cost of the wrong decision.
Ninety-nine percent accuracy sounds impressive. Yet if only one part in a thousand is defective, a useless system that accepts every part can report 99.9 percent accuracy. Confusion matrices, recall, precision, specificity, and false-alarm rates must therefore be considered together.
When a missed defect affects safety or a critical quality attribute, sensitivity becomes the priority. In high-volume production, even a small false-reject rate can create major scrap and reinspection load. The operating threshold should balance these risks through the business and quality case.
Development, validation, and final test data must be separated. Near-identical frames of the same part should not be distributed across those sets; otherwise the system can appear to generalize while merely recognizing what it has already seen.
A production system has a lifecycle.
A deployed vision system must manage camera recipes, light levels, software version, model file, thresholds, and acceptance criteria together. Retaining every rejected frame may not be necessary, but the record strategy must support decision traceability in proportion to risk and data volume.
Light sources age, lenses collect contamination, mechanical connections move, and products change. Golden-sample checks, periodic performance monitoring, trend analysis, and controlled change management are therefore essential. The system must measure the same physical feature not only on launch day but months later.
A successful project is not an impressive demonstration. It is a decision mechanism with known limits, tested failure modes, and an operating model the production team can sustain.
References and further reading
- A foundational approach to camera calibrationZ. Zhang, A Flexible New Technique for Camera Calibration
- Practical reference for thresholding, filtering, and morphologyOpenCV — Image Processing Tutorials
- Optics, image acquisition, and analysis in industrial defect detectionRen et al., State of the Art in Defect Detection Based on Machine Vision
- A real-world benchmark for industrial anomaly detectionBergmann et al., MVTec AD — CVPR 2019
- A classical and effective representation of local textureOjala et al., Multiresolution Gray-Scale and Rotation Invariant Texture Classification with Local Binary Patterns
Industrial image processing usually starts too late when it begins as an algorithm-selection problem. The right starting point is to understand defect physics, make it visible with appropriate illumination, calibrate the imaging chain, and validate decision performance against production risk. A dependable result is not the product of one model; it is the combined outcome of optics, mechanics, data, software, and quality engineering.

