Skip to main content

Rule-Based vs. Deep-Learning Inspection: When AI Wins

Machine vision inspection can be built from rule-based tools that an engineer configures or from deep-learning models trained on example images, and the two are set up, trained and validated differently. UTEC Industrial designs, engineers, machines, fabricates, and installs custom material handling systems for aerospace and heavy industry from its Spokane Valley, WA facility, integrating Allen-Bradley PLC and motion control with in-house CNC machining, heat treating, and stress relief. This article compares how each approach reaches a pass or fail, what an anomaly-detection benchmark and a defect-detection survey found, how much data deep learning needs, where thresholds come from and how a trained model is kept valid, with every when-to-choose rule labelled as engineering reasoning. An inspection station sits in the controls and monitoring links of one chain, design → engineering → parts machining → fabrication → assembly → weld fatigue → stress relief → drives → controls → tuning → monitoring, and its results depend on the fixtures, mounts and alignment the earlier links build.

What is the difference between rule-based and deep-learning inspection?​

The sources below describe the difference as a change in where the image features come from. A 2020 survey of visual defect detection by Czimmermann and co-authors says most of the approaches covered in its earlier sections are considered traditional solutions, "where the focus is on the explicitly engineered features which can be challenging to describe in complex cases." It says deep learning "uses data representation learning," and that "This ability of deep learning overcomes the requirement of complex features for a specific defect."

MVTec's HALCON operator reference, a vision-software manual, puts the same shift in workflow terms. Its deep-learning chapter says the model "is trained by only considering the input and output, which is also called end-to-end learning," with the outcome of "no need for manual feature specification. Instead you have to select and collect appropriate data."

Cognex's deep-learning help page uses the label this article's title uses. Cognex says libraries from other machine vision solutions "lie on the traditional machine vision technologies which are basically rule-based ones," and that its own conventional VisionPro tools, which it says can solve many machine vision problems, including geometric object location, measurement, edge detection and color analysis, "should be 'manually' configured in many cases and have limitations for some tasks in terms of their performances." Those are a vendor's claims about its own and competing products, not independent findings.

As engineering reasoning, the practical split is this: with a rule-based tool the engineer writes the decision, with deep learning the engineer supplies the examples it is learned from, and both depend on the same imaging chain of lighting, optics and sensor. The machine vision in material handling article covers that imaging chain (Czimmermann et al. 2020, §5; MVTec Software GmbH 2026, HALCON 26.05 Deep Learning chapter, introduction; Cognex Deep Learning Help rev. 3.2.1.15, 2024).

How does a rule-based inspection tool decide pass or fail?​

The MVTec AD paper by Bergmann and co-authors describes two traditional methods it used as baselines, and they show the mechanics.

  • Variation Model. The paper says this method "requires the objects in question to be aligned." A reference image is built from the pixelwise mean over a set of training images, and permissible variation is defined from the standard deviation of each pixel's gray value. At inference, a statistical test at each pixel measures the deviation from the reference and builds an anomaly map. The paper cites Steger et al. (2018) for the method.
  • GMM-based texture inspection. Hand-crafted feature descriptors are extracted from defect-free texture images, their distribution is modeled by a Gaussian Mixture Model, and anomalies are the descriptors to which the model gives a low probability. The paper attributes this method to Böttger and Ulrich (2016) and notes it was originally intended for images of regular textures.

The Czimmermann survey adds how the final call is made. It says the classification of a defect "is a severely subjective judgement, i.e., it greatly depends on what a defect represents for the human supervisor," and that this decision "is usually based on a threshold and a logical-based representation of the size ratio of both the component and the defect." Its textural defect detection section treats statistical, structural, filter-based and model-based approaches in four subsections, the four categories of texture-feature extraction techniques it credits to Xie et al., and closes with a fifth subsection comparing resource dependency.

