A Defect Detection Method with Information Quantification, an Image Detection Device, and a Storage Medium

By using neural network initial detection and surface discretization processing, the problem of quantitative detection of defects in power battery casings was solved, achieving pixel-level defect detection and three-dimensional information acquisition, thus improving detection accuracy and precision.

CN115018772BActive Publication Date: 2025-08-01SHENZHEN HUAHAN WEIYE TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210563971.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-23
Publication Date
2025-08-01
Estimated Expiration
2042-05-23

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately quantify defects on the casing of power batteries, especially on curved surfaces where it is difficult to specify a benchmark for the quantitative height of defects, leading to a decline in detection capabilities.

Method used

A quantitative defect detection method is adopted. By acquiring the surface image of the object to be tested, the neural network is used for initial defect detection. After expanding the defect area, the surface is discretized to establish a continuous and smooth ideal surface model. The defect location and depth information are obtained through differential processing.

Benefits of technology

It improves the accuracy and precision of defect detection, enabling quantitative detection of tiny pinhole defects, reducing false detection rates, providing pixel-level defect detection accuracy and three-dimensional information, and enhancing the positioning accuracy of defect areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115018772B_ABST
    Figure CN115018772B_ABST
Patent Text Reader

Abstract

The present application relates to a defect detection method for information quantification, an image detection device, and a storage medium. The defect detection method includes: performing initial defect detection on a first image of an object to be measured to obtain an initial defect region, expanding the initial defect region and forming a second image based on the expanded region, performing surface discretization processing on the second image to obtain a continuous and smooth ideal surface model, restoring an ideal surface image according to the ideal surface model, performing differential processing on the ideal surface image and the second image to obtain a defect-enhanced image, and obtaining defect location information and defect depth information within the surface inspection region of the object to be measured based on the defect-enhanced image. The technical solution can provide pixel-level defect detection accuracy, enhance the positioning accuracy of the defect region through restoring the ideal surface image and differential processing, and can provide more accurate three-dimensional defect information when statistically calculating defect quantification indicators, which helps to strictly determine the surface defects of the object to be measured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image processing, and particularly relates to a defect detection method for information quantification, a detection device, and a storage medium. Background Art

[0002] With the popularization and promotion of new energy vehicles, as a core component, the power lithium battery is playing an increasingly important role in the industrial chain of new energy vehicles. The cost of the power battery accounts for about 40% of the total vehicle cost. Moreover, the safety performance indicators of new energy vehicles are often bound to those of the power battery, and the quality of the power battery during the production and processing directly affects the quality of the whole vehicle. Common accidents such as the fire and burning of new energy vehicles are also caused by the leakage, short circuit, overload, and thermal runaway of the electrolyte due to the damage of the power battery shell or abnormal sealing. The famous "steel needle piercing experiment" is also sufficient to illustrate the danger of lithium battery leakage and short circuit.

[0003] At present, the shell sealing design of the power battery mainly adopts laser welding technology, which mainly includes pole welding technology, top cover welding technology, and sealing nail welding technology, etc. The main functions of these welding technologies are connection and sealing to prevent the leakage of the electrolyte in the shell or poor airtightness. Generally, the penetration depth of laser welding is required to be about 0.3 mm to 1 mm. The laser welding technology melts and evaporates the welding material instantaneously through a laser beam with a high energy density to form a penetration depth. However, the change of laser power, the change of welding speed, and the cleanliness of the welding material will all affect the welding quality. Among them, the change of laser power may lead to local non-welding and wave welding. Welding slag, oil stains, or particulate foreign matters on the surface of the welding material will cause welding explosion points, tiny pinholes, or hidden cracks in the weld bead. When defects such as non-welding, explosion points, pinholes, and hidden cracks are serious, they will directly cause the leakage and short circuit of the electrolyte. Although minor defects can pass the airtightness test, leakage accidents are very likely to occur during the long-term use in the later stage. In order to prevent such defective products from flowing out of the welding station, an appearance inspection station is often added at the later stage of the welding station to detect the welding quality and intercept defective products.

[0004] In order to improve the safety performance of lithium batteries and balance the production cost, power battery manufacturers have put forward strict quantitative defect definitions for the quality control of laser welding processes. The typical quality inspection requirements for seal nail welding are as follows: pinhole explosion points with a length and width ≥ 0.2 mm and a depth ≥ 0.2 mm need to be detected, and broken weld lengths ≥ 0.5 mm need to be detected. Due to the quantitative definitions of the three dimensions of length, width, and height in quality control, and the uneven, reflective, and irregular surface of the weld seam, 3D line lasers or structured light cameras are usually used in the industry for power battery shell appearance inspection to take pictures, analyze the height image, and use height information and length and width information for defect detection. There are still some problems with the existing defect detection capabilities. Since the weld seams of power battery shells often present irregular curved surface forms, such as the top cover weld seam being a cylindrical convex surface, the seal nail weld seam being a concave surface, and the pole weld seam being a flat surface, it is often difficult to specify a reference for the quantitative height information of defects on the curved surface, and it is often difficult to unify with the customer's standards, which will result in a decline in detection capabilities. Summary of the Invention

[0005] The main technical problem to be solved by this application is: how to accurately and quantitatively detect the defect information on the power battery shell. To solve the above technical problem, this application provides a defect detection method with information quantification, an image detection device, and a storage medium.

[0006] According to a first aspect, in one embodiment, a defect detection method with information quantification is provided, including: obtaining a first image of the surface inspection area of the object to be tested; performing initial defect detection on the first image to obtain an initial defect area; expanding the initial defect area to obtain an expanded area, and forming a second image based on the expanded area; performing surface discretization processing on the second image to obtain a continuous and smooth ideal surface model; restoring the ideal surface model to obtain an ideal surface image; performing differential processing on the ideal surface image and the second image to obtain a defect enhancement image; obtaining defect location information and defect depth information within the surface inspection area of the object to be tested according to the defect enhancement image.

[0007] In one embodiment, the initial defect detection of the first image to obtain an initial defect region, expanding the initial defect region to obtain an expanded region, and forming a second image based on the expanded region includes: inputting the first image into a preset neural network model, and extracting coarse-grained features of the first image in the neural network model; segmenting the initial defect region from the first image according to the coarse-grained features; constructing a bounding rectangle of the initial defect region, and the bounding rectangle is represented as (x, y, w, h); wherein, x and y are respectively the abscissa and ordinate of the center point of the bounding rectangle, and w and h are respectively the number of pixels of the width and height of the bounding rectangle; performing pixel expansion on the bounding rectangle in terms of width and height to obtain the expanded region, and the expanded region is represented as (x′, y′, w′, h′); wherein, x′ = x, y′ = y, w′ = 2×w, h′ = 2×h; intercepting the expanded region from the first image to form the second image.

[0008] In one embodiment, the curved surface discretization process of the second image to obtain a continuous and smooth ideal surface model includes: inputting the second image into a preset discretization geometric model; the discretization geometric model is a parabolic surface model, a plane model or a cylindrical surface model; using the discretization geometric model to discretize the surface where the second image is located into corresponding curve modules, and establishing a continuous and smooth ideal surface model according to the curve modules.

[0009] In one embodiment, when the discretization geometric model is a parabolic surface model; the curve modules participating in establishing the ideal surface model include a plurality of continuously distributed X-direction parabolas and a plurality of continuously distributed Y-direction parabolas; each X-direction parabola and each Y-direction parabola are mutually collinear constrained. If each X-direction parabola is represented as Z1(x) and each Y-direction parabola is represented as Z1(y), then the discretization algebraic formula of the parabolic curve model is expressed as

[0010] Z1(x) = ax 2 + bx + c, Z1(y) = Ay 2 + By + C;

[0011] wherein, a, b, c, A, B, and C are all parabola parameters, and X, Y, and Z are respectively the X-axis, Y-axis, and Z-axis in the camera reference coordinate system.

[0012] In one embodiment, when the discretized geometric model is a planar model, the curve module participating in the establishment of the ideal surface model includes a plurality of continuously distributed X-direction straight lines and a plurality of continuously distributed Y-direction straight lines; each X-direction straight line and each Y-direction straight line are mutually collinear constrained. If each X-direction straight line is represented as Z2(x) and each Y-direction straight line is represented as Z2(y), then the discretized algebraic formula of the planar model is expressed as

[0013] Z2(x) = ax + b, Z2(y) = Ay + B;

[0014] where a, b, A, and B are all straight line parameters.

[0015] In one embodiment, when the discretized geometric model is a cylindrical surface model, the curve module participating in the establishment of the ideal surface model includes a plurality of continuously distributed X-direction parabolas and a plurality of continuously distributed Y-direction straight lines; each X-direction parabola and each Y-direction straight line are mutually collinear constrained. If each X-direction parabola is represented as Z3(x) and each Y-direction straight line is represented as Z3(y), then the discretized algebraic formula of the cylindrical surface model is expressed as

[0016] Z3(x) = ax 2 + bx + c, Z3(y) = Ay + B;

[0017] where a, b, and c are all parabola parameters, and A and B are all straight line parameters;

[0018] Alternatively, the curve module participating in the establishment of the ideal surface model includes a plurality of continuously distributed Y-direction parabolas and a plurality of continuously distributed X-direction straight lines; each Y-direction parabola and each X-direction straight line are mutually collinear constrained. If each Y-direction parabola is represented as Z′3(y) and each X-direction straight line is represented as Z′3(x), then the discretized algebraic formula of the cylindrical surface model is expressed as

[0019] Z′3(y) = ay 2 + by + c, Z′3(x) = Ax + B;

[0020] where a, b, and c are all parabola parameters, and A and B are all straight line parameters.

[0021] In one embodiment, the method of using the discretized geometric model to discretize the surface where the second image is located into corresponding curve modules and establishing a continuous and smooth ideal surface model based on the curve modules includes: discretizing the surface where the second image is located in the X direction using the discretized geometric model to obtain a surface model in the X direction; establishing a discretized local surface based on the surface module in the X direction; discretizing the local surface in the Y direction using the discretized geometric model to obtain a surface model in the Y direction; and establishing a continuous and smooth surface model based on the surface model in the Y direction.

