A method and system for tracing canned fish production information

By analyzing the grayscale and edge characteristics of the QR code on the surface of canned fish, calculating the image enhancement coefficient, and improving the adaptive contrast enhancement algorithm, the problem of low information traceability efficiency caused by damage to the QR code in the production of canned fish was solved, and an efficient, Accurate fish canned production information traceability.

CN118378648BActive Publication Date: 2024-08-30SHANDONG YULANG FOOD CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410797022.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-08-30
Estimated Expiration
2044-06-20

AI Technical Summary

Technical Problem

During the production process of canned fish, the QR code on the surface of the canned fish is easily damaged during transportation, resulting in low or impossible information traceability. The existing adaptive contrast enhancement algorithm fails to effectively consider the global contrast information, affecting the image enhancement effect.

Method used

By acquiring the QR code image on the surface of the canned fish, analyzing its grayscale features and edge features, calculating the image enhancement coefficient, improving the adaptive contrast enhancement algorithm, and combining global information for image enhancement, we can improve the efficiency of traceability of canned fish production information.

Benefits of technology

It improves the efficiency and accuracy of traceability of canned fish production information, solves the difficult problem of information traceability caused by blurry QR codes on the surface of canned fish, and achieves efficient and accurate image enhancement effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118378648B
    Figure CN118378648B
Patent Text Reader

Abstract

The present invention relates to the field of image enhancement technology, and proposes a method and system for tracing canned fish production information, obtaining a two-dimensional code image on the surface of the canned fish, obtaining a marked judgment area of ​​the two-dimensional code image, obtaining the regional contrast of the marked judgment area according to the grayscale distribution of the marked judgment area, obtaining the neighborhood gradient consistency of each pixel point according to the gradient distribution of the pixel value of the marked judgment area, clustering is performed using the neighborhood gradient consistency of each pixel point, obtaining the regional fidelity of the marked judgment area according to the different clustering set position distributions in the clustering results, obtaining the regional edge contrast of the marked judgment area, combining the regional contrast, regional fidelity and regional edge contrast of the marked judgment area to obtain an image enhancement coefficient, and completing the tracing of canned fish production information. The present invention aims to improve the accuracy and efficiency of tracing canned fish production information, and realize the tracing of canned fish production information based on image enhancement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image enhancement, and in particular to a method and system for tracing canned fish production information. Background Art

[0002] Food production safety traceability refers to a management method that ensures food quality and safety by recording and tracing the entire food production process. It includes monitoring and tracing from the procurement of food raw materials, production and processing, packaging to circulation, aiming to provide reliable food supply chain information and evidence to ensure food quality and safety. The implementation of a food production safety traceability system can improve the effectiveness of food safety management, help companies identify and solve problems in a timely manner, and quickly trace affected product batches and circulation paths when food safety incidents occur, and implement effective recall and disposal measures. In addition, food production safety traceability can also strengthen the supervision of the food industry and the government's supervision of food safety, and protect the food safety rights and interests of consumers.

[0003] As a common food product, the safety of canned fish is of vital importance to the health of consumers. However, there may be some risks and potential safety hazards in the production process of canned fish, such as raw material quality problems, improper use of additives, metal impurities, etc., which may affect the quality and safety of the product. In order to cope with these problems, canned fish manufacturers have gradually introduced production safety traceability methods. Since the two-dimensional code on the surface of the canned fish may be damaged during transportation, when tracing information through the two-dimensional code, it may result in low tracing efficiency or failure to trace. Therefore, it is necessary to enhance the image of the collected two-dimensional code. When using the adaptive contrast enhancement algorithm, the algorithm itself only considers local contrast information, and does not consider global contrast information. Therefore, the present invention analyzes the image and then adaptively adjusts the enhancement coefficient to achieve the purpose of considering global contrast information to make the image enhancement effect better.

[0004] In summary, the present invention proposes a method and system for tracing canned fish production information, which obtains a two-dimensional code image on the surface of the canned fish, analyzes the grayscale features and edge features of the two-dimensional code image, and finally obtains the image enhancement coefficient, improves the adaptive contrast enhancement algorithm, completes the tracing of canned fish production information based on image enhancement, and improves the efficiency of the tracing of canned fish production information. Summary of the invention

[0005] In order to solve the above technical problems, the purpose of the present invention is to provide a method and system for tracing canned fish production information. The technical solutions adopted are as follows:

[0006] In a first aspect, an embodiment of the present invention provides a method for tracing canned fish production information, the method comprising the following steps:

[0007] Collect the QR code image on the surface of the fish can;

[0008] Obtain the marked judgment area of ​​the two-dimensional code image; use the Otsu threshold algorithm to obtain the segmentation threshold of the marked judgment area; take the pixel points with grayscale values ​​greater than or equal to the segmentation threshold in the marked judgment area as high threshold pixel points; take the pixel points with grayscale values ​​less than the segmentation threshold in the marked judgment area as low threshold pixel points; obtain the regional contrast of the marked judgment area according to the grayscale distribution of the pixel points in the marked judgment area; obtain the neighborhood gradient similarity of each low threshold pixel point according to the gradient amplitude distribution of the low threshold pixel points in the marked judgment area;

