Method and system for detecting distribution of graphite particles of nodular cast iron

Through computer vision technology and Kolmogorov-Smirnov inspection method, the distribution uniformity of graphite particles in ductile cast iron is automatically evaluated, and the problems of subjectivity error and inefficiency in the existing technology are solved, and efficient and accurate detection results are achieved.

CN120125499APending Publication Date: 2025-06-10CHONGQING UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510029479.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-06-10

AI Technical Summary

Technical Problem

The prior art is difficult to automatically and objectively evaluate the distribution uniformity of graphite particles in ductile cast iron, resulting in subjectivity errors, time-consuming, inefficient, high cost and lack of consistency.

Method used

Computer vision technology is used to perform threshold processing, edge detection and contour extraction on metallographic images, calculate the center of mass, and construct an empirical distribution function through the nearest neighbor distance method. Finally, the uniformity of graphite particle distribution is evaluated using the Kolmogorov-Smirnov test method.

Benefits of technology

The automatic and objective evaluation of the distribution of ductile iron graphite particles is achieved, which reduces artificial errors, improves detection efficiency and accuracy, and ensures the consistency of material quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120125499A_ABST
    Figure CN120125499A_ABST
Patent Text Reader

Abstract

The invention discloses a nodular cast iron graphite particle distribution detection method and system, and the method comprises the following steps: 1) obtaining an original metallographic image of nodular cast iron graphite particles, and converting the original metallographic image into a grayscale image; 2) performing threshold processing on the grayscale image to generate a binary image; 3) extracting an edge in the binarized image by adopting an edge detection algorithm; 4) carrying out closing operation on the edge to form a closed outline; 5) extracting and screening contours, and removing noise and incomplete contours; 6) calculating the centroid of the screened contour; 7) constructing an empirical distribution function; and 8) evaluating the distribution uniformity of the graphite particles. The system comprises an image acquisition module, an image processing module, a calculation module, an inspection module and an output module. Through the automatic process, the efficiency of quality detection of the nodular cast iron material is improved, the subjectivity and errors of manual detection are reduced, and the method has important significance for controlling the mechanical property and toughness of the nodular cast iron material.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical fields of materials science and computer vision, and specifically to a method and system for detecting the distribution of graphite particles in ductile iron. Background Art

[0002] Ductile iron is a cast iron material obtained through spheroidization treatment. It has excellent mechanical properties, such as high strength, toughness, and good wear resistance. During the production process of ductile iron, a spheroidizing agent (usually magnesium or rare earth elements) is added to the molten iron, so that the carbon elements doped in the cast iron exist in the form of spherical graphite instead of flake graphite. This spherical graphite structure endows ductile iron with better impact toughness and shock absorption performance, making it widely used in the fields of manufacturing automotive parts, pipes, valves, etc. Due to its superior comprehensive performance, ductile iron is a very important material in the industrial field.

[0003] However, the performance of ductile iron highly depends on the uniform distribution of spherical graphite particles. Uneven distribution may lead to problems such as crack initiation and stress concentration, which will further affect the overall mechanical properties and toughness of the material, and even cause brittle fracture. At present, there is no unified standard in China to regulate the distribution of graphite particles in ductile iron. The detection work mainly relies on laboratory sampling, observing the cast iron samples through a microscope and manually judging the distribution of graphite particles by the naked eye. This method has subjective errors, is time-consuming, inefficient, costly, and lacks consistency. Therefore, an automated spatial statistical method and system for evaluating the distribution of graphite particles in ductile iron are needed to objectively grasp the distribution of graphite particles, thereby reducing human errors and further improving the quality of cast iron. Summary of the Invention

[0004] The purpose of the present invention is to provide a method for detecting the distribution of graphite particles in ductile iron, including the following steps:

[0005] 1) Obtain the original metallographic image of ductile iron graphite particles and convert it into a grayscale image;

[0006] 2) Perform threshold processing on the grayscale image to generate a binary image for distinguishing graphite particles from the background;

[0007] 3) Use an edge detection algorithm to extract the edges in the binary image;

[0008] 4) Perform a closing operation on the edges to form a closed contour;

[0009] 5) Extract and screen the contours to remove noise and incomplete contours;

[0010] 6) Calculate the centroid of the screened contours;

[0011] 7) Perform distribution detection on all centroids and construct an empirical distribution function;

[0012] 8) The Kolmogorov-Smirnov test method is used to compare the empirical distribution function and the theoretical distribution function, so as to evaluate the uniformity of the graphite particle distribution.

[0013] Furthermore, the original metallographic image of the graphite particles in ductile iron is the original metallographic image of the metallographic specimen;

[0014] The metallographic specimen is intercepted from a test block cast synchronously with the casting or the casting itself, and is processed under the same furnace heat treatment conditions.

[0015] Furthermore, the equation for threshold processing of the grayscale image is as follows:

[0016]

[0017] In the formula, result(x, y) represents the segmentation result, 0 represents the foreground, 255 represents the background; threshold is the threshold value.

[0018] Furthermore, the edge detection algorithms include the Sobel operator and the Canny operator;

[0019] The Sobel operator calculates the gradients in the horizontal and vertical directions to obtain the gradient amplitude S at each point in each direction. If the gradient amplitude is higher than the threshold value, the pixel point is an edge point;

[0020] The gradient amplitude S is as follows:

[0021]

[0022] In the formula, Sx and Sy are the gradients in the horizontal and vertical directions;

[0023] The Canny operator uses a Gaussian filter to smooth the binary image, calculates the gradient amplitude and direction of the smoothed image, uses the non-maximum suppression method to refine the edge, and connects the edges through double-threshold detection and edge linking;

[0024] The Gaussian filter G(x, y, σ) is as follows:

[0025]

