Injection molded part detection system and method thereof
Through technologies such as dynamic filtering and superpixel segmentation, the filter intensity is adaptively adjusted, which solves the accuracy of injection molded parts detection in complex light sources and dynamic scenarios, and achieves the detection effect of efficiently removing noise while retaining key details.
Patent Information
- Application Number
- CN202510182267.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-02-19
AI Technical Summary
Existing methods for detecting injection molded parts are easily disturbed under complex light source conditions, resulting in inaccurate detection results. Especially when injection molded parts move rapidly, the brightness difference in part of the image area is very large, and the static histogram equalization operation is difficult to adapt to this dynamic scene, which may lead to excessively enhancement of the highlighted area or loss of information in the shadow area.
By obtaining the grayscale image of the injection molded parts, calculating the gradient amplitude map and performing dynamic filtering, adaptively adjusting the filter intensity to remove noise while preserving key details. The superpixel segmentation algorithm is used to identify the grayscale area, and the edge texture is determined through the edge detection algorithm. The intersection point between the spot area and the wave edge and the distance to the injection point is matched to fit the overall edge, and the quality of the injection molded parts is evaluated in the integration of all edges and wave areas.
In complex light sources and dynamic scenarios, dynamic filtering technology effectively removes noise, retains important details, improves the accuracy and reliability of injection molded parts detection, and avoids the problem of loss of details.
Smart Images