[0009] According to the gradient direction distribution of low-threshold pixels in the marked judgment area, the neighborhood gradient direction similarity of each low-threshold pixel is obtained; the neighborhood gradient consistency of each low-threshold pixel is obtained by combining the neighborhood gradient similarity and neighborhood gradient direction similarity of each low-threshold pixel; for high-threshold pixels, the neighborhood gradient consistency of each high-threshold pixel is calculated by using the method of obtaining the neighborhood gradient consistency of low-threshold pixels; the neighborhood gradient consistency of each pixel in the marked judgment area is used for clustering; the regional fidelity of the marked judgment area is obtained according to the clustering results of low-threshold pixels and high-threshold pixels;

[0010] The regional edge contrast of the mark judgment area is obtained; the image enhancement coefficient of the QR code image is obtained by combining the regional contrast, regional fidelity and regional edge contrast of each mark judgment area; the fish can production information traceability based on image enhancement is completed by combining the adaptive contrast enhancement algorithm and the image enhancement coefficient.

[0011] Furthermore, the step of obtaining the marking verification area of ​​the two-dimensional code image includes:

[0012] Perform edge detection on the QR code image, fit the detected edges using a rectangular fitting algorithm, obtain the rectangular area in the QR code image, and use the rectangular areas at the upper left corner, lower left corner, and upper right corner of the QR code image as the marking and verification area of ​​the QR code image.

[0013] Furthermore, obtaining the regional contrast of the marked verification area according to the grayscale distribution of the pixels in the marked verification area includes:

[0014] Calculate the absolute value of the difference between each low-threshold pixel point in the mark judgment area and the average of all low-threshold pixel points, and use the average of the absolute value of the difference of all low-threshold pixel points as the first regional contrast of all low-threshold pixel points; and so on, calculate the second regional contrast of all high-threshold pixel points in the mark judgment area; use the negative number of the sum of the first regional contrast and the second regional contrast in the mark judgment area as the exponent of an exponential function with a natural constant as the base; and use the calculation result of the exponential function as the regional contrast of the mark judgment area.

[0015] Furthermore, the neighborhood gradient similarity of each low-threshold pixel point is obtained according to the gradient amplitude distribution of the low-threshold pixel point in the marked judgment area, including:

[0016] The first neighborhood gradient similarity is constructed based on the difference in gradient amplitude between the low threshold pixel and each pixel in the neighborhood. The expression is:

[0017]

[0018] In the formula, Indicates the first neighborhood gradient similarity between the ath low threshold pixel and the bth pixel in the neighborhood. represents the gradient amplitude of the a-th low threshold pixel, represents the gradient amplitude of the bth pixel in the neighborhood of the ath low threshold pixel, is the preset gradient threshold;

[0019] The sum of all first neighborhood gradient similarities in the neighborhood of each low threshold pixel point is taken as the neighborhood gradient similarity of each low threshold pixel point.

[0020] Furthermore, the method of obtaining the neighborhood gradient direction similarity of each low-threshold pixel point according to the gradient direction distribution of the low-threshold pixel points in the marked judgment area includes:

[0021] The first neighborhood gradient direction similarity is constructed based on the gradient direction difference between the low threshold pixel and each pixel in the neighborhood. The expression is:

[0022]

[0023] In the formula, Indicates the similarity of the first neighborhood gradient direction between the ath low threshold pixel and the bth pixel in the neighborhood. represents the gradient direction of the a-th low threshold pixel, Indicates the gradient direction of the bth pixel in the neighborhood of the ath low threshold pixel. is the preset gradient direction threshold;

[0024] The sum of all first neighborhood gradient direction similarities in the neighborhood of each low threshold pixel point is taken as the neighborhood gradient direction similarity of each low threshold pixel point.

[0025] Furthermore, the neighborhood gradient consistency of each low threshold pixel point is obtained by combining the neighborhood gradient similarity and the neighborhood gradient direction similarity of each low threshold pixel point, including:

[0026] The normalized value of the sum of the neighborhood gradient similarity and the neighborhood gradient direction similarity of each low threshold pixel point is taken as the neighborhood gradient consistency of each low threshold pixel point.

[0027] Furthermore, the regional fidelity of the marked judgment area is obtained according to the clustering results of the low threshold pixel points and the high threshold pixel points, including:

[0028] The low threshold chaos degree is constructed based on the difference in the consistency of neighborhood gradients in different clustering sets of low threshold pixels. The expression is:

[0029]

