A method for visual inspection of food packaging during food processing

Through edge detection and spot coefficient analysis, the problem of the abnormal impact of spots in visual detection of food packaging bags is solved, and more accurate ink mark recognition is achieved, which improves the stability and reliability of the detection.

CN118781104BActive Publication Date: 2024-11-15SHANGHAI XIAOKOU CHANGKAI TRADING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411252366.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2024-11-15
Estimated Expiration
2044-09-09

AI Technical Summary

Technical Problem

In the prior art, the visual detection of food packaging bags causes abnormal spots due to optical acquisition factors, which affects the identification accuracy and stability of the ink trace area, resulting in low detection reliability.

Method used

By obtaining the grayscale image of the food packaging bag, edge detection determines the defect area, combining the grayscale differences between the geometric center point and edge pixel point, calculates the initial abnormal impact coefficient and light spot coefficient, and screens out the ink trace area to improve the accuracy and reliability of the detection. sex.

Benefits of technology

Effectively eliminate the impact of spot abnormalities, improve the stability and accuracy of visual inspection of food packaging, enhance the reliability of detection results, and accurately identify the ink trace area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118781104B_ABST
    Figure CN118781104B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of defect recognition using optical means, and specifically to a method for visual inspection of food packaging during food processing. The method comprises: obtaining a grayscale image of a food packaging bag, and determining a circular defect area in the grayscale image; determining an initial abnormal influence coefficient according to the grayscale difference between the center and the edge of the area to be tested, and the grayscale value of the pixel to be tested; determining a target abnormal influence coefficient according to the grayscale value variance of the area to be tested, the gradient distribution of all edge pixels of the area to be tested, and the initial abnormal influence coefficient; determining a light spot coefficient according to the distance between the pixel to be tested and the geometric center point of the area to be tested, and the target abnormal influence coefficient, screening according to the light spot coefficient to obtain an ink area; and determining the detection result according to the number of pixels in all ink areas. The present invention combines light spot features and ink features to accurately identify the ink area, thereby improving the stability and accuracy of visual inspection of food packaging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of defect recognition using optical means, and in particular to a food packaging visual inspection method during food processing. Background Art

[0002] During the printing process of food packaging bags, ink spots usually remain on the food packaging bags due to the ink dipping of the printing equipment and the flow characteristics of the pigment itself, affecting the overall printing quality. Therefore, it is necessary to perform ink spot detection on the printed food packaging bags.

[0003] In the related art, a circular area that is different from the standard template is detected through morphological detection as the area corresponding to the ink mark. In this way, when collecting images of food packaging bags, the collection equipment used will have a certain light spot effect in the imaging due to the characteristics of optical collection, thereby causing abnormal light spot effects, making it impossible to effectively identify the ink mark area in the subsequent process, and the stability and accuracy of visual inspection of food packaging are poor, and the reliability of ink mark detection is low. Summary of the invention

[0004] In order to solve the technical problems in the related art that the abnormal light spot caused by optical collection factors makes it impossible to effectively identify the ink area, the stability and accuracy of food packaging visual inspection are poor, and the reliability of ink inspection is low, the present invention provides a food packaging visual inspection method in the food processing process, and the technical scheme adopted is as follows:

[0005] The present invention proposes a method for visually inspecting food packaging during food processing, the method comprising:

[0006] Acquire a grayscale image of the food packaging bag, determine edge pixel points in the grayscale image through edge detection, and determine a circular defect area according to the distribution of edge pixel points in the grayscale image and the texture of a preset standard image;

[0007] Taking any defective area as the area to be tested, and any pixel point in the area to be tested as the pixel point to be tested, determining the edge difference influence index of the area to be tested according to the grayscale difference between the geometric center point and the edge pixel point of the area to be tested; determining the initial abnormal influence coefficient of the pixel point to be tested according to the grayscale value of the pixel point to be tested and the edge difference influence index of the area to be tested;