[0026] Among them, x and y are the coordinates of the pixel point relative to the center of the kernel, and σ is the standard deviation of the Gaussian distribution;

[0027] The gradient amplitude S and direction θ of the smoothed image are as follows:

[0028]

[0029] Where, Sx and Sy are the gradients in the horizontal and vertical directions.

[0030] Further, the steps for closing the edge are: performing a topological operation of dilation followed by erosion to close the edge and fill the internal small holes, preventing different graphite particles from connecting together.

[0031] Further, the centroid of the filtered contour is as follows:

[0032]

[0033] Here, ∫∫ R dA represents the area A of the region R; (x c , y c ) are the coordinates of the centroid; ∫∫ R represents the double integral over the region R, dA is the area element; x and y are the abscissa and ordinate of any point within the region R.

[0034] Further, when detecting the distribution of all centroids, the nearest neighbor distance method is used to calculate the distance from each centroid to its nearest neighbor point.

[0035] Further, the empirical distribution function is as follows:

[0036]

[0037] Where, F n (x) is the empirical distribution function; n i is the frequency of occurrence of the observed centroid x (i) .

[0038] Further, the steps for comparing the empirical distribution function with the theoretical distribution function using the Kolmogorov-Smirnov test method include: using the one-sample KS test to compare the maximum difference between the empirical distribution function and the theoretical distribution function as the KS statistic; the smaller the KS statistic, the more uniform the distribution of graphite particles.

[0039] A system applying the method for detecting the distribution of graphite particles in ductile iron includes an image acquisition module, an image processing module, a calculation module, an inspection module, and an output module;

[0040] The image acquisition module is used to obtain a metallographic inspection image;

[0041] The image processing module is used to perform grayscale conversion, threshold processing, edge detection, and contour extraction on the metallographic inspection image;

[0042] The calculation module is used to calculate the centroid, detect the distribution of all centroids, and construct an empirical distribution function;

[0043] The inspection module is used to evaluate the uniformity of the graphite particle distribution;

[0044] The output module is used to display and record the detection results of the uniformity of the graphite particle distribution.

[0045] The technical effect of the present invention is beyond doubt. The present invention proposes a method for measuring the spherical graphite particle distribution based on computer vision, the nearest neighbor distance method, and the Kolmogorov-Smirnov test (hereinafter referred to as KS for short). This method first locates and segments graphite particles in a microscope image based on an image segmentation algorithm of computer vision, and calculates the centroid of irregular graphite particles through integration. Then, the nearest neighbor distance of each graphite particle is calculated by the nearest neighbor distance method to construct an empirical distribution. Finally, the KS test is used to compare the empirical distribution with the theoretical distribution to achieve an objective evaluation of the spherical graphite distribution of the sample. Description of the Drawings

[0046] Figure 1 It is a flowchart for the detection of the graphite particle distribution;

[0047] Figure 2 It is a schematic diagram of linear interpolation of the pixel gradient direction;

[0048] Figure 3 It is an 8-neighborhood edge detection map;

[0049] Figure 4 It is a KS theoretical critical value map;

[0050] Figure 5 It is an architecture diagram of the hardware system for the detection of the graphite particle distribution;

[0051] Figure 6 It is a module diagram of the software system for the detection of the graphite particle distribution;

[0052] Figure 7 It is a standard metallographic inspection diagram of nodular cast iron;

[0053] Figure 8 It is a grayscale image obtained through processing;

[0054] Figure 9 It is a binary image obtained through processing;

[0055] Figure 10 It is an image obtained after edge detection;

[0056] Figure 11 It is an image obtained after closing the edges;

[0057] Figure 12 It is an image obtained after extracting the contour;

[0058] Figure 13The image obtained by selecting and rating the contour;

[0059] Figure 14 The image obtained by calculating the centroid of the contour;

[0060] Figure 15 The distribution diagram of the minimum distance list;

[0061] Figure 16 The superimposed comparison diagram of the empirical distribution function and the theoretical distribution function obtained by the KS test. Detailed implementation manners

[0062] The present invention will be further described below in conjunction with embodiments, but it should not be understood that the above-mentioned subject scope of the present invention is limited to the following embodiments. Without departing from the above technical idea of the present invention, various substitutions and changes made according to common general technical knowledge and customary means in the art shall be included within the protection scope of the present invention.

[0063] Embodiment 1:

[0064] Refer to Figures 1 to 16 , a method for detecting the graphite particle distribution of ductile iron, comprising the following steps:

[0065] 1) Obtain the original metallographic image of the graphite particles of ductile iron and convert it into a grayscale image;

[0066] 2) Perform threshold processing on the grayscale image to generate a binary image to distinguish graphite particles from the background;

[0067] 3) Use an edge detection algorithm to extract the edges in the binary image;

[0068] 4) Perform a closing operation on the edges to form a closed contour;

[0069] 5) Extract and screen the contours to remove noise and incomplete contours;

[0070] 6) Calculate the centroid of the screened contour;

[0071] 7) Perform distribution detection on all centroids to construct an empirical distribution function;

[0072] 8) Use the Kolmogorov-Smirnov test method to compare the empirical distribution function with the theoretical distribution function to evaluate the uniformity of the graphite particle distribution.

[0073] The original metallographic image of the graphite particles of ductile iron is the original metallographic image of the metallographic specimen;

[0074] The metallographic specimen is intercepted from a test block cast synchronously with the casting or the casting itself and is processed under the same furnace heat treatment conditions.

[0075] The equation for thresholding a grayscale image is as follows:

[0076]

[0077] Where result(x,y) represents the segmentation result, 0 represents the foreground, 255 represents the background; threshold is the threshold value.

[0078] The edge detection algorithm includes the Sobel operator and the Canny operator;

