Method for automatically identifying and positioning surface defects of plastic injection molded part
By constructing windows of different sizes to obtain the comprehensive importance and jump degree of pixel points, the center coefficient of the laplace operator is optimized, and the problem of poor effect of the laplace operator in image enhancement is solved, and more accurate automatic recognition of surface defects of injection molded parts is achieved.
Patent Information
- Application Number
- CN202510584242.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-05-07
AI Technical Summary
In the prior art, the laplace operator has poor enhancement effect on the areas with obvious grayscale jumps during image enhancement, resulting in low accuracy of automatic defect recognition, and areas with insufficient grayscale jumps may be over-enhanced and artifacts may occur.
By building windows with different preset sizes, we can obtain the comprehensive importance and jump degree of pixel points, optimize the center coefficient of the laplace operator, and personalize the laplace operator according to the characteristics of the pixel points, and enhance image processing.
It improves the accuracy of the image enhancement process, reduces the occurrence of artifacts, and improves the accuracy of automatic identification and positioning of defect areas on the surface of injection molded parts.
Smart Images

Figure CN120525818A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision, and in particular to a method for automatically identifying and locating surface defects of plastic injection molded parts. Background Art
[0002] With the rapid development of plastic injection molding technology, injection molded products are increasingly used in daily life, industrial production, and scientific and technological fields. However, during the production process, due to the influence of various factors such as mold design, material selection, and molding process, various surface defects such as scorch marks, color mixing, water marks, fog spots, concave spots, convex spots, scratches, shrinkage, spots, and water marks often appear on the surface of injection molded products. These defects not only affect the appearance quality of the product, but also may reduce the product's performance and lifespan. In severe cases, they may even lead to product scrapping, resulting in economic losses for the company. Traditionally, surface defect detection of injection molded parts mainly relies on manual inspection, but the detection effect is unstable and inefficient.
[0003] With the development of computer vision technology, existing technologies generally use image processing technology to achieve automatic identification and positioning of surface defects of plastic injection molded parts. First, the acquired injection molded part images are enhanced to make the defects more obvious. Then, the surface texture, color, shape and other features of a large number of defective area images are acquired and trained, and machine learning algorithms are used to achieve automatic identification and positioning of defective areas of injection molded parts.
[0004] In the prior art, the Laplace transform algorithm is usually used to enhance the acquired injection molded part images. However, when the Laplace transform algorithm is used to enhance image details, it has a better enhancement effect on the areas in the image where the grayscale jumps are obvious. Since the degree of defect is different, the degree of local grayscale jump of the defect part is also different. When a fixed Laplace operator is used to enhance the image, the area with unclear grayscale jump may not be effectively enhanced because the Laplace operator is too small; the area with obvious grayscale jump is over-enhanced and artifacts appear due to the Laplace operator being too large, which leads to poor subsequent defect automatic recognition effect and reduces the accuracy of automatic recognition of surface defects of injection molded parts.
[0005] Therefore, how to optimize the Laplace operator and increase its accuracy in image enhancement becomes an urgent problem to be solved. Summary of the Invention
[0006] In view of this, an embodiment of the present invention provides a method for automatically identifying and locating surface defects of plastic injection molded parts to solve the problem of how to optimize the Laplace operator and increase its accuracy in the image enhancement process.
[0007] An embodiment of the present invention provides a method for automatically identifying and locating surface defects of a plastic injection molded part, the method comprising the following steps:
[0008] Acquiring a surface image of a plastic injection molded part, and performing grayscale processing on the surface image to obtain a grayscale image;
[0009] For any pixel point in the grayscale image, construct at least two windows of different preset sizes with the pixel point as the center, and obtain the comprehensive importance of the pixel point based on the grayscale value difference and grayscale value correlation degree of the pixel points in each window;
[0010] A target window of a preset size is established with any pixel point as the center, and the jump degree of any pixel point is obtained according to the grayscale value difference of the pixel points in the target window;
[0011] Setting an initial Laplace operator, optimizing the initial Laplace operator according to the comprehensive importance and jump degree of any pixel point to obtain an optimized Laplace operator for any pixel point, using the optimized Laplace operator as the Laplace operator in the Laplace transform algorithm, and performing image enhancement processing on the any pixel point;
[0012] Image enhancement processing is performed on each pixel point in the grayscale image to obtain an enhanced image, and defect detection is performed on the enhanced image to obtain a surface defect area of the plastic injection molded part.
[0013] Preferably, the step of constructing at least two windows of different preset sizes with any pixel point as the center includes:
[0014] In the grayscale image, taking the any pixel point as the center, the any pixel point and a first preset number of pixel points in the horizontal direction thereof form a horizontal window;
[0015] Form a vertical window by combining the any pixel point and a first preset number of pixel points in the vertical direction thereof;
[0016] A second preset number of square windows of different sizes are established with any pixel point as the center.
[0017] Preferably, obtaining the comprehensive importance of any pixel point according to the grayscale value difference and grayscale value correlation degree of the pixel points in each window includes:
[0018] Obtaining the gradient value of each pixel point in the horizontal window respectively to obtain a horizontal gradient line graph, wherein the horizontal coordinate of the horizontal gradient line graph is the pixel position number and the vertical coordinate is the gradient value;
[0019] Obtaining the gradient value of each pixel point in the vertical window respectively to obtain a vertical gradient line graph, wherein the horizontal coordinate of the vertical gradient line graph is the pixel position number and the vertical coordinate is the gradient value;
[0020] Obtaining the importance of any pixel point according to fluctuation characteristics of gradient values in the horizontal gradient line graph and the vertical gradient line graph;
[0021] Obtaining the abnormality degree of any pixel point according to the grayscale value difference and grayscale value correlation degree of the pixel points in each square window;
[0022] The product of the importance and the abnormality is normalized to obtain the comprehensive importance of any pixel.
[0023] Preferably, obtaining the importance of any pixel point according to the fluctuation characteristics of the gradient values in the horizontal gradient line graph and the vertical gradient line graph includes:
[0024] In the horizontal gradient line graph, the gradient change rate between any pixel point and its left adjacent pixel point is obtained, which is recorded as the left change rate; the gradient change rate between any pixel point and its right adjacent pixel point is obtained, which is recorded as the right change rate;
[0025] Obtaining the absolute value of the ratio of the left change rate to the right change rate to obtain a change rate ratio, and calculating the absolute value of the difference between a constant 1 and the change rate ratio to obtain a gradient change difference value of any pixel point;
[0026] Obtaining a gradient mean of the horizontal gradient line graph, calculating the product of the reciprocal of the gradient mean and the reciprocal of the gradient change difference value, and obtaining an edge feature value of any pixel point in the horizontal direction;
[0027] The edge feature value of any pixel point in the vertical direction is obtained according to the vertical gradient line graph, and the importance of any pixel point is obtained according to the average value between the edge feature value in the horizontal direction and the edge feature value in the vertical direction of any pixel point.
[0028] Preferably, obtaining the abnormality degree of any pixel point according to the grayscale value difference and grayscale value correlation degree of the pixel points in each square window includes:
[0029] For any square window, the grayscale values of each row of pixels in the square window are combined into a grayscale value sequence, the standard deviation of each grayscale value sequence is obtained, and the mean of the standard deviation is obtained. The ratio of the standard deviation of each grayscale value sequence to the mean of the standard deviation is calculated, and the accumulated value of the ratio is obtained.
[0030] Obtain the Pearson correlation coefficient between the gray value sequences of every two adjacent rows in any square window, and obtain the corresponding mean of the Pearson correlation coefficient;
[0031] Obtaining the product of the ratio cumulative value and the inverse of the mean of the Pearson correlation coefficient to obtain the outlier value of any square window;
[0032] The outlier value of each square window is obtained respectively, and the corresponding outlier value mean is obtained as the outlier degree of any pixel point.
[0033] Preferably, obtaining the jump degree of any pixel point according to the grayscale value difference of the pixel points in the target window includes:
[0034] In the target window, the grayscale value mean of the four neighboring pixels of any pixel is obtained, and the absolute value of the difference between the grayscale value mean and the grayscale value of any pixel is normalized to obtain the jump degree of any pixel.
[0035] Preferably, optimizing the initial Laplace operator according to the comprehensive importance and jump degree of any pixel point to obtain the optimized Laplace operator of any pixel point includes:
[0036] Setting a transition degree threshold and a central coefficient of an initial Laplace operator, and if the transition degree of any pixel point is greater than or equal to the transition degree threshold, optimizing the central coefficient of the initial Laplace operator according to the transition degree and importance of any pixel point to obtain an optimized central coefficient;
[0037] If the jump degree of any pixel point is less than the jump degree threshold, optimizing the central coefficient of the initial Laplace operator according to the jump degree and comprehensive importance of any pixel point to obtain an optimized central coefficient;
[0038] According to the optimized center coefficient, the optimized Laplace operator of any pixel point is obtained.
[0039] Preferably, the optimizing the central coefficient of the initial Laplace operator according to the jump degree and importance of any pixel point includes:
[0040] Normalizing the product of the jump degree and the importance degree of any pixel point to obtain an adjustment value, and obtaining an optimized center coefficient based on the sum of the center coefficient and the adjustment value.
[0041] Preferably, the optimizing the central coefficient of the initial Laplace operator according to the jump degree and comprehensive importance of any pixel point includes:
[0042] The product of the inverse of the jump degree of any pixel point and the comprehensive importance is normalized to obtain an adjustment value, and the optimized center coefficient is obtained according to the difference between the center coefficient and the adjustment value.
[0043] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0044] The present invention obtains a surface image of a plastic injection molded part, performs grayscale processing on the surface image to obtain a grayscale image; for any pixel point in the grayscale image, at least two windows of different preset sizes are constructed with the any pixel point as the center, and the comprehensive importance of the any pixel point is obtained according to the grayscale value difference and grayscale value correlation degree of the pixel points in each of the windows; a target window of preset size is established with the any pixel point as the center, and the jump degree of the any pixel point is obtained according to the grayscale value difference of the pixel points in the target window; an initial Laplace operator is set, and the initial Laplace operator is optimized according to the comprehensive importance and jump degree of the any pixel point to obtain an optimized Laplace operator of the any pixel point, and the optimized Laplace operator is used as the Laplace operator in a Laplace transform algorithm to perform image enhancement processing on the any pixel point; image enhancement processing is performed on each pixel point in the grayscale image to obtain an enhanced image, and defect detection is performed on the enhanced image to obtain a surface defect area of the plastic injection molded part. Among them, according to the grayscale value difference and grayscale value correlation degree of pixel points in the grayscale image, the comprehensive importance and jump degree of each pixel point are obtained, and then the Laplace operator in the Laplace transform algorithm is optimized according to the comprehensive importance and jump degree of each pixel point, so that the defective part in the enhanced image obtained by the Laplace transform algorithm is effectively enhanced while the overall image remains clear and free of artifacts, thereby increasing the accuracy of subsequent automatic identification and positioning of defective areas of injection molded parts. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1This is a flow chart of a method for automatically identifying and locating surface defects of plastic injection molded parts provided in the first embodiment of the present invention;
[0047] Figure 2 The surface images of the front and both sides of a plastic injection molded part provided in the first embodiment of the present invention are as follows;
[0048] Figure 3 This is a schematic diagram of a laplace kernel provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0049] The embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0050] It should be noted that the terms "first," "second," and the like in the specification of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure.
[0051] In order to illustrate the technical solution of the present invention, specific embodiments are provided below.
[0052] See also Figure 1 , is a flow chart of a method for automatically identifying and locating surface defects of plastic injection molded parts provided by the first embodiment of the present invention, such as Figure 1 As shown, the method may include:
[0053] Step S101 : acquiring a surface image of a plastic injection molded part, and performing grayscale processing on the surface image to obtain a grayscale image.
[0054] During the production process of injection molded products, various defects often appear on their surfaces due to the influence of various factors such as mold design, material selection, and molding process. These defects include scorch marks, color mixing, water marks, fog spots, concave spots, convex spots, scratches, shrinkage, spots, water marks, etc. These defects not only affect the appearance quality of the product, but may also reduce the product's performance and lifespan. In severe cases, they may even lead to product scrapping, causing economic losses to the company.
[0055] With the development of computer vision technology, existing technologies generally use image processing technology to achieve automatic identification and positioning of surface defects of plastic injection molded parts. First, the acquired injection molded part images are enhanced to make the defects more obvious. Then, the surface texture, color, shape and other features of a large number of defective area images are acquired and trained, and machine learning algorithms are used to achieve automatic identification and positioning of defective areas of injection molded parts.
[0056] In this embodiment, after the plastic injection molding is completed, a high-definition camera is installed directly above and on both sides of the plastic injection molding conveyor belt. When the plastic injection molding is conveyed to the bottom (opposite) of the camera, it is photographed to obtain the surface images of the front and both sides of the plastic injection molding, such as Figure 2 As shown, the surface images of the front and both sides of the plastic injection molded part are then grayscaled to obtain grayscale images. Grayscale processing belongs to the existing technology and will not be described here. Since the method for automatically identifying defective areas for each surface image is the same, this embodiment takes a surface image of the plastic injection molded part as an example to automatically identify defective areas.
[0057] In the prior art, the Laplace transform algorithm is usually used to enhance the acquired injection molded part images. However, when the Laplace transform algorithm is used to enhance image details, it has a better enhancement effect on the areas in the image where the grayscale jumps are obvious. Since the degree of defect is different, the degree of local grayscale jump of the defect part is also different. When a fixed Laplace operator is used to enhance the image, the area with unclear grayscale jump may not be effectively enhanced because the Laplace operator is too small; the area with obvious grayscale jump is over-enhanced and artifacts appear due to the Laplace operator being too large, which leads to poor subsequent defect automatic recognition effect and reduces the accuracy of automatic recognition of surface defects of injection molded parts.
[0058] Therefore, this embodiment obtains the comprehensive importance and jump degree of each pixel point based on the grayscale value difference and grayscale value correlation degree of the pixel points in the grayscale image, and then optimizes the Laplace operator in the Laplace transform algorithm based on the comprehensive importance and jump degree of each pixel point, so that the defective part in the enhanced image obtained by the Laplace transform algorithm is effectively enhanced while the overall image remains clear and free of artifacts, thereby increasing the accuracy of subsequent automatic identification and positioning of defective areas of injection molded parts.
[0059] Step S102: for any pixel point in the grayscale image, at least two windows of different preset sizes are constructed with the pixel point as the center, and the comprehensive importance of the pixel point is obtained according to the grayscale value difference and grayscale value correlation degree of the pixel points in each window.
[0060] Since the Laplace transform algorithm has a strong sharpening effect on the part of the grayscale image with obvious local grayscale changes, and the part of the grayscale image with obvious local grayscale changes is the edge part, the importance of each pixel can be obtained according to the local grayscale change characteristics of each pixel. The greater the importance of the pixel, the more likely it is an edge pixel and the more it needs to be enhanced.
[0061] However, not only do edge parts exist in the defective areas of grayscale images, but also in the normal textures of plastic injection molded parts. Since the defective areas of plastic injection molded parts are characterized by complex local grayscale changes and poor texture continuity and consistency, that is, strong local grayscale fluctuations and low similarity of local grayscale changes, for any pixel in the grayscale image, the degree of abnormality of any pixel can be obtained based on its local grayscale change characteristics; then, the comprehensive importance of any pixel can be obtained by combining the importance and abnormality of any pixel, that is, the possibility that any pixel belongs to the edge pixel of the defective area, and then the Laplace operator in the Laplace transform algorithm is optimized according to the comprehensive importance of any pixel to increase the accuracy of the subsequent automatic identification and positioning of the defective area of the injection molded parts. The steps to obtain the comprehensive importance of any pixel are:
[0062] (1) Obtain the importance of any pixel.
[0063] In the grayscale image, with any pixel as the center, a horizontal window is formed by combining the pixel and a first preset number of pixels in the horizontal direction thereof; a vertical window is formed by combining the pixel and a first preset number of pixels in the vertical direction thereof. Because there are many types of surface defects of injection molded parts, in order to prevent a window from containing multiple edge pixels, the importance of any pixel should be analyzed in a smaller area. In this embodiment, the first preset number is set to 5, which is not limited here and can be set according to the specific implementation scenario.
[0064] Since the edge is located at the intersection of grayscale changes, the grayscale changes of pixels on both sides of the edge are relatively uniform in a smaller area with the edge as the boundary. That is, if any pixel is an edge pixel, the mean gradient of its neighboring pixels is lower, and with any pixel as the center, the gradient value changes of pixels on both sides are similar to each other.
[0065] Therefore, the gradient value of each pixel point in the horizontal window is obtained respectively to obtain a horizontal gradient line graph, wherein the horizontal coordinate of the horizontal gradient line graph is the pixel position number and the vertical coordinate is the gradient value; the gradient value of each pixel point in the vertical window is obtained respectively to obtain a vertical gradient line graph, wherein the horizontal coordinate of the vertical gradient line graph is the pixel position number and the vertical coordinate is the gradient value. The gradient value belongs to the prior art and will not be described here; according to the fluctuation characteristics of the gradient values in the horizontal gradient line graph and the vertical gradient line graph, the importance of any pixel point is obtained, specifically:
[0066] In the horizontal gradient line graph, the gradient change rate between any pixel and its left adjacent pixel is obtained, which is recorded as the left change rate, and the gradient change rate between any pixel and its right adjacent pixel is obtained, which is recorded as the right change rate. The change rate belongs to the prior art and will not be repeated here.
[0067] Obtaining the absolute value of the ratio of the left change rate to the right change rate to obtain a change rate ratio, and calculating the absolute value of the difference between a constant 1 and the change rate ratio to obtain a gradient change difference value of any pixel point;
[0068] Obtaining a gradient mean of the horizontal gradient line graph, calculating the product of the reciprocal of the gradient mean and the reciprocal of the gradient change difference value, and obtaining an edge feature value of any pixel point in the horizontal direction;
[0069] According to the method for obtaining the edge feature value of any pixel point in the horizontal direction, the edge feature value of any pixel point in the vertical direction is obtained according to the vertical gradient line graph, and the importance of any pixel point is obtained according to the average between the edge feature value in the horizontal direction and the edge feature value in the vertical direction of any pixel point.
[0070] In one embodiment, the calculation formula for the importance of any pixel is:
[0071]
[0072] Among them, X is the importance of any pixel; is the gradient value of the jth pixel in the horizontal gradient line graph or the vertical gradient line graph; n is the number of pixels in the horizontal gradient line graph or the vertical gradient line graph; is the left change rate of any pixel in the horizontal gradient line graph or vertical gradient line graph; is the right change rate of any pixel point in the horizontal gradient line graph or the vertical gradient line graph; a is the horizontal gradient line graph or the vertical gradient line graph; || is the absolute value symbol; 1 is a constant.
[0073] It should be noted that is the gradient mean of the horizontal gradient line graph or the vertical gradient line graph, The smaller the value, the more evenly the grayscale distribution on both sides of any pixel in the horizontal gradient line graph or vertical gradient line graph is, and the more consistent it is with the local distribution characteristics of edge pixels, the greater the importance of any pixel. is the gradient change difference value of any pixel in the horizontal gradient line graph or vertical gradient line graph, The smaller it is, the more similar the left change rate and right change rate of any pixel point in the horizontal gradient line graph or the vertical gradient line graph are, the higher the degree of symmetry of the gradient values of the pixels on both sides is, the more consistent it is with the local distribution characteristics of the edge pixels, and the greater the importance of any pixel point.
[0074] (2) Obtain the abnormality degree of any pixel.
[0075] Since the position and size of the defect area are random, in order to prevent the defect area features in a too small window from being too weak to be obtained, and the too large window from containing too many normal areas, thereby weakening the defect area features, windows of different sizes should be set when obtaining the abnormality degree of any pixel point. In this embodiment, the second preset number is set to 3, and square windows of sizes of 3×3, 7×7, and 11×11 are established with any pixel point as the center. There is no limitation here and it can be set according to the specific implementation scenario;
[0076] Since the grayscale changes of the defective part are complex, and it is necessary to consider whether the grayscale fluctuation is caused by the regular texture of the plastic injection molded part; secondly, although some defective parts have texture, their texture continuity is poor, and the texture may be broken or missing, which is manifested as low similarity in the grayscale changes of pixels in adjacent rows within the square window. Therefore, the abnormality degree of any pixel can be obtained based on the grayscale value difference and grayscale value correlation degree of the pixel points in each square window. Specifically:
[0077] For any square window, the grayscale values of each row of pixels in the square window are combined into a grayscale value sequence, the standard deviation of each grayscale value sequence is obtained, and the mean of the standard deviation is obtained. The ratio of the standard deviation of each grayscale value sequence to the mean of the standard deviation is calculated, and the accumulated value of the ratio is obtained.
[0078] Obtain the Pearson correlation coefficient between the grayscale value sequences of every two adjacent rows in any square window, and obtain the corresponding mean of the Pearson correlation coefficient. The Pearson correlation coefficient belongs to the prior art and will not be described in detail here.
[0079] Obtaining the product of the ratio cumulative value and the inverse of the mean of the Pearson correlation coefficient to obtain the outlier value of any square window;
[0080] According to the method for obtaining the abnormal value of any square window, the abnormal value of each square window is obtained respectively, and the corresponding average of the abnormal values is obtained as the abnormal degree of any pixel point.
[0081] In one embodiment, the calculation formula for the abnormality degree of any pixel is:
[0082]
[0083] Wherein, Y is the abnormality degree of any pixel; m is the second preset number (i.e., the number of square windows); is the standard deviation of the grayscale value sequence of the pixel point in the tth row in the cth square window; s is the total number of rows of pixel points in the cth square window; is the Pearson correlation coefficient between the gray value sequence of the pixels in the t-th row and the gray value sequence of the pixels in the t+1-th row in the c-th square window.
[0084] It should be noted that is the cumulative value of the ratio of the c-th square window of any pixel point, The larger the value is, the greater the fluctuation of the grayscale value of each row of pixels in the c-th square window of any pixel is, the more consistent any pixel is with the characteristics of the edge pixel of the defect area, and the greater the abnormality of any pixel is; is the mean of the Pearson correlation coefficient of the c-th square window of any pixel point, The smaller it is, the lower the similarity of the grayscale values of the pixels in the c-th square window of any pixel is, which is more consistent with the characteristics of poor texture continuity in the defect area, and the greater the abnormality of any pixel is.
[0085] (3) Combining the importance and abnormality of any pixel point, the comprehensive importance of any pixel point is obtained.
[0086] Specifically, the product of the importance and the abnormality is normalized to obtain the comprehensive importance of any pixel.
[0087] In one embodiment, the calculation formula for the comprehensive importance of any pixel is:
[0088] Z=nrom(X×Y)
[0089] Among them, Z is the comprehensive importance of any pixel; X is the importance of any pixel; Y is the abnormality of any pixel; norm() is the normalization function.
[0090] It should be noted that the greater the importance of any pixel point, the more likely it is that any pixel point is an edge pixel point, and the greater the comprehensive importance of any pixel point; the greater the abnormality of any pixel point, the more likely it is that any pixel point is an edge pixel point of the defect area, and the greater the comprehensive importance of any pixel point.
[0091] At this point, the comprehensive importance of any pixel is obtained.
[0092] Step S103 : establishing a target window of a preset size with the arbitrary pixel point as the center, and obtaining the jump degree of the arbitrary pixel point according to the grayscale value difference of the pixel points in the target window.
[0093] After obtaining the comprehensive importance of any pixel, it is necessary to perform image enhancement on any pixel. However, due to the different degrees of defect, the local grayscale jump degree of the defect part is also different. When a fixed Laplace operator is used to enhance the image, the area with inconspicuous grayscale jump may not be effectively enhanced because the Laplace operator is too small; the area with obvious grayscale jump is over-enhanced and artifacts appear because the Laplace operator is too large. In order to enhance the subtle defect area while eliminating the artifacts caused by over-enhancement of strong edges, it is necessary to combine the jump degree and comprehensive importance of the pixel point to obtain the optimized Laplace operator corresponding to any pixel point, and then use the optimized Laplace operator to perform image enhancement on any pixel point.
[0094] In this embodiment, when using the Laplace transform algorithm, the following is adopted: Figure 3 The Laplace kernel shown in the figure is used. Therefore, a target window with a preset size of 3×3 is established with any pixel as the center. There is no limitation here. It can be set according to the specific implementation scenario. The jump degree of any pixel is obtained according to the gray value difference of the pixels in the target window. Specifically:
[0095] In the target window, the grayscale value mean of the four neighboring pixels of any pixel is obtained, and the absolute value of the difference between the grayscale value mean and the grayscale value of any pixel is normalized to obtain the jump degree of any pixel.
[0096] In one embodiment, the calculation formula for the transition degree of any pixel is:
[0097]
[0098] Where T is the jump degree of any pixel; g is the gray value of any pixel; is the mean grayscale value of the four neighboring pixels of any pixel; norm() is the normalization function.
[0099] It should be noted that the greater the difference between the grayscale values of the four neighboring pixels of any pixel and the grayscale value of any pixel, the greater the jump degree of any pixel.
[0100] At this point, the jump degree of any pixel point is obtained.
[0101] Step S104: Set an initial Laplace operator, optimize the initial Laplace operator according to the comprehensive importance and jump degree of any pixel point, obtain an optimized Laplace operator for any pixel point, use the optimized Laplace operator as the Laplace operator in the Laplace transform algorithm, and perform image enhancement processing on any pixel point.
[0102] After obtaining the jump degree and comprehensive importance of any pixel point, it is necessary to obtain the optimized Laplace operator corresponding to any pixel point, and then use the optimized Laplace operator to perform image enhancement on any pixel point.
[0103] When the jump degree of any pixel point is smaller, if the comprehensive importance of any pixel point is higher, it means that any pixel point belongs to the edge pixel point of the defect area, but the jump degree is not obvious and difficult to distinguish. At this time, it is necessary to increase the response strength of the Laplace operator to further enhance it; when the jump degree of any pixel point is larger, in order to prevent artifacts from appearing in the image, regardless of whether it is a defect area, the response strength of the Laplace operator needs to be reduced to prevent artifacts from appearing. That is, at this time, only the importance of any pixel point is considered. Then, according to the comprehensive importance and jump degree of any pixel point, the initial Laplace operator is optimized, and the steps for obtaining the optimized Laplace operator of any pixel point are as follows:
[0104] In this embodiment, the jump degree threshold is set to 0.6 based on historical experience. Since the commonly used center coefficient of the Laplace operator is -4, the center coefficient of the initial Laplace operator is set to -4. There is no restriction here and it can be set according to the specific implementation scenario. If the jump degree of any pixel point is greater than or equal to 0.6, any pixel point is recorded as a high-jump pixel point. According to the jump degree and importance of the high-jump pixel point, the center coefficient of the initial Laplace operator is optimized to obtain the optimized center coefficient.
[0105] Specifically, the product of the jump degree and the importance degree of any pixel point is normalized to obtain an adjustment value, and the optimized center coefficient is obtained according to the addition result of the center coefficient and the adjustment value.
[0106] In one embodiment, the calculation formula for the optimized center coefficient of the high-jump pixel point is:
[0107] G = -4 + exp(T × X)
[0108] Among them, G is the optimized center coefficient of the high-jump pixel; T is the jump degree of the high-jump pixel; X is the importance of the high-jump pixel; exp() is an exponential function with a natural constant as the base, used for normalization; -4 is the center coefficient of the initial Laplace operator.
[0109] It should be noted that the greater the jump degree of the high-jump pixel, the higher the possibility that the high-jump pixel belongs to the edge pixel, the larger the optimized center coefficient of the high-jump pixel, and the smaller the sharpening intensity of the optimized Laplace operator corresponding to the optimized center coefficient.
[0110] If the jump degree of any pixel point is less than 0.6, then any pixel point is recorded as a low jump pixel point, and the central coefficient of the initial Laplace operator is optimized according to the jump degree and comprehensive importance of the low jump pixel point to obtain the optimized central coefficient.
[0111] Specifically, the product of the inverse of the jump degree of any pixel point and the comprehensive importance is normalized to obtain an adjustment value, and the optimized center coefficient is obtained according to the difference between the center coefficient and the adjustment value.
[0112] In one embodiment, the calculation formula for the optimized center coefficient of the low-jump pixel point is:
[0113]
[0114] Among them, D is the optimized center coefficient of the low-jump pixel; T is the jump degree of the low-jump pixel; Z is the comprehensive importance of the low-jump pixel; exp() is an exponential function with a natural constant as the base, used for normalization; -4 is the center coefficient of the initial Laplace operator.
[0115] It should be noted that the greater the comprehensive importance of the low-jump pixel, the greater the possibility that the low-jump pixel belongs to the edge pixel of the defect area, the smaller the optimization center coefficient of the low-jump pixel, and the greater the sharpening intensity of the optimized Laplace operator corresponding to the optimization center coefficient.
[0116] After obtaining the optimized center coefficient of any pixel point, the optimized Laplace operator of any pixel point is obtained according to the optimized center coefficient. Obtaining the Laplace operator according to the center coefficient belongs to the existing technology and will not be repeated here.
[0117] Furthermore, after obtaining the optimized Laplace operator of any pixel point, the optimized Laplace operator is used as the Laplace operator in the Laplace transform algorithm to perform image enhancement processing on any pixel point. The Laplace transform algorithm belongs to the existing technology and will not be described in detail here.
[0118] At this point, the image enhancement processing of any pixel is completed.
[0119] Step S105 , performing image enhancement processing on each pixel in the grayscale image to obtain an enhanced image, performing defect detection on the enhanced image to obtain a surface defect area of the plastic injection molded part.
[0120] According to the above-mentioned method for image enhancement processing of any pixel point, image enhancement processing is performed on each pixel point in the grayscale image to obtain an enhanced image.
[0121] Acquire and train a large number of defect area images with surface texture, color, shape and other features, use machine learning algorithms to obtain a detection model for automatic identification and positioning of surface defect areas of plastic injection molded parts, input the obtained enhanced images into the detection model, obtain the surface defect areas of the plastic injection molded parts, and complete the automatic identification and positioning of surface defect areas of the plastic injection molded parts.
[0122] The main purpose of the present invention is to optimize the Laplace operator in the Laplace transform algorithm. Using a machine learning algorithm to obtain a detection model and using the detection model to detect the enhanced image belong to the existing technology and will not be repeated here.
[0123] In summary, this embodiment obtains a surface image of a plastic injection molded part, performs grayscale processing on the surface image, and obtains a grayscale image; for any pixel point in the grayscale image, at least two windows of different preset sizes are constructed with the any pixel point as the center, and the comprehensive importance of the any pixel point is obtained according to the grayscale value difference and grayscale value correlation degree of the pixel points in each of the windows; a target window of a preset size is established with the any pixel point as the center, and the jump degree of the any pixel point is obtained according to the grayscale value difference of the pixel points in the target window; an initial Laplace operator is set, and the initial Laplace operator is optimized according to the comprehensive importance and jump degree of the any pixel point to obtain an optimized Laplace operator of the any pixel point, and the optimized Laplace operator is used as the Laplace operator in the Laplace transform algorithm to perform image enhancement processing on the any pixel point; image enhancement processing is performed on each pixel point in the grayscale image respectively to obtain an enhanced image, and defect detection is performed on the enhanced image to obtain a surface defect area of the plastic injection molded part. Among them, according to the grayscale value difference and grayscale value correlation degree of pixel points in the grayscale image, the comprehensive importance and jump degree of each pixel point are obtained, and then the Laplace operator in the Laplace transform algorithm is optimized according to the comprehensive importance and jump degree of each pixel point, so that the defective part in the enhanced image obtained by the Laplace transform algorithm is effectively enhanced while the overall image remains clear and free of artifacts, thereby increasing the accuracy of subsequent automatic identification and positioning of defective areas of injection molded parts.
[0124] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for automatically identifying and locating surface defects of plastic injection molded parts, characterized in that: The method comprises: Acquiring a surface image of a plastic injection molded part, and performing grayscale processing on the surface image to obtain a grayscale image; For any pixel point in the grayscale image, construct at least two windows of different preset sizes with the pixel point as the center, and obtain the comprehensive importance of the pixel point based on the grayscale value difference and grayscale value correlation degree of the pixel points in each window; A target window of a preset size is established with any pixel point as the center, and the jump degree of any pixel point is obtained according to the grayscale value difference of the pixel points in the target window; Setting an initial Laplace operator, optimizing the initial Laplace operator according to the comprehensive importance and jump degree of any pixel point to obtain an optimized Laplace operator for any pixel point, using the optimized Laplace operator as the Laplace operator in the Laplace transform algorithm, and performing image enhancement processing on the any pixel point; Image enhancement processing is performed on each pixel point in the grayscale image to obtain an enhanced image, and defect detection is performed on the enhanced image to obtain a surface defect area of the plastic injection molded part.
2. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 1, characterized in that: The step of constructing at least two windows of different preset sizes with any pixel point as the center includes: In the grayscale image, taking the any pixel point as the center, the any pixel point and a first preset number of pixel points in the horizontal direction thereof form a horizontal window; Form a vertical window by combining the any pixel point and a first preset number of pixel points in the vertical direction thereof; A second preset number of square windows of different sizes are established with any pixel point as the center.
3. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 2, characterized in that: Obtaining the comprehensive importance of any pixel point according to the grayscale value difference and grayscale value correlation degree of the pixel points in each window includes: Obtaining the gradient value of each pixel point in the horizontal window respectively to obtain a horizontal gradient line graph, wherein the horizontal coordinate of the horizontal gradient line graph is the pixel position number and the vertical coordinate is the gradient value; Obtaining the gradient value of each pixel point in the vertical window respectively to obtain a vertical gradient line graph, wherein the horizontal coordinate of the vertical gradient line graph is the pixel position number and the vertical coordinate is the gradient value; Obtaining the importance of any pixel point according to fluctuation characteristics of gradient values in the horizontal gradient line graph and the vertical gradient line graph; Obtaining the abnormality degree of any pixel point according to the grayscale value difference and grayscale value correlation degree of the pixel points in each square window; The product of the importance and the abnormality is normalized to obtain the comprehensive importance of any pixel.
4. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 3, characterized in that: The obtaining the importance of any pixel point according to the fluctuation characteristics of the gradient values in the horizontal gradient line graph and the vertical gradient line graph includes: In the horizontal gradient line graph, the gradient change rate between any pixel point and its left adjacent pixel point is obtained, which is recorded as the left change rate; the gradient change rate between any pixel point and its right adjacent pixel point is obtained, which is recorded as the right change rate; Obtaining the absolute value of the ratio of the left change rate to the right change rate to obtain a change rate ratio, and calculating the absolute value of the difference between a constant 1 and the change rate ratio to obtain a gradient change difference value of any pixel point; Obtaining a gradient mean of the horizontal gradient line graph, calculating the product of the reciprocal of the gradient mean and the reciprocal of the gradient change difference value, and obtaining an edge feature value of any pixel point in the horizontal direction; The edge feature value of any pixel point in the vertical direction is obtained according to the vertical gradient line graph, and the importance of any pixel point is obtained according to the average value between the edge feature value in the horizontal direction and the edge feature value in the vertical direction of any pixel point.
5. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 3, characterized in that: The step of obtaining the abnormality degree of any pixel point according to the grayscale value difference and grayscale value correlation degree of the pixel points in each square window includes: For any square window, the grayscale values of each row of pixels in the square window are combined into a grayscale value sequence, the standard deviation of each grayscale value sequence is obtained, and the mean of the standard deviation is obtained. The ratio of the standard deviation of each grayscale value sequence to the mean of the standard deviation is calculated, and the accumulated value of the ratio is obtained. Obtain the Pearson correlation coefficient between the grayscale value sequences of every two adjacent rows in any square window, and obtain the corresponding mean of the Pearson correlation coefficient; Obtaining the product of the ratio cumulative value and the inverse of the mean of the Pearson correlation coefficient to obtain the outlier value of any square window; The outlier value of each square window is obtained respectively, and the corresponding outlier value mean is obtained as the outlier degree of any pixel point.
6. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 1, characterized in that: The step of obtaining the transition degree of any pixel point according to the grayscale value difference of the pixel points in the target window includes: In the target window, the grayscale value mean of the four neighboring pixels of any pixel is obtained, and the absolute value of the difference between the grayscale value mean and the grayscale value of any pixel is normalized to obtain the jump degree of any pixel.
7. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 3, characterized in that: The step of optimizing the initial Laplace operator according to the comprehensive importance and jump degree of any pixel point to obtain the optimized Laplace operator of any pixel point includes: Setting a transition degree threshold and a central coefficient of an initial Laplace operator, and if the transition degree of any pixel point is greater than or equal to the transition degree threshold, optimizing the central coefficient of the initial Laplace operator according to the transition degree and importance of any pixel point to obtain an optimized central coefficient; If the jump degree of any pixel point is less than the jump degree threshold, optimizing the central coefficient of the initial Laplace operator according to the jump degree and comprehensive importance of any pixel point to obtain an optimized central coefficient; According to the optimized central coefficient, the optimized Laplace operator of any pixel point is obtained.
8. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 7, characterized in that: Optimizing the central coefficient of the initial Laplace operator according to the jump degree and importance of any pixel point includes: Normalizing the product of the jump degree and the importance degree of any pixel point to obtain an adjustment value, and obtaining an optimized center coefficient based on the sum of the center coefficient and the adjustment value.
9. The method for automatically identifying and locating surface defects of plastic injection molded parts according to claim 7, characterized in that: Optimizing the central coefficient of the initial Laplace operator according to the jump degree and comprehensive importance of any pixel point includes: The product of the inverse of the jump degree of any pixel point and the comprehensive importance is normalized to obtain an adjustment value, and the optimized center coefficient is obtained according to the difference between the center coefficient and the adjustment value.
Citation Information
Patent Citations
Aluminum alloy auto part mold defect detection method based on image processing
CN117011297A
Injection molding part production quality detection method based on image enhancement
CN117036205A
Defect detection method for high-strength stamping part
CN117830139A
Road surface defect intelligent identification method and system based on machine vision
CN119205784A
Screen defect detection method and apparatus, and device and storage medium
WO2025045021A1