[0022] If the object for surface discretization in the Y direction is set as the first target surface, then the surface discretization of the first target surface in the Y direction includes: performing an X-direction image pyramid process on the first target surface, reducing the X-direction resolution in the first target surface by taking the pixel average every other column while keeping the Y-direction resolution unchanged; performing a one-dimensional column filtering process on the Y direction in the first target surface after the image pyramid process using Gaussian filtering or mean filtering; fitting the pixel coordinates of the first target surface after the one-dimensional column filtering process using the least squares method based on iterative weights to calculate the curve parameters corresponding to each column of pixels in the Y direction; constructing the continuous height information corresponding to each column of pixels in the Y direction according to the curve parameters corresponding to each column of pixels in the Y direction; performing a one-dimensional row filtering process on the X direction for the continuous height information corresponding to each column of pixels using Gaussian filtering or mean filtering to obtain the X-direction ideal surface corresponding to the ideal surface model; performing linear interpolation in the X direction on the X-direction ideal surface to restore the X-direction resolution; thus achieving the surface discretization of the first target surface in the Y direction.

[0023] The step of using the least squares method based on iterative weights to fit the pixel coordinates of the first target surface after the one-dimensional column filtering process and calculate the curve parameters corresponding to each column of pixels in the Y direction includes: setting a first constraint condition such that the weight of a pixel point that deviates more from the geometric curve model is smaller, and the weight of a pixel point that is closer to the geometric curve model is larger; wherein the geometric curve model includes a parabola model and a straight line model; the first constraint condition includes a first weight function and is expressed as

[0024]

[0025] where τ is a clipping factor and δ is the algebraic distance from the pixel point to the discretized geometric model;

[0026] Establishing a minimization loss function for the parabola model according to the first constraint condition, and expressing it as

[0027] ε 2 =∑w h(ax 2 + bx + cz + d) 2 + λ(a 2 + b 2 + c 2 - 1)n;

[0028] Establish the minimization loss function of the straight - line model according to the first constraint condition, and express it as

[0029] ε 2 = ∑w h (ax + bz + c) 2 + λ(a 2 + b 2 - 1)n;

[0030] Take the minimization loss function of the parabolic model and / or the minimization loss function of the straight - line model as the iterative calculation conditions of the least - squares method, fit the pixel coordinates of the first target surface after one - dimensional column filtering, and when the corresponding minimization loss function converges, calculate the curve parameters corresponding to each column of pixels in the Y - direction.

[0031] In one embodiment, the using the discretized geometric model to discretize the surface where the second image is located into corresponding curve modules and establishing a continuous and smooth ideal surface model according to the curve modules includes: using the discretized geometric model to perform X - direction surface discretization on the surface where the second image is located to obtain a continuous and smooth surface model in the X - direction; using the discretized geometric model to perform Y - direction surface discretization on the surface where the second image is located to obtain a continuous and smooth surface model in the Y - direction; performing weighted fusion processing on the continuous and smooth surface model in the X - direction and the continuous and smooth surface model in the Y - direction to establish a continuous and smooth ideal surface model; the weighted fusion processing is expressed by the formula Z xy = δ x ·Z x + δ y ·Z y ; where δ x , δ y are the weight functions in the X - direction and Y - direction respectively, Z x represents the continuous and smooth surface model in the X - direction, and Z y represents the continuous and smooth surface model in the Y - direction.

[0032] The weight functions participating in the weighted fusion processing are expressed by the formula

[0033]

[0034] δ y = 1 - δ x ;

[0035] where \(t\) represents the deviation threshold, and represents the absolute value of the gradient of \(Z\) x in the \(Y\) direction, and represents the absolute value of the gradient of \(Z\) y in the \(X\) direction;

[0036] When the absolute value of the deviation between the two surface models of \(Z\) x and \(Z\) y is less than the deviation threshold, the two surface models are weighted and averaged in a ratio of 1 / 2; when the absolute value of the deviation between the two surface models of \(Z\) x and \(Z\) y is greater than the deviation threshold, they are weighted and fused according to the weight functions \(\delta\) x and \(\delta\) y and each weight function satisfies the constraint condition: the greater the gradient of the continuously smooth surface model in the \(X\) direction in the \(Y\) direction, the smaller the weight function; the smaller the gradient of the continuously smooth surface model in the \(Y\) direction in the \(X\) direction, the greater the weight function.

[0037] Set the object for surface discretization in the \(X\) direction as the second target surface. Then, the surface discretization of the second target surface in the \(X\) direction includes: performing an image pyramid process on the second target surface in the \(Y\) direction, reducing the \(Y\)-direction resolution in the second target surface by taking the pixel average every two rows, and keeping the \(X\)-direction resolution unchanged; using Gaussian filtering or mean filtering to perform one-dimensional row filtering on the \(X\) direction in the second target surface after the image pyramid process; using the least squares method based on iterative weights to fit the pixel coordinates of the second target surface after one-dimensional row filtering, and calculating the curve parameters corresponding to each row of pixels in the \(X\) direction; calculating the continuous height information corresponding to each row of pixels in the \(X\) direction according to the curve parameters corresponding to each row of pixels in the \(X\) direction; using Gaussian filtering or mean filtering to perform one-dimensional column filtering on the continuous height information corresponding to each row of pixels in the \(Y\) direction to obtain the ideal surface in the \(Y\) direction corresponding to the ideal surface model; performing linear interpolation in the \(Y\) direction on the ideal surface in the \(Y\) direction to restore the \(Y\)-direction resolution; thus, the second target surface achieves surface discretization in the \(X\) direction.

[0038] The step of using the least squares method based on iterative weights to fit the pixel coordinates of the second target surface after one-dimensional row filtering and calculating the curve parameters corresponding to each row of pixels in the \(X\) direction includes: setting a first constraint condition such that the weight of the pixel points that deviate more from the geometric curve model is smaller, and the weight of the pixel points that are closer to the geometric curve model is larger; the geometric curve model therein includes a parabola model and a straight line model; the first constraint condition includes a first weight function and is expressed as

[0039]

[0040] Among them, τ is the clipping factor, and δ is the algebraic distance from the pixel to the discretized geometric model;

[0041] Set the second constraint condition so that the weight of the pixel closer to the column center of the initial defect area is smaller, and the weight of the pixel farther from the column center of the initial defect area is larger; the second constraint condition includes a second weight function and is expressed as

[0042]

[0043] where y is the column coordinate of the pixel, and y c is the coordinate of the column center of the pixel;

[0044] Then, establish the minimization loss function of the parabolic curve model according to the first constraint condition and the second constraint condition, and it is expressed as

[0045] ε 2 =∑w h ×w g ×(ax 2 +bx+cz+d) 2 +λ(a 2 +b 2 +c 2 -1)n;

[0046] Establish the minimization loss function of the plane model according to the first constraint condition and the second constraint condition, and it is expressed as

[0047] ε 2 =∑w h ×w g ×(ax+bz+c) 2 +λ(a 2 +b 2 -1)n;

[0048] Take the minimization loss function of the parabola model and / or the minimization loss function of the straight line model as the iterative calculation condition of the least squares method, fit the pixel coordinates of the second target surface after one-dimensional row filtering, and when the corresponding minimization loss function converges, calculate the curve parameters corresponding to each row of pixels in the X direction.

[0049] In one embodiment, restoring the ideal surface image according to the surface model includes: obtaining the ideal surface in the X direction and the ideal surface in the Y direction according to the ideal surface model; restoring the ideal surface image by using the ideal surface in the Y direction and the ideal surface in the X direction; the ideal surface image has the same image resolution as the second image.

[0050] In one embodiment, obtaining defect location information and defect depth information within the surface inspection area of the object to be measured based on the defect-enhanced image includes: performing binarization processing on the defect-enhanced image to segment out the defect-enhanced area; obtaining the number of X-direction pixels and the number of Y-direction pixels of the defect-enhanced area, and the pixel height value of the defect-enhanced area from the defect-enhanced image; determining the defect location information within the surface inspection area of the object to be measured according to the number of X-direction pixels and the number of Y-direction pixels of the defect-enhanced area; and determining the defect depth information within the surface inspection area of the object to be measured according to the pixel height value of the defect-enhanced area.

[0051] According to a third aspect, an image detection device is provided in an embodiment, including: an imaging component for imaging the surface inspection area of the object to be measured to obtain a first image; a processing component for processing the first image by the defect detection method for information quantification described in the first aspect above to obtain defect location information and defect depth information within the surface inspection area of the object to be measured; and a display for displaying the defect location information and defect depth information within the surface inspection area of the object to be measured in the first image.

[0052] The processing component includes: an image acquisition module for acquiring the first image from the imaging component; a region detection module for performing initial defect detection on the first image to obtain an initial defect area; a region expansion module for expanding the initial defect area to obtain an expanded area and forming a second image based on the expanded area; a discretization module for performing surface discretization processing on the second image to obtain a continuous and smooth ideal surface model; an image restoration module for restoring an ideal surface image according to the ideal surface model; a differential processing module for performing differential processing on the ideal surface image and the second image to obtain a defect-enhanced image; and an information generation module for obtaining defect location information and defect depth information within the surface inspection area of the object to be measured according to the defect-enhanced image.

[0053] According to a third aspect, a computer-readable storage medium is provided in an embodiment, on which a program is stored, and the program can be executed by a processor to implement the defect detection method for information quantification described in the first aspect above.

[0054] The beneficial effects of this application are:

[0055] A defect detection method, an image detection device, and a storage medium for information quantification according to the above embodiments. The defect detection method includes: obtaining a first image of the surface inspection area of the object to be inspected, performing initial defect detection on the first image to obtain an initial defect area; expanding the initial defect area to obtain an expanded area, and forming a second image based on the expanded area; performing surface discretization processing on the second image to obtain a continuous and smooth ideal surface model, and restoring the ideal surface image according to the surface model; performing differential processing on the ideal surface image and the second image to obtain a defect enhancement image; obtaining defect location information and defect depth information in the surface inspection area of the object to be inspected according to the defect enhancement image. On the one hand, the technical solution first performs coarse-grained detection on the defect area in the image, can absorb the detection advantages of the neural network, improves the detection ability and reduces the on-site debugging cost and difficulty. In addition, the proposed surface discretization processing method can make up for the shortcoming that deep learning cannot quantitatively judge, especially for micro pinhole defects, the detection rate can be greatly improved, thus reducing the misdetection rate of the product. On the other hand, the technical solution can provide pixel-level defect detection accuracy. By restoring the ideal surface image and performing differential processing, the positioning accuracy of the defect area can be enhanced. When counting defect quantitative indicators, more accurate three-dimensional defect information can be provided, which is helpful for the strict judgment of surface defects of the object to be inspected. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a flowchart of a defect detection method for information quantification in an embodiment of the present application;

[0057] Figure 2 It is a flowchart for obtaining the initial defect area;

[0058] Figure 3 It is a flowchart for forming the second image;

[0059] Figure 4 It is a flowchart for obtaining a continuous and smooth ideal surface model;