As engineering reasoning, the strength of this route is that every parameter can be read and argued in engineering terms, and the Variation Model's stated precondition is alignment: a part that shifts in its fixture can read as a defect to a method that compares pixel by pixel against an aligned reference (Bergmann et al. 2021, §2.2.4; Czimmermann et al. 2020, §2 and §4).

How does a deep-learning inspection model learn what a defect is?​

HALCON's chapter lists, among others, classification of an image into one class out of a given set, object detection, semantic segmentation, and anomaly detection, which assigns "to each pixel the likelihood that it shows an unknown feature." It also lists Global Context Anomaly Detection, which scores how likely each pixel shows "a structural or logical anomaly."

Cognex describes two phases, training on a labeled image set and deployment at runtime, and four tools. Its Red Analyze tool "detects anomalies and aesthetic defects" by "learning the normal appearance of an object including its significant but tolerable variations," and its Green Classify tool classifies from labeled images. Cognex says the tools can serve "highly supervised (with image label) or completely unsupervised (without image label) applications."

The Czimmermann survey describes the same fork in general terms. It says two distinct principles apply to naturally occurring visual observations: one works from previous knowledge about the object to be found, and the other works with no given information about the object but with knowledge of the environment considered as normal. It adds that these principles can be replicated in artificial systems, using different approaches.

The rest of this answer is engineering reasoning. Those are two different projects. A classifier needs labeled examples of every defect class it must name. An anomaly detector needs a well-sampled picture of normal and flags whatever departs from it, without naming the defect (MVTec Software GmbH 2026, HALCON 26.05 Deep Learning chapter, introduction; Cognex Deep Learning Help rev. 3.2.1.15, 2024; Czimmermann et al. 2020, §3).

Why do anomaly-detection models train only on good parts?​

The MVTec AD paper gives the reason: defect images are scarce. Its introduction says "optical inspection tasks often lack defective samples that could be used for supervised training or it is unclear which kinds of defects may appear." It adds that "industrial processes are highly optimized in order to minimize the number of defective samples. Therefore, only a very limited amount of images with defects is available, in contrast to a vast amount of defect-free samples that can be used for training."

The dataset built on that premise contains 5,354 high-resolution color images of five textures and ten objects, with 73 types of anomalies and 1,888 pixel-accurate ground-truth regions. Its training images are defect-free; the images with anomalies are for testing. These figures are from the 2021 journal version of the paper, which extends an earlier 2019 conference paper.

The rest of this answer is engineering reasoning. The premise carries over to low-volume heavy parts such as large castings, weldments and machined frames, where a plant may never collect enough defect images to train a classifier. The failure mode on the other side is a normal variation that was missing from the good-part set, such as a second supplier's surface finish, which an anomaly detector can then flag as a defect (Bergmann et al. 2021, abstract, §1 and §3).

What does the MVTec AD benchmark show about deep learning against traditional methods?​

The paper reports that the two top-performing approaches on mean performance, Student–Teacher and Feature Dictionary, both use pretrained feature extractors. It then states: "The generative deep learning-based methods that are trained from scratch perform significantly worse, often only performing on par or inferior to the more traditional approaches, i.e., the Variation Model and the GMM-based Texture Inspection." Its list of contributions adds that "the evaluated methods do not perform equally well across object and defect categories."

These results carry conditions. They come from one benchmark dataset of 15 object and texture categories, under the paper's training and evaluation setup, for the methods evaluated in 2021. They are not results from a production line, and later methods are not covered.

The rest of this answer is engineering reasoning. The useful lesson is that "deep learning" names a family of methods, not one level of performance. A buyer can ask a vision supplier which kind of model is proposed, whether it starts from pretrained features, and how it was evaluated against a traditional baseline on the buyer's own parts (Bergmann et al. 2021, §1, §6.2 and §7).

How much image data does a deep-learning inspection need?​

No source cited here gives a required image count. HALCON's chapter says a project needs "a suitable amount of data," and MVTec recommends splitting the dataset "into three distinct datasets which are used for training, validation, and testing." Those subsets "should be independent and identically distributed," and the validation and test datasets "should have statistically relevant data, which gives a lower bound on the amount of data needed." It also says to train with representative images "and not only 'perfect' images, as otherwise the network may have difficulties with non-'perfect' images."