[0079] The Sobel operator calculates the gradients in the horizontal and vertical directions to obtain the gradient magnitude S at each point in each direction. If the gradient magnitude is higher than the threshold, then the pixel point is an edge point;

[0080] The gradient magnitude S is as follows:

[0081]

[0082] Where Sx and Sy are the gradients in the horizontal and vertical directions;

[0083] The Canny operator uses a Gaussian filter to smooth the binary image, calculates the gradient magnitude and direction of the smoothed image, uses the non-maximum suppression method to refine the edges, and connects the edges through double-threshold detection and edge linking;

[0084] The Gaussian filter G(x,y,σ) is as follows:

[0085]

[0086] Where x and y are the coordinates of the pixel point relative to the center of the kernel, and σ is the standard deviation of the Gaussian distribution;

[0087] The gradient magnitude S and direction θ of the smoothed image are as follows:

[0088]

[0089]

[0090] Where Sx and Sy are the gradients in the horizontal and vertical directions.

[0091] The steps for closing the edges are: performing a topological operation of dilation first and then erosion to close the edges and fill the internal small holes to prevent different graphite particles from connecting together.

[0092] The centroid of the filtered contour is as follows:

[0093]

[0094] Here, ∫∫R dA represents the area A of region R; (x c , y c ) are the coordinates of the centroid; ∫∫ R represents the double integral over region R, dA is the area element; x and y are the horizontal and vertical coordinates of any point within region R.

[0095] When performing distribution detection on all centroids, the nearest neighbor distance method is used to calculate the distance from each centroid to its nearest neighbor point.

[0096] The empirical distribution function is as follows:

[0097]

[0098] In the formula, F n (x) is the empirical distribution function; n i is the frequency of occurrence of the observed centroid x (i) .

[0099] The steps of using the Kolmogorov - Smirnov test method to compare the empirical distribution function with the theoretical distribution function include: using the one - sample KS test to compare the maximum difference between the empirical distribution function and the theoretical distribution function as the KS statistic; the smaller the KS statistic, the more uniform the distribution of graphite particles.

[0100] Example 2:

[0101] A method for detecting the distribution of graphite particles in ductile iron, comprising the following steps:

[0102] 1) Obtain the original metallographic image of graphite particles in ductile iron and convert it into a grayscale image;

[0103] 2) Perform threshold processing on the grayscale image to generate a binary image for distinguishing graphite particles from the background;

[0104] 3) Adopt an edge detection algorithm to extract the edges in the binary image;

[0105] 4) Perform a closing operation on the edges to form a closed contour;

[0106] 5) Extract and screen the contours to remove noise and incomplete contours;

[0107] 6) Calculate the centroid of the screened contours;

[0108] 7) Perform distribution detection on all centroids to construct an empirical distribution function;

[0109] 8) Use the Kolmogorov - Smirnov test method to compare the empirical distribution function with the theoretical distribution function to evaluate the uniformity of the distribution of graphite particles.

[0110] Example 3:

[0111] A method for detecting the graphite particle distribution of ductile iron, the technical content is the same as that of Example 2. Further, the original metallographic image of the graphite particles in the ductile iron is the original metallographic image of the metallographic specimen;

[0112] The metallographic specimen is intercepted from a test block cast synchronously with the casting or the casting itself, and is processed under the same furnace heat treatment conditions.

[0113] Example 4:

[0114] A method for detecting the graphite particle distribution of ductile iron, the technical content is the same as any one of Examples 2-3. Further, the equation for threshold processing of the grayscale image is as follows:

[0115]

[0116] In the formula, result(x, y) represents the segmentation result, 0 represents the foreground, 255 represents the background; threshold is the threshold.

[0117] Example 5:

[0118] A method for detecting the graphite particle distribution of ductile iron, the technical content is the same as any one of Examples 2-4. Further, the edge detection algorithm includes Sobel operator and Canny operator (either one can be used);

[0119] The Sobel operator calculates the gradients in the horizontal and vertical directions, so as to obtain the gradient amplitude S of the point in each direction. If the gradient amplitude is higher than the threshold, the pixel point is an edge point;

[0120] The gradient amplitude S is as follows:

[0121]

[0122] In the formula, Sx and Sy are the gradients in the horizontal and vertical directions;

[0123] The Canny operator uses a Gaussian filter to smooth the binary image, calculates the gradient amplitude and direction of the smoothed image, uses the non-maximum suppression method to refine the edge, and connects the edge through double threshold detection and edge connection;

[0124] The Gaussian filter is as follows:

[0125]

[0126] Among them, x and y are the coordinates of the pixel point relative to the center of the kernel, and σ is the standard deviation of the Gaussian distribution;

[0127] The gradient magnitude S and direction θ of the smoothed image are as follows:

[0128]

[0129] Example 6:

[0130] A method for detecting the graphite particle distribution in ductile iron. The technical content is the same as any one of Examples 2-5. Further, the step of closing the edge is as follows: performing a topological operation of dilation first and then erosion to close the edge and fill the internal small holes to prevent different graphite particles from connecting together.

[0131] Example 7:

[0132] A method for detecting the graphite particle distribution in ductile iron. The technical content is the same as any one of Examples 2-6. Further, the centroid of the screened contour is as follows:

[0133]

[0134] Here, ∫∫ R dA represents the area A of region R; (x c , y c ) are the coordinates of the centroid; ∫∫ R represents the double integral over region R, dA is the area element; x and y are the abscissa and ordinate of any point within region R.

[0135] Example 8:

[0136] A method for detecting the graphite particle distribution in ductile iron. The technical content is the same as any one of Examples 2-7. Further, when detecting the distribution of all centroids, the nearest neighbor distance method is used to calculate the distance from each centroid to its nearest neighbor point.

[0137] Example 9:

[0138] A method for detecting the graphite particle distribution in ductile iron. The technical content is the same as any one of Examples 2-8. Further, the empirical distribution function is as follows:

[0139]

[0140] In the formula, F n (x) is the empirical distribution function; n i is the frequency of occurrence of the observed centroid x (i) .

[0141] Example 10:

[0142] A method for detecting the graphite particle distribution in ductile iron, the technical content being the same as any one of Embodiments 2-9. Further, the steps of using the Kolmogorov-Smirnov test method to compare the empirical distribution function and the theoretical distribution function include: using the one-sample KS test to compare the maximum difference between the empirical distribution function and the theoretical distribution function as the KS statistic; the smaller the KS statistic, the more uniform the graphite particle distribution.

[0143] Embodiment 11:

[0144] A system applying the method for detecting the graphite particle distribution in ductile iron, comprising an image acquisition module, an image processing module, a calculation module, a test module and an output module;

[0145] The image acquisition module is used to obtain a metallographic inspection image;

[0146] The image processing module is used to perform graying, threshold processing, edge detection and contour extraction on the metallographic inspection image;

[0147] The calculation module is used to calculate the centroid, perform distribution detection on all centroids, and construct an empirical distribution function;

[0148] The test module is used to evaluate the uniformity of the graphite particle distribution;

[0149] The output module is used to display and record the detection results of the graphite particle distribution uniformity.

[0150] Embodiment 12:

[0151] A method for detecting the graphite particle distribution in ductile iron, the steps being as follows:

[0152] S1: Prepare the original metallographic image to ensure the representativeness and accuracy of the specimen;

[0153] S2: Convert the original image into a gray image for subsequent processing;

[0154] S3: Perform threshold processing on the gray image to generate a binary image to distinguish graphite particles from the background;

[0155] S4: Adopt an edge detection algorithm to extract the edges in the binary image;

[0156] S5: Perform a closing operation on the edges to form a closed contour;

[0157] S6: Extract and screen the contours to remove noise and incomplete contours;

[0158] S7: Calculate the centroid of the screened contours;

[0159] S8: Perform distribution detection on all centroids and construct an empirical distribution function;

[0160] S9: Use the Kolmogorov-Smirnov test (hereinafter referred to as KS) to compare the empirical distribution function with the theoretical distribution function to evaluate the uniformity of the graphite particle distribution.

[0161] In the threshold processing step, the threshold is 100, which is used to distinguish graphite particles from the background. The threshold is set to 100 based on the analysis of a large number of grayscale image samples, which can better distinguish graphite particles from the background and ensure the accurate extraction of graphite particles.

[0162] The edge detection algorithm includes the Sobel operator and the Canny operator. The Sobel operator calculates the gradients in the horizontal and vertical directions. The Canny operator uses a Gaussian filter for smoothing, calculates the gradient magnitude and direction, and determines the edges through non-maximum suppression and double-threshold detection.

[0163] The contour closing operation uses closing, with a 3×3 structuring element. Closing performs a topological operation of first dilating and then eroding to close the edges and fill the internal small holes, preventing different graphite particles from connecting together.

[0164] In the distribution detection step, the nearest neighbor distance method is used to calculate the distance from each centroid to the nearest neighbor point. The nearest neighbor distance method constructs an empirical distribution function by calculating the distance from each centroid to the nearest neighbor point, and compares it with the empirical distribution function under the theoretical uniform distribution to evaluate the uniformity of the point distribution.

[0165] In the KS test step, the one-sample KS test is used to compare the consistency of the sample data with the normal distribution. The one-sample KS test determines whether to accept the null hypothesis by calculating the maximum difference between the empirical distribution function and the theoretical distribution function, that is, the KS statistic, so as to evaluate the uniformity of the graphite particle distribution.

[0166] Example 13:

[0167] A ductile iron graphite distribution detection system includes:

[0168] a. An image acquisition module for acquiring metallographic inspection images;

[0169] b. An image processing module for grayscale conversion, threshold processing, edge detection, and contour extraction;

[0170] c. A calculation module for calculating centroids and distribution detection;

[0171] d. A test module for performing the KS test;

[0172] e. An output module for displaying and recording the detection results.

[0173] The image processing module includes computer vision algorithms for automatically identifying and quantifying the distribution of graphite particles. The image processing module uses computer vision algorithms to automatically identify and quantify the distribution of graphite particles, improving the detection efficiency and accuracy.

[0174] The calculation module includes a centroid calculation algorithm and a nearest neighbor distance algorithm. The calculation module uses integral to calculate the centroid and the nearest neighbor distance algorithm to calculate the distance from each centroid to the nearest neighbor point and construct an empirical distribution function.

[0175] The inspection module includes a statistical inspection algorithm for evaluating the uniformity of the graphite particle distribution. The inspection module uses a statistical inspection algorithm to evaluate the uniformity of the graphite particle distribution through the KS test, providing a scientific basis for material quality control.

[0176] Example 14:

[0177] A method for detecting the graphite particle distribution in ductile iron is as follows:

[0178] 1. Prepare the original image

[0179] The following points should be noted when preparing the metallographic specimen: The metallographic specimen should be intercepted from a test block cast simultaneously with the casting or the casting itself and should be processed under the same furnace heat treatment conditions (for example, during the heat treatment process).

[0180] When sampling from the casting, the casting surface and the areas affected by chill should be avoided to ensure the representativeness and accuracy of the sampling. During the interception and preparation of the metallographic specimen, measures must be taken to prevent changes in the material structure, graphite exfoliation, and graphite tailing. The surface of the specimen should be kept smooth without significant scratches to avoid affecting the accuracy of subsequent analysis.

[0181] 2. Obtain the grayscale image