[0060] Figure 5 It is a flowchart of discretization processing in an embodiment;

[0061] Figure 6 It is a flowchart of discretization processing in another embodiment;

[0062] Figure 7 It is a flowchart for obtaining the defect enhancement image;

[0063] Figure 8 It is a flowchart for obtaining defect location information and defect depth information;

[0064] Figure 9 It is a schematic diagram of the pixel matrix in the first image;

[0065] Figure 10 Schematic diagram of the surface where the second image is located. Among them, Fig. (a) is the schematic diagram of the surface under normal conditions, and Fig. (b) is the schematic diagram of the surface with a region of abrupt height change;

[0066] Figure 11 Principle diagram for discretization using a parabolic surface model;

[0067] Figure 12 Principle diagram for discretization using a plane model;

[0068] Figure 13 Principle diagram for discretization using a cylindrical surface model;

[0069] Figure 14 Principle diagram for obtaining the corresponding curve by pixel fitting of each pixel coordinate on the surface;

[0070] Figure 15 Principle diagram for image difference processing;

[0071] Figure 16 Structural diagram of an image detection device in an embodiment of the present application;

[0072] Figure 17 Schematic diagram of the structure of the processor;

[0073] Figure 18 Structural diagram of an image detection device in another embodiment of the present application. Detailed implementation manners

[0074] The present application will be further described in detail below in conjunction with the accompanying drawings through specific implementation manners. Similar elements in different implementation manners use related similar element numbers. In the following implementation manners, many detailed descriptions are provided to enable a better understanding of the present application. However, those skilled in the art can easily recognize that some of the features can be omitted in different situations, or can be replaced by other elements, materials, or methods. In some cases, some operations related to the present application are not shown or described in the specification, which is to avoid the core part of the present application being overwhelmed by excessive descriptions. For those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations based on the descriptions in the specification and the general technical knowledge in the art.

[0075] In addition, the features, operations or characteristics described in the specification can be combined in any suitable manner to form various embodiments. At the same time, the steps or actions in the method description can also be reordered or adjusted in a manner obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for clearly describing a certain embodiment and do not mean a necessary sequence, unless it is stated otherwise that a certain sequence must be followed.

[0076] The serial numbers assigned to the components herein, such as "first", "second", etc., are only used to distinguish the objects described and do not have any sequential or technical meaning. And the "connection" and "coupling" mentioned in this application, unless otherwise specified, both include direct and indirect connection (coupling).

[0077] To accurately understand the technical solution of this application, some explanations will be made here on the concept of the technical solution.

[0078] Currently, the algorithmic solutions for the appearance defect detection of power battery casings can be roughly divided into the following three types, namely background estimation algorithms, image neighborhood block comparison algorithms, and deep learning algorithms. Among them, background estimation algorithms mainly restore and estimate the image background through image filtering and scale scaling, obtain a defect-emphasized image by differentiating the workpiece image from the background image, classify and statistically screen the defect features of the defect-emphasized image, and finally confirm the defect area and type; this algorithm has a good effect on estimating the image background and can achieve pixel-level positioning of the defect detection area, but it has the disadvantage of being difficult to adapt to defect detection with large size differences; because a too large background estimation scale is not conducive to the detection of micro defects, while a too small background estimation scale is not conducive to the detection of macro defects, so it is necessary to continuously optimize the background estimation scale during the detection process, which results in a large debugging operation difficulty, and the accuracy of the obtained pixel-level defect area is not high, which has a great relationship with the size of the background estimation scale. Among them, image neighborhood block comparison algorithms mainly perform block processing on the image, the block size can be set in advance, calculate the gray statistical features of each image block, and confirm the defect level by comparing the statistical features between neighborhood blocks, and confirm the defect area and type by classifying and screening the defect levels of each neighborhood block; this algorithm can better solve the problem of local noise interference by performing block statistics on the workpiece image, but the image still needs to set the block size for block processing, and the smallest granularity of the detected defect area is a block, so it can only achieve block-level positioning of the defect detection area, and can only make a qualitative determination of the defects. Among them, deep learning algorithms refer to labeling a large number of normal and defective image samples, using deep learning for offline training and online inference, and directly making defect area determination and defect category determination on the network output structure; this algorithm can greatly improve the defect detection ability through a large number of sample learnings, but it is only limited to qualitative detection, unable to quantitatively confirm the specific information of the defects, and the neural network model often needs to normalize the scale of the input image, this process will reduce the detection ability of micro defects, and the pooling layer in the model will also downsample the feature image, and finally the defect area detected by deep learning can only reach the block level and cannot achieve pixel-level accurate positioning. To sum up, most of the current methods for welding quality detection of power battery casings can achieve qualitative detection and give a defect detection area at the pixel level or block level with low accuracy, but they cannot further accurately extract quantitative length, width, and height information for the defect detection area; moreover, on the basis of the pixel-level or block-level defect area, it is not difficult to quantify the length and width dimensions of the defect, but there are many problems in quantifying the height information of the defect.

[0079] The technical solution of this application provides a substantial solution to the problems existing in the prior art. Specifically, it is a high-precision pixel-level or block-level defect detection method based on local surface discretization. The defect regions roughly detected by the existing pixel-level or block-level defect detection methods are used as the initial input. An adaptive circumscribed rectangle is performed on the local neighborhood of the roughly screened region to achieve region extension. After intercepting the local defect image according to the circumscribed rectangle, height image surface discretization processing is carried out. The local surfaces in the height image are discretized into straight line models or parabolic curve models in the X-Y directions respectively. The straight line models or parabolic curve models are fitted by iterative weighted least squares. The real surface of the defect region neighborhood is restored through image interpolation, and then the defect enhanced image can be obtained through image difference. The technical solution in this application can accurately restore the surface information of the defect local neighborhood through surface discretization in the height image, realize pixel-level defect detection, greatly improve the positioning accuracy of the defect region, and can also accurately quantitatively calculate the defect height information for the defect enhanced image after difference. The solution is not affected by the calculation benchmark.

[0080] The following specifically describes the technical solution of this application in conjunction with embodiments.

[0081] Embodiment 1

[0082] Please refer to Figure 1 , in this embodiment, a defect detection method for information quantification is provided, which mainly includes steps 110-170, and will be described separately below.

[0083] Step 110, obtain a first image of the surface inspection area of the object to be measured. For example, a 3D line laser camera or a structured light camera is used to photograph the object to be measured (such as the outer shell of a power battery), and the height image of the surface inspection area of the product is obtained. This height image can be used as the first image.

[0084] Step 120, perform initial defect detection on the first image to obtain an initial defect region.

[0085] To ensure the detection ability for various types of defects and meet the usability requirements of on-site debugging, a deep learning segmentation model can be used here as a tool for coarse-grained defect detection. The deep learning segmentation model performs initial defect detection on the first image, and thus infers and gives the initial defect region with block-level accuracy in the first image.

[0086] It can be understood that the defects mentioned here can be defects such as broken welds, explosion points, pinholes, and hidden cracks existing on the outer shell of the power battery.

[0087] Step 130, expand the initial defect region to obtain an expanded region, and form a second image based on the expanded region.

[0088] Due to the defect of block-level accuracy, the initial region can only represent the approximate position of the defect and cover most of the defective area, but it cannot characterize the macroscopic background surface of the surface where the defect is located through this region, nor can it restore the surface background. Therefore, it is necessary to expand the initial region of the defect with block-level accuracy, and it is necessary to ensure that the expanded region can completely cover the surface where the defect is located; moreover, it should be noted that an overly large detection region will increase the complexity of the local surface.

[0089] Step 140: Perform surface discretization processing on the second image to obtain a continuous and smooth ideal surface model.

[0090] It can be understood that since there are defects in the second image, it is also necessary to obtain the macroscopic background surface (i.e., the continuous and smooth ideal surface model) of the surface where the defect is located through surface discretization processing. By comparison, the accurate position of the defect can be obtained.

[0091] Step 150: Restore the ideal surface model to obtain an ideal surface image. Since there is no defective area in the restored ideal surface image and the influence of the defect is excluded, it can be used as a reference image to compare with the second image.

[0092] Step 160: Perform differential processing to obtain a defect-enhanced image.

[0093] Image difference can subtract the corresponding pixel values of two images to weaken the similar parts of the images and highlight the changed parts of the images, so that the contour of a specific region can be detected, and thus the defective area existing in the second image can be found.

[0094] Step 170: Obtain defect location information and defect depth information within the inspected area of the surface of the object to be tested according to the defect-enhanced image. The defect location information and defect depth information here can be used as quantitative indicators of the defect to accurately obtain the position and depth of the defect in a quantitative form, and even the type of the defect.

[0095] In one embodiment, refer to Figure 2 , the above step 120 mainly involves the process of obtaining the initial defect region, which can specifically include steps 121-123, which are described as follows.

[0096] Step 121: Input the first image into a preset neural network model.

[0097] The neural network model here can be a conventional deep learning segmentation model, which can be used after being labeled and trained. To enhance the detection ability of the neural network model for specific defects (such as tiny pinhole defects), during the labeling and training, all tiny abnormal pixels of specific defects or suspected specific defects can be labeled and trained to ensure that the trained neural network model can detect all suspected features without the risk of missed detection. The false detection rate (the probability of detecting a normal sample as a defective sample) of the block-level precision defect detection can be significantly improved through the trained neural network model. Moreover, the subsequent solution will perform a fine-grained secondary detection and determination on the false detection samples, so the final detection ability is not affected.

[0098] Step 122: Extract the coarse-grained features of the first image in the neural network model. For example, in the neural network model, the defect features or the features of suspected defects are found through the feature extraction layer, and these features are used as the coarse-grained features.

[0099] Step 123: Segment the initial defect region from the first image according to the coarse-grained features. Since the coarse-grained features represent the position, shape, and size of the defect, it can be directly segmented to form the initial defect region.

[0100] It should be noted that the first image here may include a pixel matrix with evenly arranged rows and columns, and each pixel point in the pixel matrix has a height value in the camera reference coordinate system. Refer to Figure 9 , the first image (such as a height image) can be as Figure 9 shown in the grayscale image in Figure 9 . The pixel matrix corresponding to the first image can refer to the pixel table in Figure 9 . Each pixel value in the pixel table is filled with a single-precision floating-point number, representing the height value of the current pixel point in the camera reference coordinate system. Of course, the camera reference coordinate system here is the coordinate system calibrated by the manufacturer when the camera leaves the factory, and the invalid pixels caused by imaging reasons are filled with Nan. For details, refer to the pixel table in