The Czimmermann survey reports a case from the work it reviewed: Sacco et al. (2018) built a CNN-based system for automatic quality control of fiber placement manufacturing that "failed to achieve satisfactory results due to their small (only 200 samples/defect) training dataset," which led to over-fitting. That figure is Sacco and co-authors' result as the survey reports it, not the survey's own test. In its conclusions, the survey calls the required large amount of training samples the main drawback of neural networks, adding that in artificial image processing this issue can be easily solved with labeled datasets or stochastic solutions such as mini-batches, while it remains a challenging problem in robotics and other systems that learn from real-world operations. It also says supervised methods "in many cases" are time consuming to train and require large datasets.

Cognex's help page states that its software "allows technicians to train a neural network model in minutes, based only on a small sample image set." That is a vendor claim with no stated test conditions, and the survey and benchmark cited here do not test it.

As engineering reasoning, the requirement worth writing into a purchase specification is the performance on a held-out test set collected from production parts, with its size and defect mix stated, rather than an image count (MVTec Software GmbH 2026, HALCON 26.05 Deep Learning chapter, General Workflow and Data; Czimmermann et al. 2020, §5 and §6; Cognex Deep Learning Help rev. 3.2.1.15, 2024).

Where does the pass/fail threshold come from?​

Both approaches end in a threshold. The MVTec AD paper concludes that "determining suitable thresholds solely on anomaly-free data is a challenging problem because the performance of each estimator highly varies for different dataset categories and evaluated methods." The Czimmermann survey says the defect decision "is usually based on a threshold and a logical-based representation of the size ratio of both the component and the defect," and that what counts as a defect depends on the human supervisor.

The rest of this answer is engineering reasoning. A rule-based threshold can be written in engineering units, such as a flaw length in millimeters or an edge position against a drawing tolerance, and traced to the drawing. A deep-learning threshold sits on a model score with no physical unit and has to be tied to the part by testing against agreed limit samples. Either way, the threshold trades escapes against false rejects, and that trade belongs to the customer's quality function, not to the vision supplier alone. A failure mode to plan for is a threshold set during one clean week of production, which then rejects good parts when the next material lot arrives (Bergmann et al. 2021, §7; Czimmermann et al. 2020, §2).

When does deep learning win, and when does a rule-based tool stay the better choice?​

No independent source cited here benchmarks rule-based against deep-learning inspection on heavy-industry or material handling lines; the MVTec AD figures come from one benchmark dataset of 15 object and texture categories. Cognex states that deep learning "offers an advantage over traditional machine vision approaches, which struggle to appreciate variability and deviation between very visually similar parts"; that is a vendor claim. Cognex also documents exporting a trained deep-learning tool into its conventional VisionPro environment as a tool block and using it as one of the VisionPro tools.

The two lists below and the combined-station suggestion after them are engineering reasoning, drawn from the sources above but not stated by any of them.

Deep learning is more likely to fit when:

  • the defect is visible but hard to describe with rules, for example a cosmetic flaw on an anodized aluminum extrusion or a textured cast surface
  • the acceptable part varies naturally in texture or color, and the tolerable range is easier to show with examples than to write down
  • normal appearance is well sampled but the defect types are not known in advance, which suits anomaly detection
  • the decision is a human judgement of appearance that inspectors can label consistently

A rule-based tool is more likely to stay the better choice when:

  • the requirement is a dimension, position or count in engineering units with a drawing tolerance, such as a hole pattern on a machined weldment
  • the part is fixtured and aligned, and the check is presence, absence or position of a known feature
  • few images exist and the part family changes from order to order, which makes each retraining a new validation job
  • the result has to be explained to an auditor in engineering terms