[0182] A grayscale image is a single-channel image that shows the grayscale information of the image through a single brightness channel without any color information. Each pixel point in this image only contains an integer value between 0 (pure black) and 255 (pure white), and this value reflects the light brightness of that point. Since only brightness information is involved, grayscale images are more efficient to store and process than color images. At the same time, they also retain sufficient visual information to preserve the structure and details in the image, facilitating subsequent processing such as image analysis and feature extraction. Grayscale images serve as a preprocessing step in image processing and computer vision algorithms and are the basis for further analysis and applications.

[0183] 3. Obtain the binary image

[0184] A binary image is a black-and-white image in which each pixel has only two possible values, usually 0 and 255, representing black and white respectively. This image does not contain grayscale information and has only two pure colors, black and white. The uniformity of the graphite particle distribution is mainly reflected by the position distribution of the graphite particles. Therefore, distinguishing the foreground (regions of interest such as graphite particles) and the background (regions of no interest such as etching solution) is the main purpose of image binarization. The color characteristics of the graphite particles are very obvious, and the difference between their black color and the gray color of the background is large. Therefore, based on the color characteristics of the graphite particles, a threshold segmentation algorithm is used to extract the graphite particles. In the present invention, image segmentation is performed by setting a threshold (threshold). Let src(x, y) represent the pixel position and result(x, y) represent the segmentation result. 0 represents the foreground and 255 represents the background, and the following segmentation method is defined:

[0185]

[0186] By analyzing a large number of grayscale image samples, it is found that the pixel values of the graphite particles are basically below 80, and the pixel values of the etching solution are basically above 130. Therefore, setting the threshold to 100 can better distinguish the foreground and the background.

[0187] 4. Perform edge detection

[0188] In digital images, edges are places where the image brightness changes significantly. This change may be caused by changes in the contour, texture, color, or other visual features of an object. Edge detection algorithms identify these positions by analyzing the brightness changes of pixel points in the image. Commonly used edge detection algorithms are mainly the Sobel operator and the Canny operator.

[0189] The Sobel operator is a discrete differential operator for edge detection. It combines Gaussian smoothing and differential differentiation to calculate the spatial gradient of the image brightness, thereby highlighting the edges of the image. The Sobel operator calculates the gradients in the horizontal and vertical directions respectively, and then combines these two gradients to detect edges. The Sobel operator uses two 3x3 convolution kernels, which are used to detect edges in the horizontal and vertical directions respectively:

[0190] Horizontal direction (Sx):

[0191] Vertical direction (Sy):

[0192] For each pixel point in the image, the Sobel operator calculates the gradient magnitude of this point in each direction:

[0193]

[0194] The gradient amplitude S reflects the intensity of the brightness change at the pixel point. Usually, points with larger gradient amplitudes are considered edge points. In order to determine which gradient amplitudes belong to the edge, a threshold needs to be set. Pixels with gradient amplitudes higher than the threshold are considered edge points, while those below the threshold are considered non-edge points.

[0195] The Canny operator is a popular edge detection algorithm. It is a multi-stage algorithm that uses a Gaussian filter for smoothing, then calculates the gradient magnitude and direction of the image, then uses non-maximum suppression to refine the edge, and finally determines the edge through double threshold detection and edge connection.

[0196] The two-dimensional Gaussian function in the Gaussian filter is usually defined as:

[0197]

[0198] Among them, x and y are the coordinates of the pixel relative to the center of the kernel, and σ is the standard deviation of the Gaussian distribution, which controls the diffusion range of the Gaussian kernel.

[0199] For a template of size (2k+1)×(2k+1), each element G in the template ij The value of can be calculated by the following formula:

[0200]

[0201] Where i and j represent the row and column indices of the template matrix, respectively, and k is half of the template size.

[0202] The Gaussian kernel template for Gaussian filtering is calculated according to the above formula, and the template can then be used to perform a convolution operation with the image to achieve the effect of smoothing the image and removing noise.

[0203] Canny gradient calculation usually uses the Sobel operator to calculate the gradient magnitude and direction of the image, where the direction θ is:

[0204]

[0205] The purpose of non-maximum pixel gradient suppression is to eliminate the stray response caused by edge detection and play a role in "slimming" the edge. The basic method is to compare the gradient strength of the current pixel with the gradient strength of the adjacent pixels along the positive and negative gradient directions. If it is the maximum (that is, the extreme value), the pixel is retained as an edge point. If it is not the maximum, it is suppressed and not regarded as an edge point. For more accurate calculation, linear interpolation is usually used between two adjacent pixels that cross the gradient direction to obtain the pixel gradient to be compared. The schematic diagram of linear interpolation of pixel gradient direction is shown in the figure. Figure 2As shown, the adjacency of pixels can be divided into 4 regions, each of which contains upper and lower parts. If the gradient intensity of the central pixel in the x direction is g x (i, j), and the gradient intensity in the y direction is g y (i, j), and the gradient intensity is g xy (i, j), then according to the positive and negative and magnitude of g x (i, j) and g y (i, j), the region to which its gradient direction belongs can be judged, and then two gradient intensities g up (i, j) and g down (i, j) participating in the comparison in the positive and negative gradient directions can be obtained by linear interpolation of its pixel gradient direction and the pixel gradients of adjacent points. The formula is as follows:

[0206] g up (i, j) = (1 - t)·g xy (i, j + 1) + t·g xy (i - 1, j + 1)

[0207] g down (i, j) = (1 - t)·g xy (i, j - 1) + t·g xy (i + 1, j - 1)

[0208] The calculation methods for the other three regions are similar. It should be noted that if g x (i, j) = g y (i, j) = 0, it means that the pixel has no pixel gradient and it is a non-edge. After non-maximum suppression, the edge becomes thinner and closer to the real object boundary.