[0030] In the formula, Represents the low threshold chaos of all low threshold pixels, Indicates the number of cluster sets of all low-threshold pixels in the marked judgment area. Indicates The number of cluster sets adjacent to the cluster set with common edges, Indicates The adjacent clusters around The number of pixels contained in the cluster set is calculated. The mean of the neighborhood gradient consistency of all pixels in the cluster set is determined as the first mean, and the The adjacent clusters around The neighborhood gradient consistency mean of the pixel points contained in the cluster set is determined as the second mean. represents the absolute value of the difference between the first mean and the second mean, Indicates The number of pixels contained in a cluster set, Indicates The mean of the neighborhood gradient consistency of all pixels in a cluster set;

[0031] By analogy, for high-threshold pixels, the low-threshold disorder degree calculation method is used to obtain the high-threshold disorder degree of all high-threshold pixels;

[0032] The information entropy of the neighborhood gradient consistency of all pixels in the marked judgment area is used as the neighborhood gradient entropy of the marked judgment area; the sum of the low threshold chaos and the high threshold chaos in the marked judgment area is calculated, and the inverse of the product of the sum and the neighborhood gradient entropy is used as the regional fidelity of the marked judgment area.

[0033] Furthermore, the step of obtaining the regional edge contrast of the marking judgment area includes:

[0034] Perform edge detection in the marking judgment area using the Canny edge detection algorithm, preset different low thresholds, and for the marking judgment area, calculate the absolute value of the difference between the number of outermost edge pixel points detected under different preset low thresholds and the average number of outermost edge pixel points detected under all preset low thresholds, use the opposite number of the absolute value of the difference as the exponent of an exponential function with a natural constant as the base, and use the calculation result of the exponential function as the rectangular completeness of the marking judgment area under each low threshold;

[0035] The absolute value of the difference between the integrity of each rectangle and the mean of the completeness of all rectangles is calculated, recorded as the first absolute value of the difference, the ratio of the first absolute value of the difference to the integrity of each rectangle is calculated, the opposite of the sum of the ratios under all low thresholds in the mark judgment area is used as the exponent of an exponential function with a natural constant as the base, recorded as the first exponential function, and the calculation result of the first exponential function is used as the regional edge contrast of the mark judgment area.

[0036] Furthermore, the image enhancement coefficient of the two-dimensional code image is obtained by combining the regional contrast, regional fidelity, and regional edge contrast of each mark verification area, including:

[0037] The product of the regional contrast, regional fidelity and regional edge contrast of the mark judgment area is taken as the rectangular clarity of the mark judgment area; the average of the rectangular clarity of all mark judgment areas in the two-dimensional code image is taken as the complete contrast of the two-dimensional code image; and the normalized value of the inverse of the complete contrast of the two-dimensional code image is taken as the image enhancement coefficient of the two-dimensional code image.

[0038] In a second aspect, an embodiment of the present invention further provides a canned fish production information traceability system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the above methods when executing the computer program.

[0039] The present invention has at least the following beneficial effects:

[0040] The present invention acquires a two-dimensional code image on the surface of a canned fish, analyzes the grayscale features, gradient features, and edge features of the two-dimensional code image, and finally obtains an image enhancement coefficient to improve the adaptive contrast enhancement algorithm, thereby completing the fish can production information tracing based on image enhancement. The present invention improves the efficiency of fish can production information tracing by performing image enhancement on the two-dimensional code image on the surface of the canned fish;

[0041] Furthermore, according to the characteristics of the two-dimensional code image, the marking judgment area is obtained, and the grayscale distribution information, gradient information and edge information of the marking judgment area are analyzed to obtain the rectangular clarity, and the complete contrast of the two-dimensional code image is obtained according to the rectangular clarity of the three marking judgment areas, thereby improving the enhancement coefficient in the adaptive contrast enhancement algorithm, so that the improved adaptive contrast enhancement algorithm can analyze global information while considering local information during the image enhancement process, thereby improving the image enhancement effect of the two-dimensional code on the surface of the fish can. The present invention solves the problem that the surface two-dimensional code image is blurred due to bumps and other reasons during the production and transportation of canned fish, thereby making it difficult to trace the production information. The present invention has the beneficial effects of high efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 A flowchart of a method for tracing canned fish production information provided by one embodiment of the present invention;

[0044] Figure 2 Flowchart for obtaining the QR code image enhancement coefficient indicator. DETAILED DESCRIPTION

[0045] 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 a method and system for tracing canned fish production information proposed by the present invention, its specific implementation, structure, features and effects, in conjunction 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.

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

[0047] The specific scheme of the method and system for tracing the production information of canned fish provided by the present invention is described in detail below with reference to the accompanying drawings.

[0048] See also Figure 1 , which shows a flow chart of the steps of a method for tracing canned fish production information provided by an embodiment of the present invention, the method comprising the following steps:

[0049] Step S001, obtaining a two-dimensional code image on the surface of a canned fish by an image acquisition device and performing preprocessing.

[0050] Specifically, firstly, this embodiment will use an industrial camera to obtain an RGB image of a two-dimensional code on the surface of a canned fish under uniform light conditions as a data source for tracing the production information of the canned fish. It should be noted that there are many methods for obtaining an RGB image of a two-dimensional code on the surface of a canned fish. The specific image acquisition method can be implemented by the existing technology and is not within the scope of protection of this embodiment, so no detailed description will be given.

