Die-casting die defect detection method and system based on image recognition
Through image recognition-based methods, the defects on the surface of die-casting molds are identified and analyzed, and the problem of insufficient identification of complex surface structures in the prior art is solved, and high-precision defect detection and quantitative analysis are realized. It is suitable for small and medium-sized enterprises and improves production efficiency and product quality.
Patent Information
- Application Number
- CN202411982323.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art has insufficient identification of surface defects such as tiny cracks or incomplete molding of complex surface structures in the detection of defects of die casting molds, and requires high operating skills and expensive equipment, which limits the application of small and medium-sized enterprises, and is difficult to provide effective early warning and preventive measures, affecting production efficiency and product quality.
Using an image recognition-based method, the die-casting mold surface is illuminated by the target wavelength light source, high-definition original images are captured and color correction and light compensation are performed, contrast and texture clarity are adjusted, defect profile is identified, grayscale frequency distribution is calculated, defect shape and size is quantified, defect classification and distribution analysis is performed.
It improves the accuracy of identification of surface defects of die-casting molds, provides quantitative defect management data, extends the service life of the mold, reduces production problems caused by defects, and reduces inspection costs. It is suitable for small and medium-sized enterprises.
Smart Images

Figure CN119904431A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of defect detection, and in particular to a die-casting mold defect detection method and system based on image recognition. Background Art
[0002] The field of defect detection technology involves the use of various detection technologies and systems to identify defects or defects in materials, components or structures, which can ensure product quality and production efficiency while reducing possible faults or failures. Defect detection technology is widely used in metal processing, electronic manufacturing, automobile assembly and other fields. Technical means include X-ray detection, ultrasonic detection, magnetic particle detection and visual inspection. In particular, visual inspection technology can accurately identify surface and internal defects such as cracks, holes, inclusions, etc.
[0003] Among them, the die-casting mold defect detection method is a defect detection technology specific to the die-casting field. Its purpose is to identify and evaluate the defects that may occur in the die-casting mold during the production process, such as cracks, pores, and incomplete molding. Its main purpose is to improve the quality of die-casting products and ensure the integrity of the mold, thereby reducing production costs and improving production efficiency. By regularly inspecting the mold, problems can be discovered in time and repaired or replaced to avoid production quality problems and extend the service life of the mold.
[0004] Existing technologies have obvious limitations in defect detection of die casting molds. Although technologies such as X-rays and ultrasound can detect internal defects, they are insufficient in identifying surface defects such as tiny cracks or incomplete molding on the surface structure of complex die casting molds. At the same time, high operating skills and expensive equipment are also required, which restricts its application in small and medium-sized enterprises. The lack of accurate quantification of defect type, location and size makes it difficult to provide effective early warning and preventive measures, which in turn affects production efficiency and product quality. Especially in high-standard production processes, key defects are overlooked, affecting the quality control effect of the entire production line. Summary of the invention
[0005] The purpose of the present invention is to solve the shortcomings in the prior art and to propose a die-casting mold defect detection method based on image recognition.
[0006] In order to achieve the above object, the present invention adopts the following technical solution: a die casting mold defect detection method based on image recognition, comprising the following steps:
[0007] S1: Use a target wavelength light source to illuminate the die-casting mold surface, use a camera to capture the mold surface image, perform color correction and lighting compensation on the captured mold surface image, and save the output high-definition original image;
[0008] S2: Based on the high-definition original image, adjust the contrast to highlight the defect features, extract image edge information and reveal image details, identify the defect contour, calculate the texture clarity according to the defect contour recognition result, separate the defect area, mark each defect area, record the position and shape of each defect, and generate defect feature data;
[0009] S3: Based on the defect feature data, grayscale analysis is performed to calculate the grayscale frequency distribution of each defect area, and the shape and size of the defect area are quantified according to the grayscale frequency distribution calculation result, and the defect and non-defect areas are isolated, and each type of defect is classified according to the morphological characteristics to generate a defect classification result;
[0010] S4: Based on the defect classification results, the number and type of defects are summarized and analyzed, the distribution ratio of different types of defects on the surface of the die-casting mold is calculated, a defect distribution map is drawn, and a defect distribution analysis report is generated.
[0011] As a further solution of the present invention, the step of outputting the high-definition original image is:
[0012] S111: Select a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material, perform irradiation, adjust the light source angle to evenly cover the mold surface, and generate a target wavelength light source irradiation result;
[0013] S112: according to the target wavelength light source irradiation result, use a camera to capture the mold surface image, adjust the camera exposure time and ISO to match the current lighting conditions, and generate a captured original image;
[0014] S113: Perform color correction and illumination compensation on the captured original image, using the formula:
[0015]
[0016] Calculate the corrected color value C corrected , adjust the image to match the real color representation and generate a high-definition original image, where C raw Represents the original image color value, L current Represents the current light intensity, L optimal Represents ideal light intensity.
[0017] As a further solution of the present invention, the step of identifying the defect contour is:
[0018] S211: Adjust the contrast of the high-definition original image using the formula:
[0019]
[0020] Calculate the adjusted contrast value C new, and get the image after contrast adjustment, where C original represents the contrast of the original image, σ represents the standard deviation of the contrast adjustment, and μ represents the average value of the contrast of the original image;
[0021] S212: performing edge detection based on the contrast-adjusted image to highlight edge information and reveal image details, thereby obtaining an image edge information result;
[0022] S213: Based on the image edge information result, analyze the edge information and background contrast, identify the shape and position of the defect, extract the defect contour, and generate a defect contour recognition result.
[0023] As a further solution of the present invention, the step of acquiring the defect feature data is:
[0024] S221: Based on the defect contour recognition result, the formula is used:
[0025]
[0026] Calculate the image texture clarity value T and obtain the overall texture clarity calculation result, where N represents the total number of pixels in the defect area, and p i represents the gray value of the i-th pixel, r i represents the gray level of the pixel, and u is the average gray level;
[0027] S222: According to the overall texture clarity calculation result, by comparing the texture clarity value of each area with a preset threshold, threshold segmentation is used to determine the defect area, each defect area is individually marked, and a defect area determination result is generated;
[0028] S223: According to the defect area determination result, the geometric position and morphological characteristics of the defect are recorded, and the boundary coordinates, area and perimeter of each defect area are counted to generate defect feature data.
[0029] As a further solution of the present invention, the calculation steps of the grayscale frequency distribution are:
[0030] S311: using the defect feature data, separating each defect area, converting the defect area into a grayscale image, extracting grayscale image data of each defect, and generating a grayscale image data set;
[0031] S312: Analyzing the grayscale value pixel by pixel through the grayscale image data set, accumulating the number of pixels for each grayscale level, and generating a grayscale level pixel counting result;
[0032] S313: According to the pixel counting result of the gray level, the formula is used:
[0033]
[0034] Calculate the frequency P(g) of gray level g and obtain the gray frequency distribution record of each defect area, where n g is the number of pixels of gray level g, and N is the total number of pixels in the defect area.
[0035] As a further solution of the present invention, the step of obtaining the defect classification result is:
[0036] S321: Based on the gray frequency distribution record of each defect area, by analyzing the ratio and spatial arrangement of gray concentrated area and dispersed area, estimating the geometric shape and area of the defect, quantifying the shape and size of each defect area, and generating shape and size quantification data;
[0037] S322: using the shape and size quantitative data, automatically setting a grayscale threshold to distinguish defective and non-defective areas by analyzing the comparison between the quantitative data and the background grayscale, and generating isolated defective and non-defective areas;
[0038] S323: Applying morphological operations to the isolated defect and non-defect regions to extract morphological features of the defect regions, identifying and classifying defects based on the morphological features, and generating defect classification results.
[0039] As a further solution of the present invention, the steps of obtaining the defect distribution analysis report are:
[0040] S411: Based on the defect classification result, count the number of occurrences of each defect, summarize all defect data, and obtain a defect type summary result;
[0041] S412: Summarize the results according to the defect type, using the formula:
[0042]
[0043] Calculate the distribution percentage P of each type of defect on the die casting mold surface k , generate defect distribution ratio results, where n k represents the number of the kth defect, and K represents the total number of defect types;
[0044] S413: Perform data visualization processing according to the defect distribution ratio result, draw a defect distribution map, and obtain a defect analysis report.
[0045] A die-casting mold defect detection system based on image recognition, comprising:
[0046] The light source selection module selects a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material, irradiates it, uses a camera to capture the mold surface image, performs color correction and light compensation, and generates a high-definition original image;
[0047] The image processing module adjusts the contrast of the high-definition original image, highlights the edge information and reveals the image details, analyzes the edge information and background contrast, identifies the shape and position of the defect, extracts the defect contour, and generates a defect contour recognition result;
[0048] The defect location module calculates the image texture clarity value based on the defect contour recognition result, compares the texture clarity value of each area with a preset threshold, determines the defect area and marks it separately, records the geometric position and morphological characteristics of the defect, and generates defect feature data;
[0049] The grayscale analysis module uses the defect feature data to separate each defect area, and converts the defect area into a grayscale image, accumulates the number of pixels for each grayscale level, calculates the grayscale frequency, and obtains the grayscale frequency distribution record of each defect area;
[0050] The defect recognition module estimates the geometric shape and area of the defect based on the gray frequency distribution record of each defect area, quantifies the shape and size of each defect area, automatically sets the gray threshold to distinguish between defect and non-defect areas, extracts the morphological features of the defect area, identifies and classifies the defects, and generates defect classification results;
[0051] Based on the defect classification results, the data statistics module counts the number of occurrences of each defect, calculates the distribution percentage of each type of defect on the surface of the die-casting mold, performs data visualization, draws a defect distribution map, and obtains a defect analysis report.
[0052] Compared with the prior art, the advantages and positive effects of the present invention are:
[0053] In the present invention, by adjusting the color depth and contrast of the high-definition original image, the highlighting of defect features is greatly improved, the recognizability of surface defects such as cracks and pores is enhanced, the accuracy of detection is improved, the detail disclosure and the identification of defect contours are further accurately separated from the background, the accuracy and efficiency of the analysis are optimized, and the accurate quantification of the defect shape and size is achieved through grayscale analysis, which provides quantitative data for defect management and mold maintenance, comprehensively improves the service life of the die-casting mold, and reduces production problems caused by defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 It is a main step flow chart of the present invention;
[0055] Figure 2This is a flow chart for outputting high-definition original images of the present invention;
[0056] Figure 3 is a flow chart for identifying defect contours of the present invention;
[0057] Figure 4 It is a flow chart of obtaining defect characteristic data of the present invention;
[0058] Figure 5 is a calculation flow chart of grayscale frequency distribution of the present invention;
[0059] Figure 6 A flowchart for obtaining defect classification results of the present invention;
[0060] Figure 7 The figure is a flow chart for obtaining the defect distribution analysis report of the present invention. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0062] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, in the description of the present invention, "multiple" means two or more, unless otherwise clearly and specifically defined.
[0063] See also Figure 1 , a die casting mold defect detection method based on image recognition, comprising the following steps:
[0064] S1: Use a target wavelength light source to illuminate the die-casting mold surface, use a camera to capture the mold surface image, perform color correction and lighting compensation on the captured mold surface image, and save the output high-definition original image;
[0065] S2: Based on the high-definition original image, adjust the contrast to highlight the defect features, extract the image edge information and reveal the image details, identify the defect outline, calculate the texture clarity based on the defect outline recognition result, separate the defect area, mark each defect area, record the position and shape of each defect, and generate defect feature data;
[0066] S3: Based on the defect feature data, grayscale analysis is performed to calculate the grayscale frequency distribution of each defect area. The shape and size of the defect area are quantified according to the grayscale frequency distribution calculation results, and the defect and non-defect areas are isolated. Each type of defect is classified according to the morphological characteristics to generate defect classification results;
[0067] S4: Based on the defect classification results, the number and type of defects are summarized and analyzed, the distribution ratio of different types of defects on the surface of the die-casting mold is calculated, the defect distribution map is drawn, and a defect distribution analysis report is generated.
[0068] The high-definition original image includes color correction results and lighting compensation effects; the defect feature data includes defect position records, defect morphology records and texture clarity calculation results; the defect classification results include defect shape quantification results, defect size quantification results and defect morphology classification results; the defect distribution analysis report includes defect quantity summary records, defect type analysis results and defect distribution diagram.
[0069] See also Figure 2 , the output steps of the high-definition original image are:
[0070] S111: Select a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material, perform irradiation, adjust the light source angle to evenly cover the mold surface, and generate a target wavelength light source irradiation result;
[0071] In the process of selecting a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material for irradiation, it is first necessary to determine the spectral characteristics of the mold material, including spectral analysis of the material sample and recording the specific data of its absorption and reflection spectra. Based on the analysis results, select the wavelength of the light source that can maximize energy absorption and minimize reflection, usually in the visible to near-infrared range. Next, for the selected light source, adjust the position of the light source from the mold and measure the uniformity and intensity of the light at different distances. Use a illuminance meter to measure the light intensity at the irradiation point and adjust the light source until the desired lighting coverage and uniformity are achieved. In addition, it is necessary to calculate the power output of the required light source to ensure sufficient lighting intensity across the entire mold surface.
[0072] S112: according to the target wavelength light source irradiation result, use a camera to capture the mold surface image, adjust the camera exposure time and ISO to match the current lighting conditions, and generate a captured original image;
[0073] Based on the illumination effect of the target wavelength light source, when using a camera to capture the image of the mold surface, first adjust the basic settings of the camera, including exposure time, ISO sensitivity, and aperture size, according to the physical characteristics of the mold and the ambient lighting conditions. Through field testing of the effects of different settings, select the configuration that best highlights the details of the mold surface. In order to further improve the image quality, real-time monitoring is used to dynamically adjust the focus and exposure parameters. This process also includes the use of high dynamic range imaging technology (HDR) to enhance the image contrast and detail display of the mold surface. By continuously capturing multiple frames of images, analyzing image data, and adjusting camera parameters to adapt to the reflective or shadowed areas on the mold surface, the most suitable photography technology parameters are finally determined to ensure that the captured image can clearly reflect the true state of the mold surface.
[0074] S113: Perform color correction and illumination compensation on the captured original image using the formula:
[0075]
[0076] Calculate the corrected color value C corrected , adjust the image to match the real color representation and generate a high-definition original image, where C raw Represents the original image color value, L current Represents the current light intensity, L optimal Represents the ideal light intensity;
[0077] By measuring the photometer on site, we can get L current =1000lux, and L optimal According to the setting requirements, it is 1200 lux. The color value of the original image is C raw Obtained from camera capture data, set to 0.5.
[0078] First calculate the ratio of the difference in light intensity:
[0079]
[0080] Apply the formula to calculate the corrected color value:
[0081] C corrected =0.5×(1+0.1667)=0.5×1.1667=0.58335
[0082] Calculations show that since the current light intensity is lower than the ideal light intensity, the color value of the original image needs to be increased by approximately 16.67% to compensate for the lack of light, and 0.58335 reflects the color enhancement ratio required from the current light condition (1000 lux) to the ideal light condition (1200 lux), making the color of the image closer to the real color under ideal light conditions. Through this correction, the visual accuracy and quality of the image can be ensured.
[0083] See also Figure 3 , the identification steps of defect contour are:
[0084] S211: Adjust the contrast of the HD original image using the formula:
[0085]
[0086] Calculate the adjusted contrast value C new , and get the image after contrast adjustment, where C original represents the contrast of the original image, σ represents the standard deviation of the contrast adjustment, and μ represents the average value of the contrast of the original image;
[0087] C original =120, representing the contrast value of the original image, obtained by selecting typical values from the contrast statistics of multiple sample images;
[0088] σ = 15, representing the standard deviation of contrast, which is calculated based on the contrast variation range in the image dataset;
[0089] μ = 100, which represents the average value of the contrast of the original image, and is calculated based on the average value of the contrast in a large number of image samples.
[0090] First calculate the absolute value of the difference between the contrast and the mean:
[0091] |C original -μ|=|120-100|=20
[0092] Take the square root of the absolute value of the difference:
[0093]
[0094] Calculate the adjusted contrast:
[0095]
[0096] The results show that the adjusted contrast value is C new≈402.68, indicating that the contrast of the image has increased significantly from 120 to about 402.68, indicating that the light-dark contrast in the image has been enhanced. By improving the contrast, the detail levels and edge features in the image are more clearly distinguished, which is crucial for subsequent edge detection and defect contour recognition.
[0097] S212: performing edge detection based on the contrast-adjusted image to highlight edge information and reveal image details, thereby obtaining an image edge information result;
[0098] Based on the image after contrast adjustment, the change of image gradient is calculated by pixel-by-pixel processing, and the Laplace operator is used to extract the edge information of the image. First, the gradient of the grayscale value of each pixel is calculated, and the difference in grayscale value between each pixel and its surrounding pixels is calculated. The difference value is cumulatively analyzed to generate a gradient distribution map. The threshold of gradient change is set to determine whether it is an edge point, and the gradient change area exceeding the threshold is extracted as edge information. At the same time, the second-order derivative of the local pixel area is calculated to enhance the edge feature signal and reduce the interference of noise in the image on the edge result. The process is completed by scanning row by row and column by column in the entire image range, and finally the edge information of the image is generated.
[0099] S213: Based on the image edge information result, analyze the edge information and background contrast, identify the shape and position of the defect, extract the defect contour, and generate a defect contour recognition result;
[0100] From the image edge information, the defect contour is identified through the grayscale threshold segmentation technology. First, the grayscale value statistical analysis of the image edge information is performed, the grayscale value distribution of all pixels in the image is calculated, and an optimal grayscale threshold is determined. The threshold divides the image into foreground and background areas. The foreground area is the possible defect area. All edge points in the foreground area are connected to form a closed contour. At the same time, the connected edge points are geometrically analyzed, including calculating the area, perimeter, geometric center and other features of each defect area. By statistically analyzing the geometric features, those that do not meet the preset conditions (such as areas that are too small or too large) are eliminated, and only possible defect contours are retained, providing a basis for positioning and morphological description.
[0101] See also Figure 4 , the steps for obtaining defect feature data are:
[0102] S221: Based on the defect contour recognition results, the formula is used:
[0103]
[0104] Calculate the image texture clarity value T and obtain the overall texture clarity calculation result, where N represents the total number of pixels in the defect area, and p i represents the gray value of the i-th pixel, ri represents the gray level of the pixel, and u is the average gray level;
[0105] N: the total number of pixels in the defect area, which is 10000;
[0106] The gray value p of each pixel i : Assume that these values are randomly distributed in the range of 140 to 160, and take a specific value, such as 145, to simplify the calculation.
[0107] The gray level of each pixel is r i : Assume that the values are randomly distributed in the range of 130 to 170, and take a specific value, such as 155.
[0108] The average gray level of all pixels u: based on r i range, set a different i The average value of, for example, 145.
[0109] Now, rerun the calculation using these new specific parameters.
[0110] Calculate r for each pixel i -μ:
[0111] 155-145=10
[0112] Calculate the denominator for each pixel:
[0113] 1+(10) 2 =101
[0114] Sum the grayscale values of all pixels:
[0115]
[0116] The final texture clarity T is calculated as:
[0117]
[0118] The final calculated texture clarity T is about 14.356, indicating that the texture clarity in the defect area is low, indicating that the texture changes greatly and the texture features are not obvious. Further image processing technology is needed to improve the usability of the image.
[0119] S222: According to the overall texture clarity calculation result, by comparing the texture clarity value of each area with a preset threshold, threshold segmentation is used to determine the defect area, each defect area is individually marked, and a defect area determination result is generated;
[0120] In the step of separating high-definition defect areas, a threshold based on texture clarity is first determined through statistical analysis of the gray value distribution. This threshold is determined based on the average texture clarity plus its standard deviation, which is calculated as follows: First, the average texture clarity of all marked defect areas is calculated and set to 14.356; then, the standard deviation is calculated and the value is assumed to be 10; therefore, the threshold is set to 20. Next, the system scans the texture clarity of each defect area and compares the clarity value of each area with 20. Areas exceeding this threshold are identified as high-definition areas and marked. This method ensures that only areas with significantly high texture clarity are selected, improving the accuracy of subsequent processing.
[0121] S223: According to the defect area determination result, the geometric position and morphological characteristics of the defect are recorded, the boundary coordinates, area and perimeter of each defect area are counted, and defect feature data is generated;
[0122] A detailed morphological feature analysis is performed on each marked defect area, including determining the boundary coordinates of each area and its geometric characteristics. First, the outer contour of each area is identified using edge detection technology, and then the area and perimeter of each defect are calculated through geometric analysis. For the calculation of the area, the pixel counting method is used, that is, the number of pixels in each area is counted; the perimeter is obtained by tracing the pixels on the boundary contour and accumulating them. In addition, the geometric center of each defect is calculated, that is, it is determined by the average coordinate value of all boundary points. These geometric data are sorted and recorded to generate a detailed data record for each defect, including information such as location, size and shape. This information is the basis for subsequent defect classification and analysis, ensuring the comprehensiveness of the data and the depth of analysis.
[0123] See also Figure 5 , the calculation steps of gray frequency distribution are:
[0124] S311: using the defect feature data, separating each defect area, converting the defect area into a grayscale image, extracting the grayscale image data of each defect, and generating a grayscale image data set;
[0125] Using the defect feature data, the image is first read and analyzed, the specific image file is retrieved from the database, and loaded into an operable image format. Then, for each identified defect area, the image segmentation technology is used to separate the defect area from the surrounding environment. Next, the grayscale conversion algorithm is applied to the defect area to convert the color or other format image into a grayscale image. The grayscale processing is achieved by calculating the weighted average of the red, green, and blue channels of each pixel. The processed image will only contain brightness information but no color information, which is crucial for the subsequent pixel-level grayscale analysis because the grayscale value is directly related to the subsequent grayscale analysis and pixel statistics, generating an image data set containing the grayscale information of each defect area.
[0126] S312: Analyze the grayscale value pixel by pixel through the grayscale image data set, accumulate the number of pixels for each grayscale level, and generate a grayscale pixel counting result;
[0127] According to the grayscale image data set obtained, the next step is to perform a detailed grayscale analysis on these data. The analysis process starts with counting the grayscale value of each pixel in the image. The grayscale value of each pixel is extracted and recorded to construct a histogram of grayscale distribution. The histogram shows the distribution of the number of pixels at each grayscale level in the image. The operation requires traversing each pixel in the image, reading its grayscale value, and accumulating the count at the corresponding grayscale level. The process is automatically completed on the computer through programming, ensuring the speed and accuracy of data processing. At the same time, after counting the number of pixels at each grayscale level, the data is organized into a table format to establish a clear record of the number of pixels for each grayscale level. The record is the basis for analyzing the grayscale distribution of the image and provides the necessary data support for subsequent steps to obtain detailed pixel counting results for each grayscale level.
[0128] S313: According to the pixel counting result of the gray level, the formula is used:
[0129]
[0130] Calculate the frequency P(g) of gray level g and obtain the gray frequency distribution record of each defect area, where n g is the number of pixels of gray level g, and N is the total number of pixels in the defect area;
[0131] In a specific defect area, the total number of pixels N = 10,000 pixels, the number of pixels n with gray level g = 14.356 g = 1500. The frequency of this gray level is calculated as:
[0132]
[0133] This means that the gray level 14.356 accounts for 15% of the total pixels, thus obtaining the gray frequency distribution of each defect area.
[0134] See also Figure 6 , the steps to obtain the defect classification results are:
[0135] S321: Based on the gray frequency distribution record of each defect area, by analyzing the ratio and spatial arrangement of the gray concentrated area and the scattered area, the geometric shape and area of the defect are estimated, and the shape and size of each defect area are quantified to generate shape and size quantification data;
[0136] First, load the grayscale frequency distribution data generated in the previous steps. The data reflects the grayscale value changes of different defect areas on the image, identifying patterns and trends in the data, especially the concentrated areas of grayscale values and boundary diffusion. Next, use edge detection algorithms, such as the Sobel operator, to scan these areas, identify and depict the precise outlines of the defects. By calculating the number and distribution density of pixels within these outlines, the area and shape of the defects can be estimated. These geometric data include the length, width, and approximate parameters of the irregular shape of the defects, ensuring the consistency and repeatability of the data.
[0137] S322: using the shape and size quantitative data, automatically setting a grayscale threshold to distinguish between defective and non-defective areas by analyzing the comparison between the quantitative data and the background grayscale, and generating isolated defective and non-defective areas;
[0138] By analyzing the shape and size data obtained, the threshold settings are automatically adjusted to distinguish defects from non-defective areas. A dynamic threshold algorithm is used, which evaluates the grayscale histogram of the entire image and automatically selects a threshold based on the total grayscale distribution of the image, which can maximize the contrast between the defective area and the background. After the threshold is determined, the algorithm traverses each pixel and marks the pixels above or below this threshold as defective or non-defective. This process not only relies on the precise calculation of the automated software, but also involves post-processing steps such as noise removal and small area filtering to ensure that the final image segmentation result is highly accurate and reliable.
[0139] S323: applying morphological operations to the isolated defect and non-defect regions to extract morphological features of the defect regions, identifying and classifying the defects through the morphological features, and generating defect classification results;
[0140] After successfully isolating the defective and non-defective areas, the next task is to perform a detailed morphological analysis of these areas. First, a morphological dilation process is applied to the defective area to emphasize the defect features by increasing the size of the structural elements, making the boundaries more obvious. Subsequently, an erosion process is performed to remove the non-feature noise introduced by the dilation. Through the two-step process, the features of each defect, such as edge sharpness, texture, and shape, are more prominent, facilitating subsequent classification and identification. During the classification process, the defects are pre-classified according to the morphological features, and the supervised learning method is combined with historical classification data to achieve accurate identification and classification of each type of defect.
[0141] See also Figure 7 , the steps to obtain the defect distribution analysis report are:
[0142] S411: Based on the defect classification result, count the number of occurrences of each defect, summarize all defect data, and obtain a defect type summary result;
[0143] Based on the known defect classification results, the number of each type of defects is counted through the weighted frequency analysis method. First, all types of defect data in the mold are collected and preliminarily classified and summarized. Then, by setting appropriate frequency weights, the number of each type of defects is weighted and calculated to ensure that the statistical results are closer to the frequency of occurrence of each type of defects in actual production. This method can accurately calculate the actual number of each defect type in the production process, providing basic data support for subsequent defect type analysis, and finally generating a defect type summary result.
[0144] S412: Summarize the results by defect type, using the formula:
[0145]
[0146] Calculate the distribution percentage P of each type of defect on the die casting mold surface k , generate defect distribution ratio results, where n k represents the number of the kth defect, and K represents the total number of defect types;
[0147] If a total of 500 defects are detected in the die casting mold, of which 100 are defects of the first type, the distribution ratio of the first type of defects is calculated as follows:
[0148]
[0149] This means that the first type of defects account for 20% of the total defects. This result shows the proportion of this type of defects in all defects, which has guiding significance for the formulation of defect prevention and improvement measures.
[0150] S413: Perform data visualization processing according to the defect distribution ratio result, draw a defect distribution map, and obtain a defect analysis report result;
[0151] According to the defect distribution ratio results, data visualization technology is used to draw a defect distribution map. In this process, the distribution ratio of each defect is first converted into a visually recognizable chart element, such as bars of different colors or sizes. Then, the appropriate scale and chart type, such as a bar chart or pie chart, are set through the chart design software to ensure that the proportions of various defect types are visually accurately presented. In addition, the annotations and legends of the chart need to be adjusted to clearly express the information so that the observer can read the data directly from the chart. After the chart is completed, it is integrated with the previous statistical data and analysis results to form a detailed defect distribution analysis report. This report not only shows the number and type of various defects, but also intuitively reveals the distribution of these defects on the entire die-casting mold surface through charts, providing a basis for formulating further quality control measures.
[0152] A die-casting mold defect detection system based on image recognition, comprising:
[0153] The light source selection module selects a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material, irradiates it, uses a camera to capture the mold surface image, performs color correction and light compensation, and generates a high-definition original image;
[0154] The image processing module adjusts the contrast of the high-definition original image, highlights the edge information and reveals the image details, analyzes the edge information and background contrast, identifies the shape and position of the defect, extracts the defect contour, and generates the defect contour recognition result;
[0155] The defect location module calculates the image texture clarity value based on the defect contour recognition result, compares the texture clarity value of each area with the preset threshold, determines the defect area and marks it separately, records the geometric position and morphological characteristics of the defect, and generates defect feature data;
[0156] The grayscale analysis module uses defect feature data to separate each defect area and convert the defect area into a grayscale image, accumulates the number of pixels for each grayscale level, calculates the grayscale frequency, and obtains the grayscale frequency distribution record of each defect area;
[0157] The defect recognition module estimates the geometric shape and area of the defect based on the gray frequency distribution record of each defect area, quantifies the shape and size of each defect area, automatically sets the gray threshold to distinguish between defect and non-defect areas, extracts the morphological features of the defect area, identifies and classifies the defects, and generates defect classification results;
[0158] Based on the defect classification results, the data statistics module counts the number of occurrences of each defect, calculates the distribution percentage of each type of defect on the surface of the die-casting mold, performs data visualization, draws a defect distribution map, and obtains a defect analysis report.
[0159] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in other forms. Any technician familiar with the profession may use the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A die-casting mold defect detection method based on image recognition, characterized in that: The following steps are involved: Use a light source with a target wavelength to illuminate the die-casting mold surface, use a camera to capture the mold surface image, perform color correction and light compensation on the captured mold surface image, and save and output a high-definition original image; Based on the high-definition original image, adjust the contrast to highlight the defect features, extract image edge information and reveal image details, identify the defect contour, calculate the texture clarity according to the defect contour recognition result, separate the defect area, mark each defect area, record the position and shape of each defect, and generate defect feature data; Based on the defect feature data, grayscale analysis is performed to calculate the grayscale frequency distribution of each defect area, the shape and size of the defect area are quantified according to the grayscale frequency distribution calculation result, the defect and non-defect areas are isolated, each type of defect is classified according to the morphological characteristics, and a defect classification result is generated; Based on the defect classification results, the number and type of defects are summarized and analyzed, the distribution ratio of different types of defects on the surface of the die-casting mold is calculated, a defect distribution map is drawn, and a defect distribution analysis report is generated.
2. The die-casting mold defect detection method based on image recognition according to claim 1 is characterized in that: The output steps of the high-definition original image are: Select a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material, perform irradiation, adjust the light source angle to evenly cover the mold surface, and generate the target wavelength light source irradiation result; According to the target wavelength light source irradiation result, use a camera to capture the mold surface image, adjust the camera exposure time and ISO to match the current lighting conditions, and generate a captured original image; The captured original image is subjected to color correction and illumination compensation using the formula: Calculate the corrected color value C corrected , adjust the image to match the real color representation and generate a high-definition original image, where C raw Represents the original image color value, L current Represents the current light intensity, L optimal Represents ideal light intensity.
3. The die-casting mold defect detection method based on image recognition according to claim 2 is characterized in that: The steps of identifying the defect contour are: The contrast of the high-definition original image is adjusted using the formula: Calculate the adjusted contrast value C new , and get the image after contrast adjustment, where C original represents the contrast of the original image, σ represents the standard deviation of the contrast adjustment, and μ represents the average value of the contrast of the original image; Based on the contrast-adjusted image, edge detection is performed to highlight edge information and reveal image details to obtain image edge information results; Based on the image edge information result, the edge information and background contrast are analyzed, the shape and position of the defect are identified, the defect contour is extracted, and the defect contour recognition result is generated.
4. The die-casting mold defect detection method based on image recognition according to claim 3 is characterized in that: The steps for obtaining the defect feature data are as follows: Based on the defect contour recognition results, the formula is adopted: Calculate the image texture clarity value T and obtain the overall texture clarity calculation result, where N represents the total number of pixels in the defect area, p i represents the gray value of the i-th pixel, r i represents the gray level of the pixel, and u is the average gray level; According to the overall texture clarity calculation result, by comparing the texture clarity value of each area with a preset threshold, threshold segmentation is used to determine the defect area, each defect area is individually marked, and a defect area determination result is generated; According to the defect area determination result, the geometric position and morphological characteristics of the defect are recorded, the boundary coordinates, area and perimeter of each defect area are counted, and defect feature data is generated.
5. The die-casting mold defect detection method based on image recognition according to claim 4 is characterized in that: The calculation steps of the gray frequency distribution are: Using the defect feature data, separate each defect area, convert the defect area into a grayscale image, extract the grayscale image data of each defect, and generate a grayscale image data set; By using the grayscale image data set, the grayscale value is analyzed pixel by pixel, the number of pixels is accumulated for each grayscale level, and a pixel counting result of the grayscale level is generated; According to the pixel counting result of the gray level, the formula is adopted: Calculate the frequency P(g) of gray level g and obtain the gray frequency distribution record of each defect area, where n g is the number of pixels of gray level g, and N is the total number of pixels in the defect area.
6. The die-casting mold defect detection method based on image recognition according to claim 5 is characterized in that: The steps for obtaining the defect classification result are: Based on the gray frequency distribution record of each defect area, by analyzing the ratio and spatial arrangement of gray concentration area and dispersion area, the geometric shape and area of the defect are estimated, the shape and size of each defect area are quantified, and shape and size quantification data are generated; Using the shape and size quantitative data, by analyzing the comparison between the quantitative data and the background grayscale, automatically setting the grayscale threshold to distinguish between defective and non-defective areas, and generating isolated defective and non-defective areas; Morphological operations are applied to the isolated defect and non-defect regions to extract morphological features of the defect regions, and defects are identified and classified by the morphological features to generate defect classification results.
7. The die-casting mold defect detection method based on image recognition according to claim 6 is characterized in that: The steps for obtaining the defect distribution analysis report are as follows: Based on the defect classification results, the number of occurrences of each defect is counted, all defect data are summarized, and a defect type summary result is obtained; Summarize the results according to the defect type, using the formula: Calculate the distribution percentage P of each type of defect on the die casting mold surface k , generate defect distribution ratio results, where n k represents the number of the kth defect, and K represents the total number of defect types; According to the defect distribution ratio result, data visualization processing is performed, a defect distribution map is drawn, and a defect analysis report is obtained.
8. A die-casting mold defect detection system based on image recognition, characterized in that: The system is used to execute the die-casting mold defect detection method based on image recognition according to any one of claims 1 to 7, comprising: The light source selection module selects a target wavelength light source that matches the spectral absorption characteristics of the die-casting mold material, irradiates it, uses a camera to capture the mold surface image, performs color correction and light compensation, and generates a high-definition original image; The image processing module adjusts the contrast of the high-definition original image, highlights the edge information and reveals the image details, analyzes the edge information and background contrast, identifies the shape and position of the defect, extracts the defect contour, and generates a defect contour recognition result; The defect location module calculates the image texture clarity value based on the defect contour recognition result, compares the texture clarity value of each area with a preset threshold, determines the defect area and marks it separately, records the geometric position and morphological characteristics of the defect, and generates defect feature data; The grayscale analysis module uses the defect feature data to separate each defect area, and converts the defect area into a grayscale image, accumulates the number of pixels for each grayscale level, calculates the grayscale frequency, and obtains the grayscale frequency distribution record of each defect area; The defect recognition module estimates the geometric shape and area of the defect based on the gray frequency distribution record of each defect area, quantifies the shape and size of each defect area, automatically sets the gray threshold to distinguish between defect and non-defect areas, extracts the morphological features of the defect area, identifies and classifies the defects, and generates defect classification results; Based on the defect classification results, the data statistics module counts the number of occurrences of each defect, calculates the distribution percentage of each type of defect on the surface of the die-casting mold, performs data visualization, draws a defect distribution map, and obtains a defect analysis report.
Citation Information
Cited By
Color ring element appearance detection device and detection system based on machine vision
CN120177368A
Test paper bag packaging detection system based on machine vision
CN120598915A
Intelligent packaging production line defect detection method and system based on image recognition model
CN120782735A
Pile hole sediment thickness identification method and system based on machine vision
CN121147281A