A method for detecting abnormal damage to food product packaging boxes

By clustering and feature analysis of packaging box appearance images, and calculating color and edge complexity, the difficulty of damage detection under complex patterns in traditional algorithms is solved, and highly accurate damage identification is achieved.

CN120707564BActive Publication Date: 2025-11-14SHENYANG RUYAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511157329.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-19
Publication Date
2025-11-14
Estimated Expiration
2045-08-19

AI Technical Summary

Technical Problem

Traditional image processing algorithms struggle to accurately identify damage or anomalies in food packaging, especially when the surface has rich colored patterns and text.

Method used

By acquiring images of the packaging box's appearance, the K-means clustering algorithm is used to segment it into different point clusters. The color complexity and edge complexity of the connected components are calculated, and the degree of damage is analyzed by combining color and edge features.

Benefits of technology

It improves the accuracy of damage detection, reduces the interference of complex patterns on detection, and can accurately identify damaged areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707564B_ABST
    Figure CN120707564B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image recognition technology, specifically to a method for detecting abnormal damage to food product packaging boxes. The method involves clustering pixels in an appearance image based on color difference characteristics to obtain different pixel clusters; obtaining different connected components based on the distribution characteristics of pixels within each cluster; obtaining color complexity based on color difference characteristics between adjacent pixels within a connected component and overall color difference characteristics within the connected component; and obtaining edge complexity based on angular variation characteristics of adjacent edge pixels and smoothness characteristics of edge lines within a connected component. This invention determines the degree of abnormal damage to connected components based on color complexity and edge complexity; and detects damage to food product packaging boxes based on the degree of abnormal damage, thus improving the accuracy of damage detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, specifically to a method for detecting abnormal damage to food product packaging boxes. Background Technology

[0002] Food packaging box damage detection refers to the automated identification and judgment of structural defects such as cracks and holes on the surface of food packaging boxes using machine vision technology. Image processing algorithms such as edge detection or feature extraction are typically used to obtain relatively obvious damage edges. However, because food packaging boxes usually have rich colored patterns, trademarks, and text, these can interfere with the recognition process of traditional image processing algorithms. This results in traditional image processing algorithms being unable to accurately determine whether there are damage anomalies in the packaging boxes, affecting the accuracy of food packaging box damage detection. Summary of the Invention

[0003] To address the aforementioned technical problems, the present invention aims to provide a method for detecting abnormal damage to food product packaging boxes. The specific technical solution adopted is as follows:

[0004] Obtain an image of the exterior of the food product packaging box;

[0005] The pixels in the appearance image are clustered according to the color difference characteristics of the pixels to obtain different point clusters; different connected components are obtained according to the distribution characteristics of the pixels in the point clusters.

[0006] Color complexity is obtained based on the color difference features between adjacent pixels in the connected component and the overall color difference features within the connected component; edge complexity is obtained based on the angle change features of adjacent edge pixels in the connected component and the smoothness features of the edge lines.

[0007] The degree of damage anomaly of the connected component is obtained based on the color complexity and the edge complexity; the degree of damage anomaly is used to detect the damage status of the food product packaging box.

[0008] Furthermore, the step of clustering pixels based on color difference features in the appearance image to obtain different pixel clusters includes:

[0009] Based on the RGB three-channel values ​​of the pixels in the appearance image, different point clusters are obtained by using the K-means clustering algorithm.

[0010] Furthermore, the step of obtaining different connected components based on the distribution characteristics of pixels in the point cluster includes:

[0011] The region formed by pixels that are in the same cluster and are adjacent in position is considered as the same connected region.

[0012] Furthermore, the step of obtaining the color complexity based on the color difference features between adjacent pixels in the connected component and the overall color difference features within the connected component includes:

[0013] In the connected component, the sum of the maximum differences in each RGB channel is calculated and normalized to obtain the overall color difference value; the sum of the absolute values ​​of the differences in the RGB three channels between any pixel in the connected component and other pixels in the same connected component within eight neighboring regions is calculated to obtain the first difference between the arbitrary pixel and other pixels; the average of the first differences between the arbitrary pixel and all other pixels in the same connected component within eight neighboring regions is calculated to obtain the local color difference value of the arbitrary pixel; the average of the local color difference values ​​of all pixels in the connected component is calculated and normalized to obtain the local average color difference value; the sum of the overall color difference value and the local average color difference value is calculated to obtain the color complexity of the connected component.