[0051] Then, the QR code RGB image is converted into a grayscale image using the average method. Secondly, the QR code grayscale image is denoised using a Gaussian filter denoising algorithm to remove noise interference. Since the average method and the Gaussian filter denoising algorithm are both existing well-known technologies, they will not be described in detail here.

[0052] At this point, the grayscale image of the QR code can be obtained according to the above method of this embodiment, which serves as the data basis for the subsequent tracing of canned fish production information.

[0053] Step S002, obtaining the mark judgment area of ​​the two-dimensional code image, obtaining the regional contrast, regional fidelity and regional edge contrast of the mark judgment area, and finally obtaining the image enhancement coefficient.

[0054] Specifically, the present embodiment first obtains the marking judgment area of ​​the two-dimensional code image, obtains the regional contrast of the marking judgment area according to the grayscale distribution of the marking judgment area, obtains the neighborhood gradient consistency of each pixel point according to the gradient distribution of the pixel value of the marking judgment area, clusters the neighborhood gradient consistency of each pixel point, obtains the regional fidelity of the marking judgment area according to the position distribution of different clustering sets in the clustering result, obtains the regional edge contrast of the marking judgment area, and obtains the image enhancement coefficient by combining the regional contrast, regional fidelity and regional edge contrast of the marking judgment area to complete the traceability of canned fish production information. The specific two-dimensional code image enhancement coefficient indicator acquisition flow chart is as follows: Figure 2 The specific process of constructing the image enhancement coefficient of the two-dimensional code image is as follows:

[0055] Since the QR code of canned fish that needs to be traced back to production information may be worn during transportation and storage, it is difficult to obtain traceability information when the QR code is scanned. Therefore, it is necessary to enhance the collected QR code image to reduce the difficulty of tracing production information based on the QR code.

[0056] In order to improve the efficiency of canned fish production information tracing, it is necessary to enhance the unclear QR code image on the surface of the canned fish. The embodiment of the present invention uses the existing adaptive contrast ACE image enhancement algorithm for image enhancement, but the enhancement coefficient in the algorithm is The size of determines the effect of image enhancement. Therefore, the embodiment of the present invention analyzes the two-dimensional code image and then adaptively obtains the enhancement coefficient in the algorithm. .

[0057] Analyze the acquired two-dimensional code image. First, edge detection is performed on the two-dimensional code image using the Canny edge detection algorithm, and all rectangular edges in the two-dimensional code image are obtained using the rectangular fitting algorithm for each detected edge pixel point. According to the inherent characteristics of the two-dimensional code image, there are three relatively standardized rectangular areas in the upper left corner, lower left corner and upper right corner of the two-dimensional code image. Therefore, the above three relatively standardized rectangular areas are obtained according to the position coordinates of all rectangular edges, and the three rectangular areas are determined as the marking and verification areas of the two-dimensional code image. The Canny edge detection algorithm and the rectangular fitting algorithm are both existing well-known technologies, and this embodiment will not be described in detail here.

[0058] For a QR code, its mark judgment area does not represent other information, but is only for the convenience of QR code calibration and recognition. Therefore, the arrangement of pixels in the mark judgment area is fixed. Therefore, the enhancement coefficient can be adjusted according to the contrast of the QR code image by obtaining the difference degree of pixels in each mark judgment area. , thereby achieving the purpose of image enhancement.

[0059] Firstly, the three mark judgment areas in the QR code image are analyzed. In order to measure the grayscale distribution in the mark judgment area, the Otsu threshold method is used to segment each mark judgment area. The segmentation threshold obtained by the Otsu threshold method is recorded as ,in is the number of marked verification areas in the QR code image. For each marked verification area, the pixel gray value is greater than or equal to the segmentation threshold. The pixel points with grayscale values ​​less than the segmentation threshold are recorded as high threshold pixels, and the pixel points with grayscale values ​​less than the segmentation threshold are recorded as high threshold pixels. The pixel points with are recorded as low threshold pixels.

[0060] The first regional contrast of all low-threshold pixels is calculated according to the grayscale distribution of the low-threshold pixels in the marking judgment area. The specific expression of the first regional contrast is:

[0061]

[0062] In the formula, is the first area contrast of all low threshold pixels in the marked judgment area, n is the number of all low threshold pixels in the marked judgment area, g is the mean gray value of all low threshold pixels in the marked judgment area, Represents the gray value of the i-th low threshold pixel in the mark judgment area.

[0063] In the marking judgment area, if the gray value of the low threshold pixel point is more different from the gray value average of all low threshold pixel points, it means that the first area contrast of the low threshold pixel point is greater.

[0064] By analogy, the second regional contrast of all high threshold pixel points in the marking judgment area is calculated in the same way as the first regional contrast of all low threshold pixel points. The specific expression of the second regional contrast is:

[0065]

[0066] In the formula, The second area contrast of all high threshold pixels in the identification area is marked. Indicates the number of all high threshold pixels in the marking judgment area. It represents the mean gray value of all high threshold pixels in the marking judgment area. Represents the gray value of the i-th high threshold pixel in the mark judgment area.

[0067] The regional contrast of the marking judgment area is calculated according to the first regional contrast and the second regional contrast in the marking judgment area. The specific expression of the regional contrast is:

[0068]

[0069] In the formula, Indicates the regional contrast of the marked judgment area. is an exponential function with a natural constant as base, To mark the first area contrast of all low threshold pixels in the judgment area, The second area contrast is used to mark all high threshold pixels in the judgment area.

[0070] At the same time, it is necessary to obtain the distribution of pixels in each mark judgment area in the two-dimensional code image. For a completely printed and clear two-dimensional code, the distribution characteristics of the corresponding internal pixels are the same. However, in the case of wear, if the distribution of pixels in the mark judgment area is more regular, it means that the degree of wear in the mark judgment area is smaller. Conversely, if the distribution of pixels in the mark judgment area is more irregular, it means that the degree of wear in the mark judgment area is greater. Therefore, the gradient characteristics of the pixels in the mark judgment area are analyzed, and in order to ensure that there is a relatively consistent change direction when analyzing the gradient direction of the pixel points, so as to represent the change trend of the gradient direction of the pixel points, therefore, for each low-threshold pixel point in the mark judgment area, the Sobel operator is used to calculate the gradient amplitude and gradient direction of each low-threshold pixel point, and each low-threshold pixel point is used as the center point to construct In this embodiment, , the implementer can set it according to the actual situation, and this embodiment does not limit it. The first neighborhood gradient similarity of each low threshold pixel point is calculated. The specific expression of the first neighborhood gradient similarity is:

[0071]

[0072] In the formula, Indicates the first neighborhood gradient similarity between the ath low threshold pixel and the bth pixel in the neighborhood. represents the gradient amplitude of the a-th low threshold pixel, represents the gradient amplitude of the bth pixel in the neighborhood of the ath low threshold pixel, is the preset gradient threshold. The implementer can set it according to the actual situation, and this embodiment does not limit it.

[0073] That is, the closer the gradient amplitude of the a-th low threshold pixel point is to the b-th pixel point in the neighborhood, the higher the corresponding first neighborhood gradient similarity is, and the first neighborhood gradient similarity between the two pixels is recorded as 1, otherwise it is recorded as 0.

[0074] The neighborhood gradient similarity of each low threshold pixel is calculated according to the first neighborhood gradient similarity between the low threshold pixel and each pixel in the neighborhood. The specific expression of the neighborhood gradient similarity is:

[0075]

[0076] In the formula, represents the neighborhood gradient similarity of the a-th low threshold pixel, Represents the number of pixels in the neighborhood of the a-th low threshold pixel, Indicates the first neighborhood gradient similarity between the ath low threshold pixel and the bth pixel in the neighborhood.

[0077] By analogy, the first neighborhood gradient direction similarity of each low threshold pixel is calculated. The specific expression of the first neighborhood gradient direction similarity is:

[0078]

[0079] In the formula, Indicates the similarity of the first neighborhood gradient direction between the ath low threshold pixel and the bth pixel in the neighborhood. represents the gradient direction of the a-th low threshold pixel, Indicates the gradient direction of the bth pixel in the neighborhood of the ath low threshold pixel. is the preset gradient direction threshold. The implementer can set it according to the actual situation, and this embodiment does not limit it.

[0080] That is, the closer the gradient direction of the a-th low threshold pixel point is to the b-th pixel point in the neighborhood, the higher the similarity of the corresponding first neighborhood gradient direction is. The first neighborhood gradient direction similarity between the two pixels is recorded as 1, otherwise it is recorded as 0.

[0081] The neighborhood gradient direction similarity of each low threshold pixel is calculated according to the first neighborhood gradient direction similarity between the low threshold pixel and each pixel in the neighborhood. The specific expression of the neighborhood gradient direction similarity is:

[0082]

[0083] In the formula, Indicates the similarity of the neighborhood gradient direction of the a-th low threshold pixel, Represents the number of pixels in the neighborhood of the a-th low threshold pixel, Indicates the similarity of the first neighborhood gradient direction between the ath low threshold pixel and the bth pixel in the neighborhood.

[0084] The neighborhood gradient consistency of each low threshold pixel point is calculated according to the neighborhood gradient similarity and neighborhood gradient direction similarity of each low threshold pixel point. The specific expression of the neighborhood gradient consistency is:

[0085]

[0086] In the formula, Indicates the neighborhood gradient consistency of the a-th low threshold pixel, represents the normalization function, Indicates the similarity of the neighborhood gradient direction of the a-th low threshold pixel, Represents the neighborhood gradient similarity of the a-th low threshold pixel.