[0101] In one embodiment, refer to Figure 3 , the above step 130 mainly involves the process of forming the second image based on the extended region, which can specifically include steps 131 - 133, and are described as follows.

[0102] Step 131: Construct the circumscribed rectangle of the initial defect region, and the circumscribed rectangle is represented as (x, y, w, h). Among them, x and y are the abscissa and ordinate of the center point of the circumscribed rectangle respectively, and w and h are the number of pixel points of the width and height of the circumscribed rectangle respectively.

[0103] Step 132: Expand the outsourcing rectangle in terms of pixel width and height to obtain an expanded area, and the expanded area is represented as (x′, y′, w′, h′). The expanded area satisfies: x′ = x, y′ = y, w′ = 2×w, h′ = 2×h;

[0104] Step 133: Crop the expanded area from the first image to form a second image.

[0105] It can be understood that due to the defect of block-level accuracy, the initial area only represents the approximate position of the defect. Therefore, it is impossible to characterize the macroscopic background surface of the surface where the defect is located through this area, nor to restore the macroscopic background area. This requires expanding the initial area of the defect to ensure that the expanded area can completely cover the surface where the defect is located. Then, the obtained expanded area can cover the surface where the initial area of the defect is located.

[0106] In one embodiment, referring to Figure 4 , the above step 140 mainly involves the process of obtaining a continuous and smooth ideal surface model, which can specifically include steps 141-143, described as follows.

[0107] Step 141: Input the second image into a preset discretized geometric model. Here, the discretized geometric model can be a parabolic surface model, a plane model, or a cylindrical surface model, and the user can flexibly select according to different application scenarios.

[0108] Referring to Figure 10 , it is a schematic diagram of the surface where the second image is located. Among them, Figure (a) is a schematic diagram of the surface under normal conditions, and the surface has a smooth concave surface part and a smooth convex surface part. Among them, Figure (b) is a schematic diagram of the surface with a height mutation area. If there is a defect on the surface where the second image is located, then the defect itself is a height mutation area A on the surface. The purpose of using the discretized geometric model here is to mathematically represent the surface where the second image is located with the help of the geometric model.

[0109] Step 142: Use the discretized geometric model to discretize the surface where the second image is located into corresponding curve modules.

[0110] In a specific embodiment, the second image (i.e., the defect cropped image) can be respectively subjected to surface discretization processing in the X direction and surface discretization processing in the Y direction, so as to discretize the surface into two-dimensional geometric curves in the X-Z plane and two-dimensional geometric curves in the Y-Z plane. According to the different discretized geometric models, it is divided into 3 types, namely, parabolic surface model, plane model, and cylindrical surface model. For example, Figure 10 is more suitable for the cylindrical surface model.

[0111] Step 143: Establish a continuous and smooth ideal surface model based on the curve module. It can be understood that since the curve module contains the parabolic parameters, linear parameters of the surface, and the combined parameters of both, it can be used to establish a continuous and smooth ideal surface model.

[0112] In a specific embodiment, when the discretized geometric model is a parabolic curve model, the curve module participating in the establishment of the ideal surface model may include a plurality of continuously distributed X-direction parabolas and a plurality of continuously distributed Y-direction parabolas. For details, refer to Figure 11 , in Figure 11 it can be seen that each X-direction parabola and each Y-direction parabola are mutually collinear constrained. If each X-direction parabola is represented as Z1(x) and each Y-direction parabola is represented as Z1(y), the discretized algebraic formula of the parabolic curve model is expressed as

[0113] Z1(x) = ax 2 + bx + c, Z1(y) = Ay 2 + By + C;

[0114] where a, b, c, A, B, and C are all parabola parameters, and X, Y, and Z are the X-axis, Y-axis, and Z-axis in the camera reference coordinate system, respectively.

[0115] It can be understood that since Figure 11 is discretized into two groups of parabolas along the X and Y directions and is in the same space, the continuous parabolas in the X direction need to satisfy the collinear constraint of the Y-direction parabolas.

[0116] In a specific embodiment, when the discretized geometric model is a plane model, the curve module participating in the establishment of the ideal surface model may include a plurality of continuously distributed X-direction lines and a plurality of continuously distributed Y-direction lines. For details, refer to Figure 12 , in Figure 12 each X-direction line and each Y-direction line are mutually collinear constrained. If each X-direction line is represented as Z2(x) and each Y-direction line is represented as Z2(y), the discretized algebraic formula of the plane model is expressed as

[0117] Z2(x) = ax + b, Z2(y) = Ay + B;

[0118] where a, b, A, and B are all linear parameters.

[0119] It can be understood that since Figure 12 is discretized into two groups of lines along the X and Y directions and is in the same space, the continuous lines in the X direction need to satisfy the collinear constraint of the Y-direction lines.

[0120] In a specific embodiment, when the discretized geometric model is a cylindrical surface model, if the curve module participating in establishing the ideal surface model may include multiple continuously distributed X-direction parabolas and multiple continuously distributed Y-direction straight lines, specifically refer to Figure 13 , in Figure 13 , each X-direction parabola and each Y-direction straight line are mutually collinear constrained. If each X-direction parabola is expressed as Z3(x) and each Y-direction straight line is expressed as Z3(y), then the discretized algebraic formula of the cylindrical surface model is expressed as

[0121] Z3(x) = ax 2 + bx + c, Z3(y) = Ay + B.

[0122] Of course, if the curve module participating in establishing the ideal surface model includes multiple continuously distributed Y-direction parabolas and multiple continuously distributed X-direction straight lines; each Y-direction parabola and each X-direction straight line are mutually collinear constrained. If each Y-direction parabola is expressed as Z′3(y) and each X-direction straight line is expressed as Z3(x), then the discretized algebraic formula of the cylindrical surface model is expressed as

[0123] Z′3(y) = ay 2 + by + c, Z′3(x) = Ax + B.

[0124] Wherein, a, b, and c are all parabola parameters, and A and B are all straight line parameters.

[0125] It can be understood that since Figure 13 can be discretized into a group of parabolas along the X direction and a group of straight lines along the Y direction, and they are in the same space, so the continuously discretized parabolas need to satisfy the collinear constraint of the Y-direction straight lines.

[0126] It should be noted that the above gives the discretized algebraic representations of the three discretized geometric models in the second image (i.e., the height image). In actual image processing, according to practical experience, single-direction discretization can restore the local surface to a certain extent, but the robustness is slightly poor and it is easily affected by local anomalies. The technical solution is to mainly adopt the combination of X-direction discretization and Y-direction discretization to perform surface restoration to improve the robustness and accuracy of the discretization process.

[0127] The schemes for X-direction discretization and Y-direction discretization can be mainly divided into two cases. The first case is to perform discretization processing in two directions on the surface where the second image is located, and then restore the surface information, specifically refer to Figure 5 . The second case is: perform discretization processing in two directions on the surface where the second image is located, and then perform weighted fusion processing, specifically refer to Figure 6 . [[ID=�7]]

[0128] Since the above step 142 mainly involves the process of discretizing the surface where the second image is located into corresponding curve modules, the following two cases are used to separately introduce the operation process of the discretization process.

[0129] In a specific embodiment, the first case of the discretization process is disclosed. Refer to Figure 5 , which specifically may include steps 211-214 and are described as follows.

[0130] Step 211, use the discretization geometric model to perform X-direction surface discretization on the surface where the second image is located, and obtain a continuous and smooth surface model in the X direction.

[0131] Step 212, establish a discretized local surface according to the continuous and smooth surface model in the X direction.

[0132] Step 213, use the discretization geometric model to perform Y-direction surface discretization on the local surface, and obtain a continuous and smooth surface model in the Y direction.

[0133] Step 214, establish a continuous and smooth ideal surface model according to the continuous and smooth surface model in the Y direction.

[0134] To implement the X-direction surface discretization operation in step 211, the object for X-direction surface discretization can be set as the first target surface (such as the surface where the second image is located). Then, the X-direction surface discretization of the first target surface includes the following steps:

[0135] (101) Perform Y-direction image pyramid processing on the first target surface, and reduce the Y-direction resolution in the first target surface by taking the pixel average every two rows, while keeping the X-direction resolution unchanged. It can be understood that in order to increase the smoothness of the discretization geometric model (such as a straight line or a parabola) and reduce the calculation amount, perform Y-direction image pyramid processing on the surface where the second image is located, that is, take the average every two rows, reduce the resolution in the image height H direction, and keep the resolution in the width W direction unchanged; if the resolution of the second image is W*H and the pyramid level is N, the calculation formula for N is expressed as

[0136]

[0137] where represents rounding up. Of course, if Y-direction discretization processing is performed, then H in the above formula should be replaced by W.

[0138] (102) Using Gaussian filtering or mean filtering, one-dimensional row filtering is performed on the X direction of the first target surface after image pyramid processing. It can be understood that using Gaussian filtering or mean filtering to perform one-dimensional row filtering on the X direction can reduce abnormal noise interference and improve the robustness and smoothness of subsequent geometric model fitting. The degree of filtering can be specified by the filter kernel size or the number of filtering times.

[0139] (103) Using the iterative weighted least square method, the pixel coordinates of the first target surface after the one-dimensional line filtering process are fitted, and the curve parameters corresponding to each row of pixels in the X direction are calculated.

[0140] (104) Calculate the continuous height information corresponding to each row of pixels in the X direction according to the curve parameters corresponding to each row of pixels in the X direction.

[0141] (105) Using Gaussian filtering or mean filtering, the continuous height information corresponding to each row of pixels is subjected to one-dimensional column filtering in the Y direction to obtain the Y-direction ideal surface corresponding to the ideal surface model.

[0142] (106) Then, linear interpolation is performed on the Y-direction ideal surface to restore the Y-direction resolution.

[0143] (107) After going through all the above steps, the first target surface is discretized in the X direction.

[0144] It should be noted that in the above step (103), the surface after row filtering is fitted row by row, that is, the (x, z) coordinates of all pixel points in each row are used for fitting. Although the ordinary least squares method will involve the coordinates of each point in the fitting process, the fitting needs to be improved for this application scenario. The participation of the coordinate points located in the defect area will cause the geometric model to deviate from the actual non-defective background surface. Therefore, the iterative weighted least squares method can be used for fitting here. Its weight function needs to eliminate the interference of the defect area on the discrete model fitting as much as possible, so two constraints must be met. For example, the first constraint is: the smaller the weight of the pixel point that deviates from the geometric curve model, the larger the weight of the pixel point that is closer to the geometric curve model, and the geometric curve model includes a parabola model and a straight line model; for example, the second constraint is: the smaller the weight of the pixel point that is closer to the column center of the defect initial area, the larger the weight of the pixel point that is farther away from the column center of the defect initial area.

