Skip to content

Workflow for texture analysisπŸ”—

PreprocessingπŸ”—

It migth be necessary to preprocess images before applying texture analysis:

Rectify the image
If the camera looks at an angle onto the object to inspect, it may be necessary to rectify the image to remove lens distortion and perspective distortion.
Scale down images
When both the texel and its smallest substructure are relatively large, you can downscale the image with the operator zoom_image_factor to speed up the texture analysis.
You can also create a pyramid of downscaled images by calling zoom_image_factor multiple times and then apply the texture filtering or feature computation to the image pyramid.
Use a region of interest
A region of interest can be created to reduce the image domain for which the texture analysis will be performed. This will reduce the processing time. In particular when computing texture features, the region of interest can be the result of a previous segmentation.

Applying texture filtersπŸ”—

With a texture filter, specific textural structures can be emphasized or suppressed. HALCON’s standard texture filter is texture_laws.

The operator texture_laws actually provides a family of texture filters. More information can be found in refsec{texture:aboutfilters}. After calling texture_laws, you should smooth the image by using mean_image with the mask size set to the size of the texel.

For certain images with simple textures, the operator dyn_threshold can be a good alternative to a regular filter as it is faster. Before using this operator, you must call mean_image with the mask size set to twice the texel size.

Computing texture featuresπŸ”—

The standard HALCON operator for computing texture features is gen_cooc_matrix, which generates the co-occurrence matrix of an image.

If you want to use the cooccurrence matrix corresponding to different directions, it is more efficient to generate the matrix with gen_cooc_matrix and then compute the features with cooc_feature_matrix.

Besides the texture features based on the cooccurrence matrix, you can also use the entropy and anisotropy of an image, which are computed by the operator entropy_gray, respectively. After the filtering has been performed, the intensity of a feature in the image can be computed using a threshold.

All operators can compute the texture features either for the complete image or for image regions.

As an advanced texture feature, you can also compute the distribution of the image gradient, which shows how the gray values change by first filtering the image with sobel_amp and then computing the histogram with gray_histo_abs.

Programming examplesπŸ”—

Some example applications are shown in the following programs:

  • Detecting defects in a texture with novelty detection:
    %HALCONEXAMPLES%/hdevelop/Segmentation/Classification/novelty_detection_svm.hdev

  • Detecting defects in a web using dynamic thresholding:
    %HALCONEXAMPLES%/solution_guide/basics/novelty_detection_dyn_threshold.hdev

  • Classifying different types of wood:
    %HALCONEXAMPLES%/solution_guide/basics/classify_wood.hdev