Industrial defect detection~

This article introduces the application of algorithms in image processing, and also introduces commonly used image processing algorithms and currently available visual inspection software libraries. The article aims to help readers better understand the application of algorithms in image processing and improve the effect and efficiency of image processing.

Algorithm (preprocessing algorithm, detection algorithm)

Commonly used image processing algorithms:

1. Image transformation: (spatial domain and frequency domain, geometric transformation, chromaticity transformation, scale transformation)

Geometric transformation: image translation, rotation, mirroring, transposition;

Scale transformation: image scaling, interpolation algorithm (nearest neighbor interpolation, linear interpolation, bicubic interpolation);

Transformation between spatial domain and frequency domain: Since the image array is very large, processing it directly in the spatial domain involves a large amount of calculation. Therefore, sometimes it is necessary to transform the spatial domain into the frequency domain for processing. For example: indirect processing techniques such as Fourier transform, Walsh transform, discrete cosine transform, etc., convert spatial domain processing into frequency domain processing, which can not only reduce the amount of calculation, but also obtain more effective processing (for example, Fourier transform can be performed in the frequency domain digital filtering).

2. Image enhancement:

Image enhancement does not consider the reasons for image degradation and highlights the interesting parts of the image. For example, strengthening the high-frequency components of the image can make the object contours in the image clear and the details obvious; strengthening the low-frequency components can reduce the impact of noise in the image.

Grayscale transformation enhancement (linear grayscale transformation, piecewise linear grayscale transformation, nonlinear grayscale transformation);

Histogram enhancement (histogram statistics, histogram equalization);

Image smoothing/noise reduction (neighborhood averaging method, weighted average method, median filtering, nonlinear mean filtering, Gaussian filtering, bilateral filtering);

Image (edge) sharpening: gradient sharpening, Roberts operator, Laplace operator, Sobel operator, etc.;

3. Texture analysis (skeleton and connectivity);

4. Image segmentation:

Image segmentation is to extract meaningful features from the image. The meaningful features include edges, areas, etc. in the image. This is the basis for further image recognition, analysis, and understanding.

(1) Threshold segmentation (fixed threshold segmentation, optimal/OTSU threshold segmentation, adaptive threshold segmentation);

(2) Based on boundary segmentation (Canny edge detection, contour extraction, boundary tracking);

(3) Hough transform (line detection, circle detection);

(4) Based on region segmentation (region growing, region merging and splitting, clustering segmentation);

(5) Color segmentation;

(6) Watershed segmentation;

5. Image features:

(1) Geometric features (position and direction, perimeter, area, major axis and minor axis, distance (Euclidean distance, block distance, checkerboard distance));

(2) Shape characteristics (geometric morphology analysis (Blob analysis): rectangularity, circularity, invariant moment, eccentricity, polygon description, curve description);

(3) Amplitude characteristics (moment, projection);

(4) Histogram features (statistical features): mean, variance, energy, entropy, L1 norm, L2 norm, etc.; the histogram feature method is simple to calculate, has translation and rotation invariance, and is not accurate for the precise spatial distribution of color pixels. Sensitive, etc., it has many applications in surface detection and defect identification.

(5) Color characteristics (color histogram, color moment)

(6) Local binary pattern (LBP) features: LBP has strong robustness to image grayscale changes caused by changes in lighting, etc., and is used in surface defect detection, fingerprint recognition, optical character recognition, face recognition and license plate recognition. It is applied in other fields. Since LBP calculation is simple, it can also be used for real-time detection.

6. Image/template matching:

Contour matching, normalized product correlation gray level matching, invariant moment matching, minimum mean square error matching

7. Color analysis

Chroma, color density, spectrum, color histogram, automatic white balance

8. Image data encoding, compression and transmission

Image coding and compression technology can reduce the amount of data (i.e., the number of bits) used to describe an image in order to save image transmission and processing time and reduce the memory capacity occupied. Compression can be achieved without distortion or with allowed distortion. Encoding is the most important method in compression technology, and it is the earliest and relatively mature technology in image processing technology.

9. Surface defect target recognition algorithm:

Traditional methods: Bayesian classification, K-nearest neighbor (KNN), artificial neural network (ANN), support vector machine (SVM), K-means, etc.;

10. Image classification (recognition)

Image classification (recognition) belongs to the category of pattern recognition. Its main content is to perform image segmentation and feature extraction after certain pre-processing (enhancement, restoration, compression) of the image, so as to carry out decision classification.

11. Image restoration

Image restoration requires a certain understanding of the causes of image degradation. Generally speaking, a "degradation model" should be established based on the degradation process, and then a certain filtering method should be used to restore or reconstruct the original image.

Existingly available visual inspection software libraries

1. Vision systems that can be developed twice: Labview, DVT, Halcon, OpenCV, etc.

2. Commonly used visual inspection software/libraries

Vision development software tools include Halcon, VisionPro, LabView, OpenCV, as well as eVision, Mil, Sapera, etc.

