Grinding wheel abrasive particle image segmentation method based on machine vision

Through the grinding wheel abrasive image segmentation method based on machine vision, combined with grayscale image enhancement, gradient calculation and morphological processing, the problems of low profile segmentation accuracy and noise interference in the traditional method are solved, and efficient grinding wheel abrasive particles are achieved Contour recognition and segmentation.

CN119151979APending Publication Date: 2024-12-17HUNAN UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411007817.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Traditional image segmentation methods have low detection efficiency and low segmentation accuracy in the extraction of grinding wheel abrasive grain profiles, and cannot effectively identify grinding wheel abrasive grain profiles, especially in the grinding wheel matrix area and environmental noise interference, which is weak in adaptability.

Method used

The grinding wheel abrasive image segmentation method based on machine vision includes grayscale image enhancement, two-dimensional Gaussian filtering, gradient calculation, non-maximum suppression, and Otsu algorithm to obtain global thresholds, combined with the adaptive function of the Canny algorithm for edge connection, and Refine and fill holes by morphological treatment.

Benefits of technology

It significantly improves the segmentation accuracy and flexibility of the grinding wheel abrasive profile, reduces noise interference, highlights the fine structural details of the grinding wheel abrasives in the matrix, and clearly divides the abrasive profile from the matrix, improving the visual quality and analysis of the image. ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119151979A_ABST
    Figure CN119151979A_ABST
Patent Text Reader

Abstract

The invention discloses a grinding wheel abrasive particle image segmentation method based on machine vision, and the method comprises the following steps: inputting a grinding wheel abrasive particle sample image, converting the sample image into a gray-scale image, and carrying out the preprocessing of image enhancement on the gray-scale image; performing operation on the gray-scale map line by line and column by column by two-dimensional Gaussian filtering; calculating the partial derivative of each pixel point in the x-axis direction and the y-axis direction, and obtaining the gradient of each pixel point according to the partial derivative; performing non-maximum suppression according to the gradient; acquiring a global threshold by using an Otsu algorithm, and introducing the global threshold into an adaptive function for setting image segmentation by high and low thresholds of a Canny algorithm to realize edge connection; lag compensation is carried out, and middle edges are accepted and rejected; and morphologically processing irrelevant areas and filling holes. According to the method, edge connection is achieved by setting the adaptive function of image threshold segmentation, the problem of noise interference caused by the grinding wheel base body area and the environment is effectively solved, the boundary of the grinding wheel abrasive particle image contour can be accurately divided, and good flexibility is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of digital image segmentation, and in particular relates to a grinding wheel abrasive grain image segmentation method based on machine vision. Background Art

[0002] The grinding wheel is composed of three parts: abrasive grains, binder and grinding wheel matrix. During the grinding process, abrasive grains are the main material involved in grinding. The abrasive grains slide against the workpiece, resulting in mechanical wear. The grinding wheel, the workpiece being processed and the external environmental factors jointly determine the state of the abrasive grain profile. Obtaining the abrasive grain profile on the grinding wheel helps optimize the grinding process and improve processing efficiency, and can also ensure that the quality and precision of the processed workpiece meet the design requirements. Therefore, accurately identifying the abrasive grain profile of the grinding wheel is an important research content for improving and developing grinding processing technology.

[0003] Compared with the traditional image segmentation method applied to the grinding wheel abrasive contour extraction, it has the disadvantages of low detection efficiency, low segmentation accuracy, and inability to give a specific grinding wheel abrasive image segmentation contour. For example, the weak edges detected by the traditional Canny algorithm sometimes confuse the edges detected in the image. The threshold selection in image segmentation depends on manual work and has weak adaptability. The maximum inter-class variance method is derived from the least squares principle based on the grayscale histogram. It has the best segmentation in a statistical sense, identifies the global threshold in the image, and uses the threshold for image segmentation, but it has no filtering function and lacks the function of anti-noise and reducing tiny edges.

[0004] In view of this, the present invention is proposed. Summary of the invention

[0005] In view of the problem that the threshold segmentation in the traditional image segmentation method has weak adaptability and is disturbed by the noise caused by the grinding wheel matrix area and the environment, it is impossible to effectively extract the accurate grinding wheel abrasive grain contour boundary. The present invention provides a grinding wheel abrasive grain image segmentation method based on machine vision. In order to solve the above technical problems, the basic concept of the technical solution adopted by the present invention is:

[0006] A method for segmenting abrasive wheel images based on machine vision comprises the following steps:

[0007] Step 1: Input the grinding wheel abrasive sample image and convert it into a grayscale image, and perform image enhancement pre-processing on the grayscale image;

[0008] Step 2: Two-dimensional Gaussian filtering is performed on the grayscale image row by row and column by column;

[0009] Step 3: Calculate the partial derivatives of each pixel in the x and y axis directions, and obtain the gradient of each pixel accordingly;

[0010] Step 4: Perform non-maximum suppression based on the gradient;

[0011] Step 5: Use the Otsu algorithm to obtain the global threshold, and introduce it into the adaptive function of the high and low threshold settings of the Canny algorithm to achieve edge connection;

[0012] Step 6: Lag compensation, trade-off of the middle edge;

[0013] Step 7: Morphological processing of irrelevant areas and hole filling.

[0014] Furthermore, the step 1 inputs the grinding wheel abrasive sample image and converts it into a grayscale image, and the specific expression of the pre-processing of the grayscale image for image enhancement is as follows:

[0015] Step 1.1: Calculate the best input interval [a, b] in the grayscale image to expand the grayscale range of the grayscale image to 0-255; it is easy to find the best grayscale value, which is mainly concentrated between a and b, so the image is relatively blurred. If the grayscale values ​​between a and b are evenly distributed between 0 and 255, the image will become clearer. It is necessary to assign the grayscale value less than a to 0 and the grayscale value greater than b to 255. Let the grayscale value between a and b be u, and the grayscale value between 0 and 255 be v, then u and v satisfy the following formula:

[0016]

[0017] Simplifying the formula, we get the following relationship between v and u:

[0018]

[0019] Step 1.2: Perform contrast enhancement through image morphology, perform high-hat filtering and low-hat filtering on the image, and then perform addition and subtraction operations, which are defined as follows:

[0020]

[0021] Where A○B is the opening operation of the structure element B on the input image A, that is, the structure element is first used to perform an erosion operation on A, and then an expansion operation is performed, using the same structure element; A·B closing operation is the dual operation of the opening operation, that is, the structure element B is first used to perform an expansion operation on A, and then an erosion operation is performed, using the same structure element; H1 is the image after high-hat filtering, and H2 is the image after low-hat filtering;

[0022] Step 1.3: Through histogram equalization, histogram equalization is a method that uses grayscale transformation to automatically adjust the image contrast quality. The basic idea is to find the grayscale transformation function through the probability density function of the grayscale level. It is a histogram correction method based on the cumulative distribution function transformation method, including the following steps:

[0023] Step A: Find the histogram P of the given image to be processed k (r):

[0024]

[0025] Where n k is the number of pixels of the kth grayscale, N is the total number of pixels of the image, r is the kth grayscale, L is the number of grayscale levels, P k (r) is the relative frequency of occurrence of gray level r;

[0026] Step B: Use the cumulative distribution function to transform the statistical histogram of the original image to obtain a new image grayscale. The transformation function T(r) is consistent with the probability density function P of the original image. k The relationship between (r):

[0027]

[0028] Where, T(r) must satisfy 0≤T(r)≤1;

[0029] Step C: Perform approximation processing, replace the old grayscale with the new grayscale, and merge each grayscale histogram with equal or similar grayscale values ​​together to obtain P s (s).

[0030] Furthermore, the specific expression of the two-dimensional Gaussian filtering operation on the grayscale image row by row and column by column in step 2 is:

[0031] Step 2.1: Convert the eight-bit data in the image to sixteen-bit data using double-precision floating point numbers;

[0032] Step 2.2: Normalize the obtained image, that is, divide each data by 255;

[0033] Step 2.3: The obtained image is subjected to Gaussian filtering. The standard deviation determines the width of the Gaussian filter function, which affects the filtering effect. The larger the standard deviation, the flatter the redistribution of the Gaussian filter function, and the larger the coverage range, thus the stronger the smoothing effect on the image. On the contrary, the smaller the standard deviation, the sharper the weight distribution of the Gaussian filter function, the smaller the coverage range, and the relatively weaker the smoothing effect on the image. The general standard deviation is 1 to 5. Set the standard deviation to 3.5 to obtain a better filtering effect.