[0014] Furthermore, the step of obtaining the edge complexity based on the angular variation features of adjacent edge pixels of the connected component and the smoothness features of the edge line includes:

[0015] Calculate the angle between any edge pixel and the horizontal axis at the previous adjacent edge pixel in a clockwise direction along the edge lines of the connected region to obtain the relative angle of the arbitrary edge pixel; calculate and normalize the absolute value of the difference between the relative angle and the previous relative angle to obtain the degree of change of the arbitrary edge pixel; count the proportion of edge pixels whose degree of change is not a constant 0 to obtain the degree of change value of the connected region; connect consecutive edge pixels whose degree of change is not a constant 0 to obtain a pixel chain; calculate and normalize the sum of the squares of the number of pixels in all pixel chains on the edge lines to obtain the contour abrupt change degree; calculate the product of the average degree of change of all edge pixels, the degree of change value, and the contour abrupt change degree to obtain the edge complexity of the connected region.

[0016] Furthermore, the step of obtaining the degree of disruption anomaly of the connected component based on the color complexity and the edge complexity includes:

[0017] The degree of disruption of the connected component is obtained by mapping the negative correlation between the color complexity and the edge complexity and calculating the average value of the edge complexity.

[0018] Furthermore, the step of detecting the damage to the food product packaging box based on the degree of damage anomaly includes:

[0019] When there is a connected region where the degree of damage exceeds a preset abnormality threshold, the food product packaging box is damaged.

[0020] The present invention has the following beneficial effects:

[0021] In this invention, since the packaging box surface has rich colors, obtaining different point clusters can divide the positions of different colors in the appearance image, thereby determining the regions of connected components. Since damage appears as a single area in the appearance image, obtaining different connected components can identify areas with similar colors and adjacent positions, thus determining whether the connected component is caused by packaging damage. Because the color distribution characteristics of normal and damaged areas on the packaging box surface differ significantly, obtaining color complexity can analyze whether the connected component is a damaged area based on color features. Since the burr characteristics of the damaged edge are quite obvious, obtaining edge complexity can analyze whether the connected component is a damaged area based on edge shape features. Obtaining the degree of damage anomaly of the connected component based on color complexity and edge complexity can accurately characterize the probability that the connected component is a damaged area. Finally, the damage status of food product packaging boxes is detected based on the degree of damage anomaly, improving the accuracy of damage detection and reducing the interference of complex patterns on the surface of food product packaging boxes on damage detection. Attached Figure Description

[0022] To more clearly illustrate the technical solutions and advantages 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.

[0023] Figure 1 This is a flowchart of a method for detecting abnormal damage to food product packaging boxes, provided as an embodiment of the present invention. Detailed Implementation

[0024] 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 a method for detecting abnormal damage to food product packaging boxes 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.

[0025] 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.

[0026] The following describes in detail, with reference to the accompanying drawings, a specific scheme for detecting abnormal damage to food product packaging boxes provided by the present invention.

[0027] Please see Figure 1 The diagram illustrates a flowchart of a method for detecting abnormal damage to food product packaging boxes according to an embodiment of the present invention. The method includes the following steps:

[0028] Step S1: Obtain an image of the exterior of the food product packaging box.

[0029] In this embodiment of the invention, the food product packaging box being tested is a paper box-type packaging, and the packaging appearance is rich and complex in color. First, an image of the appearance of the food product packaging box is acquired by taking images of each surface of the packaging box using an industrial camera. The shooting environment is kept well-lit and uniform. To prevent shadows and reflections, a high-brightness LED ring light source and a diffuser are used. After shooting, different appearance images of different surfaces are obtained.

[0030] Step S2: Cluster the pixels according to the color difference features of the pixels in the appearance image to obtain different point clusters; obtain different connected components according to the distribution features of the pixels in the point clusters.