[0008] Determine the grayscale dispersion coefficient of the area to be measured according to the grayscale value variance of all pixels in the area to be measured and the gradient distribution of all edge pixels in the area to be measured; determine the target abnormal influence coefficient of the pixel to be measured according to the initial abnormal influence coefficient of the pixel to be measured and the grayscale dispersion coefficient of the area to be measured;

[0009] According to the distance between the pixel to be tested and the geometric center point of the area to be tested, and the target abnormality influence coefficient of the pixel to be tested, the spot coefficient of the pixel to be tested is determined; according to the spot coefficient of all pixels in each defect area, the defect area is screened to obtain the ink area; the detection result is determined according to the number of pixels in all the ink areas.

[0010] Furthermore, the step of determining the edge difference impact index of the area to be measured based on the grayscale difference between the geometric center point and the edge pixel points of the area to be measured includes:

[0011] Calculate the average of the grayscale values ​​of all edge pixels in the area to be tested as the edge grayscale average;

[0012] The absolute value of the difference between the grayscale value of the geometric center point of the area to be measured and the edge grayscale mean value is determined, and normalized to be used as the edge difference influence index of the area to be measured.

[0013] Further, the initial abnormal influence coefficient of the pixel to be tested is determined according to the gray value of the pixel to be tested and the edge difference influence index of the area to be tested, including:

[0014] Performing positive correlation mapping on the grayscale value of the pixel to be tested to obtain a grayscale coefficient;

[0015] The normalized value of the product of the grayscale coefficient and the edge difference influence index of the area to be measured is calculated to obtain the initial abnormal influence coefficient of the pixel to be measured.

[0016] Furthermore, the grayscale dispersion coefficient of the area to be measured is determined according to the grayscale value variance of all pixels in the area to be measured and the gradient distribution of all edge pixels in the area to be measured, including:

[0017] Calculate the variance of the grayscale values ​​of all pixels in the area to be tested as the variance to be tested;

[0018] Calculate the mean of the gradient amplitudes of all edge pixels in the area to be measured as the mean of the edge to be measured;

[0019] The grayscale dispersion coefficient of the area to be measured is determined according to the variance to be measured and the mean value of the edge to be measured.

[0020] Furthermore, the variance to be measured is positively correlated with the grayscale dispersion coefficient; the edge mean to be measured is negatively correlated with the grayscale dispersion coefficient, and the value of the grayscale dispersion coefficient is a normalized value.

[0021] Further, determining the target abnormal influence coefficient of the pixel to be measured according to the initial abnormal influence coefficient of the pixel to be measured and the grayscale dispersion coefficient of the area to be measured includes:

[0022] The normalized value of the product of the initial abnormal influence coefficient of the pixel to be measured and the grayscale dispersion coefficient of the area to be measured is calculated to obtain the target abnormal influence coefficient of the pixel to be measured.

[0023] Further, the step of determining the spot coefficient of the pixel to be measured according to the distance between the pixel to be measured and the geometric center point of the area to be measured and the target abnormality influence coefficient of the pixel to be measured includes:

[0024] The distance between the pixel to be measured and the geometric center point of the area to be measured is negatively correlated and normalized to obtain a center distance coefficient;

[0025] The product of the center distance coefficient and the target abnormality influence coefficient of the pixel to be measured is calculated, and normalized as the spot coefficient of the pixel to be measured.

[0026] Furthermore, the defective area is screened according to the spot coefficients of all pixels in each defective area to obtain the ink area, including:

[0027] Calculate the average of the spot coefficients of all pixels in each defect area to obtain the spot judgment index;

[0028] When the light spot judgment index meets the index condition, the corresponding defect area is used as the ink area, wherein the index condition is that the light spot judgment index is less than a preset index threshold.

[0029] Furthermore, the step of determining the detection result according to the number of pixels in all the ink areas includes:

[0030] The ratio of the number of pixels in the ink area to the number of all pixels in the grayscale image of the food packaging bag is calculated to obtain an abnormal coefficient, and the abnormal coefficient is used as the detection result.