[0034] Furthermore, the step 3 calculates the partial derivatives of each pixel point in the x and y axis directions, and accordingly obtains the specific expression of the gradient of each pixel point as follows:

[0035] Step 3.1: Define the convolution kernel in the x and y directions:

[0036] X=[1,0,-1]

[0037] Y = [1, 0, -1] T

[0038] Wherein, X is the convolution kernel in the x direction, and Y is the convolution kernel in the y direction;

[0039] Step 3.2: Perform operations of flipping, traversing, and weighting on the image through a 3rd-order convolution kernel to obtain the partial derivatives in the x and y directions corresponding to each point in the image;

[0040] Step 3.3: Perform gradient calculation, and its expression:

[0041]

[0042] Wherein, Dx is the partial derivative along the x direction, Dy is the partial derivative along the y direction, θ is the angle formed by the gradient and the x direction, and m is the modulus of the gradient.

[0043] Further, the specific description of performing non-maximum suppression according to the gradient in step 4 is: Performing non-maximum suppression essentially means finding local maxima. Approximate the gradient direction angles of each pixel point to four straight lines in four directions (-45, +45, 0, -90, +90). Then, find the two pixel points on the approximate straight line where the point is located from the eight adjacent pixel points of a certain point, and judge the modulus values of the gradients of the point and the two pixel points found. Determine whether the point is a maximum value. If not, set the gray value of the point to 0; if so, retain it.

[0044] Further, the specific description of using the Otsu algorithm to obtain the global threshold and introducing it into the adaptive function for setting the high and low thresholds of the Canny algorithm to achieve edge connection in step 5 is:

[0045] Step 5.1: Use the Otsu algorithm to divide regions and find the average gray value. Let f(x, y) be the gray value at the position (x, y) of the image I m×n The gray level is L, then f(x, y) ∈ [0, L - 1]; if the number of all pixels with gray level i is N i , then the probability of the i-th gray level appearing:

[0046]

[0047] Divide the pixels in the image into two categories by the threshold T according to the gray level, namely the background region C0 and the target region C1; the gray level of the background region C0 is 0 to T - 1, and the gray level of the target C1 is T to L - 1; the pixels corresponding to the background region C0 and the target region C1 are respectively: {f(x, y) < T} and {f(x, y) ≥ T}; then there are:

[0048]

[0049] Where P1 and P2 are the probabilities of the background area C0 and the target area C1 appearing, m1 and m2 are the average grayscale values ​​of the background area C0 and the target area C1, respectively. v is the average gray value of the entire image area;

[0050] Step 5.2: Calculate the inter-class variance of the background and target regions in the image:

[0051] σ 2 (T) = P1(m v -m1) 2 +P2(m v -m2) 2

[0052] According to the known conditions:

[0053] P1+P2=1, P1m1+P2m2=m v

[0054] And then:

[0055] σ 2 (T) = P1P2(m1-m2) 2

[0056] Let the value of T change from 0 to L-1, and calculate the between-class variance σ under different T values 2 (T), so that σ 2 The T value when (T) is the largest is the required optimal threshold. It can be seen that there are four variables, each of which changes with T, and the amount of calculation is huge.

[0057] Step 5.3: Optimize the amount of calculation, redefine the variables, divide the pixels in the image by grayscale using the threshold T, and define the grayscale of 0 to T-1 as the background area C0. Let P be the probability of the background area C0 appearing, and m be the ratio of the grayscale value of the background area C0 to the whole area:

[0058]

[0059] Therefore, the inter-class variance expression of the background and target areas in the image is:

[0060]

[0061] In the formula, mv is the average gray value of the image; at this time, making σ 2 The T value when (T) is the largest is the required global threshold of the image;

[0062] Step 5.4: Setting of double thresholds and edge connection. By setting the adaptive function of image segmentation, it is connected with the double threshold of Canny algorithm and set as an adaptive function:

[0063]

[0064] Where T is the global threshold of the above image, f0 is the low threshold function, f1 is the high threshold function, a, b, c correspond to the adaptive function coefficients, and their values ​​are non-negative constants;