[0209] Double-threshold detection requires defining a high threshold and a low threshold. Pixel points with gradient intensity lower than the low threshold are suppressed and not regarded as edge points; pixel points higher than the high threshold are defined as strong edges and retained as edge points; those between the high and low thresholds are defined as weak edges and left for further processing. For pixel points with gradient magnitude between the high and low thresholds, it is necessary to check whether there are strong edge pixels in their 8-neighborhood. If so, the pixel point is marked as an edge, otherwise it is marked as a non-edge. The 8-neighborhood detection method is as Figure 3 shown. Define the black square as a strong edge point, the white square as a non-edge point, and the gray square as a weak edge point. According to the definition in the 8-neighborhood detection method, the central pixel point is a weak edge point, and it is necessary to judge whether there are strong edge points in its 8-neighborhood. There are strong edge points in the figure, so this weak edge point is marked as an edge point.

[0210] 5. Extract the contour

[0211] The edges detected in the above steps are a set of boundaries with obvious pixel value changes in the image, and it is necessary to further determine which parts of them belong to the contours. The main steps of contour extraction are contour finding, contour filtering, and contour drawing.

[0212] Contour finding is based on edge detection, further identifying and connecting edge points to form complete object boundaries. It involves tracing edge points and organizing them into closed contours to represent the shape of the object. These contours are stored as point sets and can be used for further geometric analysis or visualization.

[0213] Contour filtering is to filter out the contours of interest according to the characteristics of the contour size, shape, position, etc. In this paper, small contours (noise), unclosed contours (incomplete graphite particles), and contours located at the image bounding box (incomplete graphite particles) need to be removed, leaving the contours that can be used for subsequent analysis.

[0214] Contour drawing is to draw the obtained contour point set on the original image, so that the shape and position of the object can be visually seen, which is very important for image understanding and display. Through observing the drawn contours, further shape analysis can be carried out, such as features like contour perimeter, area, and centroid.

[0215] 6. Calculate the centroid

[0216] The centroid is the average position of all point sets on an object or figure. In this paper, the centroid is used to describe the geometric center of the contour or object for subsequent analysis.

[0217] For a planar region R and its density function ρ(x, y), the coordinates (x c , y c ) of the centroid can be calculated by the following integral formula: Among them, ∫∫ R represents the double integral over the region R, and dA is the area element.

[0218] In this paper, the density function ρ(x, y) is regarded as a constant, then the above formula can be simplified to:

[0219]

[0220] Here, ∫∫ R dA is the area A of the region R.

[0221] 7. Conduct distribution detection

[0222] The empirical distribution function, also known as the sample distribution function, approximates the unknown distribution function by estimating the cumulative distribution function of the data sample. Let (X 1 , X 2 , …, X n) is a simple random sample from the population X. An observation (x 1 , x 2 , …, x n ) has its components arranged in ascending order as x (1) < x (2) < … < x (r) , where the frequency of x (i) (i = 1, 2, …, r) is n i (n 1 + n 2 + … + n r = n). Denote the following function F n (x) as the empirical distribution function of the population X:

[0223]

[0224] The theoretical distribution function refers to a statistical function that describes the probabilities of various outcomes in a random experiment. It is a model that, based on fundamental assumptions about the population from which the data is drawn, predicts how data points will behave under specific conditions. Common examples of theoretical distribution functions include the normal distribution, binomial distribution, Poisson distribution, and exponential distribution, each characterized by specific parameters that define their shape and properties. The normal distribution is a very important continuous probability distribution, and its probability density function has the shape of a bell curve. Since it can describe the random errors in many natural and social phenomena, the normal distribution function is adopted as the theoretical distribution function in this paper.

[0225] The nearest neighbor distance method is a method for evaluating the uniformity of point distribution. Its basic idea is to calculate the distance from each point to its nearest neighbor, construct the empirical distribution function of the nearest neighbor distances, and compare it with the empirical distribution function under the theoretical uniform distribution, thereby evaluating the uniformity of the point distribution. The empirical distribution function is constructed to obtain the distribution of the nearest neighbor distances from the actual data. The theoretical distribution function is obtained based on the assumption of a uniform random point distribution. The comparison between the two aims to observe whether the actual data is consistent with the theoretical assumption (uniform random distribution).

[0226] 8. Conduct the KS test

[0227] The Kolmogorov - Smirnov test is a non - parametric test, commonly used to determine whether a sample is consistent with a pre - given distribution, or whether the probability distributions of two samples are different. In other words, it is to check whether it is credible that the observed sample follows a certain distribution.

[0228] When performing a one-sample KS test, first arrange the sample data in ascending order, and then calculate its empirical distribution function. Next, calculate the maximum difference between the empirical distribution function and the theoretical distribution function (such as normal distribution, exponential distribution, etc.). This maximum difference is called the KS statistic. Finally, by comparing the KS statistic with the critical value, we can decide whether to reject the null hypothesis. The null hypothesis is usually that the sample comes from a specified theoretical distribution. The KS critical values are as Figure 4 shown. Here, α is the significance level (usually 0.05 in general), which represents the probability of making a mistake when the population parameter falls within a certain interval, and N is the sample size. The data in the figure are the KS critical values corresponding to the significance level and the sample size.

[0229] The result of the one-sample KS test can tell us the degree of fit between the sample data and the theoretical distribution. If the KS statistic is small, it indicates that the sample data is relatively close to the theoretical distribution; if the KS statistic is large, it means that there are significant differences between the sample data and the theoretical distribution.

[0230] In this paper, first, the nearest neighbor distance method is used to obtain a set of the nearest neighbor distances of each centroid, and then this set of distance data is sorted in ascending order. The empirical distribution function and its mean standard deviation are calculated, and a KS test is performed with the normal distribution function corresponding to the mean standard deviation. If the calculated KS statistic is less than the critical value, the null hypothesis is accepted, and it is considered that this set of distance data conforms to the normal distribution, and the graphite particle distribution is relatively uniform.