[0031] The gaps and cracks caused by damage have a certain area and occupy a certain region of pixels in the image, forming connected components. Therefore, it is first necessary to obtain all connected components in the image, and then further analyze the areas that may be damaged based on the connected components. Thus, the pixels are clustered according to the color difference characteristics of the pixels in the appearance image to obtain different point clusters. In this embodiment of the invention, the step of obtaining point clusters includes: clustering the pixels in the appearance image using the K-means clustering algorithm based on the RGB three-channel values ​​of the pixels to obtain different point clusters. It should be noted that the K-means clustering algorithm is an existing technology, and the specific steps will not be described in detail. The pixels in each point cluster are similar in color, and the pixels in the same point cluster may not be distributed in the same area in the appearance image. Therefore, different connected components are obtained according to the distribution characteristics of the pixels in the point cluster. The area formed by the pixels that are in the same point cluster and are adjacent in position is taken as the same connected component. By traversing, the appearance image is divided into different connected components, and the pixels in each connected component are similar in color.

[0032] Step S3: Obtain color complexity based on the color difference features between adjacent pixels in the connected component and the overall color difference features within the connected component; obtain edge complexity based on the angle change features of adjacent edge pixels in the connected component and the smoothness features of the edge lines.

[0033] Because the color of some areas on the packaging surface may be similar to that of the damaged area, analyzing only color features is insufficient to accurately identify the damaged area. The packaging boxes detected in this embodiment of the invention, as well as common food packaging boxes of the same type, contain rich color variations such as gradients to meet the visual aesthetics of customer product selection. The color distribution is relatively irregular, and within connected regions with similar color distributions, the color variations in normal surface areas are more pronounced. However, the damaged area of ​​the packaging, due to its deeper interior, does not reflect light, thus presenting a more uniform color; or it may reflect the color of the interior of the packaging, which is not printed to ensure food safety, resulting in a more uniform color. Therefore, the connected regions corresponding to the damaged area have more uniform colors and stronger distribution regularity. Thus, color complexity is obtained based on the color difference features between adjacent pixels in the connected region and the overall color difference features within the connected region.

[0034] Preferably, in this embodiment of the invention, the step of obtaining color complexity includes: calculating and normalizing the sum of the maximum differences in each RGB channel within a connected component to obtain an overall color difference value; the larger the maximum difference in each RGB channel, the larger the overall color difference value, meaning the poorer the uniformity of pixels within the connected component, the more obvious the color change characteristics, and the less likely the connected component is a damaged area; the smaller the overall color difference value, the more uniform the pixel colors within the connected component, and the more likely it is a damaged area. The sum of the absolute values ​​of the differences in the RGB three channels between any pixel in the connected component and other pixels in the same connected component within eight neighboring regions is calculated to obtain a first difference between the arbitrary pixel and other pixels; the larger the first difference value, the more obvious the color difference between the arbitrary pixel and other pixels in the same connected component within eight neighboring regions. The average of the first differences between the arbitrary pixel and all other pixels in the same connected component within eight neighboring regions is calculated to obtain a local color difference value for the arbitrary pixel; the larger the local color difference value for the arbitrary pixel, the more obvious the color change characteristics of the local area. Calculate and normalize the average local color difference values ​​of all pixels in the connected component to obtain the local average color difference value. A larger local average color difference value indicates a more pronounced color gradient within the connected component, suggesting it is more likely to be a normal area on the packaging surface. Calculate the sum of the overall color difference value and the local average color difference value to obtain the color complexity of the connected component. A smaller color complexity indicates a more uniform color within the connected component, suggesting it is more likely to be a damaged area. The formula for obtaining color complexity includes:

[0035]

[0036] In the formula, W represents the color complexity of the connected components. This represents the maximum difference of the R channels in the connected component. This represents the maximum difference between channels G in the connected component. This represents the maximum difference of channel B in the connected component. This represents the sum of the ranges of all RGB channels, used for normalization. This represents the overall color difference value; N represents the number of pixels in the connected components. This represents the local color difference value of the nth pixel. This represents the average difference in local color.

[0037] Furthermore, since food product packaging boxes often feature numerous printed characters conveying product information, and these characters are typically the same color, color complexity alone is insufficient to distinguish between text areas and damaged areas. Therefore, edge features of connected components are necessary for differentiation. The overall edges of patterns or text on the packaging surface are relatively smooth, while damaged areas are caused by external forces resulting in gaps or cracks. Tearing of the paper material leads to numerous burrs on the edges, resulting in weaker smoothness of the edge contours of the connected components corresponding to damaged areas, with irregular and random edge shape changes. In contrast, text edges only exhibit shape changes at specific locations, remaining relatively smooth in the unchanging positions. Therefore, edge complexity is obtained based on the angular variation features of adjacent edge pixels within the connected components and the smoothness features of the edge lines.