[0065] Segmentation is achieved by setting two dual threshold adaptive functions, that is, the edges whose gradient modulus is higher than the high threshold adaptive function value are retained - set to 1, the edges whose gradient modulus is lower than the low threshold adaptive function value are discarded - set to 0, and the edges between the high and low dual thresholds are processed in the next step - set to 0.5.

[0066] Furthermore, the specific expression of the hysteresis compensation in step 6 for selecting the middle edge is as follows: hysteresis compensation is adopted for the edge between the high and low double thresholds, and whether there is 1 in the eight adjacent points around the pixel point of the 0.5 boundary in the image, if so, the middle edge of 0.5 is retained as 1, otherwise it is set to 0.

[0067] Furthermore, the specific description of the morphological processing of irrelevant areas and hole filling in step 7 is as follows: in morphology, the structure element is the most basic component of dilation and erosion, and the two-dimensional structure element is a matrix composed of values ​​0 and 1; the origin of the structure element specifies the pixel range to be processed in the image, and the point with a value of 1 in the structure element determines whether the domain pixels of the structure element participate in the calculation when performing dilation or erosion operations;

[0068] Step 7.1: Thin the edges in the image to avoid thick edges;

[0069] Step 7.2: Fill the closed edges in the image and fill the holes in the image;

[0070] Step 7.3: Remove other small irrelevant edges in the image.

[0071] After adopting the above technical scheme, the present invention has the following beneficial effects compared with the prior art.

[0072] The present invention uses an adaptive function of image threshold segmentation to achieve edge connection, effectively solves the problem of noise interference caused by the grinding wheel matrix area and the environment, can accurately divide the boundaries of the grinding wheel abrasive image contour, and has very good flexibility:

[0073] Firstly, in order to solve the problem of poor segmentation of grinding wheel abrasive grains and grinding wheel matrix caused by the binder, the image morphology is contrast enhanced, the image is preprocessed by high hat filtering and low hat filtering respectively, and the image is enhanced by histogram equalization, which highlights the subtle structural details of the grinding wheel abrasive grains in the matrix image, reduces the interference of noise or background changes in the grinding wheel abrasive grain image on the abrasive grains, improves the visual quality and analysis ability of the grinding wheel abrasive grain image, and helps to complete the subsequent image processing tasks;

[0074] Secondly, in view of the shortcoming of Canny algorithm in confusing the edge of the abrasive grains in the image due to its insensitivity to the contour features of the grinding wheel abrasive grains, the grayscale histogram of the entire grinding wheel abrasive grain image is analyzed according to the Otsu algorithm, and the optimal segmentation threshold between the grinding wheel abrasive grain contour and the grinding wheel matrix is ​​determined by maximizing the inter-class variance. The adaptive function of image threshold segmentation is set, and the gradient modulus is compared with the adaptive function values ​​of the high threshold and the low threshold to retain or discard the edge of the abrasive grain contour, thereby obviously segmenting the grinding wheel abrasive grain contour from the grinding wheel matrix.

[0075] Finally, the morphological algorithm is used to refine and remove the coarse edges and small irrelevant edges in the segmented image, and fill the closed edges in the image to make the extracted grinding wheel abrasive grain contour clearer.

[0076] The specific implementation modes of the present invention are further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] The accompanying drawings are part of this application and are used to provide a further understanding of the present invention. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but do not constitute an improper limitation of the present invention. Obviously, the drawings described below are only some embodiments. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0078] Figure 1 is a flow chart of the method of the present invention;

[0079] Figure 2 is a sample diagram of a grinding wheel abrasive grain collected in an embodiment of the present invention;

[0080] Figure 3 is a grayscale image of abrasive grains of a grinding wheel after image enhancement processing in an embodiment of the present invention;

[0081] Figure 4 is a three-dimensional image after Gaussian filtering in an embodiment of the present invention;

[0082] Figure 5 is a grayscale image showing the gradient direction in an embodiment of the present invention;

[0083] Figure 6 is an image segmented by using the fusion Otsu algorithm in an embodiment of the present invention;

[0084] Figure 7 is a binary image for performing hysteresis compensation in an embodiment of the present invention;

[0085] Figure 8 It is a binary image of the complete abrasive particles extracted in the embodiment of the present invention.