[0031] Furthermore, the determining of the circular defect area according to the distribution of edge pixels in the grayscale image and the texture of a preset standard image includes:

[0032] Based on edge pixel points in the grayscale image and the image texture of the preset standard image, morphological matching is performed to determine the area surrounded by edge pixel points inconsistent with the preset standard image as the area to be analyzed;

[0033] Based on the Hough circle detection algorithm, Hough circle detection is performed on all areas surrounded by edge pixels, and the circular area to be analyzed obtained by detection is used as the defect area.

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

[0035] The embodiment of the present invention identifies the circular defect area to determine the area containing ink and light spots. Since the ink area is an abnormal defect area, and the light spot area is an error area caused by optical acquisition factors, the texture features of the light spot area and the ink area are combined for analysis to avoid the influence of the light spot area on abnormal detection when all defect areas are directly identified. Since the light spot area and the ink area have chromatic aberration characteristics caused by optical influence, the embodiment of the present invention can determine the initial abnormality degree according to the grayscale difference between the geometric center point and the edge pixel point of the area, combined with the grayscale value of the pixel point itself. The initial abnormality degree is the abnormal effect under the influence of grayscale. However, since the colors of the light spot and the ink are not fixed, the reliability of the analysis based only on the initial abnormality is insufficient. Therefore, the present invention combines the gray value variance of all pixels in the area and the gradient distribution of edge pixels to perform weighted correction on the initial abnormality influence coefficient, thereby combining the gray distribution of all pixels in the area and the gray change effect of edge pixels to achieve more accurate and effective abnormality analysis, and obtain the target abnormality influence coefficient. Combine the target abnormality influence coefficient and the distance of the pixel from the geometric center to obtain the light spot coefficient. The light spot coefficient is the accurate degree of light spot influence. The ink area can be effectively distinguished in combination with the light spot coefficient, thereby making the analysis of the ink area more reliable and enhancing the visual inspection effect of food packaging. In summary, the present invention combines the light spot characteristics and the ink characteristics, eliminates the abnormal influence of the light spot caused by the optical acquisition factors, accurately identifies the misprinted ink area, thereby improving the stability and accuracy of food packaging visual inspection, and improving the reliability of the inspection results. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. 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 creative work.

[0037] Figure 1 A flow chart of a method for visually inspecting food packaging during food processing provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation method, structure, features and effects of a food packaging visual inspection method in a food processing process proposed by the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0039] Unless defined otherwise, 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 belongs.

[0040] The specific scheme of the food packaging visual inspection method in the food processing process provided by the present invention is described in detail below with reference to the accompanying drawings.

[0041] See also Figure 1 , which shows a flow chart of a method for visual inspection of food packaging during food processing provided by one embodiment of the present invention, the method comprising:

[0042] S101: Acquire a grayscale image of a food packaging bag, determine edge pixels in the grayscale image by edge detection, and determine a circular defect area according to the distribution of edge pixels in the grayscale image and the texture of a preset standard image.

[0043] A specific implementation scenario of the present invention is: after the production of food packaging bags is completed, a corresponding optical acquisition device is used to perform image acquisition processing. Due to the instability of the printing effect during printing, corresponding ink marks will remain on the food packaging bags, and the ink marks usually exist in the form of ink dots. Therefore, the ink marks on the food packaging bags are corresponding circular ink dot areas, and the original image of the collected food packaging bags also has corresponding ink dot areas. It should be noted that since the optical acquisition device is usually an optical acquisition device such as an optical camera, and in order to facilitate the image collection of the food packaging bag, it is usually necessary to illuminate it. During the shooting process, due to the diffraction effect of light, light will directly enter the lens, and the light directly entering the lens will enter the camera's photosensitive element after a series of reflections, and will have a corresponding circular light spot in the image. The circular light spot does not actually belong to the ink area, but because it has the same circular feature as the ink area, it affects the detection effect of the ink area.