A combined station, with rule-based tools to locate and measure and a deep-learning tool to classify appearance, is one way to use each where it fits (Bergmann et al. 2021, §6.2; Czimmermann et al. 2020, §5; Cognex Deep Learning Help rev. 3.2.1.15, 2024).

What compute and platform demands does deep learning add?​

The Czimmermann survey states that "large neural networks used for deep learning require significant computational resources." HALCON's chapter says that for deep learning "additional prerequisites apply," referring to the requirements in its Installation Guide, and that the required module license depends on the model type used. Cognex's help page states that its VisionPro, Designer and deep-learning software require a valid Cognex security dongle installed on the PC during all phases of operation, including programming, processing, training and testing.

The custom machinery project lifecycle article covers how obsolescence of controls and components is managed over a machine's service life. The rest of this answer is engineering reasoning. Those demands turn into specification items: the training computer and the runtime computer, the inspection time budget per part, the license and hardware keys held as spares, and a plan for the day the runtime computer or its graphics hardware goes out of production. A failure mode here is a line stopped not by the model but by a failed PC, license key or dongle with no spare on site (Czimmermann et al. 2020, §6; MVTec Software GmbH 2026, HALCON 26.05 Deep Learning chapter, system requirements; Cognex Deep Learning Help rev. 3.2.1.15, 2024).

How is a deep-learning inspection validated, and what triggers revalidation?​

HALCON's chapter sets the basic gate: "before deploying it in the real world you should evaluate how well the network performs on basis of your test dataset." It explains why the test set is separate from the validation set: even if the validation dataset is disjoint from the training data, "it has an influence on the network optimization," and the third, test dataset is used to test the possible predictions when the model is deployed. At inference, images are to be preprocessed "in the same way as for training." The same chapter lists continual learning, which extends a classification model "with new data to learn additional classes or to improve the performance on existing classes."

The machine vision in material handling article covers acceptance on production parts, gauge capability and drift monitoring for any vision system. The European Machine Vision Association publishes EMVA 1288 Release 4.0 (2021), titled Standard for Measurement and Presentation of Specifications for Machine Vision Sensors and Cameras.

The rest of this answer is engineering reasoning. For a trained model, revalidation triggers include every retraining or continual-learning update, since the result is a different model; any change of camera, lens, lighting or preprocessing, since the inputs can then differ from the training images; and a new part variant or supplier. Comparing a replacement camera's EMVA 1288 data against the original is one check before the model is re-tested (MVTec Software GmbH 2026, HALCON 26.05 Deep Learning chapter, General Workflow and Data; EMVA 1288 Release 4.0-2021).

Can a deep-learning inspection result feed a safety function?​

The machine vision in material handling article already answers whether a camera can serve as a safety device. The copilots article sets out how Regulation (EU) 2023/1230, which applies from 14 January 2027 with some Articles applying from earlier dates, lists machine-learning safety components in Annex I Part A, and what the abstract of ISO/IEC TR 5469:2024, a technical report, describes for AI used inside a safety-related function.

The rest of this answer is engineering reasoning. The straightforward design keeps an inspection model's output a quality decision on the standard side of the control system. Where the reject action moves a load, such as a diverter or a transfer that pushes a part off the line, the guarding and safety functions of that motion are designed separately and do not depend on the model (Regulation EU 2023/1230, Art. 54 and Annex I Part A points 5 and 6; ISO/IEC TR 5469:2024, scope).

What controls and sensing does an inspection station need around the model?​