[0145] See Figure 14, which is a schematic diagram of obtaining a surface model by pixel fitting for each pixel coordinate on the surface. The pixel fitting of each pixel coordinate of the surface image corresponding to the second image can be performed with the help of a cylindrical surface model. By calculating the curve parameters (including parabola parameters and straight-line parameters) corresponding to each row of pixels in the X direction, the curves corresponding to each row of pixels in the X direction can be constructed, and the depth change amount of the defect is included in the curve. Since the curve is represented by combining a parabola and a straight line, the curve can be divided into the component of the parabola, that is, z = ax 2 + bx + c, and can also be divided into the component of the straight line, that is, z = Ay + B; where a, b, and c are all parabola parameters, and A and B are all straight-line parameters.

[0146] Then, for the above step (103), that is, using the least squares method based on iterative weights to perform pixel fitting on the first target surface after one-dimensional row filtering, and calculating the curve parameters corresponding to each row of pixels in the X direction, including:

[0147] A11) Set the first constraint condition so that the weight of the pixel points that deviate more from the geometric curve model is smaller, and the weight of the pixel points that are closer to the geometric curve model is larger; the geometric curve model includes a parabola model and a straight-line model; the first constraint condition includes a first weight function and is expressed as

[0148]

[0149] where τ is the clipping factor and δ is the algebraic distance from the pixel point to the discretized geometric model.

[0150] A12) Set the second constraint condition so that the weight of the pixel points closer to the column center of the initial defect area is smaller, and the weight of the pixel points farther from the column center of the initial defect area is larger; the second constraint condition includes a second weight function and is expressed as

[0151]

[0152] where y is the column coordinate of the pixel, and y c is the coordinate of the column center of the pixel.

[0153] A13) Establish a minimization loss function of the parabolic curve model according to the first constraint condition and the second constraint condition, and it is expressed as

[0154] ε 2 = ∑w h × w g × (ax 2 + bx + cz + d) 2 + λ(a 2 + b 2 + c 2 - 1)n;

[0155] And / or, a minimization loss function of the plane model is established according to the first constraint and the second constraint, and is expressed as

[0156] ε 2 =∑w h ×w g ×(ax+bz+c) 2 +λ(a 2 +b 2 -1)n;

[0157] A14) Using the parabola model's minimization loss function and / or the straight line model's minimization loss function as the iterative calculation condition of the least squares method, the first target surface after the one-dimensional row filtering process is fitted with the coordinates of each pixel, and when the corresponding minimization loss function converges, the curve parameters corresponding to each row of pixels in the X direction are calculated. In order to implement the surface discretization operation in the Y direction in step 213, the object of the surface discretization in the Y direction can be set to the first target surface (such as using a surface module about the X direction to establish a discretized local surface), and the surface discretization in the Y direction of the first target surface includes the following steps:

[0158] (201) Performing image pyramid processing in the X direction on the first target surface, reducing the X direction resolution of the first target surface by taking the average value of pixels every two columns, and keeping the Y direction resolution unchanged.

[0159] (202) Using Gaussian filtering or mean filtering, perform one-dimensional column filtering on the Y direction of the first target surface after image pyramid processing.

[0160] (203) Using the iterative weighted least squares method, the pixel coordinates of the first target surface after the one-dimensional column filtering process are fitted to calculate the curve parameters corresponding to each column of pixels in the Y direction. This step (203) can be referred to the relevant content above and will not be repeated here.

[0161] (204) Calculate the continuous height information corresponding to each column of pixels in the Y direction according to the curve parameters corresponding to each column of pixels in the Y direction.

[0162] (205) Using Gaussian filtering or mean filtering, the continuous height information corresponding to each column of pixels is subjected to one-dimensional row filtering in the X direction to obtain the X-direction ideal surface corresponding to the ideal surface model.

[0163] (206) Perform linear interpolation in the X direction on the ideal surface to restore the X direction resolution.

[0164] (207) After going through all the above steps, the first target surface is discretized in the Y direction.

[0165] It should be noted that since Figure 5 the discretization processing scheme in

[0166] performs Y - direction discretization on the local surface after surface restoration after X - direction discretization. Since there is no defect area in the local surface restored by X - direction discretization, the weight function used in the fitting process in the Y - direction discretization stage only needs to satisfy the first constraint condition.

[0167] Then, for step (203) above, that is, using the least - squares method based on iterative weights to fit the pixel coordinates of the first target surface after one - dimensional column filtering, and calculating the curve parameters corresponding to each column of pixels in the Y - direction, including:

[0168]

[0169] A21) Set the first constraint condition so that the weight of the pixel points farther from the geometric surface model is smaller, and the weight of the pixel points closer to the geometric surface model is larger. The geometric curve model includes a parabola model and a straight - line model. Among them, the first constraint condition includes the first weight function (i.e., the Huber weight function) and is expressed as

[0170] where τ is the clipping factor and δ is the algebraic distance from the pixel point to the discretized geometric model.

[0171] ε 2 =∑w h (ax 2 +bx + cz + d) 2 +λ(a 2 +b 2 +c 2 - 1)n;

[0172] And / or, establish a minimization loss function for the plane model according to the first constraint condition, and it is expressed as

[0173] ε 2 =∑w h (ax + bz + c) 2 +λ(a 2 +b 2 - 1)n.

[0174] A23) Take the minimized loss function of the parabola model and / or the minimized loss function of the straight line model as the iterative calculation conditions of the least squares method, fit the pixel coordinates of the first target surface after one-dimensional column filtering, and when the corresponding minimized loss function converges, calculate the curve parameters corresponding to each column of pixels in the Y direction, that is, calculate the parameters a, b, c, and d in the minimized loss function.

[0175] In another specific embodiment, the second case of discretization processing is disclosed. Refer to Figure 6 , which specifically may include steps 221-224 and are described as follows.

[0176] Step 221: Obtain the surface where the second image is located.

[0177] Step 222: Use the discretized geometric model to discretize the surface where the second image is located in the X direction to obtain a continuous and smooth surface model in the X direction.

[0178] Step 223: Use the discretized geometric model to discretize the surface where the second image is located in the Y direction to obtain a continuous and smooth surface model in the Y direction.

[0179] Step 224: Perform weighted fusion processing on the continuous and smooth surface model in the X direction and the continuous and smooth surface model in the Y direction to establish a continuous and smooth ideal surface model.

[0180] It should be noted that the weighted fusion processing is expressed by the formula

[0181] Z(x,y) = δ x ·Z i (x) + δ y ·Z i (y);

[0182] Among them, δ x , δ y are the weight functions in the X direction and the Y direction respectively, Z i (x) represents the continuous and smooth surface model in the X direction, and Z i (y) represents the continuous and smooth surface model in the Y direction. It can be understood that for the continuous and smooth surface models generated after discretization in the X and Y directions, the final continuous and smooth surface model can be obtained by directly weighted fusion of them.

[0183] It should be noted that the weight function participating in the weighted fusion processing is expressed by the formula

[0184]

[0185] δ y = 1 - δ x ;

[0186] where t represents a deviation threshold (such as input externally), and represents the absolute value of the gradient of Z x in the Y direction, and represents the absolute value of the gradient of Z y in the X direction.

[0187] When the absolute value of the deviation between the two surface models of Z x and Z y is less than the deviation threshold, the two surface models are weighted-averaged in a 1 / 2 ratio.

[0188] When the absolute value of the deviation between the two surface models of Z x and Z y is greater than the deviation threshold, they are weighted-fused according to the weight functions δ x and δ y and each weight function satisfies the constraint condition: the greater the gradient of the continuously smooth surface model in the X direction in the Y direction, the smaller the weight function; the smaller the gradient of the continuously smooth surface model in the Y direction in the X direction, the greater the weight function.

[0189] It can be understood that the continuously smooth surface model in the X direction only guarantees the continuity of the surface in the X direction, and the continuity in the Y direction cannot be guaranteed. At this time, the continuity in the Y direction is quantified by the Y-direction gradient; the continuously smooth surface model in the Y direction only guarantees the continuity of the surface in the Y direction, and the continuity in the X direction cannot be guaranteed. At this time, the continuity in the X direction is quantified by the X-direction gradient; therefore, when there is a deviation between the two surface models of Z x and Z y the fusion weight function should tend to the model with a smaller gradient.

[0190] To implement the X-direction surface discretization operation in step 222, the object for X-direction surface discretization can be set as the second target surface (such as the surface where the second image is located), and the X-direction surface discretization of the second target surface includes the following steps:

[0191] (301) Perform a Y-direction image pyramid process on the second target surface, and reduce the Y-direction resolution in the second target surface by taking the pixel average every two rows, while keeping the X-direction resolution unchanged.

[0192] (302) Use Gaussian filtering or mean filtering to perform one-dimensional row filtering on the X direction in the second target surface after the image pyramid process. It can be understood that using Gaussian filtering or mean filtering to perform one-dimensional row filtering on the X direction can reduce abnormal noise interference and improve the robustness and smoothness of subsequent geometric model fitting. The filtering degree can be specified by the filter kernel size or the number of filtering times.

[0193] (303) Using the iterative weighted least square method, the coordinates of each pixel of the second target surface after the one-dimensional row filtering process are fitted, and the curve parameters corresponding to each row of pixels in the X direction are calculated.

[0194] (304) Based on the curve parameters corresponding to the pixels in each row in the X-direction, continuous height information corresponding to the pixels in each row in the X-direction is constructed.

[0195] (305) Using Gaussian filtering or mean filtering, the continuous height information corresponding to each row of pixels is subjected to one-dimensional column filtering in the Y direction to obtain the Y-direction ideal surface corresponding to the ideal surface model.

[0196] (306) Then, linear interpolation is performed on the Y-direction ideal surface to restore the Y-direction resolution.

[0197] (307) After going through all the above steps, the second target surface is discretized in the X direction.

[0198] Then, for the above step (303), the least square method based on iterative weights is used to fit the coordinates of each pixel of the second target surface after the one-dimensional line filtering process, and the curve parameters corresponding to each row of pixels in the X direction are calculated, including:

[0199] B11) setting a first constraint condition such that the weight of a pixel point that is further away from the geometric curve model is smaller, and the weight of a pixel point that is closer to the geometric curve model is larger; wherein the geometric curve model includes a parabola model and a straight line model; the first constraint condition includes a first weight function and is expressed as

[0200]

[0201] Where τ is the clipping factor and δ is the algebraic distance from the pixel to the discretized geometric model.

