Article sections
What is the difference between structural and logical anomalies?Why can a normal-looking part be defective?How are missing parts detected?When does counting become difficult?How are incorrect position and orientation verified?How are relationships between objects represented?When is reference image comparison appropriate?What does MVTec LOCO AD measure?Are vision foundation models sufficient for logical anomalies?How should occlusion and uncertainty be handled?Numerical scenario: inspecting eight screwsWhich family of solutions should be chosen, and when?Requirements for acceptance testingHow is the reference arrangement defined for logical anomalies?Advantages of separating perception outputs from the rule engineDistinguishing a missing component from one hidden in the imageStatistical reliability of relational decisionsHow should field tests for logical anomalies be prepared?Human review and maintenanceFrequently asked questionsImage sourcesVisual inspection methods that distinguish scratches, missing components, incorrect placement, sequencing, counting, and relationships between parts. This guide examines the assumptions behind these methods, the conditions in which they can be used, reasons for failure, and practical decision points in deployment.
What is the difference between structural and logical anomalies?
Short answer: A structural anomaly is an unexpected physical change in an object's local appearance: a scratch, crack, dirt, dent, or surface deterioration. A logical anomaly is a violation of a specific rule even when the individual parts look visually normal: a missing screw, an incorrect slot, the wrong part sequence, a missing required label, or an extra component. Expecting the same algorithm to solve both in the same way overlooks a fundamental difference in the problem definition.
All the resistors on a board may look intact, but the product is defective if one is placed in the wrong position. Pixel-level texture anomaly detection may not notice this. Conversely, knowing the number of components on the board is useless for detecting a fine surface scratch. Both problems concern quality control, but they require different visual representations and decision logic.
Why can a normal-looking part be defective?
Visual anomalies are often considered in terms of differences, color, shape, or texture. A logical defect, however, requires relational knowledge such as 'part X must be in region Y.' If a part is not where it is expected, it does not matter that it looks completely normal elsewhere in the image. What defines the anomaly is not just the object's appearance but the task context.
For example, if an assembly must contain three red caps and two black caps, seeing five caps in total is not enough. Counts by color and position rules must be verified separately. If there are product variants, the same arrangement may be correct for one SKU and incorrect for another. Visual inspection must therefore also know the product identity and production recipe.

How are missing parts detected?
The simplest method checks whether objects are present at the expected locations. If the camera geometry is stable, an ROI can be defined for each slot, with local classification, feature extraction, or thresholding applied. If the part's position changes, the product pose must first be identified and the image aligned with the reference. Producing an independent prediction for each slot can sometimes be easier to maintain than a complex end-to-end model.
A missing part and a part that cannot be seen are not the same thing. If another component covers a metal part, the detector may report an empty location. An incorrect recipe can also trigger an alarm if some production variants intentionally leave that slot empty. The operational design must explicitly distinguish 'absent,' 'not visible,' and 'not required for this variant.'
When does counting become difficult?
Object detection, instance segmentation, or geometric feature analysis can be used to count multiple similar components. Components that appear merged or overlap in a single frame can reduce the detected object count. Counting the same product again across several frames, by contrast, increases it. Counting objects in a static assembly image and counting parts moving through a stream are therefore different algorithmic problems.
Counting accuracy is distinct from an individual detection score. Missing just one screw in a nine-screw assembly means an incorrect product-level decision. Under an independence assumption, 95% object-level recall reduces the probability of detecting all nine objects together to approximately 0.95 to the power of 9, or 63%. Detection errors may not actually be independent; this example only illustrates how errors accumulate at product level.
How are incorrect position and orientation verified?
The center coordinates of an object's bounding box can be compared with the reference slot using their distance. A rotated box or principal axis can provide orientation information. However, converting image coordinates into physical product coordinates requires geometric alignment and calibration. If the camera moves, all components may appear to shift together; this is not an actual assembly error.
Part symmetry also matters. Rotating a symmetrical bolt by 180 degrees may not produce a visually distinguishable change; an orientation check may require a mark or mechanical reference. In some cases, distinguishing incorrect orientation using a single overhead camera is physically impossible. The need for a second view or different lighting should be established before model development.
How are relationships between objects represented?
Each detected part can be treated as a node, with relationships between parts represented as edges. Rules can be defined, for example, as 'cover A is above socket B,' 'screw C is inside hole D,' or 'label E is on the right edge of the part.' These relationships can be calculated geometrically or, for certain tasks, assessed using learned relational models.
The advantage of a rule-based approach is that it is explainable to the organization. Its disadvantage is that the number of rules and the maintenance cost grow as variants increase. An end-to-end learning approach may handle some complex relationships more flexibly, but explaining which rule was violated and validating rare variants can become more difficult. The two approaches can be combined in a hybrid system.
When is reference image comparison appropriate?
For a fixed mechanical fixture and repeatable products, difference analysis against an aligned reference image can work. Simple pixel differences, however, are sensitive to surface gloss, small camera movements, and changing shadows. Not every difference between two images is an assembly defect. Alarms based on reference differences are unreliable without physical positioning, controlled lighting, and geometric alignment.
The product variant associated with the reference image must also be stored. Small design revisions to the product can cause an old reference to generate false alarms. Image comparison must therefore be integrated with production recipes and version management.