The model is one block in a station that also has to trigger the image, track the part and act on the result. For a laser line profiler, Cognex's reference guide describes projecting a sheet of laser light, viewing it at an angle, reducing the stripe to a height profile and combining successive profiles into a point cloud, and says the vision system typically relies on encoder signals to generate images, so that image capture follows the speed of the moving object rather than a preset timing, and that many vision applications use a rotary encoder attached to the conveyor. The 2D vs 3D machine vision article covers 3D sensing in depth. On the PLC side, Rockwell's Logix 5000 design considerations manual says tasks can be configured as continuous, periodic, or event, and the event-task triggers in its controller characteristics tables differ by family: the ControlLogix 5580 table lists module input data changes among them, while the CompactLogix 5370 table, which also covers the Armor versions, lists consumed tag, EVENT instruction triggers and motion events. The manual's event-task trigger table, on p. 43, notes that the embedded input points on certain CompactLogix 5370 controllers can be configured to trigger an event task when a change of state occurs. The same table includes a module input data state change, in which a remote input module triggers an event task based on its change-of-state (COS) configuration; the manual says to enable COS for only one point on the module and warns that if COS is enabled for multiple points, a task overlap of the event task can occur.

The list below is engineering reasoning:

  • Trigger and tracking: a part-present sensor or encoder count starts the image, and the PLC tracks each part from camera to reject point.
  • Lighting: strobe or light control tied to the trigger, with light output trended for drift.
  • Result handshake: pass or fail plus a status word, a model or recipe identifier and a heartbeat, all checked by the PLC before it acts.
  • Reject action: a diverter, pusher or robot pick timed to the tracked position, with confirmation that the reject happened.
  • Fixtures and mounts: the Variation Model's need for aligned parts points to machined nests and stiff camera mounts.

As engineering reasoning, the last item ties the station to the signature chain: machined fixtures and stress-relieved, stiff frames hold alignment, and the drives, PLC logic and monitoring then run and watch the station. UTEC Industrial delivers FANUC robotics and machine vision, including AI-based vision, with a FANUC design and engineering partner, and builds the surrounding controls on Allen-Bradley ControlLogix and CompactLogix platforms (Cognex 2021, laser profiler reference guide rev. 1.0.1.7, Theory of Operation; Rockwell Automation 1756-RM094N-EN-P-2025, Ch. 5 pp. 39 and 43, Ch. 2 p. 17 5580 characteristics table, and Ch. 4 p. 30; Bergmann et al. 2021, §2.2.4).

Related Articles

References​

  • Czimmermann, T., Ciuti, G., Milazzo, M., Chiurazzi, M., Roccella, S., Oddo, C. M., and Dario, P. (2020). "Visual-Based Defect Detection and Classification Approaches for Industrial Applications—A SURVEY." Sensors, 20(5), 1459.
  • MVTec Software GmbH: HALCON Operator Reference, Version 26.05.0.0: Deep Learning. MVTec Software GmbH, 2026 (undated web documentation, accessed September 2026).
  • Cognex Deep Learning Help, rev. 3.2.1.15: What is Cognex VisionPro Deep Learning. Cognex Corporation, 2024.
  • Bergmann, P., Batzner, K., Fauser, M., Sattlegger, D., and Steger, C. (2021). "The MVTec Anomaly Detection Dataset: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection." International Journal of Computer Vision, 129, 1038-1059.
  • EMVA 1288 Release 4.0-2021: Standard for Measurement and Presentation of Specifications for Machine Vision Sensors and Cameras. European Machine Vision Association, 2021.
  • Official Journal of the European Union. Regulation (EU) 2023/1230 on machinery, 2023.
  • ISO/IEC TR 5469:2024: Artificial intelligence — Functional safety and AI systems. ISO/IEC, 2024.
  • Cognex In-Sight 3D-L4000 Reference Guide, rev. 1.0.1.7: In-Sight 3D-L4000 Series Vision System Reference Guide. Cognex Corporation, 2021.
  • Rockwell Automation 1756-RM094N-EN-P-2025: Logix 5000 Controllers Design Considerations. Rockwell Automation, 2025.

Ready to Discuss a Material Handling System?​

UTEC Industrial designs, engineers, machines, fabricates, and installs custom material handling systems for heavy industry, from the stress-relieved structure and drives to the Allen-Bradley PLC controls, tuning, and monitoring that run them, at its Spokane Valley, WA facility. Send UTEC the application, loads, and duty cycle to start a system review.

Request a Quote →

Questions? Call (509) 922-1832 or email sales@utec.co