"
[1]. A common rule-based method is template matching, which compares test images to reference templates using metrics like normalized cross-correlation. Template matching can effectively detect systematic defects but struggles with mixed or random patterns. Thresholding techniques are also rule-based, where global or local thresholds on metrics like pixel intensity are used to segment defects from backgrounds. Rule-based classification approaches for AOI have several limitations. The thresholds and boundaries used in the rules must be carefully predefined, which can limit flexibility and require reprogramming if new defect types are encountered. Feature selection is also critical, as redundant or uninformative features may reduce accuracy. Rule-based classifiers also struggle to generalize well when defects occur in nonspecific or overlapping patterns. Additionally, manual feature engineering is typically required rather than learning features directly from data. The accuracy of rule-based classifiers is highly dependent on consistent image quality and may be reduced by noise, lighting variations or component shifts between teaching and test images. While simple to implement, the limitations of rule-based AOI suggest machine learning techniques could provide benefits through self-learning features and greater robustness to variability in defect occurrence and image conditions.
Fig. 4.1 (a) The 1-NN decision rule: the point ? is assigned to the class on the left; (b) the k-NN
decision rule, with k = 4: the point ? is assigned to the class on the left as well.
only one known sample; in Figure 4.1(b) more than one known sample is used. In the
last case, the parameter k is set to 4, so that the closest four samples are considered
for classifying the unknown one. Three of them belong to the same class, whereas
only one belongs to the other class. In both cases, the unknown sample is classified as
belonging to the class on the left. Figure 4.2 provides a sketch of the k-NN algorithm.
The distance function plays a crucial role in the success of the classification, as is
the case in many data mining techniques. Indeed, the most desirable distance function
is the one for which a smaller distance among samples implies a greater likelihood
for samples to belong to the same class. The choice of this function may not be trivial.
Another important factor is the choice of the value for the parameter k. This is the
main parameter of the method, since it represents the number of nearest neighbors
considered for classifying an unknown sample. Usually it is fixed beforehand, but
selecting an appropriate value for k may not be trivial. If k is too large, classes with
a great number of classified samples can overwhelm small ones and the results will
be biased. On the other hand, if k is too small, the advantage of using many samples
in the training set is not exploited. Usually, the k value is optimized by trials on
the training and validation sets (see Chapter 8). Moreover, assigning a classification
on the basis of the majority of the k “votes’’ of the nearest neighbors could not be
accurate in some particular cases. For example, if the nearest neighbors vary widely
in their distance, then an unknown sample may be classified considering sample
"
Summarize the k-nn approach for classification in paragraph form , try not to directly copy the sentences from the paragraphs, use your own words .