[0087] The greater the neighborhood gradient direction similarity and neighborhood gradient similarity of the low threshold pixel point, the stronger the neighborhood gradient consistency of the low threshold pixel point.

[0088] Similarly, the same method as above is used to obtain the neighborhood gradient consistency of each high threshold pixel.

[0089] Then, in the marking judgment area of ​​the two-dimensional code image, each pixel point has an indicator of neighborhood gradient consistency. First, for low-threshold pixels, the neighborhood gradient consistency of all low-threshold pixels is clustered using the DBSCAN clustering algorithm, wherein the DBSCAN clustering algorithm is an existing well-known technology and will not be repeated in this embodiment.

[0090] After the clustering of the marked judgment area is completed using the DBSCAN clustering algorithm, all low-threshold pixels will be divided into different clusters, but the same cluster may be located in different areas of the marked judgment area. Therefore, different cluster areas are marked as cluster sets, and different cluster sets are analyzed to construct a low-threshold chaos index. The specific expression of the low-threshold chaos is:

[0091]

[0092] In the formula, Represents the low threshold chaos of all low threshold pixels, Indicates the number of cluster sets of all low-threshold pixels in the marked judgment area. Indicates The number of cluster sets adjacent to the cluster set with common edges, Indicates The adjacent clusters around The number of pixels contained in the cluster set is calculated. The mean of the neighborhood gradient consistency of all pixels in the cluster set is determined as the first mean, and the The adjacent clusters around The neighborhood gradient consistency mean of the pixel points contained in the cluster set is determined as the second mean. represents the absolute value of the difference between the first mean and the second mean, Indicates The number of pixels contained in a cluster set, Indicates The mean of the neighborhood gradient consistency of all pixels in a cluster set.

[0093] That is, when the number of pixels contained in the cluster set is more, the neighborhood gradient consistency of the pixels in the cluster set is greater, and the low threshold confusion of the low threshold pixel is smaller.

[0094] Similarly, using the same method as above, the high threshold disorder of all high threshold pixels in the marked judgment area is calculated and determined as .

[0095] According to the neighborhood gradient consistency of all pixels in the marked verification area, the information entropy of the pixel neighborhood gradient consistency is calculated to determine the neighborhood gradient entropy of the marked verification area. According to the neighborhood gradient entropy, low threshold chaos degree and high threshold chaos degree of the marked verification area, the regional fidelity of the marked verification area is calculated. The specific expression of the regional fidelity is:

[0096]

[0097] In the formula, Indicates the regional fidelity of the marking judgment area, Represents the low threshold chaos of all low threshold pixels, Represents the high threshold chaos of all high threshold pixels, Represents the neighborhood gradient entropy of the marked judgment area.

[0098] At the same time, if the mark judgment area is worn out, the edge information in the mark judgment area will also be worn out. Therefore, the Canny algorithm is used to perform edge detection in the mark judgment area. The Canny algorithm edge detection process involves two thresholds, a low threshold and a high threshold, which are used to distinguish strong edges, weak edges and non-edges. This embodiment presets the number of low thresholds to improve the accuracy of edge detection. This embodiment presets the value range of the low threshold o as K={60,75,90,105,120}, and the high threshold is set to 150. The implementer can set it according to the actual situation. This embodiment does not limit this. The Canny algorithm is an existing well-known technology and will not be repeated in this embodiment. The regional edge contrast is calculated. The specific expression of the regional edge contrast is:

[0099]

[0100]

[0101] In the formula, Indicates that the preset low threshold is The rectangular integrity of the time mark judgment area, is an exponential function with a natural constant as base, Indicates that the preset low threshold is The number of pixels at the outermost edge is Represents the average number of outermost pixels of all preset low thresholds, Indicates the regional edge contrast of the marked judgment area, Indicates the number of preset low thresholds. In this embodiment , Indicates the value range of the preset low threshold. Indicates that the preset low threshold is The absolute value of the difference between the rectangular integrity of the time-stamped judgment area and the average of the rectangular integrity of all preset low-threshold marked judgment areas.

[0102] That is, when the rectangle completeness obtained using different preset low thresholds is higher and the difference in rectangle completeness obtained using different preset low thresholds is smaller, it means that the regional edge contrast obtained according to the edge information is greater, and the clarity of the edge pixels in the mark judgment area is higher.

[0103] The rectangular clarity of the marked verification area is calculated by combining the regional contrast of the marked verification area, the regional fidelity of the marked verification area, and the regional edge contrast of the marked verification area. The specific expression of the rectangular clarity is:

[0104]

[0105] In the formula, Indicates the rectangular clarity of the first mark verification area in the QR code image. Indicates the regional edge contrast of the marked judgment area, Indicates the regional fidelity of the marking judgment area, Indicates the regional contrast of the marked judgment area.

[0106] Similarly, the remaining two rectangular clarity marking judgment areas are obtained and recorded as , .