[0086] It should be noted that these drawings and textual descriptions are not intended to limit the conceptual scope of the present invention in any way, but are intended to illustrate the concept of the present invention for those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0087] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The following embodiments are used to illustrate the present invention but are not used to limit the scope of the present invention.

[0088] Example

[0089] like Figure 1 As shown, the grinding wheel abrasive grain image segmentation method based on machine vision described in this example includes the following steps:

[0090] Step 1: Input the grinding wheel abrasive sample image and convert it into a grayscale image, and perform image enhancement preprocessing on the grayscale image. The specific expression is:

[0091] Step 1.1: Enter Figure 2 The grinding wheel abrasive sample shown in the figure is converted into a grayscale image in MATLAB, and the optimal input interval [a, b] in the grayscale image is calculated to expand the grayscale range of the grayscale image to 0-255; it is easy to find the optimal grayscale value, which is mainly concentrated between a and b, so the image is relatively fuzzy. If the grayscale values ​​between a and b are evenly distributed between 0 and 255, the image will become clearer. It is necessary to assign the grayscale value less than a to 0 and the grayscale value greater than b to 255. Let the grayscale value between a and b be u, and the grayscale value between 0 and 255 be v, then u and v satisfy the following formula:

[0092]

[0093] Simplifying the formula, we get the following relationship between v and u:

[0094]

[0095] Step 1.2: Perform contrast enhancement through image morphology, perform high-hat filtering and low-hat filtering on the image, and then perform addition and subtraction operations, which are defined as follows:

[0096]

[0097] Where A○B is the opening operation of the structure element B on the input image A, that is, the structure element is first used to perform an erosion operation on A, and then an expansion operation is performed, using the same structure element; A·B closing operation is the dual operation of the opening operation, that is, the structure element B is first used to perform an expansion operation on A, and then an erosion operation is performed, using the same structure element; H1 is the image after high-hat filtering, and H2 is the image after low-hat filtering;

[0098] Step 1.3: Through histogram equalization, histogram equalization is a method that uses grayscale transformation to automatically adjust the image contrast quality. The basic idea is to find the grayscale transformation function through the probability density function of the grayscale level. It is a histogram correction method based on the cumulative distribution function transformation method, including the following steps;

[0099] Step A: Find the histogram P of the given image to be processed k (r):

[0100]

[0101] Where n k is the number of pixels of the kth grayscale, N is the total number of pixels of the image, r is the kth grayscale, L is the number of grayscale levels, P k (r) is the relative frequency of occurrence of gray level r;

[0102] Step B: Use the cumulative distribution function to transform the statistical histogram of the original image to obtain a new image grayscale. The transformation function T(r) is consistent with the probability density function P of the original image. k The relationship between (r):

[0103]

[0104] Where, T(r) must satisfy 0≤T(r)≤1;

[0105] Step C: Perform approximation processing, replace the old grayscale with the new grayscale, and merge each grayscale histogram with equal or similar grayscale values ​​together to obtain P s (s), the final effect is as follows Figure 3 shown.

[0106] Step 2: Two-dimensional Gaussian filtering operates on the grayscale image row by row and column by column, which is specifically expressed as:

[0107] Step 2.1: Convert the eight-bit data in the image to sixteen-bit data using double-precision floating point numbers;

[0108] Step 2.2: Normalize the obtained image, that is, divide each data by 255;

[0109] Step 2.3: The obtained image is subjected to Gaussian filtering. The standard deviation determines the width of the Gaussian filter function, which affects the filtering effect. The larger the standard deviation, the flatter the redistribution of the Gaussian filter function, and the larger the coverage range, so the stronger the smoothing effect on the image. On the contrary, the smaller the standard deviation, the sharper the weight distribution of the Gaussian filter function, the smaller the coverage range, and the relatively weaker the smoothing effect on the image. The standard deviation is generally 1 to 5. The standard deviation is set to 3.5 to obtain a better filtering effect. The three-dimensional effect diagram after filtering is referenced. Figure 4 shown.

[0110] Step 3: Calculate the partial derivatives of each pixel in the x and y axis directions, and then obtain the gradient of each pixel. The specific expression is:

[0111] Step 3.1: Define the convolution kernel in the x and y directions:

[0112] X=[1,0,-1]

[0113] Y=[1,0,-1] T