[0044] In the embodiment of the present invention, the Canny edge detection operator can be used to implement edge detection processing. The Canny edge detection operator is an edge detection method well known to those skilled in the art. Based on the Canny edge detection operator, the image can be effectively detected to obtain edge pixels. Of course, in other embodiments of the present invention, a variety of other possible edge detection methods can also be used to implement edge detection processing, and there is no limitation on this.

[0045] It should be noted that since the spot effect under the optical camera device cannot be effectively avoided, it is necessary to effectively divide the spot and ink dot areas. The spot and ink dot areas have obvious differences in the grayscale performance of pixels, and the difference effects can be analyzed.

[0046] Furthermore, in some embodiments of the present invention, a circular defect area is determined based on the distribution of edge pixels in a grayscale image and the texture of a preset standard image, including: performing morphological matching based on the edge pixels in the grayscale image and the image texture of the preset standard image, and determining the area enclosed by edge pixels inconsistent with the preset standard image as the area to be analyzed; based on the Hough circle detection algorithm, performing Hough circle detection processing on all areas enclosed by edge pixels, and using the detected circular area to be analyzed as the defect area.

[0047] Among them, the preset standard image is an image corresponding to the standard pattern of the food packaging bag. The grayscale image is morphologically matched with the texture of the preset standard image to obtain an inconsistent matching pattern. The morphological matching can be specifically, for example, an image template matching algorithm, based on which the preset standard image is used as a template for template matching to obtain inconsistent edge pixel points.

[0048] In the embodiment of the present invention, Hough circle detection is a technology well known to those skilled in the art. Based on Hough circle detection, circular and elliptical textures in an image can be identified. Then, the embodiment of the present invention identifies circular and quasi-circular areas to be analyzed as defect areas from all areas to be analyzed surrounded by edge pixels.

[0049] That is to say, the defective area is an ink dot area or a light spot area. Therefore, the present invention can analyze the difference in grayscale performance of the pixel point between the light spot area and the ink dot area.

[0050] S102: Take any defective area as the area to be tested, and any pixel point in the area to be tested as the pixel point to be tested, and determine the edge difference influence index of the area to be tested according to the grayscale difference between the geometric center point and the edge pixel point of the area to be tested; determine the initial abnormal influence coefficient of the pixel point to be tested according to the grayscale value of the pixel point to be tested and the edge difference influence index of the area to be tested.

[0051] In the embodiment of the present invention, in order to perform a specific analysis on each defect area, any defect area can be selected as the area to be tested, and any pixel point in the area to be tested can be selected as the pixel point to be tested.

[0052] Furthermore, in some embodiments of the present invention, an edge difference influence index of the area to be measured is determined based on the grayscale difference between the geometric center point and the edge pixel points of the area to be measured, including: calculating the mean of the grayscale values ​​of all edge pixel points in the area to be measured as the edge grayscale mean; determining the absolute value of the difference between the grayscale value of the geometric center point of the area to be measured and the edge grayscale mean, and normalizing it as the edge difference influence index of the area to be measured.

[0053] In the embodiment of the present invention, the grayscale values ​​of all edge pixels of the test area are analyzed. It can be understood that when the test area is an ink area, the corresponding overall color is darker, and the difference between the edge color and the center position is smaller, while the light spot area is affected by light, and the overall color is lighter, but the pixels at the edge and the center position have obvious color differences.

[0054] Therefore, the present invention combines the grayscale value of the geometric center point of the area to be measured and the edge grayscale mean to calculate the difference value. The larger the difference value, the more it conforms to the characteristics of the light spot area, and the smaller the difference value, the more it conforms to the characteristics of the ink area. Therefore, the present invention normalizes the difference value to obtain the edge difference influence index of the area to be measured.

[0055] In one embodiment of the present invention, the normalization process can be specifically, for example, a maximum and minimum value normalization process, and the normalization in subsequent steps can all adopt the maximum and minimum value normalization process. In other embodiments of the present invention, other normalization methods can be selected according to the specific range of values, which will not be described in detail. The larger the value of the edge difference influence index, the more likely the area to be measured is a light spot area, and the smaller the value of the edge difference influence index, the more likely the area to be measured is an ink area.