[0202] B12) setting a second constraint condition so that the weight of the pixel point closer to the column center of the defect initial area is smaller, and the weight of the pixel point farther away from the column center of the defect initial area is larger; the second constraint condition includes a second weight function and is expressed as

[0203]

[0204] Among them, y is the column coordinate of the pixel, c are the coordinates of the center of the pixel column.

[0205] B13) According to the first constraint and the second constraint, a minimization loss function of the parabola model is established, which is expressed as

[0206] ε2 = ∑w h × w g × (ax 2 + bx + cz + d) 2 + λ(a 2 + b 2 + c 2 - 1)n;

[0207] And / or, establish a minimization loss function for the plane model according to the first constraint condition and the second constraint condition, and it is expressed as

[0208] ε 2 = ∑w h × w g × (ax + bz + c) 2 + λ(a 2 + b 2 - 1)n;

[0209] B14) Use the minimization loss function of the parabola model and / or the minimization loss function of the straight line model as the iterative calculation conditions of the least squares method, fit the pixel coordinates of the second target surface after one-dimensional row filtering, and when the corresponding minimization loss function converges, calculate the curve parameters corresponding to each row of pixels in the X direction.

[0210] To implement the surface discretization operation in the Y direction in step 223, the object for surface discretization in the Y direction can be set as the second target surface (such as the surface where the second image is located), then the surface discretization of the second target surface in the Y direction includes the following steps:

[0211] (401) Perform image pyramid processing on the second target surface in the X direction, reduce the X - direction resolution in the second target surface by taking the pixel average every other column, and keep the Y - direction resolution unchanged.

[0212] (402) Use Gaussian filtering or mean filtering to perform one - dimensional column filtering on the Y direction in the second target surface after image pyramid processing.

[0213] (403) Use the least squares method based on iterative weights to fit the pixel coordinates of the second target surface after one - dimensional column filtering, and calculate the curve parameters corresponding to each column of pixels in the Y direction.

[0214] (404) According to the curve parameters corresponding to each column of pixels in the Y direction, construct the continuous height information corresponding to each column of pixels in the Y direction.

[0215] (405) Use Gaussian filtering or mean filtering to perform one - dimensional row filtering on the continuous height information corresponding to each column of pixels in the X direction, and obtain the ideal surface in the X direction corresponding to the ideal surface model.

[0216] (406) Perform linear interpolation in the X direction on the ideal X surface to restore the X direction resolution.

[0217] (407) After going through the above steps, the second target surface is discretized in the Y direction at this point.

[0218] For Figure 6 the situation in, the least squares method with iterative weights can be used for fitting. The weight function needs to eliminate the interference of the defect area on the discrete model fitting as much as possible, so two constraint conditions must be satisfied. For example, the first constraint condition is: the weight of the pixel points that deviate more from the geometric curve model is smaller, and the weight of the pixel points that are closer to the geometric curve model is larger. The geometric curve model includes the parabola model and the straight line model. Another example is the second constraint condition: the weight of the pixel points closer to the column center of the defect initial area is smaller, and the weight of the pixel points farther from the column center of the defect initial area is larger.

[0219] Then, for step (403) above, that is, using the least squares method with iterative weights to fit the pixel coordinates of the second target surface after one-dimensional column filtering, the curve parameters corresponding to each column of pixels in the Y direction are calculated, including:

[0220] B21) Set the first constraint condition so that the weight of the pixel points that deviate more from the geometric curve model is smaller, and the weight of the pixel points that are closer to the geometric curve model is larger. The geometric curve model includes the parabola model and the straight line model. Among them, the first constraint condition includes the first weight function and is expressed as

[0221]

[0222] where τ is the clipping factor and δ is the algebraic distance from the pixel point to the discretized geometric model.

[0223] B22) Set the second constraint condition so that the weight of the pixel points closer to the column center of the defect initial area is smaller, and the weight of the pixel points farther from the column center of the defect initial area is larger. Among them, the second constraint condition includes the second weight function and is expressed as

[0224]

[0225] where y is the column coordinate of the pixel and y c is the coordinate of the pixel column center.

[0226] B23) Establish the minimization loss function of the parabolic curve model according to the first constraint condition and the second constraint condition, and it is expressed as

[0227] ε 2 = ∑wh ×w g ×(ax 2 +bx + cz + d) 2 + λ(a 2 + b 2 + c 2 - 1)n;

[0228] And / or, establish a minimized loss function for the plane model according to the first constraint condition and the second constraint condition, and it is expressed as

[0229] ε 2 = ∑w h ×w g ×(ax + bz + c) 2 + λ(a 2 + b 2 - 1)n.

[0230] B24) Use the minimized loss function of the parabola model and / or the minimized loss function of the straight - line model as the iterative calculation conditions of the least - squares method to fit the pixel coordinates of the second target surface after one - dimensional column filtering. When the corresponding minimized loss function converges, calculate the curve parameters corresponding to each column of pixels in the Y - direction, that is, calculate the parameters a, b, c, and d in the minimized loss function.

[0231] In one embodiment, referring to Figure 7 , the above - mentioned step 150 mainly involves the process of restoring the surface model and obtaining the ideal surface image, which can specifically include steps 151 - 152 and are described as follows.

[0232] Step 151, obtain the ideal surface in the X - direction and the ideal surface in the Y - direction according to the ideal surface model. Specifically, refer to step 211 and step 213, as well as step 222 and step 223 in the above text, and details will not be repeated here.

[0233] Step 152, obtain the ideal surface image according to the ideal surface in the Y - direction and the ideal surface in the X - direction. Here, the ideal surface image and the second image should have the same image resolution.

[0234] In one embodiment, the above - mentioned step 160 mainly involves the process of obtaining a defect - enhanced image through differential processing. Perform image difference between the ideal surface image (i.e., the surface discretized image) and the second image (i.e., the original defect image), and output the different part of the second image from the background surface, which is the defect - enhanced image. It can be understood that the higher the reduction accuracy of the background surface, the higher the accuracy of the defect - enhanced area obtained after difference, and the more accurate the quantitatively calculated defect depth information.

[0235] Refer to Figure 15, is the schematic diagram of image difference processing. The real curved surface image represents the distribution of a standard parabola and a straight line on the curved surface (such as the parabola and the straight line in Figure 15 ), while the second image represents the distribution of the defect curve on the curved surface (such as the dotted line in Figure 15 ). When the parabola and the defect curve are subjected to difference processing, the distribution of the defect depth can be obtained. When the straight line and the defect curve are subjected to difference processing, the distribution of the defect depth can also be obtained.

[0236] In one embodiment, referring to Figure 8 , the above step 170 mainly involves the process of obtaining defect location information and defect depth information, which may specifically include steps 171-173, and are described as follows.

[0237] Step 171: Perform binarization processing on the defect-enhanced image to segment the defect-enhanced region.

[0238] Step  172: Obtain the number of X-direction pixels and the number of Y-direction pixels of the defect-enhanced region according to the defect-enhanced image. According to the number of X-direction pixels and the number of Y-direction pixels of the defect-enhanced region, determine the defect location information within the surface inspection region of the object to be measured.

[0239] Step 173: Obtain the pixel height value of the defect-enhanced region according to the defect-enhanced image. According to the pixel height value of the defect-enhanced region, determine the defect depth information within the surface inspection region of the object to be measured.

[0240] It should be noted that here is a secondary extraction of the defect region. For example, perform binarization processing on the defect-enhanced image after difference to segment the defect-enhanced region. Compared with other pixel-level defect detection methods, this processing method can perform pixel-level surface restoration on the defect neighborhood. Through the discrete processing operations in the X direction and the Y direction respectively, the accuracy and stability of the surface restoration can be ensured, that is, the positioning accuracy of the detected defect region is ensured. Then, for the defect-enhanced region obtained by secondary extraction, directly calculate the number of pixels in the length and width of the region, and directly obtain the defect depth information from the defect-enhanced image. Without considering other benchmarks, the depth information of the defect on the curved surface can be obtained most accurately.

[0241] In this embodiment, the disclosed technical solution is to first perform coarse-grained detection on the defect region in the first image, which can absorb the detection advantages of the neural network, improve the detection ability, and reduce the on-site debugging cost and difficulty. In addition, the proposed surface discretization processing method can make up for the shortcoming that deep learning cannot make quantitative judgments. Especially for tiny pinhole defects, the detection rate can be greatly improved, thereby reducing the false detection rate of the product.

[0242] In this embodiment, the disclosed technical solution can provide pixel-level defect detection accuracy. By restoring the ideal surface image and performing differential processing, the positioning accuracy of the defect area can be enhanced. When statistically analyzing the quantitative defect indicators, more accurate three-dimensional defect information can be provided, which helps to strictly determine the surface defects of the object to be measured.

[0243] Embodiment 2

[0244] Based on the defect detection method quantitatively disclosed in Embodiment 1, an image detection device is disclosed in this embodiment. It mainly includes an image acquisition component 31, a processing component 32, and a display component 33, which will be described separately below.

[0245] The image acquisition component 31 is used to acquire an image of the surface inspection area of the object to be measured, obtaining a first image. For example, a 3D line laser camera or a structured light camera is used to capture the height image of the surface inspection area of the product to be measured (such as the housing of a power battery), and this height image can be used as the first image.

[0246] The processing component 32 is connected to the image acquisition component 31 and is used to process the first image through the defect detection method quantitatively disclosed in Embodiment 1 to obtain the defect positioning information and defect depth information within the surface inspection area of the object to be measured.

[0247] The display component 33 is connected to the processing component 32 and is used to display the defect positioning information and defect depth information within the surface inspection area of the object to be measured in the first image.

[0248] It should be noted that the processor 32 can be implemented by software, hardware, firmware, or a combination thereof. Circuits, single or multiple application-specific integrated circuits, single or multiple general-purpose integrated circuits, single or multiple microprocessors, single or multiple programmable logic devices, or a combination of the foregoing circuits or devices, or other suitable circuits or devices can be used, so that the processor 32 can execute the algorithm processing process mentioned in the technical solution of this application.

[0249] It should be noted that the display 33 can be a screen with an image display function, which can display the first image and the detection results (such as defect positioning information and defect depth information) separately or jointly. The specific screen type and display layout method are not limited.

[0250] In a specific embodiment, referring to Figure 17 , the processing component 32 mainly includes an image acquisition module 321, a region detection module 322, a region expansion module 323, a discretization module 324, an image restoration module 325, a differential processing module 326, and an information generation module 327.

[0251] The image acquisition module 321 is used to acquire the first image from the imaging component 31. For example, after the first image obtained by the imaging component 31 is input into the processor 32, it can be acquired by the image acquisition module 321.