(1) Halcon: There are many underlying functional algorithms, fast computing performance, complete functions, easy to use, and short development project cycle. Non-open source projects are charged for commercial use and are more expensive.

Halcon: Halcon is a complete set of standard machine vision algorithm packages developed by the German company MVtec. It has a widely used machine vision integrated development environment. It is an image processing library, consisting of more than a thousand independent functions and an underlying data management core. It includes various filtering, color and geometry, mathematical conversion, morphological calculation and analysis, correction, classification recognition, shape search and other basic geometric and image calculation functions. The entire function library can be accessed in a variety of common programming languages ​​such as C, C++, C#, Visual basic and Delphi. Halcon provides interfaces for a large number of image acquisition devices, ensuring hardware independence.

(2) OpenCV: There are relatively many functional algorithms (fewer than Halcon), open source, and can be used for commercial purposes. The development cycle is longer (longer than Halcon), and some algorithms need to be written by yourself.

OpenCV is a cross-platform computer vision library based on (open source) distribution and can run on Linux, Windows and Mac OS operating systems. Its core is lightweight and efficient - it consists of a series of C functions and a small number of C++ classes that implement many common algorithms in image processing and computer vision. OpenCV is written in C++ language, and its main interface is also C++ language. The library also has a large number of interfaces for Python, Java and MATLAB/OCTAVE, and now also provides support for C# and Ruby. OpenCV can run on Windows, Android, Maemo, FreeBSD, OpenBSD, iOS, Linux and Mac OS platforms.

OpenCV origin: OpenCV is an Intel open source computer vision library. Its core consists of a series of C functions and a small number of C++ classes, which implement many common algorithms in image processing and computer vision. The characteristics of OpenCV include cross-platform mid-level and high-level APIs including more than 300 C functions. Cross-platform: Windows, Linux; Free: for both non-commercial and commercial applications; fast; easy to use.

OpenCV has the following characteristics: (1) Open source computer vision is written in C/C++. (2) The purpose of use is to develop real-time applications. (3) Independent from operating system, hardware and graphics manager. (4) It has universal image/video loading, saving and acquisition modules. (5) It has bottom-level and high-level application development packages.

The following functions can be achieved by applying OpenCV: (1) Operations on image data, including allocation, release, copying and conversion of data. (2) Input and output of images and videos refers to files and cameras as input, and image and video files as output. (3) Algorithmic procedures with operations on distances and vectors and linear algebra, including distance matrices, equation solving, eigenvalues ​​and singular values. (4) Can operate on various dynamic data structures, such as lists, queues, sets, trees, and graphs. (5) Have basic digital image processing capabilities, such as filtering, edge detection, corner detection, sampling and difference, color conversion, morphological operations, histograms and image pyramid operations.

(6) Various structures can be analyzed, including connected component analysis, contour processing, distance transformation, calculation of various distances, template matching, Hongh transformation, polygon approximation, straight line fitting, ellipse fitting and Delaunay triangulation etc. (7) Calibration of cameras, including discovery and tracking calibration modes, calibration, basic matrix estimation, homogeneous matrix estimation and stereo correspondence. (8) Analysis of motion, such as analysis of optical flow, motion segmentation and tracking. (9) To identify targets, feature method and Hidden Markov Model (HMM) method can be used. (10) Has basic GUI functions, including image and video display, keyboard and mouse event processing, scroll bars, etc. (11) Images can be annotated, such as lines, quadratic curves and polygons, and text can also be written (Chinese is currently supported). whaosoft aiot http://143ai.com 

(3) VisionPro

VisionPro is a complete vision solution provided by the American Cognex company. VisionPro provides a variety of development tools, drag-and-drop interfaces, simple scripts and programming methods, and fully supports the development of all modes. Using VisionPro QuickBuild™, users can read, select and optimize vision tools without programming configuration to determine whether the product is qualified. Users can also develop management applications using C++, C#, VB and .NET. The .NET program interface provided by Vision Pro allows users to access all tools using object-oriented high-level language programming to efficiently develop customer-specific vision solutions.

(4)LabView

LabView is a program development environment developed by National Instruments (NI) in the United States. It uses the graphical editing language G to write programs, and the generated programs are in the form of block diagrams. LabView software is the core of the NI design platform and is ideal for developing measurement or control systems. The LabView development environment integrates all the tools engineers and scientists need to quickly build a variety of applications, and is designed to help engineers and scientists solve problems, increase productivity and continue to innovate.

HSV color identification-HSV basic color component range

Generally, effective processing of images in color space is done in HSV space, and then a strict range needs to be given for the corresponding HSV component in the basic color. The following is the fuzzy range calculated through experiments (the accurate range is not available online. given).

H:  0 — 180

S:  0 — 255

V: 0 — 255

HSV (hue/saturation/value) color space is a model that represents a color space similar to the RGB color model. Color types are modeled in terms of hue channels, making them useful in image processing tasks that require segmenting objects based on color. Changes in saturation represent the amount of color components. The luma channel describes the brightness of a color.

Guess you like

Origin blog.csdn.net/qq_29788741/article/details/135039751