What does MVTec LOCO AD measure?
MVTec LOCO AD is an evaluation dataset that highlights the distinction between structural and logical anomalies. Alongside local abnormalities such as scratches and dirt, it includes rule violations such as misplaced objects or missing required objects. It contains thousands of images across five categories, with annotations for defective regions. This makes it possible to investigate how methods sensitive only to local texture differences behave on relational errors.
However, the dataset provides specific experimental scenarios; it does not represent every factory assembly. Its license also restricts commercial use. If republishing its images or developing a commercial product using the data is being considered, the terms of use must be examined separately. Benchmark performance must not be used directly as a substitute for production acceptance criteria.
Are vision foundation models sufficient for logical anomalies?
Vision-language models can interpret a scene in natural language or answer questions such as 'are there three screws?' However, on tasks such as counting, localizing small parts, and measuring precise positions, they may give misleading, inconsistent, or confidently incorrect answers. Using a vision-language model's explanation instead of physical verification is risky for critical quality decisions.
A more reliable architecture can treat perception, object identity matching, geometric checks, the product recipe, and the decision log as separate components. This makes it possible to trace which stage failed. Rather than having a model state 'there is an assembly error,' producing an auditable output such as 'the required part was not detected in slot B' is more useful operationally.
How should occlusion and uncertainty be handled?
Some parts are not visible from the camera's viewpoint. In that case, a 'missing' decision cannot be physically justified. A visibility state can be added to prevent the model from incorrectly declaring a component outside its view to be missing. At some inspection points, rotating the product, using a second camera, or changing the exposure may be necessary. This is an information acquisition problem before it is a question of model capacity.
Routing uncertain decisions to human review also makes sense. For example, if eleven of twelve locations are observed with high confidence and one with low confidence, taking a second image may be cheaper than automatically scrapping the entire product. The costs of recapture and operator inspection should be evaluated alongside the cost of errors.
Numerical scenario: inspecting eight screws
Suppose each product must contain eight screws, and recall for detecting an individual screw is 98%. Under the simplified assumption that errors are independent, the probability of detecting every screw together is approximately 0.98^8, or 85.1%. Good detection of each individual screw therefore does not mean that all products will be correctly accepted. The false reject rate must be measured separately at product level.
Using a second viewing angle can reduce some occlusion problems. However, if both cameras are affected by the same lighting or mechanical error, their errors are not independent. The approach of 'taking a vote from two models and solving the problem' therefore also requires testing. The product-level acceptance metric and decision logic must be validated directly in production.
Which family of solutions should be chosen, and when?
| Problem | Possible solution | Risk to check |
|---|---|---|
| Missing screw in a fixed slot | ROI + classification or detection | Camera movement and incorrect variant |
| Incorrect part position | Detection + reference geometry | Calibration and occlusion |
| Incorrect assembly sequence | Multi-object relationships + rules | Accumulation of detection errors |
| Surface scratches | Anomaly detection / segmentation | Lighting-induced false defects |
| Missing product on a moving conveyor | Detection + tracking + timing rule | Double counting and triggering |