[0231] Example 15:

[0232] A method for detecting the distribution of graphite particles in ductile iron, the steps are as follows:

[0233] The hardware devices used in the present invention include an industrial control camera, a metallurgical microscope, a computer, and auxiliary accessories such as data cables. After connecting the industrial control camera and the metallurgical microscope together, and then docking with the computer through a USB interface, the architecture of its overall hardware system is as Figure 5 shown. The software system used in the distribution detection system of the present invention has five modules, namely an image acquisition module, an image processing module, a calculation module, an inspection module, and an output module. The overall software module is as Figure 6 shown. The specific implementation steps of this invention are as follows:

[0234] 1. Image preprocessing

[0235] The original image of the present invention is obtained by taking pictures under a microscope during metallurgical inspection. It should be noted that the standard inspection process and principles should be followed, otherwise it will affect the accuracy of subsequent analysis. After obtaining the original image, it is necessary to mark the size according to the magnification of the microscope. A standard original image is as Figure 7As shown, where the image resolution is 1280*980 pixels. The original image is input into the graphite distribution detection system, and the color conversion function is used to convert the RGB three-channel color image into a single-channel grayscale image. The formula used is Gray = 0.299R + 0.587G + 0.114*B. This formula is designed based on the different sensitivities of the human eye to different colors, so that the converted grayscale image is visually as close as possible to the original image. The obtained grayscale image is as shown in Figure 8 As shown. The obtained grayscale image is converted into a binary image by using the threshold function with a threshold of 100 set. This function will judge the pixel value of each point in the image through the given threshold. If it is greater than the threshold, it is set to 255, otherwise it is set to 0. The specific threshold value needs to be determined according to the actual pixel values of graphite particles and etching solution. The obtained binary image is as shown in Figure 9 As shown.

[0236] 2. Obtain the centroid map

[0237] The binary image obtained above can better obtain the approximate outline of each graphite particle. Next, each graphite particle is represented by its centroid to represent its geometric center, which is convenient for subsequent analysis. To obtain the centroid map, first, the Canny function needs to be used for edge detection. The Canny function contains two threshold parameters. A lower first threshold will result in more edges being detected, and a higher second threshold will result in more accurate edges being detected. Usually, the second threshold is twice or three times the first threshold. Through a large number of experimental analyses, the first threshold is selected as 100, and the second threshold is selected as 200, and the obtained edges are the most accurate. The edge detection map obtained through the above operations is as shown in Figure 10 As shown.

[0238] The edges obtained by Canny detection have the problem of being unclosed, and closing operations need to be used to close these edges and prevent different graphite particles from connecting together. Closing operation is an image morphological operation. It first performs a dilation operation and then an erosion operation to achieve the effect of closing edges and filling internal small holes. The erosion operation will reduce the boundary of objects in the image. It can eliminate small objects or noise. During the erosion process, the structuring element (such as a 3x3 or 5x5 square or circle) slides on the image. Only when the structuring element is completely contained within the object, the central pixel is retained, otherwise the central pixel is set to 0. Contrary to erosion, the dilation operation will increase the boundary of objects in the image. It can be used to fill holes inside objects or connect adjacent objects. During the dilation process, the structuring element slides on the image. As long as the structuring element overlaps with the object, the central pixel is set to 1. In this paper, the morphological operation function is used for the closing operation, where the structuring element is defined as 3×3, which can well close the edges and prevent adjacent graphite particles from connecting. The closed edges obtained through the above operations are as shown in Figure 11as shown

[0239] After obtaining the above edge map, contour extraction operation needs to be carried out. A contour is a curve composed of a series of continuous points (pixels), and these points have the same color or brightness. In this paper, a contour extraction function is used to extract the contours in the figure. This function will first find all the contours, and then draw the contours on a black background to obtain a contour image as Figure 12 as shown. However, this operation will extract all the contours, including many small graphite particles, which will affect the subsequent analysis accuracy. These small contours need to be removed. The area of each contour is calculated using a contour area calculation function. This function will count the black pixel values in the closed contour and remove the contours with an area value of less than 20, only retaining the contours with an area of more than 20. These contours are classified according to the area size, and each graphite particle is framed and rated to facilitate observing whether these graphite particles can continue the subsequent operations. The obtained image is as Figure 13 as shown

[0240] After obtaining the classified contour map, the centroid of each graphite particle needs to be calculated. Here, the moment feature function is used for calculation. The moment feature function is a function used to calculate the moments of a 2D point set or an image. Moments are statistical quantities that describe the pixel intensity distribution in an image and are calculated through the pixel values and their coordinates. Among them, m 00 is the zero-order moment, representing the total weight (area) of the image or point set, and m 10 , m 01 are the first-order moments, representing the centroid position of the image or point set. Through the above functions, the x and y coordinates of the centroid of the graphite particle can be calculated, and the obtained centroid map of the graphite particle is as Figure 14 as shown

[0241] 3. Distribution Detection

[0242] In this paper, the nearest neighbor distance method is used to detect the distribution between centroid points. First, the distances between all centroid points are calculated, and the minimum value of the distances from each point to all other points is found and recorded in a distance list. The obtained result is as Figure 15 as shown