[0252] The region detection module 322 is used to perform initial defect detection on the first image to obtain the initial defect region. To ensure the detection ability for various types of defects and meet the usability requirements of on-site debugging, a deep learning segmentation model can be used here as a tool for coarse-grained defect detection. The deep learning segmentation model performs initial defect detection on the first image, and thus infers and gives the initial defect region with block-level accuracy in the first image. The defects mentioned here can be defects such as broken welds, explosion points, pinholes, and hidden cracks on the outer shell of the power battery. For the function of the region detection module 322, reference can be specifically made to step 120 in Embodiment 1, and Figure 2 the relevant descriptions therein, which will not be elaborated here.

[0253] The region expansion module 323 is used to expand the initial defect region to obtain an expanded region, and form a second image based on the expanded region. Since the initial defect region with block-level accuracy can only represent the approximate position of the defect and cover most of the defect region, but cannot characterize the macroscopic background surface of the surface where the defect is located through this region, nor can it restore the surface background, it is necessary to perform an expansion process on the initial defect region with block-level accuracy to ensure that the expanded region can completely cover the surface where the defect is located. For the function of the region expansion module 323, reference can be specifically made to step 130 in Embodiment 1, and Figure 3 the relevant descriptions therein, which will not be elaborated here.

[0254] The discretization module 324 is used to perform surface discretization processing on the second image to obtain a continuous and smooth ideal surface model. Since there are defects in the second image, it is also necessary to perform surface discretization processing to obtain the macroscopic background surface (i.e., the continuous and smooth ideal surface model) of the surface where the defect is located. By comparison, the accurate position of the defect can be obtained. For the function of the discretization module 324, reference can be specifically made to step 140 in Embodiment 1, and Figures 4 to 6 the relevant descriptions therein, which will not be elaborated here.

[0255] The image restoration module 325 is used to restore the ideal surface image according to the ideal surface model. Since there is no defect region in the restored ideal surface image and the influence of the defect is excluded, it can be used as a reference image to be compared with the second image. For the function of the image restoration module 325, reference can be specifically made to step 150 in Embodiment 1, and Figure 7 the relevant descriptions therein, which will not be elaborated here.

[0256] The differential processing module 326 is used to perform differential processing on the ideal surface image and the second image to obtain a defect-enhanced image. It can be understood that image differentiation can subtract the corresponding pixel values of two images to weaken the similar parts of the images and highlight the changed parts of the images, so as to detect the contours of specific regions and thus find the defect regions existing in the second image. For the function of the differential processing module 326, reference can be specifically made to step 160 in Embodiment 1, which will not be elaborated here.

[0257] The information generation module 327 is used to obtain defect location information and defect depth information within the surface inspection area of the object to be measured based on the defect-enhanced image. It should be noted that the defect location information and defect depth information here can be used as quantitative indicators of the defects to accurately obtain the position and depth of the defects in a quantitative form, and even the types of the defects. For the function of the information generation module 327, reference can be specifically made to step 170 in Embodiment 1, as well as Figure 8 the relevant descriptions in, which will not be elaborated here.

[0258] In this embodiment, a high-precision pixel-level or block-level defect detection device based on local surface discretization is provided. The device can use the defect areas roughly detected by a neural network model as the initial input, perform adaptive outer bounding rectangles on the local neighborhoods of the roughly screened areas to achieve area extension, intercept local defect images according to the outer bounding rectangles and then perform second-image surface discretization processing, discretize the local surfaces in the second image into line models or parabolic curve models in the X-Y directions respectively, then iteratively weight the least squares to fit the line models or parabolic curve models, restore the real surfaces of the defect area neighborhoods through image interpolation, and then obtain the defect-enhanced image through image differentiation.

[0259] It can be understood that the technical solution provided in this embodiment can accurately restore the surface information of the defect local neighborhood through the surface discretization in the second image, realize pixel-level defect detection, greatly improve the positioning accuracy of the defect areas, and can also accurately calculate the defect height information for the defect-enhanced image after differentiation.

[0260] Embodiment 3

[0261] In one embodiment, based on the defect detection method with information quantification disclosed in Embodiment 1, another image detection device is disclosed in this embodiment, and this image device 4 includes a memory 41 and a processor 42.

[0262] In this embodiment, the memory 41 and the processor 42 are the main components of the image detection device 4. Of course, the image detection device 4 may also include some detection components and execution components connected to the processor 42. For details, reference can be made to the above Embodiment 2, which will not be elaborated here.

[0263] Among them, the memory 41 can be used as a computer-readable storage medium, which is used to store a program here, and the program can be the program code corresponding to the defect detection method in the first embodiment.

[0264] Among them, the processor 42 is connected to the memory 41 and is used to execute the program stored in the memory 41 to implement the defect detection method disclosed in the first embodiment above. It should be noted that the functions implemented by the processor 42 can refer to the processing component 32 in the second embodiment, and details will not be described here.

[0265] Those skilled in the art can understand that all or part of the functions of the above-mentioned methods can be implemented in a hardware manner or in a computer program manner. When all or part of the functions in the above-mentioned embodiments are implemented in a computer program manner, the program can be stored in a computer-readable storage medium, and the storage medium can include: read-only memory, random access memory, magnetic disk, optical disk, hard disk, etc. The above functions are implemented by a computer executing the program. For example, the program is stored in the memory of the device, and when the processor executes the program in the memory, the above-mentioned all or part of the functions can be implemented. In addition, when all or part of the functions in the above-mentioned embodiments are implemented in a computer program manner, the program can also be stored in a storage medium such as a server, another computer, magnetic disk, optical disk, flash drive or mobile hard disk, and is saved to the memory of the local device by downloading or copying, or the system of the local device is updated. When the processor executes the program in the memory, all or part of the functions in the above-mentioned embodiments can be implemented.

[0266] The above uses specific examples to elaborate on the present application, which is only used to help understand the technical solution of the present application and does not limit the present application. For those skilled in the art, according to the idea of the present application, several simple deductions, deformations or substitutions can also be made.

Claims

1. A defect detection method for information quantification, characterized in that, Including: Obtaining a first image of the surface inspection area of the object to be measured; Performing initial defect detection on the first image to obtain an initial defect area; Expanding the initial defect area to obtain an expanded area, and forming a second image based on the expanded area; Inputting the second image into a preset discretized geometric model; the discretized geometric model is a parabolic surface model, a plane model, or a cylindrical surface model; Using the discretized geometric model to discretize the surface where the second image is located into corresponding curve modules, and establishing a continuous and smooth ideal surface model according to the curve modules; wherein, the establishment of the continuous and smooth ideal surface model includes: Use the discretized geometric model to perform X - direction surface discretization on the surface where the second image is located, and obtain a continuous and smooth surface model Z in the X direction x ; Discretize the surface where the second image is located in the Y direction by using the discretized geometric model to obtain a continuous and smooth surface model Z in the Y direction y ; For the continuous and smooth surface model Z in the X direction x and the continuous and smooth surface model Z in the Y direction y perform weighted fusion processing to establish a continuous and smooth ideal surface model; The weighted fusion process is represented by the formula Z xy = δ x ·Z x + δ y ·Z y ; Among them, δ x and δ y are the weight functions in the X and Y directions respectively, Z x represents the continuous and smooth surface model in the X direction, and Z y represents the continuous and smooth surface model in the Y direction; Restoring an ideal surface image according to the ideal surface model; Performing differential processing on the ideal surface image and the second image to obtain a defect enhancement image; Obtaining defect location information and defect depth information within the surface inspection area of the object to be measured according to the defect enhancement image.

2. The defect detection method for information quantification according to claim 1, characterized in that The performing initial defect detection on the first image to obtain an initial defect area, expanding the initial defect area to obtain an expanded area, and forming a second image based on the expanded area includes: Inputting the first image into a preset neural network model, and extracting the coarse-grained features of the first image in the neural network model; Segmenting the initial defect area from the first image according to the coarse-grained features; Constructing an outer bounding rectangle of the initial defect area, and the outer bounding rectangle is represented as (x, y, w, h); wherein, x and y are respectively the abscissa and ordinate of the center point of the outer bounding rectangle, and w and h are respectively the number of pixel widths and the number of pixel heights of the outer bounding rectangle; Performing pixel expansion on the outer bounding rectangle in terms of width and height to obtain the expanded area, and the expanded area is represented as (x′, y′, w′, h′); wherein, x′ = x, y′ = y, w′ = 2×w, h′ = 2×h; Cropping the expanded area from the first image to form the second image.

3. The defect detection method for information quantification according to claim 1, characterized in that When the discretized geometric model is a parabolic surface model; The curve modules participating in the establishment of the ideal surface model include a plurality of continuously distributed X-direction parabolas and a plurality of continuously distributed Y-direction parabolas; Each X-direction parabola and each Y-direction parabola are mutually collinear constrained. If each X-direction parabola is represented as Z1(x) and each Y-direction parabola is represented as Z1(y), then the discretized algebraic formula of the parabolic surface model is represented as Z1(x) = ax 2 + bx + c, Z1(y) = Ay 2 + By + C; Wherein, a, b, c, A, B, and C are all parabola parameters, and x, y, and Z are respectively the X-axis, Y-axis, and Z-axis in the camera reference coordinate system.

4. The defect detection method for information quantification according to claim 1, characterized in that When the discretized geometric model is a plane model; The curve modules participating in the establishment of the ideal surface model include a plurality of continuously distributed X-direction straight lines and a plurality of continuously distributed Y-direction straight lines; Each X-direction straight line and each Y-direction straight line are mutually collinear constrained. If each X-direction straight line is represented as Z2(x) and each Y-direction straight line is represented as Z2(y), then the discretized algebraic formula of the plane model is represented as Z2(x) = ax + b, Z2(y) = Ay + B; where a, b, A, and B are all line parameters.

5. The defect detection method for information quantification according to claim 1, wherein When the discretized geometric model is a cylindrical surface model; The curve modules involved in establishing the ideal surface model include multiple continuously distributed X - direction parabolas and multiple continuously distributed Y - direction straight lines; each X - direction parabola and each Y - direction straight line are mutually collinear - constrained. If each X - direction parabola is represented as Z3(x) and each Y - direction straight line is represented as Z3(y), then the discretized algebraic formula of the cylindrical surface model is expressed as Z3(x) = ax 2 + bx + c, Z3(y) = Ay + B; Alternatively, the curve modules involved in establishing the ideal surface model include multiple continuously distributed Y - direction parabolas and multiple continuously distributed X - direction straight lines; each Y - direction parabola and each X - direction straight line are mutually collinear - constrained. If each Y - direction parabola is represented as Z′3(y) and each X - direction straight line is represented as Z′3(x), then the discretized algebraic formula of the cylindrical surface model is expressed as Z′3(y) = ay 2 + by + c, Z′3(x) = Ax + B; where a, b, c are all parabola parameters, and A, B are all line parameters.

