Unit 3 / 11

Quality Control and Defect Detection: Image Processing

Gains:

  • Ability to explain how defects on the fabric surface are detected and classified by image processing and machine learning.
  • Ability to interpret false positive/negative balance, 4-point scoring system, and model performance metrics
  • Ability to design a verification setup that tests automatic defect detection output with human inspection and physical inspection

For many years, fabric quality control has relied on the human eye: an operator watches fabric for hours on an illuminated inspection table, marking and scoring any defects he sees. This work is tiring, subjective, and prone to fatigue and error; Attention is not as sharp at the end of a shift as it is at the beginning. Computer vision and machine learning promise to automate this inspection: a high-speed camera scans the fabric, detecting and classifying a pattern of defects in seconds. In this unit, we will discuss how this system works, the criteria by which it is evaluated, and why human control is still indispensable.

Fabric Defects and the Language of Inspection

To understand automatic detection, it is first necessary to know the name of the defects. Typical defects in woven fabric: warp breakage (lack of longitudinal thread), weft defect/interfacing (transverse line), hole, stain, thick/thin place, warp bounce. In knitted fabric: needle mark (longitudinal line, from a needle malfunction), stray stitch, hole, thickness difference. In printing and dyeing: color difference, abrage (dyeing irregularity), slippage, splashing.

Inspection results are often scored using a four-point system: each defect is given 1-4 points according to its longitudinal length (e.g. 1 point up to 8 cm, 4 points over 15 cm) and the total score per 100 m² is calculated. Below a threshold (e.g. 40 points/100 m²) is considered "acceptance", above is considered "rejection". Automated scoring with AI should emulate this standard; It should not produce its own arbitrary score.

Tip: The output of the automated system should always be convertible to your accepted scoring standard (such as 4-point) and client tolerance. “The model found 12 anomalies” alone does not make a business decision; It must be converted into points and decisions.

How Does Automatic Flaw Detection Work?

Modern systems often combine the two approaches. Supervised classification is when an artificial neural network (especially image-appropriate convolutional neural network, English CNN) trained with thousands of previously labeled defect examples predicts whether there is a defect in the new image and its type. Anomaly detection, on the other hand, learns the "normal" fabric and marks anything that deviates from normal as a defect candidate; It works for rare, never-before-seen defects because it is not necessary to label each defect type in advance.

We read the performance of the system with two basic criteria. Sensitivity (recall): what percentage of real defects did it detect? Precision: What percentage of what they said was a flaw was actually a flaw? There is a balance between these two. False negative (missing the defect) means faulty goods are delivered to the customer; False positive (marking the perfect as defective) means unnecessary waste and slowdown. In quality-critical application, a threshold is generally chosen to keep false negatives low, while increased false positives undergo a rapid second check by a human operator.

There is a critical trap here: accuracy alone is misleading. On a production line, perhaps 2% of the fabric is defective. A stupid model that calls everything "perfect" reports 98% accuracy but doesn't catch a single flaw. Therefore, in unbalanced data, the sensitivity and precision of the defect class is not considered, but the accuracy.

Step by Step: Evaluating a Detection System

  1. Collect representative data. Images covering the actual fabric variety (colour, texture, lighting) that the system will see; Including rare defects.
  2. Check label quality. If the training labels are wrong, the model also learns wrong; Sample the labels with an expert eye.
  3. Measure sensitivity/precision. Separately for the defect class; Don't just look at general accuracy.
  4. Examine false negatives. Do the missed defects have a common feature (certain color, certain light)?
  5. Set up human-in-the-loop. Let the operator confirm what the model has marked; direct the uncertain to people.
  6. Monitor and retrain. Update the dataset as new defect types emerge (concept drift).

Three Mini Cases: By the Numbers

Case 1 — Misleading accuracy. A supplier sold a system saying "our model is 97% accurate". Customer returns increased in the field. The analysis showed that the sensitivity of the defect class was only 61%, meaning that 39 out of every 100 true defects were missed. Accuracy was high because most of the fabric was already flawless. Threshold re-adjusted and human control added; sensitivity increased to 92%, false positives were eliminated by the operator.

