Skip to content

Classification🔗

Classification assigns objects to predefined classes. It is useful when objects are similar but show variations that cannot be described reliably by explicitly defined rules alone.

In HALCON, classification can be applied to different types of objects and for different tasks, such as general object classification, image segmentation, quality inspection, novelty detection, and optical character recognition (OCR).

Classification in general🔗

Classification methods can be broadly divided into two groups based on how the characteristics used for classification are obtained.

Classical classification approaches🔗

For classical classification approaches such as MLP classification, SVM classification, GMM classification, and k-NN classification, suitable features have to be specified for the classification task. The features are combined into feature vectors that describe the objects to be classified.

Depending on the application, feature vectors can contain region features, color information, texture features, or other properties of the objects.

For general classification, the feature vectors are explicitly built from suitable feature values. For image segmentation, the pixel values of multi-channel images can be used as features and the corresponding image segmentation operators derive the feature vectors automatically. For OCR, a restricted set of region features is used and the corresponding OCR operators calculate the features internally.

The quality of the selected features has a strong influence on the classification result. There are no general rules for selecting the best features because the suitable features depend on the application and the objects to be classified.

Deep learning-based classification🔗

Deep learning-based classification does not require the features to be specified manually. Instead, the network learns suitable features directly from labeled images during training.

This makes deep learning particularly useful when suitable features are difficult to define or when a high classification accuracy is required. However, deep learning-based classification generally requires more training data and a longer training phase than the classical classification approaches.

Image segmentation🔗

In image segmentation, pixels are classified according to their features and pixels belonging to the same class are combined into image regions.

For classical classification, features such as color or texture can be used. HALCON provides MLP classification, SVM classification, GMM classification, and k-NN classification for image segmentation.

For specific segmentation tasks, HALCON also provides simple and fast classifiers, such as a 2D histogram classifier for two-channel images and classifiers based on Euclidean or hyperbox metrics.

Object recognition🔗

Object recognition assigns objects to predefined classes. It is useful when different object types have similar characteristics but cannot be reliably distinguished using explicitly defined rules.

Depending on the application, arbitrary features such as color, texture, shape, or size can be used for classical classification. MLP classification, SVM classification, GMM classification, and k-NN classification can be used for this purpose. Deep learning classification can be used when suitable features are difficult to define manually.

Quality inspection🔗

In quality inspection, classification can be used to distinguish between conforming and defective objects or to distinguish different defect classes.

If the number of samples is strongly unbalanced between the classes, the classification task can sometimes be divided into multiple classification steps. For example, good objects can first be separated from all defective objects, followed by a second classification that distinguishes between the different defect classes.

Novelty detection🔗

Novelty detection identifies samples that do not sufficiently correspond to the trained classes.

SVM classification, GMM classification, and k-NN classification support novelty detection.

Typical applications include detecting defects, anomalies, or changes.

Optical character recognition (OCR)🔗

In OCR, character regions are classified into classes that typically represent individual characters or numbers.

HALCON provides several OCR classification approaches, including MLP classification, SVM classification, k-NN classification, and deep learning classification.

For classical OCR classification approaches, a restricted set of region features is used, while CNN-based deep learning methods can learn suitable features directly from the training data.

For OCR, it is recommended to first try the pretrained Universal font, which is based on a CNN, before developing a separate OCR classifier.

Classification approaches in HALCON🔗

HALCON provides several classification approaches with different characteristics. The most important approaches for general classification are deep learning (DL), MLP, SVM, GMM, and k-NN.

The following table provides a brief overview of their main characteristics.

Characteristic DL MLP SVM GMM k-NN
Training speed Slow Slow Medium Fast Fast
Classification speed Depends on system and network Medium to fast Medium Fast Medium
Automatic feature extraction Yes No No No No
Highest classification speed is reached for Small networks and few classes Few hidden nodes and classes Few support vectors Few classes Few training samples
Memory requirements Medium to high, depending on network Low Medium Low High
Additional training data Yes No Not recommended Not recommended Yes
Suitable for high-dimensional feature spaces Yes Yes Yes No Yes
Suitable for novelty detection No No Yes Yes Yes

The choice of a classification approach depends strongly on the requirements of the application. There are no fixed rules that determine which approach is best suited for every application.

In many cases, the quality and amount of the training data and the selected features have a greater influence on the classification result than the choice between the different classifiers. Therefore, a different classifier should only be considered after the training data and features have been verified to be suitable.

Deep learning🔗

More Info

See also Deep learning classification.

Deep learning is particularly suitable when high classification accuracy is required or when suitable features are difficult to define manually.

The features are learned automatically from labeled images. More training data can improve the generalization of the trained network, but increases the training time.

MLP🔗

More Info

See also MLP classification.

MLP classification is particularly well suited for applications that require fast classification but allow for a slow offline training phase.

The complete training data should be available before training because adding further training data requires the classifier to be trained again.

MLP classification does not support novelty detection.

SVM🔗

More Info

See also SVM classification.

SVM classification can often be tuned to achieve very high classification quality. However, classification is typically slower than with MLP, and the memory requirements are higher.

The training of an SVM classifier is substantially faster than the training of an MLP classifier, but it is typically too slow for the online phase.

GMM🔗

More Info

See also GMM classification.

GMM classification provides fast training and classification, especially when the number of classes is low.

GMM is well suited for novelty detection but is restricted to applications that do not require a high-dimensional feature space.

k-NN🔗

More Info

See also k-NN classification.

k-NN classification is particularly useful for testing different feature configurations and training data because training is very fast and the feature space is not restricted in its dimensionality.

Additional training data can also be added quickly. However, classification is typically slower than MLP classification and the memory requirements increase with the number of training samples.

Selecting a classification approach🔗

When selecting a classification approach, the requirements of the application should be considered first.

Important criteria include

  • required training speed,

  • required classification speed,

  • available memory,

  • feature-space dimensionality,

  • availability of additional training data,

  • requirement for novelty detection, and

  • whether suitable features can be defined manually.

For image segmentation, MLP, SVM, GMM, and k-NN classification can be accelerated significantly using a look-up table (LUT). LUT-accelerated classification is suitable for images with a maximum of three channels. It increases the offline processing time and memory requirements.

For OCR, the pretrained Universal font should generally be tested first before developing another OCR classification approach.

Selecting suitable features🔗

For classical classification approaches, suitable features have to be selected for the specific application.

The appropriate features depend strongly on the objects and the classification task. Features can describe properties such as

  • color,

  • texture,

  • shape,

  • size, or

  • other region properties.

If it is unclear which features are suitable, HALCON provides automatic feature-selection operators for MLP, SVM, GMM, and k-NN classification.

Selecting suitable training samples🔗

Training samples should represent both the characteristic properties of the classes and the variations that are expected during classification.

For each class, the training data should contain a sufficiently large and realistic range of variations. For example, variations caused by noise, size, orientation, texture, or other application-specific influences should be represented in the training data.

If the available training data is insufficient, artificial samples can sometimes be generated by slightly modifying existing samples. The suitability of this approach depends strongly on the application and the classification method.

If the classes contain very different numbers of samples, the classification task can sometimes be split into multiple stages to handle the imbalance.

In general, the classification result depends strongly on the quality and amount of the training data. Therefore, representative training samples should be established before changing the classification approach.