[0114] Where X is the convolution kernel in the x direction, and Y is the convolution kernel in the y direction;

[0115] Step 3.2: Use a 3rd-order convolution kernel to flip, traverse, and weight the image, and find the partial derivatives in the x and y directions corresponding to each point in the image;

[0116] Step 3.3: Calculate the gradient, its expression is:

[0117]

[0118] Where Dx is the partial derivative of the point along the x direction, Dy is the partial derivative of the point along the y direction, θ is the angle between the gradient of the point and the x direction, and m is the modulus of the gradient of the point.

[0119] Step 4: According to the gradient, non-maximum suppression is performed. Specifically, the essence of non-maximum suppression is to find the local maximum value, approximate the gradient direction angle of each pixel point to four straight lines in four directions (-45, +45, 0, -90, +90), and then find two pixel points where the approximate straight line of the point is located from the eight adjacent pixel points of a certain point, and judge the modulus value of the gradient of the point and the two found pixel points to determine whether the point is the maximum value. If not, the grayscale value of the point is set to 0; if so, it is retained, and the grayscale image with the gradient direction is displayed as follows: Figure 5 as shown

[0120] Step 5: Use the Otsu algorithm to obtain the global threshold, and introduce it into the adaptive function of the high and low thresholds of the Canny algorithm to achieve edge connection. Specifically, it is expressed as:

[0121] Step 5.1: Use the Otsu algorithm to divide the region and calculate the average gray value. Let f(x, y) be the gray value at the position (x, y) of the image I m×n The gray level is L, then f(x, y) ∈ [0, L - 1]; if the number of all pixels with gray level i is N i , then the probability of the i-th gray level occurring:

[0122]

[0123] The pixels in the image are divided into two categories by the threshold T according to the gray level, namely the background region C0 and the target region C1; the gray level of the background region C0 is 0 to T - 1, and the gray level of the target C1 is T to L - 1; the pixels corresponding to the background region C0 and the target region C1 are respectively: {f(x, y) < T} and {f(x, y) ≥ T}; then there is:

[0124]

[0125] In the formula, P1 and P2 are the probabilities of the background region C0 and the target region C1 appearing respectively, m1 and m2 are the average gray values of the background region C0 and the target region C1 respectively, and m v is the average gray value of the entire image region;

[0126] Step 5.2: Calculate the between-class variance of the background and target regions in the image:

[0127] σ 2 (T) = P1(m v - m1) 2 + P2(m v - m2) 2

[0128] According to the known conditions, there is:

[0129] P1 + P2 = 1, P1m1 + P2m2 = m v

[0130] Furthermore, there is:

[0131] σ 2 (T) = P1P2(m1 - m2) 2

[0132] Let the value of T vary from 0 to L - 1, and calculate the between-class variance σ for different T values2 (T), so that σ 2 The T value when (T) is the largest is the required optimal threshold. It can be seen that there are four variables, each of which changes with T, and the amount of calculation is huge.

[0133] Step 5.3: Optimize the amount of calculation, redefine the variables, divide the pixels in the image by grayscale using the threshold T, and define the grayscale of 0 to T-1 as the background area C0. Let P be the probability of the background area C0 appearing, and m be the ratio of the grayscale value of the background area C0 to the whole area:

[0134]

[0135]

[0136] Therefore, the inter-class variance expression of the background and target areas in the image is:

[0137]

[0138] In the formula, mv is the average gray value of the image; at this time, making σ 2 The T value when (T) is the largest is the required global threshold of the image;

[0139] Step 5.4: Setting of double thresholds and edge connection. By setting the adaptive function of image segmentation, it is connected with the double threshold of Canny algorithm and set as an adaptive function:

[0140]

[0141] Where T is the global threshold of the above image, f0 is the low threshold function, f1 is the high threshold function, a, b, c correspond to the adaptive function coefficients, and their values ​​are non-negative constants;

[0142] Segmentation is achieved by setting two dual threshold adaptive functions, that is, the edges with gradient modulus higher than the high threshold adaptive function value are retained - set to 1, the edges with gradient modulus lower than the low threshold adaptive function value are discarded - set to 0, and the edges between the high and low thresholds are processed in the next step - set to 0.5. The effect of integrating Otsu algorithm is referenced Figure 6 shown.