[0056] Furthermore, in some embodiments of the present invention, the initial abnormal influence coefficient of the pixel to be measured is determined according to the grayscale value of the pixel to be measured and the edge difference influence index of the area to be measured, including: performing positive correlation mapping on the grayscale value of the pixel to be measured to obtain the grayscale coefficient; calculating the normalized value of the product of the grayscale coefficient and the edge difference influence index of the area to be measured to obtain the initial abnormal influence coefficient of the pixel to be measured.

[0057] Among them, a positive correlation means that the dependent variable will increase as the independent variable increases, and the dependent variable will decrease as the independent variable decreases. The specific relationship can be a multiplication relationship, an addition relationship, or the power of an exponential function, which is determined by actual application; a negative correlation means that the dependent variable will decrease as the independent variable increases, and the dependent variable will increase as the independent variable decreases. It can be a subtraction relationship, a division relationship, etc., which is determined by actual application.

[0058] In the embodiment of the present invention, since the grayscale value of the ink is darker in overall color and has a smaller grayscale value than the light spot area, in order to identify the light spot area, the present invention performs a positive correlation mapping on the grayscale value of the pixel point. The positive correlation mapping means that the larger the grayscale value, the larger the corresponding grayscale coefficient. The grayscale value can be directly normalized to obtain the grayscale coefficient, or the grayscale value can be mapped to other ranges. The purpose is to eliminate the dimensional influence and facilitate subsequent calculation and analysis.

[0059] In the embodiment of the present invention, since the larger the value of the edge difference influence index is, the more likely the area to be measured is to be a light spot area, and the smaller the value of the edge difference influence index is, the more likely the area to be measured is to be an ink area, the product of the edge difference influence index and the grayscale coefficient can be calculated, and the initial abnormal influence coefficient of the pixel to be measured is obtained by normalization. The larger the initial abnormal influence coefficient is, the more likely the pixel to be measured is to be a pixel corresponding to the light spot area.

[0060] In the embodiment of the present invention, the initial abnormal influence coefficient is analyzed by combining the grayscale difference characteristics of the edge and center points in the measured area and the grayscale value characteristics of the pixel points themselves, so as to perform more accurate and effective spot recognition.

[0061] S103: Determine the grayscale dispersion coefficient of the area to be tested according to the grayscale value variance of all pixels in the area to be tested and the gradient distribution of all edge pixels in the area to be tested; determine the target abnormal influence coefficient of the pixel to be tested according to the initial abnormal influence coefficient of the pixel to be tested and the grayscale dispersion coefficient of the area to be tested.

[0062] Furthermore, in some embodiments of the present invention, the grayscale dispersion coefficient of the area to be measured is determined based on the grayscale value variance of all pixels in the area to be measured and the gradient distribution of all edge pixels in the area to be measured, including: calculating the variance of the grayscale values ​​of all pixels in the area to be measured as the variance to be measured; calculating the mean of the gradient amplitudes of all edge pixels in the area to be measured as the edge mean to be measured; and determining the grayscale dispersion coefficient of the area to be measured based on the variance to be measured and the edge mean to be measured.

[0063] Among them, since the grayscale value of pixels in the ink area varies less and has a smaller span, while the grayscale value of pixels in the light spot area has a larger span, the present invention can perform a specific analysis based on the variance and calculate the variance to be measured. The larger the value of the variance to be measured, the more complex the discrete degree of the grayscale value and the larger the span.

[0064] Among them, the edge pixels of the ink area are also the ink area, and the amplitude of the corresponding grayscale gradient is larger. Due to the diffraction effect of light, the edge of the spot area will produce a progressive color effect, that is, the color change at the edge of the spot area is relatively smooth, and the gradient amplitude of the edge pixels is smaller.

[0065] Therefore, the present invention combines the variance to be measured and the mean of the edge to be measured to calculate the grayscale dispersion coefficient of the area to be measured.

