Image enhancement method for automobile injection molding part detection
By calculating weighted local contrast and directionally correcting grayscale, the information loss problem of flow mark detection in traditional methods is solved, and high-quality flow mark enhancement effect is achieved.
Patent Information
- Application Number
- CN202511158990.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-08-19
AI Technical Summary
Traditional image enhancement methods have difficulty in effectively distinguishing and enhancing weak flow mark defects, and are prone to information loss or false detection.
By calculating the weighted local contrast of gray levels, combining spatial distribution characteristics and gradient direction consistency, the gray levels of interest are divided into gray levels of non-interest, and the non-interest gray levels are directional corrected to generate an enhanced image.
The accuracy and robustness of flow mark detection are significantly improved, the loss of defect information caused by grayscale merging is avoided, the details of the region of interest are retained and the distinction from the background is enhanced.
Smart Images

Figure CN120707455A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image enhancement method for detecting automobile injection molded parts. Background Art
[0002] Automotive injection molded parts are typically produced by melting plastic pellets at high temperatures, injecting them into a mold, and cooling them to form. However, improper melt temperature control or uneven filling speed during this process can easily lead to the formation of fine lines on the surface of the molded part that align with the direction of the melt flow, known as flow marks. These flow marks not only detract from the product's appearance but also potentially impact the mechanical properties and long-term durability of the part. Therefore, efficient and accurate quality inspection of injection molded parts to promptly detect flow mark defects is crucial for optimizing production processes and ensuring product quality.
[0003] A major characteristic of flow mark defects is that the grayscale difference between them and the normal surface of the injection molded part is very small. Even under good lighting conditions, it is difficult to directly and stably identify them. Therefore, before performing automated inspection, it is usually necessary to enhance the collected surface image of the injection molded part to improve the contrast between the flow mark area and the background area.
[0004] However, while traditional image enhancement methods, such as histogram equalization, can improve the overall contrast of an image, they involve rounding during the quantization process. This can cause areas with subtle grayscale differences to be merged into the same grayscale. For example, a flow mark region with a grayscale value of 120 and a normal region with a grayscale value of 121 might both be mapped to a new grayscale value of 150 after equalization. This smooths out the characteristics of the flow mark defect, making it easy to miss a detection. Conversely, small grayscale fluctuations in the normal region might be over-amplified and mistakenly identified as a defect, leading to false detections. Summary of the Invention
[0005] In order to solve the technical problem in the prior art that traditional image enhancement methods are difficult to effectively distinguish and enhance weak flow mark defects, and are prone to information loss or interference, the present application provides an image enhancement method for automobile injection molded parts inspection, which can effectively avoid the problem of defect information loss caused by grayscale merging in traditional methods.
[0006] The present application provides an image enhancement method for automobile injection molded parts inspection, the prevention and control method comprising: collecting a surface image of an automobile injection molded part, calculating a weighted local contrast of each grayscale level in the surface image, wherein the weighted local contrast is obtained by weighting the initial local contrast according to the spatial distribution characteristics of the pixel points within the grayscale and the gradient direction consistency; dividing the grayscale of the surface image into grayscales of interest and grayscales of no interest according to the distribution of the weighted local contrast; generating a corrected grayscale value for each grayscale of no interest, wherein the corrected grayscale value is obtained by adjusting the difference between the grayscale of no interest and the grayscale of interest closest to it; generating an enhanced image based on the grayscale of interest and the corrected grayscale value, so as to enhance the display effect of the surface flow mark defects of the automobile injection molded part.
[0007] This application can retain the details of the area of interest and increase its distinction from the background through targeted correction of non-interested gray levels. This effectively avoids the problem of defect information loss caused by gray level merging in traditional methods while enhancing the target, and significantly improves the accuracy and robustness of flow mark detection.
[0008] In one embodiment, the initial local contrast satisfies the relationship: ;in, Indicates the Initial local contrast of grayscale pixels; Indicates the Gray level Gray value of each pixel; Indicates the Gray level In the eight neighborhoods of a pixel point, Gray value of each pixel; n represents the index value and total number of pixels in the eight neighborhoods of the current pixel; Respectively represent the pixel index value and total number at the current grayscale level; Represents the standard normalization function.
[0009] By calculating the intensity of local grayscale changes of pixels within each grayscale level, we can preliminarily evaluate the correlation between different grayscale levels and image details, providing a basis for subsequent weighted processing.
[0010] In one embodiment, the weighting of the initial local contrast according to the spatial distribution characteristics and gradient direction consistency of the pixels within the grayscale includes: for any grayscale, obtaining the position information of all pixels at the grayscale, and spatially clustering the position information to obtain final clusters; obtaining the gradient direction angle of each pixel at the grayscale, and calculating the standard deviation of the mean value of the gradient direction angle of the pixels in each final cluster; calculating a local contrast weight value according to the number of the final clusters and the standard deviation; and weighting the initial local contrast based on the local contrast weight value to obtain a weighted local contrast.
[0011] By leveraging the prior knowledge that flow marks usually appear as substantial stripes, and therefore the gradient direction within a cluster is consistent and multiple lines may appear, resulting in a large number of clusters, we can effectively distinguish real flow mark defects from other high-contrast normal structures on the injection molded parts, significantly reducing interference with subsequent processing.
[0012] In one embodiment, the spatial clustering of the location information includes: performing iterative self-organizing clustering on the location information; and after each iteration, calculating the minimum Euclidean distance between any two clusters, and if all minimum Euclidean distances are greater than 1, stopping the iteration to obtain the final cluster.
[0013] In one embodiment, the local contrast weight value satisfies the relationship: ;in, Indicates the The local contrast weight value of grayscale pixel points; Indicates the The final number of clusters of all pixels at gray levels; Represents the maximum value of the final number of clusters at each gray level; Indicates the The standard deviation of the mean gradient direction angle of each pixel point in the final cluster of all pixels at the gray level, h represents the index value of the final cluster at the gray level; Indicates the maximum value of the standard deviation at each gray level.
[0014] By combining the number of spatially distributed clusters and the standard deviation of the gradient direction through addition and then uniform adjustment, a reasonable weight is generated for each gray level, making the weight calculation process more robust.
[0015] In one embodiment, dividing the grayscale of the surface image into grayscales of interest and grayscales of no interest includes: sorting the weighted local contrasts of all grayscales; finding two weighted local contrasts with the largest adjacent intervals in the sorted results, and calculating their mean as a segmentation threshold; marking the grayscale whose weighted local contrast is greater than the segmentation threshold as the grayscale of interest, and marking the grayscale whose weighted local contrast is not greater than the segmentation threshold as the grayscale of no interest.
[0016] By finding the maximum natural discontinuity point in the weighted contrast distribution as the threshold, the grayscale can be adaptively divided into the class of interest that is highly correlated with potential defects and the class of non-interest that represents the background, avoiding the difficulty and inaccuracy of manually setting a fixed threshold.
[0017] In one embodiment, the corrected grayscale value satisfies the relationship: ;in, Indicates the The corrected value of the gray level of non-interest; Indicates the The original value of gray levels not of interest; Indicates the The nearest gray level of interest of the non-gray levels of interest; 、 Respectively represent The absolute difference between a non-interesting gray level and the nearest interested gray level on its left, and the absolute difference between a non-interesting gray level and the nearest interested gray level on its right; Represents a symbolic function.
[0018] Without changing the grayscale information of the area of interest, the visual difference between it and the background area can be maximized, thereby achieving accurate enhancement of defects and effectively preventing the loss of key details.
[0019] In one embodiment, collecting the surface image of the automobile injection molded part includes: The original image of the automobile injection molded part including the background area is collected, and edge detection and contour search are performed on the original image; the maximum edge encapsulation area is screened out according to the number of pixels in the contour area, and the surface image of the automobile injection molded part is segmented using mask processing.
[0020] In one embodiment, the gradient direction angle is calculated using a Sobel operator.
[0021] In one embodiment, the number of initial cluster centers used in the iterative self-organizing clustering is determined according to a preset ratio based on the total number of pixels at the grayscale.
[0022] The technical solution of this application has the following beneficial technical effects: This application can intelligently identify the grayscale that is more likely to represent the real flow mark by introducing a weighting mechanism based on spatial distribution and gradient direction. Subsequently, by directional correction of non-interested grayscales rather than global equalization, it not only retains the details of the region of interest but also increases its distinction from the background. While enhancing the target, it effectively avoids the problem of defect information loss caused by grayscale merging in traditional methods, significantly improving the accuracy and robustness of flow mark detection.
[0023] Furthermore, the potential defect grayscale levels are first intelligently identified by combining weighted local contrast of spatial and gradient features, and then these defects are enhanced through a targeted, non-global grayscale correction method, ultimately achieving high-quality enhancement of weak flow marks on the surface of automotive injection molded parts. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a flow chart of an image enhancement method for automobile injection molded parts inspection according to an embodiment of the present application.
[0025] Figure 2 2 is a schematic diagram comparing the enhancement effects according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0027] Figure 1 FIG. 1 is a flow chart of an image enhancement method for automobile injection molded parts inspection according to an embodiment of the present application. Figure 1 As shown, the image enhancement method for automobile injection molded parts inspection includes steps S101 to S104, which are described in detail below.
[0028] S101, collecting a surface image of an automobile injection molded part and calculating a weighted local contrast of each grayscale level in the surface image, wherein the weighted local contrast is obtained by weighting the initial local contrast according to the spatial distribution characteristics of pixels within the grayscale and the consistency of the gradient direction.
[0029] In one embodiment, an industrial camera can be used to capture raw images of the surface of an automotive injection-molded part under uniform illumination provided by a circular shadowless light source. Because automotive injection-molded parts often have irregular shapes, the captured raw images often include background areas such as the workbench. To accurately analyze the injection-molded part surface, the target area must be segmented from the background.
[0030] Specifically, the collected original image can be Gaussian filtered to remove random noise introduced by sensors or environmental factors; then the Canny edge detection operator is used to perform edge detection on the filtered image to obtain a binary edge image containing the contour of the injection molded part and the edge of the internal structure; then, a contour search algorithm is applied to the binary edge image to find all closed contours.
[0031] Next, the algorithm iterates through all closed contours found, calculates the area enclosed by each contour, selects the contour with the largest number of pixels, and creates a mask based on this contour. This mask is then applied to the original image to accurately segment the molded part area, yielding an image of the automotive molded part's surface. Finally, the segmented surface image is converted to a grayscale image, and the total number of occurrences of each grayscale level in the image is counted, along with a list of the coordinates of all pixels with that grayscale value.
[0032] In an optional embodiment, the grayscale value change of the pixels in the local area of the flow mark defect is more dramatic than that of the flat normal area. Therefore, the average grayscale change of the pixel group corresponding to each grayscale level in the local area can be calculated first. For each grayscale level, its initial local contrast satisfies the relationship:
[0033] in, Indicates the Initial local contrast of grayscale pixels; Indicates the Gray level Gray value of each pixel; Indicates the Gray level In the eight neighborhoods of a pixel point, Gray value of each pixel; n represents the index value and total number of pixels in the eight neighborhoods of the current pixel; Respectively represent the pixel index value and total number at the current grayscale level; Represents the standard normalization function.
[0034] In this optional embodiment, since normal edge areas such as structural corners on the injection molded part also have a high initial local contrast, which will interfere with the identification of flow marks, the morphological characteristics of flow mark defects (multiple, fine stripes in the same direction) can be used to distinguish between real flow marks and normal structural edges.
[0035] Specifically, for each grayscale level, the coordinates of all pixels are iteratively self-organized and clustered. After each iteration, the minimum Euclidean distance between all clusters is checked. If the minimum distance between all clusters is greater than 1, the iteration is stopped and the final number of clusters is recorded. The number of initial cluster centers used in the iterative self-organizing clustering is determined according to a preset ratio based on the total number of pixels at the grayscale level. For example, for each grayscale level, the position of each pixel in the image at that grayscale level is obtained, and 10% of the cluster centers preset as the pixels at the current grayscale level are randomly selected to iteratively self-organize and cluster all the position points.
[0036] Then, the Sobel operator is used to calculate the gradient direction angle of each pixel in the image. For each final cluster of each gray level, the mean of the gradient direction angles of all pixels in the cluster is calculated, and then the standard deviation of the mean is calculated. Finally, the standard deviation of the mean is calculated. The local contrast weight value of gray levels , which is used to compare the initial local contrast Weighted to get the final weighted local contrast , where the local contrast weight value satisfies the relationship:
[0037] in, Indicates the The local contrast weight value of grayscale pixel points; Indicates the The final number of clusters of all pixels at gray levels; Represents the maximum value of the final number of clusters at each gray level; Indicates the The standard deviation of the mean gradient direction angle of each pixel point in the final cluster of all pixels at the gray level, h represents the index value of the final cluster at the gray level; Indicates the maximum value of the standard deviation at each gray level.
[0038] In this way, through image acquisition and preprocessing, an interference-free grayscale image of the injection molded part surface is obtained. By combining the spatial distribution of pixels and the gradient direction, two morphological features unique to flow marks, for weighting, the significance of the real flow mark area can be amplified while effectively suppressing the interference caused by the edges of normal structures.
[0039] S102 , dividing the grayscale of the surface image into grayscales of interest and grayscales of no interest according to the distribution of weighted local contrast.
[0040] In one embodiment, the weighted local contrast values of all gray levels can be sorted in ascending order. The sorted results form an ordered sequence, where the values in the sequence, from low to high, reflect the strength of the association between each gray level and image detail. Gray levels in normal, flat areas will have very small weighted local contrast values and be concentrated at the front of the sequence, while gray levels that constitute flow marks or strong edges will have significantly higher weighted local contrast values and be located at the back of the sequence.
[0041] Next, within the sorted results, the difference between every two adjacent values is calculated, and the two weighted local contrasts with the largest interval are found. Their mean is then calculated as the segmentation threshold. The logic behind this is that there is a natural maximum difference between the grayscale of interest and the grayscale of non-interest in the characteristic dimension of weighted local contrast. By locating this maximum difference, the optimal dividing point between the two grayscale categories can be found. The threshold determined by this method can be dynamically adjusted based on the specific circumstances of the current image, making it highly adaptive.
[0042] In this optional embodiment, the grayscale whose weighted local contrast is greater than the segmentation threshold is marked as the grayscale of interest, and the grayscale whose weighted local contrast is not greater than the segmentation threshold is marked as the grayscale of no interest.
[0043] In this way, by sorting the weighted local contrast, finding the maximum interval and calculating the adaptive threshold, it is possible to achieve automatic and accurate classification of gray levels, thereby effectively distinguishing the gray levels that may constitute flow mark defects from the gray levels representing the background.
[0044] S103 , generating a corrected grayscale value for each non-interested grayscale, wherein the corrected grayscale value is obtained by adjusting the difference between the non-interested grayscale and the nearest interested grayscale.
[0045] In an optional embodiment, in order to avoid destroying the grayscale information of interest, only the non-interesting grayscale is corrected to move it away from the grayscale of interest, thereby visually increasing the contrast. The corrected grayscale value satisfies the relationship:
[0046] in, Indicates the The corrected value of the gray level of non-interest; Indicates the The original value of gray levels not of interest; Indicates the The nearest gray level of interest of the non-gray levels of interest; 、 Respectively represent The absolute difference between a non-interesting gray level and the nearest interested gray level on its left, and the absolute difference between a non-interesting gray level and the nearest interested gray level on its right; Represents a symbolic function.
[0047] For example, assuming that the gray levels of interest are {..., 100, 105, 130, 132, ...}, the gray levels of non-interest to be corrected are is 115, the nearest gray level of interest =105, the correction direction is sign(115-105)=+1, the left and right difference variables are calculated as 115-105=10 and 115-130=-15, and the correction amplitude is calculated as =10, the generated corrected gray value is .
[0048] In this way, by making targeted and controlled corrections to non-target areas, conditions can be created for the final high-contrast enhancement without losing defect details.
[0049] S104 , generating an enhanced image based on the grayscale of interest and the corrected grayscale value, so as to enhance the display effect of the surface flow mark defect of the automobile injection molded part.
[0050] In one embodiment, the values of all grayscales marked as grayscales of interest remain unchanged, while the values of all grayscales marked as grayscales of no interest are updated to the generated corrected grayscale values. By traversing each pixel of the surface image grayscale map, once all pixel values have been updated, a final enhanced image is obtained.
[0051] like Figure 2 The figure shows a schematic diagram comparing the enhancement effects according to an embodiment of the present application. Compared to the enhanced images and histograms obtained by conventional methods, the enhanced images and histograms obtained by the present application have a higher ratio of trace defects, clearer edges, and no excessive amplification of noise and irrelevant textures in the background area.
[0052] For example, suppose there are 0-9 gray levels in the image: frequency sequence , where it is assumed that 4, 7, and 8 are gray levels of interest, 1 and 5 are normal edge gray levels (i.e., non-interesting), and the rest are normal areas (i.e., non-interesting are 0, 1, 2, 3, 5, 6, and 9). The traditional processing process is: Cumulative distribution function of an image using relative frequencies:
[0053] Among them, k represents the kth gray level, K represents the total number of gray levels, represents the frequency accumulation under the kth gray level, N is the sum of all frequencies, is the cumulative distribution function.
[0054] Grayscale after equalization using cumulative distribution function arrive Grayscale value:
[0055] The conclusion is: traditional processing will merge 3, 4, and 5, and 6 and 7 (this will blur some areas of interest).
[0056] The amendments to this application are: right , , , Maintaining the original, it is difficult to distinguish the mis-merged areas for 3, 4, 5, 6, and 7. After processing, the areas of interest are retained, and adjacent non-interest areas can be merged with non-adjacent areas, thereby highlighting the contrast of the areas of interest.
[0057] In this way, by recombining the retained grayscale details of interest and the corrected grayscale of non-interest, a high-quality enhanced image with prominent defect features is finally generated.
[0058] It should be noted that a person skilled in the art may make a number of modifications and improvements without departing from the concept of the present application, and these modifications and improvements are all within the scope of protection of the present application. Therefore, the scope of protection of the patent application shall be based on the appended claims.
Claims
1. An image enhancement method for automobile injection molded parts inspection, characterized in that: include: Acquire a surface image of an automotive injection molded part and calculate a weighted local contrast of each grayscale level in the surface image, wherein the weighted local contrast is obtained by weighting an initial local contrast based on the spatial distribution characteristics of pixels within the grayscale and the consistency of the gradient direction; dividing the grayscale of the surface image into grayscales of interest and grayscales of no interest according to the distribution of the weighted local contrast; For each of the non-interesting grayscales, generating a corrected grayscale value, wherein the corrected grayscale value is obtained by adjusting the difference between the non-interesting grayscale and the nearest interested grayscale; An enhanced image is generated based on the grayscale of interest and the corrected grayscale value, so as to enhance the display effect of the surface flow mark defect of the automobile injection molded part.
2. The image enhancement method for automobile injection molded parts inspection according to claim 1, characterized in that: The initial local contrast satisfies the relationship: in, Indicates the Initial local contrast of grayscale pixels; Indicates the Gray level Gray value of each pixel; Indicates the Gray level In the eight neighborhoods of a pixel point, Gray value of each pixel; n represents the index value and total number of pixels in the eight neighborhoods of the current pixel; Respectively represent the pixel index value and total number at the current grayscale level; Represents the standard normalization function.
3. The image enhancement method for automobile injection molded parts inspection according to claim 1, characterized in that: The weighting of the initial local contrast according to the spatial distribution characteristics of the pixels within the grayscale and the gradient direction consistency includes: For any gray level, obtain the position information of all pixels under the gray level, and perform spatial clustering on the position information to obtain the final cluster; Obtaining the gradient direction angle of each pixel at the grayscale level, and calculating the standard deviation of the mean value of the gradient direction angle of each pixel in each final cluster; Calculating a local contrast weight value according to the number of the final clusters and the standard deviation; The initial local contrast is weighted based on the local contrast weight value to obtain a weighted local contrast.
4. The image enhancement method for automobile injection molded parts inspection according to claim 3, characterized in that: The spatial clustering of the location information includes: performing iterative self-organizing clustering on the location information; and After each iteration, the minimum Euclidean distance between any two clusters is calculated. If all minimum Euclidean distances are greater than 1, the iteration is stopped to obtain the final cluster.
5. The image enhancement method for automobile injection molded parts inspection according to claim 3, characterized in that: The local contrast weight value satisfies the relationship: in, Indicates the The local contrast weight value of grayscale pixel points; Indicates the The final number of clusters of all pixels at gray levels; Represents the maximum value of the final number of clusters at each gray level; Indicates the The standard deviation of the mean gradient direction angle of each pixel point in the final cluster of all pixels at the gray level, h represents the index value of the final cluster at the gray level; Indicates the maximum value of the standard deviation at each gray level.
6. The image enhancement method for automobile injection molded parts inspection according to claim 1, characterized in that: The dividing the grayscale of the surface image into grayscales of interest and grayscales of non-interest includes: Sort the weighted local contrast of all gray levels; In the sorted results, find the two weighted local contrasts with the largest adjacent intervals and calculate their mean as the segmentation threshold; Gray levels with weighted local contrast greater than the segmentation threshold are marked as gray levels of interest, and gray levels with weighted local contrast not greater than the segmentation threshold are marked as gray levels of no interest.
7. The image enhancement method for automobile injection molded parts inspection according to claim 1, characterized in that: The corrected grayscale value satisfies the relationship: in, Indicates the The corrected value of the gray level of non-interest; Indicates the The original value of gray levels not of interest; Indicates the The nearest gray level of interest of the non-gray levels of interest; 、 Respectively represent The absolute difference between a non-interesting gray level and the nearest interested gray level on its left, and the absolute difference between a non-interesting gray level and the nearest interested gray level on its right; Represents a symbolic function.
8. The image enhancement method for automobile injection molded parts inspection according to claim 1, characterized in that: The collecting of the surface image of the automobile injection molded part comprises: Collecting an original image of an automobile injection molded part including a background area, and performing edge detection and contour search on the original image; The maximum edge enclosed area is screened out according to the number of pixels in the contour area, and the surface image of the automobile injection molded part is segmented using mask processing.
9. The image enhancement method for automobile injection molded parts inspection according to claim 3, characterized in that: The gradient direction angle is calculated using the Sobel operator.
10. The image enhancement method for automobile injection molded parts inspection according to claim 4, characterized in that: The number of initial cluster centers used in the iterative self-organizing clustering is determined according to a preset ratio based on the total number of pixels at the grayscale.
Citation Information
Patent Citations
Injection molding part production quality detection method based on image enhancement
CN117036205A
Intelligent detection method for parts produced by numerical control machine tool
CN118570216A
Defect detection method and system for automotive trim injection molded part based on computer vision
CN119090870A
Region-of-interest highlighting method and device, equipment and storage medium
CN119515753A
Method for adaptively adjusting image and image processing apparatus using the same
US20090123068A1