Case 2 — Lighting shift. In one line, false positives tripled when afternoon sunlight hit the inspection area; The model thought the shadows were stains. The problem was solved when the viewing condition (closed cabinet, constant LED lighting) was standardized. Lesson: the imaging setup is as much about quality as the model.

Case 3 — Time and labor. A business spent an average of 9 minutes manually inspecting 100 meters of fabric. With the camera pre-scanning + operator confirmation model, the time was reduced to 4 minutes and leakage was reduced because the operator paid attention only to the marked areas. What was critical was that automation sharpened not the operator, but the eye of the operator.

Weak Prompt / Strong Prompt

Note: Dedicated systems that directly analyze the defect image are separate; here we use AI for process design, data evaluation and report.

Weak prompt:

Tell me, is our defect detection model good?

Powerful prompt:

Your role: Textile quality engineer and data analyst.Below are the test results of the defect detection model (confusion matrix:true positive, false positive, false negative, true negative).Task:1) Calculate the sensitivity and precision for the defect class, show the formula.2) Explain with these numbers why the overall accuracy can be misleading.3) Comment on the business impact of the risk of false negatives in this production.4) Give concrete suggestion for threshold setting and human inspection.Numbers: [matrix]

Copiable Templates

1) Metric calculation and interpretation:

Calculate sensitivity, precision and F1 score from the following confusion matrix, write each formula and justify which one is more critical in terms of quality. Matrix: [TP, FP, FN, TN]

2) False negative root cause:

Below is the feature list of missed (false negative) defects (defect type, color, light, speed). Generate common pattern hypotheses and propose a verification trial for each hypothesis. Data: [list]

3) Conversion to 4-point points:

Convert the following detection output to a 4-point system: score each defect according to its length, calculate the total score per 100 m², compare with the [threshold] score and recommend acceptance/rejection. Defect list: [list]

4) Inspection report draft:

Derive an executive summary from the following shift defect data: top 3 defects, possible process source (hypothesis), total rejection rate, and recommended actions. Don't make up the numbers, just use what's given. Data: [table]

Metric Comparison Chart

criterion

What measures

Is it good to be high?

Importance in quality

Accuracy

Overall correct rate

Can be misleading

Low on unbalanced data

Sensitivity (recall)

Actual defect rate caught

Yes

Drops false negative (critical)

Precision

The truth of what you say is a flaw

Yes

Reduces false positives/waste

false negative

escaped defect

No, it should be low

Risk of faulty goods to the customer

false positive

empty alarm

No but it is tolerated

Efficiency/speed loss

Attention: The automated system is a "pre-screener", not an "approver". The final quality acceptance decision requires the approval of a competent quality officer, especially for batches subject to customer contract. The model accelerates human control, but does not exempt it.

Common mistakes

  • To look at righteousness and be satisfied. High accuracy hides artifacts in unbalanced data.
  • Neglecting the viewing condition. Without constant illumination and constant speed the model is unreliable.
  • Not checking label quality. The model trained with the wrong label learns incorrectly.
  • Forgetting the new type of defect. If data is not updated for new defects that appear over time, performance will silently degrade.
  • Cutting people out. The critical acceptance decision requires human approval.

In summary

Image processing greatly speeds up fabric inspection and compensates for human fatigue. But his performance is read not with accuracy, but with the sensitivity and precision of the flaw class; False negative is the most dangerous error in quality. Stable imaging condition, quality label and human-in-the-loop inspection are the three pillars of the reliability of the system. Automatic output is a preliminary screening; The final acceptance decision remains with the approval of the engineer.

Application task

Define an example confusion matrix for a defect detection system (e.g. 100 defective, 4900 perfect samples). Have sensitivity, precision and F1 calculated with the "metric calculation" template in this unit; then check the results manually. Discuss in a paragraph what happens to false positives when you change the threshold to halve the false negative in the same matrix, and decide which balance is right for your product.

checklist

  • [ ] I evaluate performance by sensitivity/precision, not accuracy.
  • [ ] I interpret the risk of false negatives along with the business impact.
  • [ ] I standardized the viewing conditions (light, speed).
  • [ ] I regularly check label quality and new defect types.
  • [ ] I place human approval on the final acceptance decision; The model is pre-sifter only.