[0066] Among them, the variance to be measured is positively correlated with the grayscale dispersion coefficient; the edge mean to be measured is negatively correlated with the grayscale dispersion coefficient, and the value of the grayscale dispersion coefficient is the normalized value.

[0067] In the embodiment of the present invention, the ratio of the variance to be measured to the mean of the edge to be measured can be calculated and normalized to obtain the grayscale dispersion coefficient, or the difference between the value of the variance to be measured and the value of the mean of the edge to be measured can be calculated and normalized to obtain the grayscale dispersion coefficient, and there is no limitation on this.

[0068] Furthermore, in some embodiments of the present invention, the target abnormality influence coefficient of the pixel to be measured is determined based on the initial abnormality influence coefficient of the pixel to be measured and the grayscale discrete coefficient of the area to be measured, including: calculating the normalized value of the product of the initial abnormality influence coefficient of the pixel to be measured and the grayscale discrete coefficient of the area to be measured to obtain the target abnormality influence coefficient of the pixel to be measured.

[0069] In the embodiment of the present invention, since the larger the initial abnormal influence coefficient is, the more likely the pixel to be measured is the pixel corresponding to the light spot area, and the larger the grayscale dispersion coefficient is, the more the area to be measured has the characteristics of the light spot area, the present invention calculates the product of the initial abnormal influence coefficient and the grayscale dispersion coefficient, and normalizes it as the target abnormal influence coefficient of the pixel to be measured. In other words, the initial abnormal influence coefficient is further limited and adjusted by the grayscale dispersion coefficient, thereby deepening the analysis effect and enhancing the ability to distinguish between the ink area and the light spot area.

[0070] S104: Determine the spot coefficient of the pixel to be tested based on the distance between the pixel to be tested and the geometric center point of the area to be tested, and the target abnormality influence coefficient of the pixel to be tested; screen the defective area based on the spot coefficients of all pixels in each defective area to obtain the ink area; determine the detection result based on the number of pixels in all ink areas.

[0071] Furthermore, in some embodiments of the present invention, the spot coefficient of the pixel to be measured is determined based on the distance between the pixel to be measured and the geometric center point of the area to be measured, and the target abnormality influence coefficient of the pixel to be measured, including: mapping and normalizing the negative correlation between the distance between the pixel to be measured and the geometric center point of the area to be measured to obtain a center distance coefficient; calculating the product of the center distance coefficient and the target abnormality influence coefficient of the pixel to be measured, and normalizing it as the spot coefficient of the pixel to be measured.

[0072] In an embodiment of the present invention, the farther the pixel to be tested is from the geometric center point of the area to be tested, the lighter the color appears in the light spot area, while the grayscale hardly changes in the ink area. Therefore, in one embodiment of the present invention, the negative number of the distance between the pixel to be tested and the geometric center point of the area to be tested can be calculated, and the negative number can be normalized to obtain a center distance coefficient. The larger the center distance coefficient is, the smaller the corresponding distance is, and the less obvious the change in the light spot area is. In this case, the coefficient needs to be increased to achieve the detection effect. The smaller the center distance coefficient is, the greater the corresponding distance is, and the more obvious the change in the light spot area is. In this case, the coefficient needs to be reduced to avoid abnormal situations, such as the influence of abnormal color at the edge of the ink area.

[0073] Therefore, the embodiment of the present invention calculates the product of the center distance coefficient and the target abnormality influence coefficient of the pixel to be tested, and normalizes the product to obtain the spot coefficient of the pixel to be tested. The larger the spot coefficient, the more likely the pixel to be tested is a pixel in the spot area.

[0074] Furthermore, in some embodiments of the present invention, the defective areas are screened according to the spot coefficients of all pixels in each defective area to obtain the ink area, including: calculating the mean of the spot coefficients of all pixels in each defective area to obtain a spot judgment index; when the spot judgment index meets the index condition, the corresponding defective area is used as the ink area, wherein the index condition is that the spot judgment index is less than a preset index threshold.

