Rule-Based Algorithms versus Deep Learning: How to Choose
The choice is usually presented as a matter of ambition, with deep learning as the modern option and classical image processing as the legacy one. That framing produces bad projects in both directions: simple gauging tasks wrapped in a model that now needs retraining, and appearance judgments attacked with thresholds that no threshold can express. The decision is not about ambition. It is about what varies between a good part and a bad one, and whether that variation can be written down as a rule.
Key takeaways
- Decide by asking what varies, not by asking which method is more advanced.
- A rule is preferable when the difference is measurable; a model is necessary when it is only recognisable.
- Rules fail loudly and can be read by a person. Models fail quietly and have to be measured.
- Both need maintenance. What differs is what the maintenance consists of.
The decision is usually framed as a matter of ambition. In practice it is settled by one question: what varies between a part that should pass and a part that should fail, and can that variation be written down as a rule? If the answer is a number — a width, a diameter, a position, a count, a grey-level difference between two defined regions — then classical image processing will express it directly, and it will do so in a way a process engineer can read and check. If the answer is a description of appearance that has no measurable form, a model is the only thing that will do the job.
Four questions that decide it
Work through these in order and stop at the first clear answer
- Can a good part and a bad part be told apart by a number?
If you can state the criterion as a measurement with a tolerance — the gap is 2.0 plus or minus 0.1 mm, the hole is present, the label is within 0.5 mm of this edge — then use a rule. It will be more repeatable, faster and far easier to explain during an audit.
- Does the variation live in the measurement or in the appearance?
Scratches, discolouration, uneven texture, weld bead appearance, small contamination: these are judged by what they look like rather than by a dimension. If two inspectors would agree on the verdict but not be able to write down the threshold, that is the signature of a task that needs a model.
- How many defect examples exist, and how varied are they?
A model needs examples. If only a handful of confirmed defects exist, or all of them came from one incident, a model cannot be trained to recognise the next one. The situation is described in detail in when defect samples are scarce.
- Who will maintain it, and how?
A rule is maintained by reading it. A model is maintained by measuring it against a held-out sample and retraining when performance has degraded. Both are real work; the question is which one the site is actually staffed for.
How the two fail, and why it matters more than accuracy
The two approaches fail differently, and the difference is more consequential than any comparison of accuracy figures. A rule fails loudly. When the lighting drifts or the part moves, the measured value jumps outside its tolerance and the station either rejects everything or obviously misbehaves, and an engineer can open the rule, read it, and see which threshold stopped making sense. The failure announces itself.
A model fails quietly. A network trained on samples from last year will continue to produce confident verdicts when the surface finish changes, the supplier changes the coating, or the camera is replaced. Because the output is a probability rather than a measurement, there is no threshold to inspect and no obviously wrong number to point at. The verdicts simply become slightly worse, in a way that only shows up in the escape rate or, more often, in the customer complaint. This is why a model deployment needs a measurement plan from the first day: a held-out sample set, a periodic re-measurement, and a defined level of degradation at which retraining is triggered. The same discipline as model drift monitoring.
| Rule-based | Deep learning | |
|---|---|---|
| Data needed | A specification | Labelled examples of both outcomes |
| Failure mode | Loud — values leave tolerance | Quiet — confident but slightly worse |
| Explainability | Readable; the threshold is the reason | Requires held-out measurements to characterise |
| Maintenance | Adjust a parameter when the process shifts | Re-measure on a sample set; retrain when it degrades |
| Compute | Light; runs on an edge device comfortably | Heavier; may need a GPU or a larger edge unit |
| Best fit | Presence, position, dimension, count, contrast between defined regions | Appearance, texture, irregular defects, variable presentation |
Common questions about algorithm selection
Is deep learning always more accurate?
No. On a task that reduces to measuring a distance between two edges, a classical sub-pixel measurement is typically more repeatable than a model, because the model was never given the notion of a calibrated distance. Where a model wins is on judgments that have no measurable form, and on tolerating the natural variation in how a part is presented.
Can a model replace an existing rule-based station later?
It can, and it should be evaluated on the data the rule station already produces rather than on a fresh sample set. Run both in parallel on the same images for a period and compare the verdicts against the confirmed outcomes. That comparison is also the only reliable way to estimate how many escapes the change would introduce or remove.
How much labelled data does a model need?
The honest answer is that it depends on how much the appearance varies, not on a fixed number. A task with a consistent presentation may work from a few hundred examples; a task with wide natural variation may need thousands. This is why the collection strategy, not the count, is what should be planned first.
Not sure whether your task needs a model?
Describe the defect in a sentence. If it turns out to be measurable, we will say so and save you the model.
Related articles
-
Alarm Fatigue: Why the Floor Turns the System Off
Many visual SOP systems are not beaten by technical problems — they are muted by…
Read more → -
Visual SOP Camera Selection and Mounting
Camera selection for visual SOP is not the same as for product inspection. The s…
Read more → -
Vision Monitoring at the Semiconductor Die Bonder
Semiconductor packaging stations are characterised by high precision, fast cycle…
Read more → -
Wrong-Assembly Alarms Without the False Alarms
The most common reason a visual SOP project fails is not poor recognition — it i…
Read more →
Need specific advice for your production line?
Our engineers can share practical approaches to process error prevention and SOP compliance inspection for your scenario.
Request a free trial plan