Figure CN120070391A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of injection molded part inspection, and more specifically, to an injection molded part inspection system and method thereof. Background Art
[0002] In modern manufacturing, the quality inspection of injection molded parts is an important link to ensure product quality. Traditional methods for quality inspection of injection molded parts mainly rely on manual visual inspection or simple edge detection algorithms. These methods are easily interfered under complex light source conditions, resulting in inaccurate inspection results. To overcome these problems, some automatic inspection methods based on image processing technology have emerged in recent years. Among them, the patent with the publication number CN118334019A proposes an injection molded part inspection method and system. This method evaluates the quality of injection molded parts by obtaining the grayscale image of the injection molded part and combining the wave texture and spot area features.
[0003] Although CN118334019A provides a relatively advanced solution, there are still some areas that need improvement. First, in the image preprocessing stage, this method uses conventional image denoising and grayscale processing. Although these steps can initially remove noise and simplify image information, for complex surface defects of injection molded parts (such as fine cracks, bubbles, etc.), the effect is not ideal. Especially for overly strong noise suppression means, it may erase the details of the wave edge, resulting in feature loss. This phenomenon is particularly obvious in the actual production environment because injection molded parts usually move quickly on the conveyor belt, and the light source and angle are constantly changing, making the brightness difference in some areas of the image very large. The static histogram equalization operation is difficult to adapt to the local grayscale changes in this dynamic scenario, which may lead to over-enhancement of the high-brightness area or loss of information in the shadow area.
[0004] Therefore, an optimized injection molded part inspection solution is expected. Summary of the Invention
[0005] To solve the above technical problems, this application is proposed. The embodiments of this application provide an injection molded part inspection system and method thereof, which can adaptively adjust the filtering intensity according to the local features of the image, avoiding the problem of detail loss that may be caused by overly strong noise suppression means. Especially in the case where the injection molded part moves quickly on the conveyor belt, this method can better adapt to the dynamic scenario where the light source and angle are constantly changing, and maintain the important details in the image.
[0006] According to one aspect of the present application, an injection molded part detection method is provided, including: obtaining a grayscale image of the injection molded part, determining edge textures and grayscale regions in the grayscale image; identifying mutually matching pixel points based on the slope features of pixel points in the nearest edge texture; screening out wavy edges from the edge textures in combination with texture morphology, grayscale distribution, and distance features; identifying a light spot region based on the overall morphology of the grayscale region and the grayscale values of pixel points; using the intersection points of the light spot region and the wavy edges and their distances from the injection points to perform pairwise matching of the intersection points, and accordingly fitting the overall edge; comprehensively using all the overall edges and the wavy edges that do not intersect with the light spot region to define the wavy region, thereby evaluating the injection quality of the injection molded part. Among them, obtaining the grayscale image of the injection molded part and determining the edge textures and grayscale regions in the grayscale image includes: obtaining the original RGB image of the injection molded part; performing grayscale processing on the original RGB image to obtain the grayscale image of the injection molded part; calculating the gradient magnitude map of the grayscale image; performing dynamic filtering on the grayscale image based on the gradient magnitude map to obtain a denoised grayscale image; using a superpixel segmentation algorithm to process the denoised grayscale image to obtain the grayscale region; using an edge detection algorithm to process the denoised grayscale image to obtain the edge texture.
[0007] In the above injection molded part detection method, calculating the gradient magnitude map of the grayscale image includes: calculating the grayscale change value of each pixel point in the grayscale image in the vertical direction; calculating the grayscale change value of each pixel point in the grayscale image in the horizontal direction; determining the gradient magnitude of each pixel point based on the grayscale change value of each pixel point in the horizontal direction and the grayscale change value in the vertical direction.
[0008] In the above injection molded part detection method, calculating the grayscale change value of each pixel point in the grayscale image in the horizontal direction includes: calculating the grayscale change value of each pixel point in the grayscale image in the horizontal direction according to the following formula, where the formula is: ; where represents the grayscale value of pixel point in the grayscale image, represents the grayscale value of pixel point in the grayscale image, represents the grayscale change value of pixel point in the horizontal direction in the grayscale image.
[0009] Calculating the grayscale change value of each pixel point in the grayscale image in the vertical direction includes: calculating the grayscale change value of each pixel point in the grayscale image in the vertical direction according to the following formula, where the formula is: ; where represents the grayscale value of pixel point The gray value, represents the pixel point in the grayscale image The gray value, represents the pixel point in the grayscale image The gray value change in the vertical direction.
[0010] Based on the gray value changes of each pixel point in the horizontal direction and the gray value changes in the vertical direction, determining the gradient magnitude of each pixel point includes: calculating the gradient magnitude of each pixel point using the following formula, and the formula is: ; where represents the pixel point in the grayscale image The gradient magnitude.
[0011] In the above-mentioned injection molding part detection method, based on the gradient magnitude map, dynamically filtering the grayscale image to obtain a denoised grayscale image includes: defining a filtering weight function and calculating the filtering weight function values of each pixel point in the grayscale image respectively, where the filtering weight function is related to the gradient magnitude of each pixel point; determining the local neighborhood of each pixel point in the grayscale map; calculating the smoothing value of this pixel point based on the gradient magnitudes and filtering weight function values of all pixel points in the local neighborhood as the gray value of this pixel point in the denoised grayscale image.
[0012] In the above-mentioned injection molding part detection method, the filtering weight function is: ; where represents the gradient magnitude of each pixel point, is a control factor used to adjust the attenuation rate of the weight, represents the natural constant, represents the filtering weight function value of each pixel point.
[0013] In the above-mentioned injection molding part detection method, calculating the smoothing value of this pixel point based on the gradient magnitudes and filtering weight function values of all pixel points in the local neighborhood as the gray value of this pixel point in the denoised grayscale image includes: calculating the neighborhood pixel similarity of the local neighborhood based on the gray values of all pixel points in the local neighborhood; calculating the smoothing value of this pixel point based on the neighborhood pixel similarity and the filtering weight function values of all pixel points in the local neighborhood as the gray value of this pixel point in the denoised grayscale image.
[0014] In the above-mentioned injection molding part detection method, calculating the neighborhood pixel similarity of the local neighborhood based on the gray values of all pixel points in the local neighborhood includes: calculating the neighborhood pixel similarity of the local neighborhood using the following formula, where the formula is: ; where represents the pixel point in the grayscale image The grayscale value, indicating the pixel point in the grayscale image The grayscale value, is the local neighborhood, is the control factor for the influence of the filtering intensity, indicating the neighborhood pixel similarity of the local neighborhood.
[0015] In the above injection molded part detection method, based on the neighborhood pixel similarity and the filtering weight function values of all pixel points in the local neighborhood, calculating the smoothing value of this pixel point as the grayscale value of this pixel point in the denoised grayscale image includes: calculating the smoothing value of this pixel point as the grayscale value of this pixel point in the denoised grayscale image according to the following formula, and the formula is: ; where, indicating the pixel point in the grayscale image The gradient magnitude of, indicating the pixel point in the grayscale image The filtering weight function value of, indicating the pixel point in the denoised grayscale image The grayscale value of.
[0016] In the above injection molded part detection method, based on the neighborhood pixel similarity and the filtering weight function values of all pixel points in the local neighborhood, calculating the smoothing value of this pixel point as the grayscale value of this pixel point in the denoised grayscale image further includes: calculating the diffusion coefficient of the filtering weight function of this pixel point; based on the diffusion coefficient, using the local neighborhood edge stopping mechanism to correct the filtering weight function of this pixel point to obtain the corrected filtering weight function of this pixel point.
[0017] According to another aspect of the present application, there is also provided an injection molded part detection system, the injection molded part detection system includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that when the processor executes the computer program, the steps of the injection molded part detection method as described above are implemented.
[0018] Compared with the prior art, the injection molded part detection system and method provided by this application first grayscale the acquired RGB image and calculate the gradient magnitude map for dynamic filtering and noise reduction, so as to obtain a clear grayscale image. Then, the superpixel segmentation algorithm is used to identify the grayscale regions, and the edge detection algorithm is used to determine the edge texture. Based on the slope characteristics of the pixel points in the nearest edge texture, the pixel points are matched, the wavy edges are screened out, and the light spot regions are identified. By combining the intersection points of the light spot regions and the wavy edges and the distances from the injection points for matching, the overall edge is fitted. Finally, all the edges and wavy regions are comprehensively used to evaluate the quality of the injection molded part. Here, the dynamic filtering technology adaptively adjusts the filtering intensity according to local features, effectively removing noise while retaining key details, and is especially suitable for the scenario where important details of the image are maintained under changing light sources and angles for injection molded parts in fast movement. This method can avoid detail loss more effectively compared with traditional means. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] By describing the embodiments of the present application in more detail with reference to the accompanying drawings, the above and other objects, features, and advantages of the present application will become more obvious. The accompanying drawings are used to provide a further understanding of the embodiments of the present application, and constitute a part of the specification, and are used to explain the present application together with the embodiments of the present application, and do not constitute a limitation to the present application.
[0020] Figure 1 The schematic flow chart of the injection molded part detection method according to the embodiment of the present application is illustrated.
[0021] Figure 2 The schematic flow chart of S1 in the injection molded part detection method according to the embodiment of the present application is illustrated.
[0022] Figure 3 The schematic flow chart of S13 in the injection molded part detection method according to the embodiment of the present application is illustrated.
[0023] Figure 4 The schematic flow chart of S14 in the injection molded part detection method according to the embodiment of the present application is illustrated.
[0024] Figure 5 The schematic flow chart of S143 in the injection molded part detection method according to the embodiment of the present application is illustrated.
[0025] Figure 6 The schematic structural diagram of the injection molded part detection system according to the embodiment of the present application is illustrated. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] Next, exemplary embodiments according to the present application will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. It should be understood that the present application is not limited by the exemplary embodiments described herein.
[0027] Based on this, the present application provides an injection molded part detection method. Figure 1 FIG. illustrates a schematic flow chart of an injection molded part detection method according to an embodiment of the present application. As Figure 1 shown, the injection molded part detection method includes: S1, obtaining a grayscale image of the injection molded part and determining the edge texture and grayscale region in the grayscale image; S2, identifying mutually matching pixel points based on the slope characteristics of pixel points in the nearest edge texture; S3, screening out wavy edges from the edge texture by combining texture morphology, grayscale distribution, and distance characteristics; S4, identifying a light spot region based on the overall morphology of the grayscale region and the grayscale values of pixel points; S5, using the intersection points of the light spot region and the wavy edges and their distances from the glue injection points to perform pairwise matching of the intersection points, and thereby fitting the overall edge; S6, comprehensively using all the overall edges and the wavy edges that do not intersect with the light spot region to define the wavy region, so as to evaluate the injection quality of the injection molded part.
[0028] In step S1, a grayscale image of the injection molded part is obtained, and the edge texture and grayscale region in the grayscale image are determined. It should be understood that the edge texture refers to the regions in the image where the grayscale values change significantly, and these regions usually correspond to the boundaries or surface defects of the object. For injection molded parts, defects such as wavy patterns, cracks, and bubbles often appear as edge textures. These key features are extracted from the grayscale image. The edge texture can not only help identify the defects on the surface of the injection molded part, but also provide information about the shape, size, and location of these defects. At the same time, the grayscale region refers to the region composed of pixel points with similar grayscale values. Identifying the grayscale region can help better understand the overall structure of the injection molded part and provide a reference for subsequent defect detection.
[0029] In step S2, mutually matching pixel points are identified based on the slope characteristics of pixel points in the nearest edge texture. It should be understood that since the wavy patterns formed during the injection molding process of injection molded parts usually show a form of spreading from the center outwards, the pixel points on two adjacent edge textures often have similar slope characteristics. By calculating the slope of each pixel point on each edge texture and finding the pixel points with the same slope in the two nearest edge textures as the matching pixel points, the corresponding relationship between pixel points can be effectively established. This process not only helps the subsequent screening of wavy edges, but also improves the accuracy and reliability of the entire detection system.
[0030] In step S3, combining the texture morphology, gray-scale distribution, and distance features, the wave edges are screened out from the edge textures. Specifically, when screening out the wave edges from the edge textures by combining the texture morphology, gray-scale distribution, and distance features, it is necessary to comprehensively consider information from multiple dimensions. First, curve fitting is performed on each edge texture to obtain a fitting curve, and the mean distance between all pixel points in the target texture and the fitting curve is calculated to determine the fitting error index. The smaller the fitting error index, the smoother the texture, which conforms to the characteristics of the wave texture. Second, the difference between the mean gray value of all pixel points in the target texture and the mean gray value of all pixel points in the overall gray-scale image is calculated as the gray-scale difference index. The larger the gray-scale difference index, the closer the texture is to the gray-scale characteristics of the wave texture. Finally, the minimum Euclidean distance between any pixel point in the target texture and the matching pixel point on the nearest other edge texture is calculated as the matching distance, and the flow feature index is determined based on the dispersion degree of the matching distance. By comprehensively considering the fitting error index, gray-scale difference index, and flow feature index, the wave edges can be accurately screened out to ensure the accuracy of the detection results.
[0031] In step S4, based on the overall morphology of the gray-scale region and the gray values of pixel points, the light spot regions are identified. Specifically, the process of identifying the light spot regions depends on the overall morphology of the gray-scale region and the gray values of pixel points. Since the light spot regions usually appear as high-brightness regions with relatively high gray values and regular morphologies, the mean gray value of all pixel points in the gray-scale region can be calculated to obtain the regional gray-scale coefficient, and the gray-scale regions with regional gray-scale coefficients greater than the preset threshold are regarded as suspected regions. Then, the line segment connecting the two farthest pixel points in each suspected region is determined as the regional feature line segment, and the angle between this line segment and the preset reference line is calculated as the direction angle. By comparing the differences between the direction angles of all suspected regions and the overall direction mean value, the regional direction feature index is determined. In addition, the overall feature difference index can also be obtained by calculating the differences between the lengths of each suspected region and the lengths of other regional feature line segments. Finally, based on the regional direction feature index and the overall feature difference index, the light spot probability is calculated, and the suspected regions with light spot probabilities greater than the preset threshold are regarded as light spot regions.
[0032] In step S5, using the intersection points of the light spot area and the wave edge and their distances from the glue injection points, pairwise matching of the intersection points is performed, and the overall edge is fitted accordingly. It should be understood that pairwise matching of the intersection points using the intersection points of the light spot area and the wave edge and their distances from the glue injection points, and fitting the overall edge accordingly is a key step in the entire detection process. First, the pixel points that intersect with the wave edge in the same light spot area are determined as the intersection points, and the distance between each intersection point and the pre-set glue injection point is calculated as the diffusion distance. Then, according to the difference in the diffusion distance values of any two intersection points on the edge of the light spot area, pairwise matching is performed on them, so that the difference in the diffusion distance values between all the matched two intersection points is minimized. By this method, the partially occluded edge by the light spot can be effectively restored. Finally, by determining the tangents of the wave edge at the positions of the two matched intersection points, and based on the intersection of the tangents and the two tangents, a wave fitting curve is determined, and the two wave edges and the wave fitting curve together form a complete wave texture, that is, the overall edge.
[0033] In step S6, all the overall edges and the wave edges that do not intersect with the light spot area are comprehensively used to define the wave area, so as to evaluate the injection quality of the injection molded part. It should be understood that by evenly dividing the grayscale image into grid areas of the same size, and according to the proportion of the number of pixel points belonging to the overall edge and the wave edge that does not intersect with the light spot area in each grid area, the wave area is determined. Specifically, the grid area with a proportion greater than the preset proportion threshold is used as the wave area. This method can not only comprehensively cover the wave area, but also effectively avoid misjudgment problems caused by light spot occlusion, thereby improving the accuracy and reliability of the entire detection system.
[0034] In particular, considering that in the actual production environment, there may be various complex texture changes and noise interferences on the surface of the injection molded part. For this, although using conventional image denoising processing and grayscale processing can initially remove noise and simplify image information, for complex surface defects of injection molded parts (such as fine cracks, bubbles, etc.), the effect is not ideal. Especially for overly strong noise suppression means, it may erase the details of the wave edge, resulting in feature loss. Based on this, in this application, by performing preprocessing on the grayscale image through dynamic filtering technology, the filtering intensity can be adaptively adjusted according to the local features of the image, effectively removing noise while retaining key details. This is crucial for accurately identifying wave patterns and other subtle defects. In addition, combining with the gradient magnitude map for dynamic filtering can further enhance the important edge information in the image and improve the detection accuracy.
[0035] Specifically, as Figure 2As shown, obtain the grayscale image of the injection molded part, and determine the edge texture and grayscale area in the grayscale image, including: S11, obtain the original RGB image of the injection molded part; S12, perform grayscale processing on the original RGB image to obtain the grayscale image of the injection molded part; S13, calculate the gradient magnitude map of the grayscale image; S14, based on the gradient magnitude map, perform dynamic filtering on the grayscale image to obtain the denoised grayscale image; S15, use the superpixel segmentation algorithm to process the denoised grayscale image to obtain the grayscale area; S16, use the edge detection algorithm to process the denoised grayscale image to obtain the edge texture.
[0036] In step S11, obtain the original RGB image of the injection molded part. In a specific embodiment, image acquisition can be achieved by a high-resolution industrial camera installed above the conveyor belt. For example, use an industrial camera of the Basler ace series, which features high frame rate and high resolution and can capture the images of the fast-moving injection molded parts on the conveyor belt in real time. The camera is connected to the computer through a USB 3.0 interface and configured with corresponding image acquisition software (such as HALCON or OpenCV) to ensure efficient transmission and storage of image data. To ensure image quality, in actual operation, the light source needs to be precisely controlled. Usually, a ring-shaped LED light source is adopted, and its uniform illumination can effectively reduce shadows and reflections, thereby improving the consistency and clarity of the image. In addition, the shooting angle of the camera also needs to be adjusted to avoid image distortion caused by perspective problems. By fixing the camera at an appropriate height and angle, all details on the surface of the injection molded part can be accurately captured.
[0037] In step S12, perform grayscale processing on the original RGB image to obtain the grayscale image of the injection molded part. It should be understood that the grayscale image only contains luminance information and removes color information, thus simplifying the subsequent computational complexity. The pixel value of each pixel in the grayscale image represents the luminance of that point, and the range is usually between 0 and 255, which makes image processing algorithms easier to focus on luminance changes rather than complex color information. For the detection of surface defects of injection molded parts, features such as wavy patterns, cracks, and bubbles are mainly reflected in luminance changes. Therefore, the grayscale image can more effectively capture these key features.
[0038] In a specific embodiment, the cv2.cvtColor function in the OpenCV library can be used to implement this process. In a Python environment, it can be implemented through the following code: gray - image = cv2.cvtColor(raw - rgb - image, cv2.COLOR_BGR2GRAY). Here, raw - rgb - image is the original RGB image captured by an industrial camera, and gray - image is the converted grayscale image.
[0039] In step S13, calculate the gradient magnitude map of the grayscale image. It should be understood that in an actual production environment, there may be various noise interferences on the surface of the injection - molded part, such as sensor noise, ambient light changes, etc. These noises will cause unnecessary brightness fluctuations in the grayscale image, thus affecting the subsequent detection results. By calculating the gradient magnitude, it is possible to effectively distinguish which changes are caused by real edges and which are caused by noises. Specifically, real edges usually exhibit larger gradient magnitudes, while brightness fluctuations caused by noises show smaller gradient magnitudes. Based on this, an adaptive filtering strategy can be adopted in subsequent filtering processing, that is, less smoothing processing is performed on regions with larger gradient magnitudes to retain key edge information; while more smoothing processing is performed on regions with smaller gradient magnitudes to remove noise interferences. This adaptive filtering method can not only effectively remove noise but also maximize the retention of important details in the image, ensuring the accuracy of the detection results.
[0040] Another important reason is that the gradient magnitude map can provide support for local grayscale changes in a dynamic scene. On an industrial production line, injection - molded parts usually move quickly on a conveyor belt, and the light source and angle are constantly changing, resulting in very large brightness differences in some areas of the image. Static histogram equalization operations are difficult to adapt to such local grayscale changes in a dynamic scene, which may lead to over - enhancement of highlight areas or loss of information in shadow areas. By calculating the gradient magnitude map, the filtering intensity can be adaptively adjusted according to the local characteristics of the image, ensuring the retention of important details while removing noise. For example, in some cases, highlight areas may lose important details due to over - enhancement, while shadow areas may have unclear features due to information loss. By introducing dynamic filtering technology based on gradient magnitude, enhancement processing can be performed separately according to the local grayscale distribution characteristics of different regions of the image, avoiding the above problems, thereby improving the overall contrast and detail retention ability of the image.
[0041] In an embodiment, such as Figure 3As shown, calculating the gradient magnitude map of the grayscale image includes: S131, calculating the grayscale change value of each pixel point in the vertical direction of the grayscale image; S132, calculating the grayscale change value of each pixel point in the horizontal direction of the grayscale image; S133, determining the gradient magnitude of each pixel point based on the grayscale change value of each pixel point in the horizontal direction and the grayscale change value in the vertical direction.
[0042] More specifically, calculating the grayscale change value of each pixel point in the horizontal direction of the grayscale image includes: calculating the grayscale change value of each pixel point in the horizontal direction of the grayscale image with the following formula, where the formula is: ; where represents the grayscale value of pixel point in the grayscale image, represents the grayscale value of pixel point in the grayscale image, represents the grayscale change value of pixel point in the horizontal direction in the grayscale image.
[0043] Calculating the grayscale change value of each pixel point in the vertical direction of the grayscale image includes: calculating the grayscale change value of each pixel point in the vertical direction of the grayscale image with the following formula, where the formula is: ; where represents the grayscale value of pixel point in the grayscale image, represents the grayscale value of pixel point in the grayscale image, represents the grayscale change value of pixel point in the vertical direction in the grayscale image.
[0044] Determining the gradient magnitude of each pixel point based on the grayscale change value of each pixel point in the horizontal direction and the grayscale change value in the vertical direction includes: calculating the gradient magnitude of each pixel point with the following formula, and the formula is: ; where represents the gradient magnitude of pixel point in the grayscale image.
[0045] In step S14, based on the gradient magnitude map, the grayscale image is dynamically filtered to obtain a denoised grayscale image. It should be understood that in an actual production environment, there may be various noise interferences on the surface of the injection molded part, such as sensor noise, ambient light changes, etc. These noises will cause unnecessary brightness fluctuations in the grayscale image, thereby affecting the subsequent detection results. Although traditional global filtering methods (such as mean filtering or Gaussian filtering) can effectively remove noise, they often also blur the edge and detail features in the image, resulting in the loss of key information. The dynamic filtering based on the gradient magnitude map can adaptively adjust the filtering intensity according to the brightness change situation around each pixel point. For example, in areas with a large gradient magnitude (usually areas with edges or rich textures), a smaller filtering intensity can be used to retain these key features; while in areas with a small gradient magnitude (usually flat or noisy areas), a larger filtering intensity can be used to effectively remove noise. This adaptive method can maximize the retention of important details in the image while removing noise, ensuring the accuracy of the detection results.
[0046] Meanwhile, the dynamic filtering based on the gradient magnitude map helps to improve the accuracy of edge detection. Edges refer to areas in the image where the grayscale values change significantly, and these areas usually correspond to the boundaries of objects or surface defects. For injection molded parts, defects such as wavy patterns, cracks, and bubbles often manifest as edge textures. By calculating the grayscale change values of each pixel point in the grayscale image in the horizontal and vertical directions and further calculating the gradient magnitude, these edge features can be accurately captured. However, if an overly strong global filtering method is used in the preprocessing stage, these subtle edge information may be erased, resulting in inaccurate subsequent edge detection. In contrast, the dynamic filtering can adaptively adjust the filtering intensity according to the gradient magnitude map, ensuring the retention of key edge information while removing noise. For example, in some cases, the crack area may lose details due to excessive smoothing, while through dynamic filtering, these subtle crack features can be retained while removing noise, thereby improving the accuracy of edge detection.
[0047] In one embodiment, as Figure 4 shown, based on the gradient magnitude map, dynamically filtering the grayscale image to obtain a denoised grayscale image includes: S141, defining a filtering weight function and calculating the filtering weight function values of each pixel point in the grayscale image respectively, where the filtering weight function is related to the gradient magnitude of each pixel point; S142, determining the local neighborhood of each pixel point in the grayscale map; S143, calculating the smoothed value of this pixel point based on the gradient magnitudes and filtering weight function values of all pixel points in the local neighborhood as the grayscale value of this pixel point in the denoised grayscale image.
[0048] In one embodiment, the filtering weight function is: ; where represents the gradient magnitude of each pixel point, is a control factor for adjusting the attenuation rate of the weight, represents the natural constant, represents the filtering weight function value of each pixel point. Here, the filtering weight of each pixel point is determined according to the gradient magnitude of each pixel point. Regions with larger gradient magnitudes are usually regions with edges or rich details, so smaller filtering weights are required to preserve these important features; while regions with smaller gradient magnitudes are usually flat or noisy regions, so larger filtering weights are required to effectively remove noise.
[0049] In one embodiment, as Figure 5 shown, based on the gradient magnitudes and filtering weight function values of all pixel points in the local neighborhood, calculating the smoothing value of this pixel point as the gray value of this pixel point in the denoised gray image includes: S1431, calculating the neighborhood pixel similarity of the local neighborhood based on the gray values of all pixel points in the local neighborhood; S1432, calculating the smoothing value of this pixel point as the gray value of this pixel point in the denoised gray image based on the neighborhood pixel similarity and the filtering weight function values of all pixel points in the local neighborhood.
[0050] In one embodiment, calculating the neighborhood pixel similarity of the local neighborhood based on the gray values of all pixel points in the local neighborhood includes: calculating the neighborhood pixel similarity of the local neighborhood with the following formula, where the formula is: ; where represents the gray value of pixel point in the gray image, represents the gray value of pixel point in the gray image, is the local neighborhood, is a filtering intensity influence control factor, represents the neighborhood pixel similarity of the local neighborhood. Here, the similarity degree between pixel points in the local neighborhood can be quantified through the above formula, so as to give different weights during filtering.
[0051] In one embodiment, calculating the smoothing value of this pixel point as the gray value of this pixel point in the denoised gray image based on the neighborhood pixel similarity and the filtering weight function values of all pixel points in the local neighborhood includes: calculating the smoothing value of this pixel point as the gray value of this pixel point in the denoised gray image with the following formula, and the formula is: ; where represents the gradient magnitude of pixel point in the gray image, Represents the value of the filtering weight function for a pixel point in a grayscale image , Represents the grayscale value of a pixel point in the denoised grayscale image . Here, the smoothed value of the pixel point is obtained by weighted averaging the pixel points in the local neighborhood. The weight is determined by the value of the filtering weight function to ensure that key edges and details are retained while removing noise
[0052] In particular, the filtering effect can be further optimized by calculating the diffusion coefficient of the filtering weight function of the pixel point. The diffusion coefficient reflects the intensity of the interaction between pixel points in the local neighborhood and is particularly important for the edge stopping mechanism. In a preferred embodiment, based on the neighborhood pixel similarity and the values of the filtering weight functions of all pixel points in the local neighborhood, calculating the smoothed value of the pixel point as the grayscale value of the pixel point in the denoised grayscale image further includes: calculating the diffusion coefficient of the filtering weight function of the pixel point; based on the diffusion coefficient, using a local neighborhood edge stopping mechanism to correct the filtering weight function of the pixel point to obtain the corrected filtering weight function of the pixel point
[0053] Specifically, considering the local neighborhood represented by , in order to balance the filtering of noise smoothing of pixel points in the local neighborhood and the retention of filtering edge information of the local neighborhood during the calculation of the filtering weight, a local neighborhood edge stopping mechanism can be used to perform the correction of the filtering weight function .
[0054] Specifically, first, based on the diffusion gradient of the gradient magnitude of each pixel, the boundary of the local neighborhood is determined, that is, the diffusion gradient is calculated as: ; where represents the forward pixel point of the pixel point relative to the reference pixel point , that is, if , then , and if , then , similarly, if , then , and if , then , represents the diffusion gradient
[0055] Then the diffusion coefficient can be expressed as: ; where is a threshold parameter proportional to the size of the local neighborhood , represents the diffusion coefficient
[0056] That is, assuming that the image smoothing process corresponding to the diffusion gradient of the filtering weight function results in edge blurring, then by obtaining the diffusion coefficient through the diffusion speed representation based on the gradient modulus, the gradient information in the local neighborhood of the image for distinguishing the edge region and other regions can be obtained. That is, when the gradient is small (flat region), more diffusion is allowed, and when the gradient is large (near the edge), the diffusion across the edge is restricted by reducing the diffusion coefficient, thereby setting up an edge stopping mechanism.
[0057] In this way, in represents the spatial attribute of the filtering weight of the pixel point, while itself represents the pixel value attribute of the filtering weight of the pixel point, and further integration can be achieved through the bilateral mutual weight response calculation considering both space and value to and to obtain the updated filtering weight function value. For example: ; where is a control factor used to adjust the attenuation rate of the weight, and represents the updated filtering weight function value. To further promote the filtering weight smoothing of the image based on the filtering noise while retaining the filtering edge information.
[0058] In step S15, the superpixel segmentation algorithm is used to process the denoised grayscale image to obtain the grayscale region. It should be understood that during the injection molding part detection process, using the superpixel segmentation algorithm to process the denoised grayscale image can improve the detection accuracy and efficiency. First of all, superpixel segmentation can divide the image into multiple small regions (superpixels), and the pixel points within each region have similar color or grayscale values. The advantage of this method is that it can effectively capture the local consistency in the image, thus helping to identify the regions with uniform grayscale and the edge transition regions. Specifically, in the surface detection of injection molding parts, the regions with uniform grayscale usually correspond to large defect-free areas, while the edge transition regions may contain defects such as cracks and bubbles. Through superpixel segmentation, these regions can be clearly distinguished, simplifying the subsequent feature extraction process. In addition, superpixel segmentation can also reduce the computational complexity because the subsequent processing only needs to be carried out on the superpixel-level data instead of processing each pixel one by one. This significantly improves the efficiency of the algorithm, especially important when dealing with high-resolution images. Another important reason is that superpixel segmentation can better retain the key details in the image. Traditional global segmentation methods may blur the edge information in the image, resulting in the loss of key features. However, superpixel segmentation can adaptively divide the image regions, retaining important edge and texture information while removing noise. This is particularly important for the surface defect detection of injection molding parts because subtle defects such as cracks and bubbles often manifest as edge or texture changes. Therefore, superpixel segmentation can not only improve the quality of the image but also provide a solid foundation for subsequent high-quality detection.
[0059] In one embodiment, a superpixel segmentation algorithm such as SLIC (Simple Linear Iterative Clustering), LSC (Linear Spectral Clustering), etc. is used. Among them, the SLIC algorithm is widely used in the field of image processing due to its simple and efficient characteristics. The SLIC algorithm achieves this goal by dividing the image into a fixed number of superpixels and minimizing the distance in the color space and position space. This algorithm can not only generate superpixels with compact shapes but also maintain the consistency of the boundaries, which is very suitable for the detection of the surface of injection molding parts.
[0060] In step S16, an edge detection algorithm is used to process the denoised grayscale image to obtain the edge texture. It should be understood that edge detection can effectively capture regions in the image where the grayscale values change significantly, and these regions usually correspond to the boundaries of objects or surface defects. For injection molded parts, defects such as waviness, cracks, and bubbles often manifest as edge textures. Through the edge detection algorithm, these features can be accurately identified, providing a reliable basis for subsequent defect identification. In addition, the Canny algorithm can retain important edge information while removing noise through multi-stage processing, ensuring the accuracy of the detection results. This is particularly important for the detection of surface defects in injection molded parts because subtle cracks and bubbles may affect the quality and performance of the product. Therefore, using an edge detection algorithm to process the denoised grayscale image can not only improve the detection accuracy but also simplify the subsequent feature extraction process, providing solid technical support for high-quality detection.
[0061] In one embodiment, common edge detection algorithms can be used. Common edge detection algorithms include Canny edge detection, Sobel operator, and Laplacian operator, etc. Among them, Canny edge detection is widely used in the industrial detection field due to its high precision and low noise sensitivity. The Canny algorithm detects edges in the image through multi-stage processing: First, a Gaussian filter is applied to smooth the image to reduce noise; then the gradient magnitude and direction of each pixel are calculated; next, the edges are refined through non-maximum suppression; finally, the final edges are determined through double threshold and hysteresis tracking. Specifically, during implementation, the denoised grayscale image can be input into the Canny edge detection algorithm. For example, in actual operation, first, a slight Gaussian smoothing process is performed on the denoised grayscale image to further reduce the influence of residual noise. Then, the gradient magnitude and direction of each pixel are calculated, and the edges are refined through non-maximum suppression. Next, two thresholds, a high threshold and a low threshold, are set. Pixel points above the high threshold are considered strong edges, pixel points below the low threshold are suppressed, and pixel points between the two are determined whether to be retained according to whether they are connected to strong edges. In this way, the edge information in the image can be accurately extracted.
[0062] In summary, for the injection molding part detection method provided in this application, first, the obtained RGB image is grayscaled, and the gradient magnitude map is calculated for dynamic filtering and noise reduction to obtain a clear grayscale image. Next, the superpixel segmentation algorithm is used to identify the grayscale regions, and the edge texture is determined through the edge detection algorithm. Based on the slope features of the pixel points in the nearest edge texture, the pixel points are matched, the wavy edges are screened out, and the light spot regions are identified. By combining the intersection points of the light spot regions and the wavy edges and the distances from the glue injection points for matching, the overall edge is fitted. Finally, all the edges and wavy regions are comprehensively used to evaluate the quality of the injection molding part. Here, the dynamic filtering technology adaptively adjusts the filtering intensity according to local features, effectively removing noise while retaining key details, and is particularly suitable for scenarios where the important details of the image are maintained under changing light sources and angles for injection molding parts in rapid movement. This method can avoid detail loss more effectively compared with traditional means.
[0063] This application also provides an injection molding part detection system, as Figure 6 shown. The injection molding part detection system 600 includes a memory 610, a processor 620, and a computer program 630 stored in the memory and executable on the processor. It is characterized in that when the processor 620 executes the computer program 630, the steps of the injection molding part detection method as described above are implemented.
[0064] An embodiment of this application also provides a computer-readable storage medium. Computer program code is stored in this computer-readable storage medium. When the computer program code runs on a computer, the computer is caused to execute the above-related method steps to implement an injection molding part detection method provided in the above embodiment.
[0065] An embodiment of this application also provides a computer program product. When this computer program product runs on a computer, the computer is caused to execute the above-related steps to implement an injection molding part detection method provided in the above embodiment.
[0066] Among them, the system, computer-readable storage medium, or computer program product provided in the embodiments of this application are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be elaborated here.
[0067] It should be noted that the above sequence of the embodiments of this application is only for description and does not represent the superiority or inferiority of the embodiments.
[0068] The processes depicted in the accompanying drawings do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous. Each embodiment in this specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other. The key point of each embodiment is to illustrate the differences from other embodiments.
Claims
1. A method for detecting injection molded parts, comprising: Acquire a grayscale image of the injection molded part, and determine edge texture and grayscale area in the grayscale image; Based on the slope characteristics of the pixels in the nearest edge texture, the matching pixels are identified; the wave edges are screened out from the edge texture in combination with the texture morphology, grayscale distribution and distance characteristics; the light spot area is identified according to the overall morphology of the grayscale area and the grayscale value of the pixels; the intersections of the light spot area and the wave edge and their distances from the injection point are used to match the intersections in pairs, and the overall edge is fitted accordingly; the wave area is defined by combining all the overall edges and the wave edges that do not intersect with the light spot area, so as to evaluate the injection quality of the injection molded parts, which is characterized in that the grayscale of the injection molded parts is obtained. The method comprises the following steps: obtaining an original RGB image of the injection molded part; gray-scaling the original RGB image to obtain a gray-scaling image of the injection molded part; calculating a gradient amplitude map of the gray-scaling image; dynamically filtering the gray-scaling image based on the gradient amplitude map to obtain a denoised gray-scaling image; processing the denoised gray-scaling image using a super-pixel segmentation algorithm to obtain the gray-scaling area; and processing the denoised gray-scaling image using an edge detection algorithm to obtain the edge texture.
2. The method for detecting injection molded parts according to claim 1, characterized in that: Calculating the gradient amplitude map of the grayscale image includes: calculating the grayscale change value of each pixel in the grayscale image in the vertical direction; calculating the grayscale change value of each pixel in the grayscale image in the horizontal direction; and determining the gradient amplitude of each pixel based on the grayscale change value of each pixel in the horizontal direction and the grayscale change value in the vertical direction.
3. The method for detecting injection molded parts according to claim 2, characterized in that: Calculating the grayscale change value of each pixel in the grayscale image in the horizontal direction includes: calculating the grayscale change value of each pixel in the grayscale image in the horizontal direction using the following formula, wherein the formula is: ;in, Represents a pixel in a grayscale image The gray value of Represents a pixel in a grayscale image The gray value of Represents a pixel in a grayscale image The grayscale change value in the horizontal direction; calculating the grayscale change value in the vertical direction of each pixel in the grayscale image, comprising: calculating the grayscale change value in the vertical direction of each pixel in the grayscale image by the following formula, wherein the formula is: ;in, Represents a pixel in a grayscale image The gray value of Represents a pixel in a grayscale image The gray value of Represents a pixel in a grayscale image The method comprises: calculating the gradient amplitude of each pixel point by the following formula: ;in, Represents a pixel in a grayscale image The gradient magnitude.
4. The method for detecting injection molded parts according to claim 3, characterized in that: Based on the gradient amplitude map, the grayscale image is dynamically filtered to obtain a denoised grayscale image, including: defining a filtering weight function and calculating the filtering weight function value of each pixel in the grayscale image respectively, wherein the filtering weight function is related to the gradient amplitude of each pixel; determining the local neighborhood of each pixel in the grayscale image; and based on the gradient amplitude and filtering weight function value of all pixels in the local neighborhood, calculating the smoothing value of the pixel as the grayscale value of the pixel in the denoised grayscale image.
5. The method for detecting injection molded parts according to claim 4, characterized in that: The filtering weight function is: ;in, Represents the gradient amplitude of each pixel. is a control factor used to adjust the decay rate of the weight. represents a natural constant, Represents the filter weight function value of each pixel.
6. The method for detecting injection molded parts according to claim 4, characterized in that: Based on the gradient amplitude and filtering weight function value of all pixels in the local neighborhood, the smoothing value of the pixel is calculated as the grayscale value of the pixel in the grayscale image after denoising, including: calculating the neighborhood pixel similarity of the local neighborhood based on the grayscale values of all pixels in the local neighborhood; based on the neighborhood pixel similarity and the filtering weight function value of all pixels in the local neighborhood, calculating the smoothing value of the pixel as the grayscale value of the pixel in the grayscale image after denoising.
7. The method for detecting injection molded parts according to claim 6, characterized in that: Calculating the neighborhood pixel similarity of the local neighborhood based on the grayscale values of all pixels in the local neighborhood includes: calculating the neighborhood pixel similarity of the local neighborhood using the following formula, wherein the formula is: ;in, Represents a pixel in a grayscale image The gray value of Represents a pixel in a grayscale image The gray value of is the local neighborhood, is the control factor affecting the filtering intensity, Neighborhood pixel similarity representing the local neighborhood.
8. The method for detecting injection molded parts according to claim 7, characterized in that: Based on the neighborhood pixel similarity and the filter weight function values of all pixels in the local neighborhood, calculating the smoothing value of the pixel as the grayscale value of the pixel in the denoised grayscale image, including: calculating the smoothing value of the pixel as the grayscale value of the pixel in the denoised grayscale image using the following formula, wherein the formula is: ;in, Represents a pixel in a grayscale image The gradient amplitude of Represents a pixel in a grayscale image The filter weight function value is Represents the pixel in the grayscale image after denoising The gray value of .
9. The method for detecting injection molded parts according to claim 8, characterized in that: Based on the neighborhood pixel similarity and the filter weight function values of all pixels in the local neighborhood, a smoothing value of the pixel is calculated as the grayscale value of the pixel in the denoised grayscale image, and the method also includes: calculating the diffusion coefficient of the filter weight function of the pixel; based on the diffusion coefficient, using the local neighborhood edge stop mechanism to correct the filter weight function of the pixel to obtain a corrected filter weight function of the pixel.
10. An injection molded part inspection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the injection molded part detection method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Edge detection method and device based on adaptive gradient threshold canny operator
CN115797300A
Illuminator accessory defect detection method based on machine vision
CN116363133A
Construction site safety risk intelligent assessment method and system based on artificial intelligence
CN116777845A
Canny edge detection method based on bilateral filtering and adaptive threshold
CN117853510A
Intelligent segmentation method for temporomandibular joint disorder image
CN117876402A
Cited By
Injection molding production line real-time monitoring method and system based on machine vision
CN120430978A
Method and system for detecting cleanliness of automobile parts to be painted
CN121259002A