6. The defect detection method for information quantification according to claim 1, characterized in that, The method of using the discretized geometric model to discretize the surface where the second image is located into corresponding curve modules and establishing a continuously smooth ideal surface model based on the curve modules includes: Using the discretized geometric model to perform X - direction surface discretization on the surface where the second image is located, obtaining a continuously smooth surface model in the X - direction; Establishing a continuously smooth local surface based on the surface model in the X - direction; Using the discretized geometric model to perform Y - direction surface discretization on the local surface, obtaining a continuously smooth surface model in the Y - direction; Establishing a continuously smooth ideal surface model based on the continuously smooth surface model group in the Y - direction.

7. The defect detection method for information quantification according to claim 6, characterized in that, If the object for Y - direction surface discretization is set as the first target surface, then performing Y - direction surface discretization on the first target surface includes: Performing X - direction image pyramid processing on the first target surface, reducing the X - direction resolution in the first target surface by taking the pixel average every two columns, and keeping the Y - direction resolution unchanged; Using Gaussian filtering or mean filtering to perform one - dimensional column filtering on the Y - direction in the first target surface after image pyramid processing; Using the least - squares method based on iterative weights to fit the pixel coordinates of the first target surface after one - dimensional column filtering, calculating the curve parameters corresponding to each column of pixels in the Y - direction; According to the curve parameters corresponding to each column of pixels in the Y - direction, constructing the continuous height information corresponding to each column of pixels in the Y - direction; Using Gaussian filtering or mean filtering to perform one - dimensional row filtering on the X - direction for the continuous height information corresponding to each column of pixels, obtaining the X - direction ideal surface corresponding to the ideal surface model; Performing linear interpolation in the X - direction on the X - direction ideal surface to restore the X - direction resolution; Thus, the first target surface achieves Y - direction surface discretization.

8. The information quantification defect detection method according to claim 7, wherein The step of using the least - squares method based on iterative weights to fit the pixel coordinates of the first target surface after one - dimensional column filtering and calculating the curve parameters corresponding to each column of pixels in the Y - direction includes: Set the first constraint condition such that the weight of the pixel points that deviate more from the geometric curve model is smaller, and the weight of the pixel points that are closer to the geometric curve model is larger; the geometric curve model therein includes a parabola model and a straight line model; the first constraint condition includes a first weight function and is expressed as where τ is the clipping factor and δ is the algebraic distance from the pixel point to the discretized geometric model; Establish the minimization loss function of the parabola model according to the first constraint condition, and it is expressed as ε 2 = ∑w h (ax 2 + bx + cz + d) 2 + λ(a 2 + b 2 + c 2 - 1)n; Establish the minimization loss function of the straight line model according to the first constraint condition, and it is expressed as ε 2 = ∑w h (ax + bz + c) 2 + λ(a 2 + b 2 - 1)n; Take the minimization loss function of the parabola model and / or the minimization loss function of the straight line model as the iterative calculation condition of the least squares method, fit the pixel coordinates of the first target surface after one-dimensional column filtering, and when the corresponding minimization loss function converges, calculate the curve parameters corresponding to each column of pixels in the Y direction.

9. The defect detection method for information quantification according to claim 1, characterized in that, The weight function participating in the weighted fusion process is expressed by the formula as δ y = 1 - δ x ; where t represents the deviation threshold, represents the absolute value of the gradient of Z x in the Y direction, represents the absolute value of the gradient of Z y in the X direction; When Z x and Z y when the absolute value of the deviation between these two surface models is less than the deviation threshold, then the two surface models are weighted and averaged in a 1 / 2 ratio; When Z x and Z y the absolute value of the deviation between these two surface models is greater than the deviation threshold, then weighted fusion of these two surface models is performed according to the weight functions δ x and δ y and each weight function satisfies the constraint condition: the greater the gradient of the continuously smooth surface model in the X direction in the Y direction, the smaller the weight function; the smaller the gradient of the continuously smooth surface model in the Y direction in the X direction, the greater the weight function.

10. The defect detection method for information quantification according to claim 1, wherein Set the object for surface discretization in the X direction as the second target surface, then the surface discretization of the second target surface in the X direction includes: Perform image pyramid processing on the second target surface in the Y direction, reduce the Y-direction resolution in the second target surface by taking the pixel average every two rows, and keep the X-direction resolution unchanged; Perform one-dimensional row filtering on the second target surface in the X direction after image pyramid processing using Gaussian filtering or mean filtering; Use the least squares method based on iterative weights to fit the pixel coordinates of the second target surface after one-dimensional row filtering, and calculate the curve parameters corresponding to each row of pixels in the X direction; Calculate the continuous height information corresponding to each row of pixels in the X direction according to the curve parameters corresponding to each row of pixels in the X direction; Perform one-dimensional column filtering on the continuous height information corresponding to each row of pixels in the Y direction using Gaussian filtering or mean filtering to obtain the ideal surface in the Y direction corresponding to the ideal surface model; Perform linear interpolation on the ideal surface in the Y direction in the Y direction to restore the Y-direction resolution; Thus, the second target surface achieves surface discretization in the X direction.

11. The defect detection method for information quantification according to claim 10, characterized in that, The step of using the least squares method based on iterative weights to fit the pixel coordinates of the second target surface after one-dimensional row filtering and calculate the curve parameters corresponding to each row of pixels in the X direction includes: Set the first constraint condition such that the weight of the pixel points that deviate more from the geometric curve model is smaller, and the weight of the pixel points that are closer to the geometric curve model is larger; the geometric curve model therein includes a parabola model and a straight line model; the first constraint condition includes a first weight function and is expressed as where τ is the clipping factor and δ is the algebraic distance from the pixel point to the discretized geometric model; Set the second constraint condition such that the weight of the pixel points closer to the column center of the defect initial region is smaller, and the weight of the pixel points farther from the column center of the defect initial region is larger; the second constraint condition includes a second weight function and is expressed as where x is the column coordinate of the pixel, and x c is the coordinate of the center of the pixel column; Then establish the minimization loss function of the parabola model according to the first constraint condition and the second constraint condition, and it is expressed as ε 2 = ∑w h × w g × (ax 2 + bx + cz + d) 2 + λ(a 2 + b 2 + c 2 - 1)n; Establish a loss function to be minimized for the straight-line model according to the first constraint condition and the second constraint condition, and it is expressed as ε 2 = ∑w h × w g × (ax + bz + c) 2 + λ(a 2 + b 2 - 1)n; Take the loss function to be minimized for the parabolic model and / or the loss function to be minimized for the straight-line model as the iterative calculation conditions for the least squares method, fit the pixel coordinates of the second target surface after one-dimensional row filtering, and when the corresponding loss function to be minimized converges, calculate the curve parameters corresponding to each row of pixels in the X direction.

12. The defect detection method for information quantification according to claim 1, wherein The restoring the ideal surface image according to the ideal surface model includes: Obtain the ideal surface in the X direction and the ideal surface in the Y direction according to the ideal surface model; Restore the ideal surface image by using the ideal surface in the Y direction and the ideal surface in the X direction; the ideal surface image has the same image resolution as the second image.

13. The defect detection method for information quantification according to claim 1, wherein The obtaining the defect location information and defect depth information in the surface inspection area of the object to be measured according to the defect-enhanced image includes: Perform binarization processing on the defect-enhanced image to segment the defect-enhanced area; Obtain the number of pixels in the X direction and the number of pixels in the Y direction of the defect-enhanced area from the defect-enhanced image, and the pixel height value of the defect-enhanced area; Determine the defect location information in the surface inspection area of the object to be measured according to the number of pixels in the X direction and the number of pixels in the Y direction of the defect-enhanced area; Determine the defect depth information in the surface inspection area of the object to be measured according to the pixel height value of the defect-enhanced area.

14. An image detection device, characterized in that, It includes: An imaging component for imaging the surface inspection area of the object to be measured to obtain a first image; A processing component for processing the first image by using the information-based quantitative defect detection method according to any one of claims 1-13 to obtain the defect location information and defect depth information in the surface inspection area of the object to be measured; A display for displaying the defect location information and defect depth information in the surface inspection area of the object to be measured in the first image.

15. The image detection device according to claim 14, characterized in that, The processing component includes: An image acquisition module for acquiring the first image from the imaging component; A region detection module for performing initial defect detection on the first image to obtain an initial defect region; A region expansion module for expanding the initial defect region to obtain an expanded region and forming a second image based on the expanded region; A discretization module for inputting the second image into a preset discretized geometric model; the discretized geometric model is a parabolic surface model, a plane model or a cylindrical surface model; Use the discretized geometric model to discretize the surface where the second image is located into corresponding curve modules, and establish a continuous and smooth ideal surface model according to the curve modules; wherein, the establishment of the continuous and smooth ideal surface model includes: Using the discretized geometric model to perform surface discretization in the X direction on the surface where the second image is located, obtaining a continuous and smooth surface model Z in the X direction x ; Using the discretized geometric model to perform surface discretization in the Y direction on the surface where the second image is located, to obtain a continuous and smooth surface model Z in the Y direction y ; For the continuous and smooth surface model Z in the X direction x and the continuous and smooth surface model Z in the Y direction y perform weighted fusion processing to establish a continuous and smooth ideal surface model; The weighted fusion processing is expressed by the formula as Z xy = δ x ·Z x + δ y ·Z y ; where, δ x , δ y are the weight functions in the X and Y directions respectively, Z x represents the continuous and smooth surface model in the X direction, and Z y represents the continuous and smooth surface model in the Y direction; An image restoration module for restoring an ideal surface image according to the ideal surface model; A difference processing module for performing difference processing on the ideal surface image and the second image to obtain a defect-enhanced image; An information generation module, configured to obtain defect location information and defect depth information within a surface inspection area of the object under test based on the defect-enhanced image.

16. A computer-readable storage medium, characterized in that, A program is stored on the medium, and the program can be executed by a processor to implement the information-quantitative defect detection method according to any one of claims 1-13.

Citation Information

Patent Citations

  • Bayesian-classifier-based method for complex surface defect classification

    CN107622277A

  • Ceramic valve core surface defect detection method based on machine vision

    CN111307820A

  • Defect detection method and device, defect detection equipment and computer storage medium

    CN111507974A