Requirements for acceptance testing
Each product variant and assembly revision should be evaluated separately. Testing should include not only visibly defective examples but also normal-looking examples that violate rules; conversely, completely normal yet visually unusual parts should be examined for false alarms. For a rejected product, the violated rule should be readable in the system log.
The reference image captured at the start of production, lighting conditions, camera geometry checks, and recipe ID can all be recorded. The model is only one part of the vision system; if the product variant or business rule is wrong, correct detections can still lead to incorrect decisions.
How is the reference arrangement defined for logical anomalies?
The expected locations of parts in an assembly image can be derived from an engineering drawing, CAD model, or quality inspection fixture. In the vision system, this arrangement must be converted into reference coordinates. If the camera angle and position are fixed, ROIs defined once can be reused; if the product rotates or shifts within the image, geometric alignment will be required. Defining rules using pixel coordinates alone, without a physical reference, can produce false alarms after small assembly changes.
Product variants are the second dimension of this design. A part required in product A may not be present in variant B. Expected object counts and positions must therefore be linked to the SKU or production recipe. Even if the model finds the correct objects, the quality decision will be wrong if rules for the wrong product variant are applied. The mechanism that matches product identity to visual results should be explicitly documented in the system architecture.
Maintaining the reference arrangement requires an approval process. If a hole position changes in a new product revision, the invalidation of the old rule must be managed automatically. This is not merely a software parameter update; it is a change to the quality standard.
Advantages of separating perception outputs from the rule engine
The perception component's task may be to 'report objects, their scores, and their positions.' The rule engine then answers 'are the objects required for this product variant in the correct places?' Separating the components makes it easier to trace the cause of an error. When an incorrect decision occurs, the investigation can determine whether the problem lies in object detection, the geometric transformation, or the product recipe.
This architecture also improves explainability. Instead of 'quality is unacceptable,' the system can say 'there is no reliable detection of the expected screw in slot C.' An operator can physically verify this information. However, a low-confidence detection is not the same as absence; the 'not visible' state must be represented separately.
Rules concerning object count, relative position, orientation, color, and relative distance can be tested independently. When the production system defines a new defect type, a rule can be updated instead of retraining the entire vision model from scratch. Success depends on whether the perception component provides sufficient detail about the available visual information.
Distinguishing a missing component from one hidden in the image
An object that cannot be seen by the camera may still be physically present. If a cable runs over a screw, the detector may fail to find it. Presenting this automatically as a missing-screw decision is misleading. Multiple cameras, images of the product in different poses, or changes to the mechanical design can resolve some uncertainties.
A visibility mask or expected occlusion regions can be defined. The model should not be asked for a definitive decision when the required observation is physically impossible from the camera's viewpoint. The same applies to depth perception: in an overhead photograph, a part at the wrong height may appear to have the correct x-y position. Geometry and lighting conditions must be considered when defining the problem.
It is safer to route uncertain decisions into separate workflows such as 'capture another image,' 'send to a second station,' or 'manual inspection.' Automatic rejection is not always the only option. A well-designed uncertainty policy can reduce unnecessary scrap.
Statistical reliability of relational decisions
A large number of parts in an assembly causes individual perception errors to accumulate at product level. In a system that correctly detects each of eight independent objects with 99% probability, the probability of detecting all of them correctly together is approximately 0.99^8 = 92.3%. This rough calculation assumes independence; in real images, errors may be correlated because of lighting or occlusion. Nevertheless, it illustrates why individual-object recall should not be confused with product acceptance performance.
Evaluation reports should therefore measure product-level false accepts and false rejects as well as recall for each required component. If the absence of a single part is critical, the decision that 'at least one is missing' may require very high sensitivity. However, false rejects must not be overlooked from an operational perspective.
In addition to the number of parts, increasing the number of rules can create more opportunities for false alarms. Checking each of twenty geometric conditions independently with 99% accuracy does not mean all the rules will be checked without error together. System-level testing is therefore essential.
How should field tests for logical anomalies be prepared?
Waiting for incorrect assemblies to occur in real production is not always practical. Missing parts, incorrect placement, reversed orientation, extra components, and occlusion can be deliberately introduced in controlled test fixtures. Which scenarios are physically plausible and safe should be determined with the production team. Synthetic image composites can help, but success on artificial images alone is not evidence of performance on the real line.
Products containing a single defect and those containing multiple simultaneous defects should be evaluated separately. For example, if a product has both a missing screw and an incorrectly placed label, the system should report both violated rules. A model that detects only one defect type may be correct in rejecting the product but still provide an incomplete diagnosis.
During application acceptance testing, test conditions, product revision, camera version, lighting state, and rule version should be recorded together. This makes it possible to see which assumptions underpinned an earlier performance claim when production changes.
Human review and maintenance
Low-confidence results from assembly images can be routed to a quality expert. Rather than showing the operator only a red alarm, however, the system should provide 'which slot, which expected part, and what observation.' This speeds up inspection and helps correct erroneous labels. Production records and visual outputs should be retrospectively auditable when needed.
Even a high-confidence model prediction can be wrong. When the geometry of parts from a new supplier changes, the model may continue relying on features of the old part. The maintenance plan should monitor reference-rule drift as well as model drift. Having rule changes approved by the quality team makes the automated system more operationally reliable.
This approach clarifies not only technical accuracy but also engineering responsibility: image processing reports which object it saw; the quality system determines which arrangement is acceptable.
Advanced engineering considerations for deployment
Expressing the rule visually
For logical anomalies, saying 'there is a missing part' is often insufficient. A specification should show which holes must be occupied for each product variant and which parts belong on which side. When the assembly recipe changes, applying the old rule to the same product can increase false rejects. Visual inspection must therefore be linked to product identity and the production recipe. The camera may see both variants clearly, yet selecting the wrong product type still produces an incorrect result even if the image processing algorithm works correctly. System validation should cover product-to-rule matching, not just the accuracy of the vision model.
Why is object counting not simple?
When screws of the same type partially overlap, the number of boxes in a single frame may be lower than the actual number of parts. A strong reflection on a shiny surface can also look like an additional object. Reliable counting requires defined part placement, image acquisition angle, and degree of occlusion. In some cases, using shadow regions or geometric information about the assembly fixture makes inspection easier. If a missing-screw location is consistently hidden behind the camera housing, changing the model does not address the source of the problem. The first requirement is that the measurement must be observable.
When is a graph representation useful?
Representing an assembly through objects and relationships can be more explanatory than examining pixel values alone. For example, if part A is expected to be to the left of B, above C, and in contact with D, these relationships can be expressed as rules. Comparing object positions found in the image against the rules can identify which relationship has been violated. However, object detection errors propagate into higher-level rule evaluation. If a component is missed, the system may interpret this as an incomplete assembly. Logical and visual uncertainties must therefore be monitored separately.
Combining scratch detection with assembly verification
A single product can be inspected for both surface defects and component placement. Using the same model for both tasks is not always economical. Surface defects call for texture-sensitive local methods, while assembly inspection may require long-range relationships and knowledge of the product variant. In a hybrid design, one stage produces a surface anomaly map while another checks object counts and relationships. The final acceptance policy must explicitly state which defect types are individually critical and what level of uncertainty requires operator review.
Application scenario: visual reasoning about incorrect assembly
Suppose product variant A requires four screws and variant B requires six. Seeing five screws in the camera image does not, by itself, explain the anomaly type unless the product variant is known. The part recipe, expected components, and geometric relationships are combined with image detections. The higher-level rule model should distinguish the observation 'five screws were found' from the error diagnosis 'one screw is missing for variant B.' This explainability can reduce the time an operator needs to intervene.
Field test checklist
- Is it documented which tests were kept independent by product, shift, and image capture conditions?
- Have failures that can be corrected by the algorithm alone been distinguished from those requiring optical or process changes?
- Has it been verified that the model score does not replace the physical acceptance criterion?
- Are input resolution, model version, threshold, and runtime hardware fixed in the experimental records?
- Are illustrative visuals clearly distinguished from actual measured model results?
- Are false rejects, missed defects, latency, and reinspection workload reported separately?
Frequently asked questions
What is the difference between a logical anomaly and a structural anomaly?
A structural anomaly is local physical deterioration visible in the image. A logical anomaly is a rule violation concerning object position, count, or relationships; the individual parts may look normal.
Can a missing screw be found using only an anomaly detector?
Although this is possible in some cases, a missing screw requires position and counting rules, so detection combined with rule-based checks may be more auditable.
Can LOCO AD be used directly in a commercial project?
The dataset is licensed under CC BY-NC-SA 4.0; commercial use is restricted. Commercial use should not be assumed permissible without verifying the license and permissions.
Can a vision-language model inspect an assembly?
It can support supplementary analysis, but critical counting and position decisions require deterministic measurement and field validation.
How can a missing part be distinguished from a hidden part?
The field of view, occlusion, and product geometry must be modeled; if necessary, a second view should be obtained or the decision recorded as uncertain.
References and image provenance
Technical references and original publications are listed below. The photographs used in the visual examples are genuine CC0/public-domain images; transformations made for comparison are explained. The diagrams are original designs. Illustrative examples are not presented as the performance of a trained model.
Image sources and illustration disclaimer
The sample photographs come from the scikit-image example data collection. Added boxes, masks, synthetic defects, and heatmaps are illustrations explaining the concepts; they are not outputs of a trained model or validated performance results. The technical diagrams are original drawings included in the package.