[0107] Combined with the rectangular clarity of all the marking judgment areas in the two-dimensional code image, the complete contrast of the two-dimensional code image is calculated. The specific expression of the complete contrast is:

[0108]

[0109] In the formula, is the full contrast of the QR code image, Indicates the rectangular clarity of the first mark verification area in the QR code image. Indicates the clarity of the rectangle of the second mark verification area in the QR code image. Indicates the rectangular clarity of the third mark judgment area in the QR code image.

[0110] According to the full contrast of the two-dimensional code image, the image enhancement coefficient after the adaptive contrast enhancement algorithm is improved is obtained. The specific expression is:

[0111]

[0112] In the formula, is the image enhancement coefficient after the adaptive contrast enhancement algorithm is improved. is the full contrast of the QR code image, Represents the normalization function.

[0113] When the rectangular definition of the two-dimensional code image is higher, the corresponding image enhancement coefficient should be lower. Conversely, when the rectangular definition of the two-dimensional code image is lower, the image enhancement coefficient should be larger.

[0114] Step S003, using the improved image enhancement coefficient combined with the adaptive contrast enhancement algorithm to complete the fish can production information traceability.

[0115] The improved image enhancement coefficient replaces the original image enhancement coefficient in the adaptive contrast enhancement algorithm to complete the QR code image enhancement, and the enhanced QR code image is scanned by a scanner to complete the traceability of canned fish production information.

[0116] Based on the same inventive concept as the above method, an embodiment of the present invention further provides a canned fish production information tracing system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the above-mentioned canned fish production information tracing methods when executing the computer program.

[0117] In summary, the embodiments of the present invention solve the problem that the surface QR code image is blurred due to bumps and other reasons during the production and transportation of canned fish, resulting in difficulty in tracing production information. The production information of canned fish is traced by combining the QR code image features on the surface of canned fish with an adaptive contrast enhancement algorithm, thereby improving the efficiency of tracing the production information of canned fish.

[0118] 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 above is a description of a specific embodiment of this specification. In addition, 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.

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

[0120] 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 in the protection scope of the present invention.

Claims