[0143] Step 6: Hysteresis compensation, make a choice for the middle edge. Specifically, take hysteresis compensation for the edge between the high and low double thresholds. Check whether the eight adjacent points around the pixel point at the 0.5 boundary in the image are 1. If so, keep the middle edge of 0.5 as 1, otherwise set it to 0. The hysteresis compensation effect is shown in Figure 6. Figure 7 shown.

[0144] Step 7: Morphological processing of irrelevant areas and hole filling, specifically stated as follows: In morphology, the structural element is the most basic component of dilation and erosion. The two-dimensional structural element is a matrix composed of values ​​0 and 1. The origin of the structural element specifies the pixel range to be processed in the image. The point with a value of 1 in the structural element determines whether the pixels in the area of ​​the structural element participate in the calculation when performing dilation or erosion operations.

[0145] Step 7.1: Thin the edges in the image to avoid thick edges;

[0146] Step 7.2: Fill the closed edges in the image and fill the holes in the image;

[0147] Step 7.3: Remove other small irrelevant edges in the image and finally extract the complete wear particle shape as shown in the figure. Figure 8 shown.

[0148] The above is only a preferred embodiment of the present invention, and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment, it is not used to limit the present invention. Any technician familiar with this patent can make some changes or modify the technical contents suggested above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention still fall within the scope of the solution of the present invention.

Claims

1. A grinding wheel abrasive grain image segmentation method based on machine vision, characterized in that: The steps include: Step 1: Input the grinding wheel abrasive sample image and convert it into a grayscale image, and perform image enhancement pre-processing on the grayscale image; Step 2: Two-dimensional Gaussian filtering is performed on the grayscale image row by row and column by column; Step 3: Calculate the partial derivatives of each pixel in the x and y axis directions, and obtain the gradient of each pixel accordingly; Step 4: Perform non-maximum suppression based on the gradient; Step 5: Use the Otsu algorithm to obtain the global threshold, and introduce it into the adaptive function of the high and low threshold settings of the Canny algorithm to achieve edge connection; Step 6: Lag compensation, trade-off of the middle edge; Step 7: Morphological processing of irrelevant areas and hole filling.

2. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: The step 1 specifically includes: Step 1.1, calculate the best input interval [a, b] in the grayscale image, so that the grayscale range of the grayscale image is extended to 0-255; assign the grayscale value less than a to 0, and the grayscale value greater than b to 255. Let the grayscale value between a and b be u, and the grayscale value between 0 and 255 be v, then u and v satisfy the following formula: Simplifying the formula, we get the following relationship between v and u: Step 1.2, contrast enhancement is performed through image morphology, high hat filtering and low hat filtering are performed on the image respectively, and then addition and subtraction operations are performed, which are defined respectively: Where A○B is the opening operation of the structure element B on the input image A, that is, the structure element is first used to perform an erosion operation on A, and then an expansion operation is performed, using the same structure element; A·B closing operation is the dual operation of the opening operation, that is, the structure element B is first used to perform an expansion operation on A, and then an erosion operation is performed, using the same structure element; H1 is the image after high-hat filtering, and H2 is the image after low-hat filtering; Step 1.3, through histogram equalization, includes the following steps: Step A: Find the histogram P of the given image to be processed k (r): Where n k is the number of pixels of the kth grayscale, N is the total number of pixels of the image, r is the kth grayscale, L is the number of grayscale levels, P k (r) is the relative frequency of occurrence of gray level r; Step B: Use the cumulative distribution function to transform the statistical histogram of the original image to obtain a new image grayscale. The transformation function T(r) is consistent with the probability density function P of the original image. k The relationship between (r): Where, T(r) must satisfy 0≤T(r)≤1; Step C: Perform approximation processing, replace the old grayscale with the new grayscale, and merge each grayscale histogram with equal or similar grayscale values ​​to obtain P s (s).

3. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: The step 2 specifically includes: Step 2.1, convert the eight-bit data in the image into sixteen-bit data using double-precision floating point numbers; Step 2.2, normalize the obtained image, that is, divide each data by 255; In step 2.3, the obtained image is subjected to Gaussian filtering, and the standard deviation is set to 3.5 to obtain a better filtering effect.

4. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: The step 3 specifically includes: Step 3.1, define the convolution kernel in the x and y directions: X=[1,0,-1] Y=[1,0,-1] T Where X is the convolution kernel in the x direction, and Y is the convolution kernel in the y direction; Step 3.2, flip, traverse, and weight the image through a 3rd-order convolution kernel to find the partial derivatives in the x and y directions corresponding to each point in the image; Step 3.3, perform gradient calculation, its expression is: Where Dx is the partial derivative along the x direction, Dy is the partial derivative along the y direction, θ is the angle between the gradient and the x direction, and |m is the modulus of the gradient.

5. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: The step 4 is specifically as follows: The essence of non-maximum suppression is to find local maxima. The gradient direction angles of each pixel point are approximated to four straight lines in four directions (-45, +45, 0, -90, +90). Then, two pixel points on the same approximate straight line as this point are found from the eight adjacent pixel points of a certain point, and the modulus values of the gradients of this point and the two pixel points found are judged to determine whether this point is the maximum value. If not, the gray value of this point is set to 0; if so, it is retained.

6. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: Step 5 specifically includes: Step 5.1: Use Otsu algorithm to divide the region and find the average gray value. Let f(x, y) be the image I m×n The gray value at position (x, y), the gray level is L, then f(x, y)∈[0,L-1]; if the number of all pixels of gray level i is N i , then the probability of the i-th grayscale appearing is: The pixels in the image are divided into two categories by the threshold T according to the gray level, namely the background region C0 and the target region C1; the gray level of the background region C0 is 0 to T - 1, and the gray level of the target C1 is T to L - 1; the pixels corresponding to the background region C0 and the target region C1 are respectively: {f(x, y) < T} and {f(x, y) ≥ T}; then there is: Where P1 and P2 are the probabilities of the background area C0 and the target area C1 appearing, m1 and m2 are the average grayscale values ​​of the background area C0 and the target area C1, respectively. v is the average gray value of the entire image area; Step 5.2, calculate the between-class variance of the background and target regions in the image: σ 2 (T)=P1(m v -m1) 2 +P2(m v -m2) 2 According to the known conditions, there is: P1+P2=1,P1m1+P2m2=m v Furthermore, there is: σ 2 (T)=P1P2(m1-m2) 2 Let the value of T change from 0 to L-1, and calculate the between-class variance σ under different T values 2 (T), so that σ 2 The T value when (T) is the largest is the required optimal threshold. It can be seen that there are four variables, each of which changes with T, and the amount of calculation is huge. Step 5.3, optimize the computational amount, redefine the variables, divide the pixels in the image by the threshold T according to the gray level, and define the gray level of 0 to T - 1 as the background region C0. Let P be the probability of the appearance of the background region C0, and m be the ratio of the gray value of the background region C0 in the whole region: Therefore, the expression of the between-class variance of the background and target regions in the image: In the formula, mv is the average gray value of the image; at this time, making σ 2 The T value when (T) is the largest is the required global threshold of the image; Step 5.4, setting of double thresholds and edge connection, connect with the double thresholds of the Canny algorithm by setting the adaptive function of image segmentation, and set it as the adaptive function: In the formula, T is the global threshold of the above image, f0 is the low-threshold function, f1 is the high-threshold function, and a, b, c correspond to the coefficients of the adaptive function, and the values are non-negative constants; Segmentation is achieved by setting two adaptive functions of high and low double thresholds, that is, the edges with the modulus of the gradient higher than the high threshold are retained - set to 1, the edges lower than the low threshold are discarded - set to 0, and the edges between the high and low double thresholds are processed in the next step - set to 0.

5.

7. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: Step 6 is specifically: For the edges between the high and low double thresholds, hysteresis compensation is adopted. According to whether there is 1 among the eight adjacent points around the pixel points on the 0.5 boundary in the image, if so, the middle edge of 0.5 is retained and set to 1, otherwise it is set to 0.

8. The method for segmenting grinding wheel abrasive grain images based on machine vision according to claim 1, characterized in that: Step 7 specifically includes: Step 7.1, thin the edges in the image to avoid thick edges; Step 7.2, fill the closed edges in the image to fill the holes in the image; Step 7.3, remove other small and irrelevant edges in the image.

Citation Information

Cited By

  • Periodic image hole filling method and system

    CN121033035A