[0038] Preferably, in this embodiment of the invention, the step of obtaining edge complexity includes: calculating the angle formed by any edge pixel and the horizontal axis of the adjacent previous edge pixel in the clockwise direction of the edge line of the connected component, to obtain the relative angle of the arbitrary edge pixel; it should be noted that the size of the angle is the angle traversed by the horizontal axis of the adjacent previous edge pixel rotating counterclockwise around the pixel to the arbitrary edge pixel, and the relative angle reflects the orientation of the arbitrary edge pixel relative to the adjacent previous edge pixel. The absolute value of the difference between the relative angle and the previous relative angle is calculated and normalized to obtain the degree of change of the arbitrary edge pixel; when the degree of change is 0, it means that the relative angles of adjacent edge pixels are the same, and the three adjacent edge pixels are on the same straight line, and the direction of the edge line has not changed; conversely, when the degree of change is not 0, it means that the relative angle has changed, and the direction of the edge line has changed. The proportion of edge pixels with a degree of change that is not a constant 0 is counted to obtain the degree of change value of the connected component; the larger the degree of change value, the more edge pixels with angle changes, the more frequent the changes in the direction of the edge line, and the more consistent with the burr characteristics of the damaged edge of the packaging. Connecting edge pixels with continuously non-constant variability (not equal to 0) creates pixel chains. Longer chains indicate a longer portion of the edge line where direction changes continuously, better matching the burr characteristics of a damaged edge. Calculating and normalizing the sum of the squares of the number of pixels in all pixel chains along the edge line yields the contour abruptness. Higher abruptness indicates a more complex edge contour shape, weaker smoothness, and a stronger match for the burr characteristics of a damaged edge. Calculating the product of the average variability, the degree of variability, and the contour abruptness of all edge pixels yields the edge complexity of the connected region. Higher edge complexity indicates a more complex edge shape, weaker smoothness, and a stronger match for the burr characteristics of a damaged edge, making the connected region more likely to be a damaged area. Formulas for obtaining edge complexity include:

[0039]

[0040] In the formula, D represents the edge complexity of the connected component, M represents the number of edge pixels with non-zero variability, and H represents the number of edge pixels. The value represents the degree of change, and Q represents the number of pixel chains. This represents the square of the number of edge pixels in the chain of pixels q. The purpose is to normalize the molecules. Indicates the degree of contour abrupt change; Indicates the h-th and the h-th The absolute value of the difference in the relative angles of the edge pixels. This represents the maximum value of the angle difference, used for normalization. This represents the degree of change of the h-th edge pixel. This represents the average value of the degree of change of all edge pixels.

[0041] Step S4: Obtain the degree of damage anomaly of the connected components based on color complexity and edge complexity; detect the damage status of the food product packaging box based on the degree of damage anomaly.

[0042] After obtaining the color complexity and edge complexity of the connected components, the degree of disruption / anomaly of the connected components can be obtained based on the color complexity and edge complexity. Preferably, in this embodiment of the invention, the step of obtaining the degree of disruption / anomaly includes: mapping the color complexity negatively to the edge complexity and then calculating the average value to obtain the degree of disruption / anomaly of the connected components. This embodiment of the invention uses a formula... A negative correlation mapping is applied to color complexity, where W represents color complexity. Lower color complexity indicates a more uniform color within the connected component, making it more likely to be a damaged area. Higher edge complexity also suggests a more likely damaged area. Therefore, a higher degree of damage anomaly indicates that the connected component is more likely to be caused by a damaged area. Furthermore, the damage status of food product packaging boxes can be detected based on the degree of damage anomaly. Specifically, when a connected component with a damage anomaly exceeding a preset anomaly threshold exists, the food product packaging box is considered damaged. In this embodiment, the preset anomaly threshold is 0.8, which can be determined by the implementer based on the implementation scenario. When a connected component exceeds the preset anomaly threshold, it means that the packaging box has a damaged area. Thus, by analyzing the color change characteristics and edge shape characteristics of the connected component, the degree of damage anomaly is obtained. This degree of damage anomaly can accurately characterize whether the connected component is caused by damage, improving the accuracy of surface damage detection for food product packaging boxes.