[0243] The average value and standard deviation of the distance list are calculated through the mean function and standard deviation function respectively. Finally, the KS test is used to detect whether the sample comes from a normal distribution. In this paper, the one-sample KS test function is used to test the sample. The first parameter is the distance list, the second parameter is norm, representing the standard normal distribution, and the third parameter is the mean value and standard deviation, representing the offset value of the standard normal function. The second and third parameters together indicate that the normal table has the same mean value and standard deviation. This function will first plot the empirical distribution function and the theoretical distribution function in an image, where the empirical distribution function is the cumulative distribution function of the sample, and the theoretical distribution function is the cumulative distribution function of the normal distribution function with the same mean value and standard deviation as the sample. The obtained image is as shown in Figure 16 . The blue line represents the empirical distribution function, and the red line represents the theoretical distribution function. Then, the maximum difference between the two functions is calculated to obtain a return value, the KS statistic, which is used to compare with the critical value. If the obtained KS statistic value is smaller than the critical value, it indicates that the sample conforms to the normal distribution, and the graphite distribution of this ductile iron sample is relatively uniform. When the KS statistic value obtained after calculating the above centroid map is significantly smaller than the critical value (by comparing the table in Figure 4 ), it shows that the graphite particles in this ductile iron sample are distributed relatively uniformly, and its uniformity passes the detection.

[0244] This system improves the efficiency of the quality inspection of ductile iron materials through an automated inspection process, reduces the subjectivity and errors of manual inspection, can objectively evaluate the uniformity of graphite distribution, is of great significance for controlling the mechanical properties and toughness of ductile iron materials, and at the same time provides a standardized inspection method, helps to establish an industry standard for the graphite distribution of ductile iron, and has a broad application prospect.

Claims

1. A method for detecting graphite particle distribution of ductile iron, characterized in that: The following steps are involved: 1) Obtaining the original metallographic image of ductile iron graphite particles and converting it into a grayscale image; 2) Perform threshold processing on the grayscale image to generate a binary image to distinguish graphite particles from the background. 3) Use edge detection algorithm to extract edges in the binary image; 4) Perform closing operation on the edge to form a closed contour; 5) Extract and filter contours to remove noise and incomplete contours; 6) Calculate the centroid of the filtered contour; 7) Perform distribution detection on all centroids and construct empirical distribution function; 8) The Kolmogorov-Smirnov test method was used to compare the empirical distribution function with the theoretical distribution function to evaluate the uniformity of graphite particle distribution.

2. The method for detecting the distribution of graphite particles in ductile iron according to claim 1, characterized in that: The original metallographic image of graphite particles in ductile iron is the original metallographic image of the metallographic sample; The metallographic specimens were taken from test blocks cast simultaneously with the castings or from the castings themselves and were processed under the same furnace heat treatment conditions.

3. The method for detecting the distribution of graphite particles in ductile iron according to claim 1, characterized in that: The equation for thresholding a grayscale image is as follows: In the formula, result(x,y) represents the segmentation result, 0 represents the foreground, 255 represents the background, and threshold is the threshold.

4. The method for detecting the distribution of graphite particles in ductile iron according to claim 1, characterized in that: The edge detection algorithm includes a Sobel operator and a Canny operator; The Sobel operator calculates the gradient in the horizontal and vertical directions to obtain the gradient amplitude S of the point in each direction. If the gradient amplitude is higher than the threshold, the pixel is an edge point. The gradient magnitude S is as follows: Where Sx and Sy are the gradients in the horizontal and vertical directions; The Canny operator uses a Gaussian filter to smooth the binary image, calculates the gradient amplitude and direction of the smoothed image, uses the non-maximum suppression method to refine the edge, and connects the edges through dual threshold detection and edge connection; The Gaussian filter G(x,y,σ) is as follows: Where x and y are the coordinates of the pixel relative to the center of the kernel, and σ is the standard deviation of the Gaussian distribution; The gradient magnitude S and direction θ of the smoothed image are as follows: Where Sx and Sy are the gradients in the horizontal and vertical directions.

5. The method for detecting the distribution of graphite particles in ductile iron according to claim 1, characterized in that: The steps of closing the edge are: performing a topological operation of first dilation and then corrosion to close the edge and fill the internal holes to prevent different graphite particles from being connected together.

6. The method for detecting the distribution of graphite particles in ductile iron according to claim 1, characterized in that: The centroid of the filtered contours is shown below: Here, ∫∫ R dA represents the area of ​​region R; (x c ,y c ) are the coordinates of the center of mass; ∫∫ R It represents the double integral over the region R, where dA is the area element and x and y are the horizontal and vertical coordinates of any point in the region R.

7. The method for detecting graphite particle distribution of ductile iron according to claim 1, characterized in that: When performing distribution detection on all centroids, the nearest neighbor distance method is used to calculate the distance from each centroid to the nearest neighbor point.

8. The method for detecting graphite particle distribution of ductile iron according to claim 1, characterized in that: The empirical distribution function is shown below: In the formula, F n (x) is the empirical distribution function; n i is the observed centroid x (i) Frequency of occurrence.

9. The method for detecting graphite particle distribution of ductile iron according to claim 1, characterized in that: The steps of comparing the empirical distribution function with the theoretical distribution function using the Kolmogorov-Smirnov test method include: using a single-sample KS test to compare the maximum difference between the empirical distribution function and the theoretical distribution function as a KS statistic; the smaller the KS statistic, the more uniform the distribution of graphite particles.

10. A system using the method for detecting graphite particle distribution of ductile iron according to any one of claims 1 to 9, characterized in that: It includes an image acquisition module, an image processing module, a calculation module, a testing module and an output module; The image acquisition module is used to obtain metallographic inspection images; The image processing module is used to perform grayscale conversion, threshold processing, edge detection and contour extraction on the metallographic inspection image; The calculation module is used to calculate the centroid, perform distribution detection on all centroids, and construct an empirical distribution function; The inspection module is used to evaluate the uniformity of graphite particle distribution; The output module is used to display and record the test results of the uniformity of graphite particle distribution.

Citation Information

Cited By

  • Method for measuring granularity and form of particles

    CN120445934A