[0075] In the embodiment of the present invention, when the light spot judgment index is less than the preset index threshold, the corresponding defect area can be regarded as the ink area, and when the light spot judgment index is greater than or equal to the preset index threshold, the corresponding defect area can be regarded as the light spot area. The preset index threshold is the threshold value of the light spot judgment index. Optionally, the preset index threshold can be specifically, for example, 0.5, or can be adjusted according to actual detection requirements, and there is no limitation on this.

[0076] Furthermore, in some embodiments of the present invention, the detection result is determined based on the number of pixels in all ink areas, including: calculating the ratio of the number of pixels in the ink area to the number of all pixels in the grayscale image of the food packaging bag, obtaining an abnormality coefficient, and using the abnormality coefficient as the detection result.

[0077] In an embodiment of the present invention, the proportion of the number of all pixels in the ink area in the grayscale image can be used as an abnormality coefficient. When the abnormality coefficient is large, it means that the ink area accounts for a large proportion and the area is large, and thus the corresponding abnormality is more serious. Therefore, the abnormality coefficient can be used as the detection result of visual inspection of food packaging.

[0078] The embodiment of the present invention identifies the circular defect area to determine the area containing ink and light spots. Since the ink area is an abnormal defect area, and the light spot area is an error area caused by optical acquisition factors, the texture features of the light spot area and the ink area are combined for analysis to avoid the influence of the light spot area on abnormal detection when all defect areas are directly identified; since the light spot area and the ink area have the characteristics of grayscale distribution difference, the embodiment of the present invention can determine the initial abnormality degree according to the grayscale difference between the geometric center point and the edge pixel point of the area, combined with the grayscale value of the pixel point itself. The initial abnormality degree is the abnormal effect under the influence of grayscale, and Since the colors of the light spot and the ink are not fixed, the reliability of the analysis based only on the initial abnormality is insufficient. Therefore, the present invention combines the gray value variance of all pixels in the area and the gradient distribution of the edge pixels to perform weighted correction on the initial abnormality influence coefficient, thereby combining the gray distribution of all pixels in the area and the gray change effect of the edge pixels to achieve a more accurate and effective abnormality analysis, and obtain the target abnormality influence coefficient. Combine the target abnormality influence coefficient and the distance of the pixel from the geometric center to obtain the light spot coefficient. The light spot coefficient is the accurate light spot influence degree. The ink area can be effectively distinguished in combination with the light spot coefficient, thereby making the analysis of the ink area more reliable and enhancing the visual inspection effect of food packaging. In summary, the present invention combines the light spot characteristics and the ink characteristics to accurately identify the misprinted ink area, thereby improving the stability and accuracy of the visual inspection of food packaging and improving the reliability of the inspection results.

[0079] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0080] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

Claims