1. A method for tracing canned fish production information, characterized in that: The method comprises the following steps: Collect the QR code image on the surface of the fish can; Obtain the marked judgment area of ​​the two-dimensional code image; use the Otsu threshold algorithm to obtain the segmentation threshold of the marked judgment area; take the pixel points with grayscale values ​​greater than or equal to the segmentation threshold in the marked judgment area as high threshold pixel points; take the pixel points with grayscale values ​​less than the segmentation threshold in the marked judgment area as low threshold pixel points; obtain the regional contrast of the marked judgment area according to the grayscale distribution of the pixel points in the marked judgment area; obtain the neighborhood gradient similarity of each low threshold pixel point according to the gradient amplitude distribution of the low threshold pixel points in the marked judgment area; According to the gradient direction distribution of low-threshold pixels in the marked judgment area, the neighborhood gradient direction similarity of each low-threshold pixel is obtained; the neighborhood gradient consistency of each low-threshold pixel is obtained by combining the neighborhood gradient similarity and neighborhood gradient direction similarity of each low-threshold pixel; for high-threshold pixels, the neighborhood gradient consistency of each high-threshold pixel is calculated by using the method of obtaining the neighborhood gradient consistency of low-threshold pixels; the neighborhood gradient consistency of each pixel in the marked judgment area is used for clustering; the regional fidelity of the marked judgment area is obtained according to the clustering results of low-threshold pixels and high-threshold pixels; Obtain the regional edge contrast of the mark verification area; combine the regional contrast, regional fidelity, and regional edge contrast of each mark verification area to obtain the image enhancement coefficient of the QR code image; combine the adaptive contrast enhancement algorithm and the image enhancement coefficient to complete the fish can production information traceability based on image enhancement; The step of obtaining the marking verification area of ​​the two-dimensional code image includes: Perform edge detection on the two-dimensional code image, fit the detected edges using a rectangular fitting algorithm, obtain a rectangular area in the two-dimensional code image, and use the rectangular areas at the upper left corner, lower left corner, and upper right corner of the two-dimensional code image as the marking and verification area of ​​the two-dimensional code image; The step of obtaining the regional contrast of the marked verification area according to the grayscale distribution of the pixels in the marked verification area includes: Calculate the absolute value of the difference between each low-threshold pixel point in the mark judgment area and the average of all low-threshold pixel points, and use the average of the absolute value of the difference of all low-threshold pixel points as the first regional contrast of all low-threshold pixel points; and so on, calculate the second regional contrast of all high-threshold pixel points in the mark judgment area; use the inverse of the sum of the first regional contrast and the second regional contrast in the mark judgment area as the exponent of an exponential function with a natural constant as the base; and use the calculation result of the exponential function as the regional contrast of the mark judgment area; The method of obtaining the neighborhood gradient similarity of each low-threshold pixel point according to the gradient amplitude distribution of the low-threshold pixel point in the marked judgment area includes: The first neighborhood gradient similarity is constructed based on the difference in gradient amplitude between the low threshold pixel and each pixel in the neighborhood. The expression is: In the formula, Indicates the first neighborhood gradient similarity between the ath low threshold pixel and the bth pixel in the neighborhood. represents the gradient amplitude of the a-th low threshold pixel, represents the gradient amplitude of the bth pixel in the neighborhood of the ath low threshold pixel, is the preset gradient threshold; The sum of all first neighborhood gradient similarities in the neighborhood of each low threshold pixel point is taken as the neighborhood gradient similarity of each low threshold pixel point; The method of obtaining the neighborhood gradient direction similarity of each low-threshold pixel point according to the gradient direction distribution of the low-threshold pixel point in the marked judgment area includes: The first neighborhood gradient direction similarity is constructed based on the gradient direction difference between the low threshold pixel and each pixel in the neighborhood. The expression is: In the formula, Indicates the similarity of the first neighborhood gradient direction between the ath low threshold pixel and the bth pixel in the neighborhood. represents the gradient direction of the a-th low threshold pixel, Indicates the gradient direction of the bth pixel in the neighborhood of the ath low threshold pixel. is the preset gradient direction threshold; The sum of all first neighborhood gradient direction similarities in the neighborhood of each low threshold pixel point is taken as the neighborhood gradient direction similarity of each low threshold pixel point; The neighborhood gradient consistency of each low-threshold pixel point is obtained by combining the neighborhood gradient similarity and the neighborhood gradient direction similarity of each low-threshold pixel point, including: The normalized value of the sum of the neighborhood gradient similarity and the neighborhood gradient direction similarity of each low threshold pixel point is taken as the neighborhood gradient consistency of each low threshold pixel point; The regional fidelity of the marking judgment area is obtained according to the clustering results of the low threshold pixel points and the high threshold pixel points, including: The low threshold chaos degree is constructed based on the difference in the consistency of neighborhood gradients in different clustering sets of low threshold pixels. The expression is: In the formula, Represents the low threshold chaos of all low threshold pixels, Indicates the number of cluster sets of all low-threshold pixels in the marked judgment area. Indicates The number of cluster sets adjacent to the cluster set with common edges, Indicates The adjacent clusters around The number of pixels contained in the cluster set is calculated. The mean of the neighborhood gradient consistency of all pixels in the cluster set is determined as the first mean, and the The adjacent clusters around The neighborhood gradient consistency mean of the pixel points contained in the cluster set is determined as the second mean. represents the absolute value of the difference between the first mean and the second mean, Indicates The number of pixels contained in a cluster set, Indicates The mean of the neighborhood gradient consistency of all pixels in a cluster set; By analogy, for high-threshold pixels, the low-threshold disorder degree calculation method is used to obtain the high-threshold disorder degree of all high-threshold pixels; The information entropy of the neighborhood gradient consistency of all pixels in the marked verification area is used as the neighborhood gradient entropy of the marked verification area; the sum of the low threshold chaos and the high threshold chaos in the marked verification area is calculated, and the inverse of the product of the sum and the neighborhood gradient entropy is used as the regional fidelity of the marked verification area; The step of obtaining the regional edge contrast of the marking verification area includes: Perform edge detection in the marking judgment area using the Canny edge detection algorithm, preset different low thresholds, and for the marking judgment area, calculate the absolute value of the difference between the number of outermost edge pixel points detected under different preset low thresholds and the average number of outermost edge pixel points detected under all preset low thresholds, use the opposite number of the absolute value of the difference as the exponent of an exponential function with a natural constant as the base, and use the calculation result of the exponential function as the rectangular completeness of the marking judgment area under each low threshold; Calculate the absolute value of the difference between the integrity of each rectangle and the average of the integrity of all rectangles, record it as the first absolute value of the difference, calculate the ratio of the first absolute value of the difference to the integrity of each rectangle, use the opposite of the sum of the ratios under all low thresholds in the mark judgment area as the exponent of an exponential function with a natural constant as the base, record it as the first exponential function, and use the calculation result of the first exponential function as the regional edge contrast of the mark judgment area; The image enhancement coefficient of the two-dimensional code image is obtained by combining the regional contrast, regional fidelity and regional edge contrast of each mark verification area, including: The product of the regional contrast, regional fidelity and regional edge contrast of the mark judgment area is taken as the rectangular clarity of the mark judgment area; the average of the rectangular clarity of all mark judgment areas in the two-dimensional code image is taken as the complete contrast of the two-dimensional code image; and the normalized value of the inverse of the complete contrast of the two-dimensional code image is taken as the image enhancement coefficient of the two-dimensional code image.

2. A canned fish production information tracing system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to claim 1 are implemented.

Citation Information

Patent Citations

  • Decoding method for automatically repairing and identifying code pattern symbols of two-dimensional codes and apparatus

    CN103778400A

  • Complex background bar code segmentation and reading method based on machine vision

    CN107633192A