Carton defect recognition method and system based on image processing
By constructing a gray-level co-occurrence matrix on the surface of cardboard boxes, analyzing texture features, and identifying scratch defects, the problem of misidentification in traditional methods is solved, and the accuracy of scratch identification is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHAANXI POLY HUAYING PACKAGING CO LTD
- Filing Date
- 2026-06-25
- Publication Date
- 2026-07-28
AI Technical Summary
Traditional defect detection methods are prone to misidentifying paper fiber textures or regular printing structures as scratch areas, resulting in low accuracy in identifying scratch defects on the surface of cartons.
By acquiring grayscale images of the cardboard box surface, dividing it into several regions and constructing a grayscale co-occurrence matrix, the dominance of the main peak, the competition of the secondary peaks, the disorder, the directional uniformity, and the randomness of the texture are analyzed. Combined with the scratch factor, scratch defect areas are identified.
It improves the accuracy of identifying scratch defects on the surface of cartons, reduces the interference of paper fiber texture and regular indentations on identification, and enhances the ability to identify scratch structures.
Smart Images

Figure CN122473162A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically to a method and system for identifying defects in cardboard boxes based on image processing. Background Technology
[0002] With the widespread use of cardboard packaging in logistics, warehousing, and industrial product packaging, the integrity of the cardboard box surface has gradually become an important factor affecting packaging quality and transportation safety. During the production, handling, and stacking of cardboard boxes, the surface of the cardboard box is easily subjected to friction from hard structures, mechanical scratches, and external impacts, resulting in scratches. Since scratches disrupt the continuity of the cardboard box's surface fiber structure, they can easily form localized stress concentration areas during subsequent pressure, transportation, and stacking, leading to a decrease in the local structural strength of the cardboard box. In severe cases, this can even cause problems such as damage, cracking, and reduced load-bearing capacity of the cardboard box.
[0003] However, since the surface of cardboard boxes usually has complex structures such as paper fiber texture, printing patterns, corrugated indentations and local random textures, different textures are prone to forming grayscale change features with similar directions in the image. As a result, traditional defect detection methods are prone to misidentifying paper fiber texture or regular printing structures as scratch areas, resulting in low accuracy in identifying scratch defects on the surface of cardboard boxes. Summary of the Invention
[0004] This invention provides a method and system for identifying cardboard box defects based on image processing, in order to solve the existing problem that traditional defect detection methods easily misidentify paper fiber textures or regular printing structures as scratch areas, resulting in low accuracy in identifying scratch defects on the cardboard box surface.
[0005] The image processing-based cardboard box defect identification method and system of the present invention adopts the following technical solution: One embodiment of the present invention provides a method for identifying defects in cardboard boxes based on image processing, the method comprising the following steps: Acquire a grayscale image of the cardboard box surface, divide the grayscale image of the cardboard box surface into several cardboard box regions, and construct the grayscale co-occurrence matrix of each direction of the cardboard box region; Based on the gray-level co-occurrence matrix of the cardboard box area in each direction, the dominance of the texture primary peak in the cardboard box area is obtained; based on the energy of the gray-level co-occurrence matrix of the cardboard box area in different directions, the competition degree of the texture secondary peak in the cardboard box area is obtained; based on the dominance of the texture primary peak and the competition degree of the texture secondary peak in the cardboard box area, the texture disorder of the cardboard box area is obtained. Based on the energy proportion of the gray-level co-occurrence matrix in each direction of the cardboard area, the texture direction uniformity of the cardboard area is obtained; based on the texture disorder and texture direction uniformity of the cardboard area, the texture disorder of the cardboard area is obtained; based on the energy distribution pattern of the gray-level co-occurrence matrix in each direction of the cardboard area, the energy peak intensity of the cardboard area is obtained; combined with the texture disorder of the cardboard area, the scratch factor of the cardboard area is obtained. Defect areas are identified based on the scratch factor of the cardboard box area.
[0006] Preferably, the specific method for obtaining the texture dominance of the cardboard box region based on the gray-level co-occurrence matrix in each direction of the cardboard box region includes: Obtain the energy of the gray-level co-occurrence matrix in all directions of the cardboard box area, and record the maximum energy as the principal energy value; divide the principal energy value by the sum of the energies of the gray-level co-occurrence matrix in all directions, and use the ratio as the texture dominance of the cardboard box area.
[0007] Preferably, the method for obtaining the texture second-peak competitiveness degree of the cardboard box region based on the energy of the gray-level co-occurrence matrix in different directions of the cardboard box region includes: The maximum energy other than the maximum energy in the gray-level co-occurrence matrix of all directions in the cardboard box area is recorded as the secondary energy value. The ratio between the secondary energy value and the sum of the primary energy value and the secondary energy value is used as the texture secondary peak competition degree of the cardboard box area.
[0008] Preferably, the method for obtaining the texture disorder of the cardboard box area based on the dominance of the primary texture peak and the competition of the secondary texture peaks includes: The texture disorder of the cardboard box area is negatively correlated with the dominance of the texture peak in the cardboard box area. The texture disorder of the cardboard box area is positively correlated with the texture second peak competition degree of the cardboard box area.
[0009] Preferably, the method for obtaining the texture direction uniformity of the cardboard box area based on the energy proportion of the gray-level co-occurrence matrix in each direction of the cardboard box area includes: Based on the proportion of the energy of the gray-level co-occurrence matrix in each direction of the cardboard box area to the total energy of the gray-level co-occurrence matrix in all directions of the cardboard box area, the information entropy of the energy probability distribution in each direction of the cardboard box area is obtained, and the information entropy of the energy probability distribution in each direction of the cardboard box area is used as the texture direction uniformity of the cardboard box area.
[0010] Preferably, the specific method for obtaining the texture disorder degree of the cardboard box area based on the texture disorder degree and texture direction uniformity of the cardboard box area includes: The product of the texture disorder of the cardboard box area and the texture direction uniformity of the cardboard box area is used as the texture disorder degree of the cardboard box area.
[0011] Preferably, the method for obtaining the energy peak intensity of the cardboard box region based on the energy distribution pattern of the gray-level co-occurrence matrix in each direction of the cardboard box region includes: The kurtosis of the energy distribution of the gray-level co-occurrence matrix in each direction of the cardboard box area is taken as the energy peak spur of the cardboard box area.
[0012] Preferably, the specific method for obtaining the scratch factor of the carton area is as follows: The scratch factor of the cardboard box area is positively correlated with the energy peak intensity of the cardboard box area; The scratch factor of the cardboard box area is negatively correlated with the texture disorder of the cardboard box area.
[0013] Preferably, the method for obtaining the defect area based on the scratch factor of the carton area includes: If the scratch factor of the carton area is greater than the preset scratch threshold, the carton area will be designated as a defective area.
[0014] Another embodiment of the present invention provides a carton defect identification system based on image processing, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of any of the above-described carton defect identification methods based on image processing.
[0015] The beneficial effects of the technical solution of this invention are as follows: This invention acquires grayscale images of the cardboard box surface and constructs grayscale co-occurrence matrices in each direction of the cardboard box area to quantitatively analyze the texture distribution state in different directions of the cardboard box area; further, it obtains the texture disorder of the cardboard box area through the dominance degree of the texture main peak and the competition degree of the texture secondary peak to characterize the competition relationship and the stability of the directional structure in different directions of the cardboard box area; simultaneously, it obtains the texture disorder of the cardboard box area through texture direction uniformity and texture disorder to quantify the diffusion state of directional energy and the disorder of the directional structure in the cardboard box area; further, it obtains the energy peak prominence of the cardboard box area by analyzing the energy distribution pattern of the grayscale co-occurrence matrix in each direction of the cardboard box area, and obtains the scratch factor of the cardboard box area by combining the texture disorder, thereby strengthening the scratch texture structure with concentrated direction, stable direction and sharp main peak, and weakening the interference of non-scratching structures such as paper fiber texture, crack branches and regular indentations on defect identification, thereby improving the accuracy of scratch defect identification on the cardboard box surface. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of the steps of the image processing-based cardboard box defect identification method of the present invention. Detailed Implementation
[0018] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of the image processing-based cardboard box defect identification method and system proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0020] The following description, in conjunction with the accompanying drawings, details the specific scheme of the image processing-based cardboard box defect identification method and system provided by this invention.
[0021] Please see Figure 1 The diagram illustrates a flowchart of a cardboard box defect identification method based on image processing according to an embodiment of the present invention. The method includes the following steps: Step S001: Obtain the grayscale image of the cardboard box surface, divide the grayscale image of the cardboard box surface into several cardboard box regions, and construct the grayscale co-occurrence matrix of each direction of the cardboard box region.
[0022] It should be noted that, since the paper fiber texture and corrugated indentations on the surface of the cardboard box will form directional grayscale changes in the image, and the scratches on the surface of the cardboard box will also appear as linear structures extending in a single direction, if a unified analysis is performed directly based on the entire image, the recognition of local defect features will easily be reduced due to the superposition of texture directions between different areas. Therefore, this embodiment first divides the grayscale image of the cardboard box surface into several cardboard box regions, so that each cardboard box region only contains texture structures within a local range, in order to reduce the interference of long-distance texture coupling on directional feature analysis. Furthermore, since the essential difference between scratches and paper fiber textures mainly lies in the texture distribution state in different directions, a grayscale co-occurrence matrix is constructed for each direction of the cardboard box region to quantify the grayscale co-occurrence relationship in different directions of the cardboard box region. This allows for subsequent analysis of the degree of directional concentration, directional competition, and directional dispersion trend in the cardboard box region, thereby accurately identifying scratch defects on the surface of the cardboard box.
[0023] Specifically, a high-definition industrial camera is used to capture surface images of the cardboard box. These images are then converted to grayscale and denoised using Gaussian filtering to obtain a grayscale image of the cardboard box surface. Since grayscale conversion and Gaussian filtering are well-known existing technologies, they will not be described in detail in this embodiment. A preset... Sliding window of different sizes, and with Using the sliding step size, the grayscale image of the cardboard box surface is traversed, and the area within each sliding window is taken as the cardboard box area; and The specific value can be set according to the actual situation. This embodiment does not make a hard requirement. In this embodiment, it is used as... Equal to 15 Let's take 15 as an example; Furthermore, a preset number of analysis directions is allowed. The The specific value can be set according to the actual situation. This embodiment does not make a hard requirement. In this embodiment, it is used as... Taking an example of 8, the gray-level co-occurrence matrix of each carton area in each direction is constructed. Since the gray-level co-occurrence matrix is a well-known existing technology, it will not be described in detail in this embodiment.
[0024] Step S002: Based on the gray-level co-occurrence matrix of the cardboard box area in each direction, obtain the texture primary peak dominance of the cardboard box area; based on the energy of the gray-level co-occurrence matrix of the cardboard box area in different directions, obtain the texture secondary peak competition degree of the cardboard box area; based on the texture primary peak dominance and texture secondary peak competition degree of the cardboard box area, obtain the texture disorder degree of the cardboard box area.
[0025] It should be noted that scratches are usually formed by external hard structures scraping along a fixed direction, and their surface texture edges have strong consistency. Therefore, the texture direction energy of scratches is usually concentrated in a certain main direction. However, structures such as paper fiber texture and local indentation will cause obvious texture responses in multiple directions at the same time, thus forming a directional competition phenomenon. Therefore, this embodiment obtains the texture main peak dominance of the cardboard area by analyzing the energy distribution of the gray-level co-occurrence matrix in different directions, so as to characterize whether there is a dominant directional texture structure in the cardboard area. At the same time, the texture secondary peak competition degree of the cardboard area is obtained to characterize the degree of competition of other directions for the main direction besides the main direction. When there are scratches in the cardboard area, its texture direction usually has strong consistency, so the energy proportion of the main direction is high and the competition degree of the secondary direction is low. Conversely, when there are no scratches in the cardboard area, energy competition is easily formed between different texture directions, resulting in a chaotic directional structure. Therefore, by combining the texture main peak dominance degree and the texture secondary peak competition degree, the texture chaos degree of the cardboard area is obtained to quantify the stability of the directional structure of the cardboard area, thereby providing a directional structure basis for subsequent scratch feature analysis.
[0026] Specifically, the energy of the gray-level co-occurrence matrix in all directions of the cardboard box area is obtained, and the maximum energy is recorded as the principal energy value. The ratio of the principal energy value to the sum of the energies of the gray-level co-occurrence matrix in all directions is used as the texture dominance of the cardboard box area.
[0027] As an example, the specific formula for calculating the dominance of the texture peak in the cardboard box area is as follows: ; In the formula, This indicates the dominance of the texture peak in the cardboard box area; Indicates the cardboard box area number The energy of the gray-level co-occurrence matrix in each direction; This represents the energy of the gray-level co-occurrence matrix with the highest energy in all directions of the cardboard box area; Indicates the cardboard box area number In the gray-level co-occurrence matrix of the i-th direction The element value of each element; Indicates the cardboard box area number The number of elements in the gray-level co-occurrence matrix in each direction; This represents the number of gray-level co-occurrence matrices in all directions of the cardboard box area.
[0028] It should be noted that the scratch texture on the surface of the cardboard box has strong directional consistency, causing the grayscale changes to be mainly concentrated in a specific direction. This results in the energy of the grayscale co-occurrence matrix in the corresponding direction being significantly higher than that in other directions. Therefore, this embodiment first quantifies the texture stability in different directions of the cardboard box area by using the energy of the grayscale co-occurrence matrix. The higher the energy of the grayscale co-occurrence matrix, the more concentrated the grayscale distribution and the more stable the texture structure in the corresponding direction. At the same time, the maximum energy in all directions is obtained as the principal energy value to characterize the dominant texture direction in the cardboard box area. The dominance of the texture peak in the cardboard box area is obtained by using the proportion of the principal energy value in the total energy of all directions to quantify the degree of dominance of the main direction texture on the overall directional structure, thereby characterizing the concentration of texture direction in the cardboard box area.
[0029] Specifically, the maximum energy other than the maximum energy in the gray-level co-occurrence matrix of all directions in the cardboard area is recorded as the secondary energy value. The ratio between this secondary energy value and the sum of the primary energy value and the secondary energy value is used as the texture secondary peak competition degree of the cardboard area.
[0030] It should be noted that when paper fiber diffusion or local random textures exist in the cardboard box area, strong texture responses may also occur in other directions besides the main direction, leading to directional competition among multiple directions. Therefore, this embodiment uses the second largest energy in the gray-level co-occurrence matrix of all directions as the secondary energy value to characterize the most significant secondary direction texture intensity in the cardboard box area besides the main direction. Furthermore, by analyzing the proximity between the secondary energy value and the main energy value, the texture secondary peak competition degree of the cardboard box area is obtained to quantify the degree of competition between the secondary direction and the main direction. When there are obvious scratches in the cardboard box area, the energy of the main direction is usually significantly higher than that of the secondary direction because the texture edge direction is uniform, resulting in low texture secondary peak competition degree. However, when there is directional diffusion or branching structure in the cardboard box area, the energy of the secondary direction will gradually approach the energy of the main direction, leading to an increase in texture secondary peak competition degree. Therefore, the texture secondary peak competition degree can effectively characterize the competition intensity and directional splitting trend between different directions in the cardboard box area.
[0031] Specifically, the texture disorder of the cardboard box area is obtained based on the dominance of the primary texture peak and the competition of the secondary texture peaks in the cardboard box area. The texture disorder of the cardboard box area is negatively correlated with the dominance of the main texture peak in the cardboard box area; the texture disorder of the cardboard box area is positively correlated with the competition of the secondary texture peaks in the cardboard box area.
[0032] As an example, the specific formula for calculating the texture disorder of the cardboard box area is: ; In the formula, Indicates the texture disorder of the cardboard box area; This indicates the dominance of the texture peak in the cardboard box area; This indicates the second-peak competitiveness of the texture in the cardboard box area.
[0033] It should be noted that the dominance of the main texture peak quantifies the concentration of texture in the main direction in the cardboard box area. Since the stronger the dominance of the main direction, the more stable the directional structure in the cardboard box area, texture disorder is negatively correlated with the dominance of the main texture peak. At the same time, the competition between the secondary texture peaks quantifies the degree of competition between different directions. Since the more obvious the competition in the secondary direction, the stronger the directional diffusion trend in the cardboard box area, texture disorder is positively correlated with the competition between the secondary texture peaks. Furthermore, by jointly analyzing the stability of the main direction and the competition relationship of the secondary direction, the texture disorder of the cardboard box area is obtained to quantify the degree of disorder in the directional structure of the cardboard box area, thereby providing a directional structural basis for subsequent scratch area identification.
[0034] At this point, the texture disorder level of the cardboard box area is obtained.
[0035] Step S003: Obtain the texture direction uniformity of the cardboard box area based on the energy proportion of the gray-level co-occurrence matrix in each direction; obtain the texture disorder of the cardboard box area based on the texture disorder and texture direction uniformity; obtain the energy peak intensity of the cardboard box area based on the energy distribution pattern of the gray-level co-occurrence matrix in each direction; and obtain the scratch factor of the cardboard box area by combining the texture disorder of the cardboard box area.
[0036] It should be noted that scratches on the surface of a cardboard box typically appear as sharp textures extending continuously in a single direction, with their directional energy often concentrated in a few directions, resulting in a highly concentrated directional energy distribution. However, the texture of paper fibers causes directional energy to diffuse in multiple directions, making the energy distribution between different directions more uniform. Therefore, this embodiment analyzes the energy proportion of the gray-level co-occurrence matrix in each direction of the cardboard box area to obtain the texture direction uniformity of the cardboard box area, thus characterizing the degree of diffusion of directional energy between different directions. Combined with the texture disorder of the cardboard box area, the texture disorder of the cardboard box area is obtained to quantify the degree of disorder in the directional structure of the cardboard box area. Simultaneously, since scratches typically... Formed by instantaneous cutting of rigid structures, the edge gradient changes more drastically, making it easier for the directional energy distribution to form a sharp main peak. In contrast, corrugated indentation textures typically exhibit a slowly changing broad peak structure. Therefore, by further analyzing the energy distribution pattern of the gray-level co-occurrence matrix in each direction of the cardboard area, the energy peak prominence of the cardboard area is obtained. Combined with the texture disorder of the cardboard area, the scratch factor of the cardboard area is obtained. This strengthens the texture structure of the scratch area, which is characterized by "concentrated direction, stable direction, and sharp main peak," while non-scratching structures such as paper fiber textures and regular indentations are suppressed due to directional dispersion or indistinct main peaks, thereby improving the accuracy of scratch area identification on the cardboard surface.
[0037] Specifically, based on the proportion of the energy of the gray-level co-occurrence matrix in each direction of the cardboard area to the total energy of the gray-level co-occurrence matrix in all directions of the cardboard area, the information entropy of the energy probability distribution in each direction of the cardboard area is obtained, and the information entropy of the energy probability distribution in each direction of the cardboard area is used as the texture direction uniformity of the cardboard area.
[0038] As an example, the specific formula for calculating the texture direction uniformity of the cardboard box area is as follows: ; In the formula, Indicates the uniformity of the texture direction in the cardboard box area; Indicates the cardboard box area number The proportion of the energy of the gray-level co-occurrence matrix in each direction to the total energy of the gray-level co-occurrence matrix in all directions of the cardboard area; Indicates the cardboard box area number The energy of the gray-level co-occurrence matrix in each direction; Indicates the cardboard box area number The energy of the gray-level co-occurrence matrix in each direction; This represents the number of gray-level co-occurrence matrices in all directions of the cardboard box area; This represents the logarithmic function with base 2.
[0039] It should be noted that in this embodiment, the proportion of the energy of the gray-level co-occurrence matrix in each direction of the cardboard area to the total directional energy is used to construct the directional energy probability distribution of the cardboard area. The higher the proportion of energy in a certain direction, the more the texture structure in the cardboard area tends to be distributed along the corresponding direction. Furthermore, the texture direction uniformity of the cardboard area is obtained by the information entropy of the directional energy probability distribution. Since information entropy can characterize the degree of dispersion of the probability distribution, when the directional energy is mainly concentrated in a few directions, the energy distribution difference between each direction is large, resulting in a low texture direction uniformity. However, when the directional energy diffuses to multiple directions, the energy proportion between each direction gradually approaches, thereby increasing the texture direction uniformity. Therefore, the texture direction uniformity can effectively characterize the diffusion degree and directional distribution state of the directional energy in the cardboard area.
[0040] Specifically, the product of the texture disorder of the cardboard box area and the texture direction uniformity of the cardboard box area is used as the texture disorder of the cardboard box area.
[0041] It should be noted that when there are obvious scratches in the cardboard area, the texture direction is stable, resulting in weak directional competition in the cardboard area. At the same time, the directional energy is mainly concentrated in a few directions, so the texture disorder and texture direction uniformity are relatively low. However, when paper fiber diffusion or random texture disturbance occurs in the cardboard area, competition easily forms between different directions, and the directional energy gradually diffuses to multiple directions, resulting in a simultaneous increase in texture disorder and texture direction uniformity. Therefore, this embodiment obtains the texture disorder of the cardboard area by multiplying the texture disorder and texture direction uniformity, so as to jointly quantify the degree of directional disorder in the cardboard area, thereby improving the ability to distinguish between directional diffusion texture and stable scratch texture.
[0042] Specifically, the kurtosis of the energy distribution of the gray-level co-occurrence matrix in each direction of the cardboard box area is taken as the energy peak prominence of the cardboard box area. Combined with the texture disorder of the cardboard box area, the scratch factor of the cardboard box area is obtained. The scratch factor of the cardboard box area is positively correlated with the energy peak intensity of the cardboard box area; the scratch factor of the cardboard box area is negatively correlated with the texture disorder of the cardboard box area.
[0043] As an example, the specific formula for calculating the scratch factor of the cardboard box area is as follows: ; In the formula, Indicates the scratch factor for the cardboard box area; Indicates the cardboard box area number The energy of the gray-level co-occurrence matrix in each direction; This represents the mean energy of the gray-level co-occurrence matrix in all directions of the cardboard box area; The standard deviation of the energy of the gray-level co-occurrence matrix in all directions of the cardboard box area; Indicates the degree of texture disorder in the cardboard box area; This represents the number of gray-level co-occurrence matrices in all directions of the cardboard box area; This embodiment uses an exponential function with the natural constant as the base. The model is used to represent the inverse proportional relationship and for normalization processing. As input to the model, implementers can set the inverse proportional function and the normalization function according to the actual situation; This represents the Softsign activation function, which is used for normalization in this embodiment.
[0044] It should be noted that, since paper fiber texture and regular indentation texture usually exhibit directional energy diffusion in multiple directions or relatively gentle changes in the main peak, this embodiment obtains the energy peak prominence of the carton area by measuring the kurtosis of the gray-level co-occurrence matrix energy distribution in each direction. This quantifies the sharpness of the main peak of directional energy. When directional energy is mainly concentrated in a few directions, the energy distribution is more likely to form a sharp main peak, increasing the energy peak prominence. Conversely, when directional energy diffuses in multiple directions, the directional energy distribution tends to be gentle, decreasing the energy peak prominence. Furthermore, since scratch areas usually have strong directional stability, their texture disorder is usually low, while paper fiber texture and regular indentation texture have high texture disorder due to directional structural disorder. Therefore, the energy peak prominence is modulated by the texture disorder of the carton area to weaken the interference of directional dispersion texture on scratch recognition. This makes the scratch factor positively correlated with the energy peak prominence and negatively correlated with the texture disorder, thereby strengthening the scratch structure with directional concentration, directional stability, and sharp main peak characteristics, and improving the accuracy of scratch area recognition on the carton surface.
[0045] Thus, the scratch factor for the cardboard box area is obtained.
[0046] Step S004: Obtain the defect area based on the scratch factor of the carton area.
[0047] It should be noted that scratches are usually formed by sharp structures continuously cutting the surface of a cardboard box. This not only damages the integrity of the cardboard box surface, but also easily creates stress concentration areas during subsequent transportation, stacking, and compression, leading to a decrease in the local structural strength of the cardboard box and further causing problems such as damage, cracking, and reduced load-bearing capacity. Therefore, in this embodiment, cardboard box areas with scratch characteristics are designated as defect areas. The scratch factor of the cardboard box area is used to quantify the intensity of scratch characteristics in the cardboard box area. When the scratch factor of the cardboard box area is greater than a preset scratch threshold, it indicates that the current cardboard box area has typical scratch texture characteristics such as directional concentration, directional stability, and sharp main peaks. Therefore, the corresponding cardboard box area is determined as a defect area to achieve the identification of scratch defects on the cardboard box surface.
[0048] Specifically, if the scratch factor of the carton area is greater than the preset scratch threshold, the carton area is considered a defective area. The specific value of the scratch threshold can be set according to the actual situation. This embodiment does not make a hard requirement. In this embodiment, the scratch threshold is 0.4 as an example.
[0049] Another embodiment of the present invention provides a carton defect identification system based on image processing, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the carton defect identification method based on image processing in steps S001 to S004.
[0050] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for identifying defects in cardboard boxes based on image processing, characterized in that, The method includes the following steps: Acquire a grayscale image of the cardboard box surface, divide the grayscale image of the cardboard box surface into several cardboard box regions, and construct the grayscale co-occurrence matrix of each direction of the cardboard box region; Based on the gray-level co-occurrence matrix of the cardboard box area in each direction, the dominance of the texture primary peak in the cardboard box area is obtained; based on the energy of the gray-level co-occurrence matrix of the cardboard box area in different directions, the competition degree of the texture secondary peak in the cardboard box area is obtained; based on the dominance of the texture primary peak and the competition degree of the texture secondary peak in the cardboard box area, the texture disorder of the cardboard box area is obtained. Based on the energy proportion of the gray-level co-occurrence matrix in each direction of the cardboard area, the texture direction uniformity of the cardboard area is obtained; based on the texture disorder and texture direction uniformity of the cardboard area, the texture disorder of the cardboard area is obtained; based on the energy distribution pattern of the gray-level co-occurrence matrix in each direction of the cardboard area, the energy peak intensity of the cardboard area is obtained; combined with the texture disorder of the cardboard area, the scratch factor of the cardboard area is obtained. Defect areas are identified based on the scratch factor of the cardboard box area.
2. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The specific method for obtaining the texture dominance of the cardboard box region based on the gray-level co-occurrence matrix in each direction of the cardboard box region includes: Obtain the energy of the gray-level co-occurrence matrix in all directions of the cardboard box area, and record the maximum energy as the principal energy value; divide the principal energy value by the sum of the energies of the gray-level co-occurrence matrix in all directions, and use the ratio as the texture dominance of the cardboard box area.
3. The image processing-based cardboard box defect identification method according to claim 2, characterized in that, The specific method for obtaining the texture second-peak competitiveness degree of the cardboard box region based on the energy of the gray-level co-occurrence matrix in different directions of the cardboard box region includes: The maximum energy other than the maximum energy in the gray-level co-occurrence matrix of all directions in the cardboard box area is recorded as the secondary energy value; the ratio between twice the secondary energy value and the sum of the secondary energy value and the principal energy value is taken as the texture secondary peak competition degree of the cardboard box area.
4. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The method for obtaining the texture disorder of a cardboard box area based on the dominance of the primary texture peak and the competition of the secondary texture peaks includes the following specific methods: The texture disorder of the cardboard box area is negatively correlated with the dominance of the texture peak in the cardboard box area. The texture disorder of the cardboard box area is positively correlated with the texture second peak competition degree of the cardboard box area.
5. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The method for obtaining the texture direction uniformity of the cardboard box area based on the energy proportion of the gray-level co-occurrence matrix in each direction of the cardboard box area includes the following specific methods: Based on the proportion of the energy of the gray-level co-occurrence matrix in each direction of the cardboard box area to the total energy of the gray-level co-occurrence matrix in all directions of the cardboard box area, the information entropy of the energy probability distribution in each direction of the cardboard box area is obtained, and the information entropy of the energy probability distribution in each direction of the cardboard box area is used as the texture direction uniformity of the cardboard box area.
6. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The method for obtaining the texture disorder degree of the cardboard box area based on the texture disorder degree and texture direction uniformity of the cardboard box area includes the following specific methods: The product of the texture disorder of the cardboard box area and the texture direction uniformity of the cardboard box area is used as the texture disorder degree of the cardboard box area.
7. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The method for obtaining the energy peak intensity of the cardboard box region based on the energy distribution pattern of the gray-level co-occurrence matrix in each direction includes: The kurtosis of the energy distribution of the gray-level co-occurrence matrix in each direction of the cardboard box area is taken as the energy peak spur of the cardboard box area.
8. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The specific method for obtaining the scratch factor of the carton area is as follows: The scratch factor of the cardboard box area is positively correlated with the energy peak intensity of the cardboard box area; The scratch factor of the cardboard box area is negatively correlated with the texture disorder of the cardboard box area.
9. The image processing-based cardboard box defect identification method according to claim 1, characterized in that, The specific method for obtaining the defect area based on the scratch factor of the carton area includes: If the scratch factor of the carton area is greater than the preset scratch threshold, the carton area will be designated as a defective area.
10. A cardboard box defect identification system based on image processing, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the steps of the image processing-based carton defect identification method as described in any one of claims 1-9.