1. A method for visual inspection of food packaging during food processing, characterized in that: The method comprises: Acquire a grayscale image of the food packaging bag, determine edge pixel points in the grayscale image through edge detection, and determine a circular defect area according to the distribution of edge pixel points in the grayscale image and the texture of a preset standard image; Taking any defective area as the area to be tested, and any pixel point in the area to be tested as the pixel point to be tested, determining the edge difference influence index of the area to be tested according to the grayscale difference between the geometric center point and the edge pixel point of the area to be tested; determining the initial abnormal influence coefficient of the pixel point to be tested according to the grayscale value of the pixel point to be tested and the edge difference influence index of the area to be tested; Determine the grayscale dispersion coefficient of the area to be measured according to the grayscale value variance of all pixels in the area to be measured and the gradient distribution of all edge pixels in the area to be measured; determine the target abnormal influence coefficient of the pixel to be measured according to the initial abnormal influence coefficient of the pixel to be measured and the grayscale dispersion coefficient of the area to be measured; Determine the spot coefficient of the pixel to be tested according to the distance between the pixel to be tested and the geometric center point of the area to be tested, and the target abnormality influence coefficient of the pixel to be tested; screen the defect area according to the spot coefficients of all pixels in each defect area to obtain the ink area; determine the detection result according to the number of pixels in all ink areas; Determining the edge difference impact index of the area to be measured according to the grayscale difference between the geometric center point and the edge pixel points of the area to be measured includes: Calculate the average of the grayscale values ​​of all edge pixels in the area to be tested as the edge grayscale average; Determine the absolute value of the difference between the grayscale value of the geometric center point of the area to be measured and the mean grayscale value of the edge, and perform normalization processing as the edge difference influence index of the area to be measured; The step of determining the initial abnormal influence coefficient of the pixel to be tested according to the gray value of the pixel to be tested and the edge difference influence index of the area to be tested comprises: Performing positive correlation mapping on the grayscale value of the pixel to be tested to obtain a grayscale coefficient; Calculating a normalized value of the product of the grayscale coefficient and the edge difference influence index of the area to be measured to obtain an initial abnormal influence coefficient of the pixel to be measured; The step of determining the target abnormal influence coefficient of the pixel to be measured according to the initial abnormal influence coefficient of the pixel to be measured and the grayscale dispersion coefficient of the area to be measured comprises: Calculating a normalized value of the product of an initial abnormal influence coefficient of the pixel to be measured and a grayscale dispersion coefficient of the area to be measured to obtain a target abnormal influence coefficient of the pixel to be measured; The step of determining the spot coefficient of the pixel to be measured according to the distance between the pixel to be measured and the geometric center point of the area to be measured and the target abnormality influence coefficient of the pixel to be measured comprises: The distance between the pixel to be measured and the geometric center point of the area to be measured is negatively correlated and normalized to obtain a center distance coefficient; The product of the center distance coefficient and the target abnormality influence coefficient of the pixel to be measured is calculated, and normalized as the spot coefficient of the pixel to be measured.

2. A method for visual inspection of food packaging during food processing as claimed in claim 1, characterized in that: The step of determining the grayscale dispersion coefficient of the area to be measured according to the grayscale value variance of all pixels in the area to be measured and the gradient distribution of all edge pixels in the area to be measured comprises: Calculate the variance of the grayscale values ​​of all pixels in the area to be tested as the variance to be tested; Calculate the mean of the gradient amplitudes of all edge pixels in the area to be measured as the mean of the edge to be measured; The grayscale dispersion coefficient of the area to be measured is determined according to the variance to be measured and the mean value of the edge to be measured.

3. A method for visual inspection of food packaging during food processing as claimed in claim 2, characterized in that: The variance to be measured is positively correlated with the grayscale dispersion coefficient; the edge mean to be measured is negatively correlated with the grayscale dispersion coefficient, and the value of the grayscale dispersion coefficient is a normalized value.

4. A method for visual inspection of food packaging during food processing as claimed in claim 1, characterized in that: The step of screening the defective area according to the spot coefficients of all pixels in each defective area to obtain the ink area includes: Calculate the average of the spot coefficients of all pixels in each defect area to obtain the spot judgment index; When the light spot judgment index meets the index condition, the corresponding defect area is used as the ink area, wherein the index condition is that the light spot judgment index is less than a preset index threshold.

5. A method for visual inspection of food packaging during food processing as claimed in claim 1, characterized in that: Determining the detection result according to the number of pixels in all ink areas includes: The ratio of the number of pixels in the ink area to the number of all pixels in the grayscale image of the food packaging bag is calculated to obtain an abnormal coefficient, and the abnormal coefficient is used as the detection result.

6. A method for visual inspection of food packaging during food processing as claimed in claim 1, characterized in that: The step of determining a circular defect area according to the distribution of edge pixels in the grayscale image and the texture of a preset standard image includes: Based on edge pixel points in the grayscale image and the image texture of the preset standard image, morphological matching is performed to determine the area surrounded by edge pixel points inconsistent with the preset standard image as the area to be analyzed; Based on the Hough circle detection algorithm, Hough circle detection is performed on all areas surrounded by edge pixels, and the circular area to be analyzed obtained by detection is used as the defect area.