[0043] In summary, this invention provides a method for detecting abnormal damage to food product packaging boxes. It clusters pixels based on color difference features in the appearance image to obtain different pixel clusters; obtains different connected components based on the distribution features of pixels within the pixel clusters; obtains color complexity based on color difference features between adjacent pixels within the connected component and overall color difference features within the connected component; and obtains edge complexity based on angular variation features of adjacent edge pixels within the connected component and smoothness features of edge lines. This invention determines the degree of abnormal damage to connected components based on color complexity and edge complexity; and detects damage to food product packaging boxes based on the degree of abnormal damage, thus improving the accuracy of damage detection.

[0044] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0045] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

Claims

1. A method for detecting abnormal damage to food product packaging boxes, characterized in that, The method includes the following steps: Obtain an image of the exterior of a food product packaging box; The pixels in the appearance image are clustered according to the color difference characteristics of the pixels to obtain different point clusters; different connected components are obtained according to the distribution characteristics of the pixels in the point clusters. Color complexity is obtained based on the color difference features between adjacent pixels in the connected component and the overall color difference features within the connected component; edge complexity is obtained based on the angle change features of adjacent edge pixels in the connected component and the smoothness features of the edge lines. The degree of damage anomaly of the connected component is obtained based on the color complexity and the edge complexity; the degree of damage anomaly is used to detect the damage status of the food product packaging box; The step of clustering pixels based on color difference features in the appearance image to obtain different pixel clusters includes: Based on the RGB three-channel values ​​of the pixels in the appearance image, different point clusters are obtained by using the K-means clustering algorithm.

2. The method for detecting abnormal damage to food product packaging boxes according to claim 1, characterized in that, The step of obtaining different connected components based on the distribution characteristics of pixels in the point cluster includes: The region formed by pixels that are in the same cluster and are adjacent in position is considered as the same connected region.

3. The method for detecting abnormal damage to food product packaging boxes according to claim 1, characterized in that, The step of obtaining the color complexity based on the color difference features between adjacent pixels in the connected component and the overall color difference features within the connected component includes: In the connected component, the sum of the maximum differences in each RGB channel is calculated and normalized to obtain the overall color difference value; the sum of the absolute values ​​of the differences in the RGB three channels between any pixel in the connected component and other pixels in the same connected component within eight neighboring regions is calculated to obtain the first difference between the arbitrary pixel and other pixels; the average of the first differences between the arbitrary pixel and all other pixels in the same connected component within eight neighboring regions is calculated to obtain the local color difference value of the arbitrary pixel; the average of the local color difference values ​​of all pixels in the connected component is calculated and normalized to obtain the local average color difference value; the sum of the overall color difference value and the local average color difference value is calculated to obtain the color complexity of the connected component.

4. The method for detecting abnormal damage to food product packaging boxes according to claim 1, characterized in that, The step of obtaining the edge complexity based on the angular change features of adjacent edge pixels of the connected component and the smoothness features of the edge line includes: Calculate the angle between any edge pixel and the horizontal axis at the previous adjacent edge pixel in a clockwise direction along the edge lines of the connected region to obtain the relative angle of the arbitrary edge pixel; calculate and normalize the absolute value of the difference between the relative angle and the previous relative angle to obtain the degree of change of the arbitrary edge pixel; count the proportion of edge pixels whose degree of change is not a constant 0 to obtain the degree of change value of the connected region; connect consecutive edge pixels whose degree of change is not a constant 0 to obtain a pixel chain; calculate and normalize the sum of the squares of the number of pixels in all pixel chains on the edge lines to obtain the contour abrupt change degree; calculate the product of the average degree of change of all edge pixels, the degree of change value, and the contour abrupt change degree to obtain the edge complexity of the connected region.

5. The method for detecting abnormal damage to food product packaging boxes according to claim 1, characterized in that, The step of obtaining the degree of disruption of the connected component based on the color complexity and the edge complexity includes: The degree of disruption of the connected component is obtained by mapping the negative correlation between the color complexity and the edge complexity and calculating the average value of the edge complexity.

6. The method for detecting abnormal damage to food product packaging boxes according to claim 1, characterized in that, The step of detecting the damage to food product packaging boxes based on the degree of abnormal damage includes: When there is a connected region where the degree of damage exceeds a preset abnormality threshold, the food product packaging box is damaged.

Citation Information

Patent Citations

  • Polyurethane floor mat forming detection method and system

    CN118334030A

  • Printing pattern defect detection method and system for plastic package

    CN118411367A