Image processing-based real-time monitoring method and system for food production line

By employing an anisotropic diffusion model and a multi-constraint edge detection method, the challenge of edge detection in complex food images was addressed, generating high-quality food contours and improving the accuracy of defect identification.

CN120807646BActive Publication Date: 2025-11-21SHAANXI YIMING FOOD CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511301239.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-12
Publication Date
2025-11-21
Estimated Expiration
2045-09-12

AI Technical Summary

Technical Problem

In existing technologies, edge detection algorithms struggle to detect both strong and weak edges when processing complex food images, and are easily affected by noise, leading to broken contours and false edges, which negatively impacts defect analysis.

Method used

An anisotropic diffusion model with diffusion coefficient inversely proportional to gradient magnitude is used for preprocessing. The threshold is adjusted by combining fractal dimension and local phase consistency. Edge connectivity is determined by gradient direction and geometric collinearity. Wavelet transform is used to locate the defect position.

Benefits of technology

It effectively suppresses noise, preserves real edge details, generates more complete, continuous, and smooth food contours, significantly reduces contour breaks and burrs, and improves the accuracy of defect identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120807646B_ABST
    Figure CN120807646B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing, and specifically discloses a food production line real-time monitoring method and system based on image processing, comprising the following steps: S1, obtaining the original image of the food to be monitored, and obtaining the pretreated image after gray scale and smoothing by using the anisotropic diffusion model with the diffusion coefficient being inversely proportional to the gradient amplitude; S2, calculating the gradient amplitude and gradient direction of each pixel point in the pretreated image; S3, for any pixel point in the pretreated image, calculating the fractal dimension and local phase consistency of the window region of the pixel point, and based on the two characteristic values, obtaining an adjustment coefficient from the preset lookup table, and adjusting the preset reference threshold value by using the adjustment coefficient to obtain a dynamic high threshold T high The present application has the beneficial effect that the basis for judging edge connection is more sufficient, and a more complete, continuous and smooth food contour can be generated, and the contour breakage and burr are significantly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and more specifically to a method and system for real-time monitoring of food production lines based on image processing. Background Technology

[0002] In modern food production and processing, automated quality inspection is a core component for ensuring product quality and improving production efficiency. Machine vision technology, with its advantages of non-contact operation, high efficiency, and high precision, is frequently applied to food production lines for real-time monitoring of product size, shape, and surface defects. In these visual inspection tasks, edge detection, as a fundamental step in image processing, directly impacts the accuracy of subsequent feature extraction and defect identification. By accurately extracting the edge contours of food, its geometric shape can be effectively analyzed, and common defects such as breakage, gaps, adhesion, or irregularities can be located. The Canny operator typically includes steps such as Gaussian filtering, gradient calculation, non-maximum suppression, and double-threshold hysteresis connections.

[0003] In practical applications, especially when processing food images with complex backgrounds, uneven lighting, and diverse textures, the use of globally uniform high and low thresholds cannot adapt to changes in local image content. When both strong and weak edges exist in an image, a single threshold pair is insufficient: an excessively high threshold leads to the loss of detailed weak edge information, causing contour breaks; an excessively low threshold introduces numerous false edges caused by background textures or noise, interfering with the extraction of true contours. Furthermore, its hysteresis connection process simply judges based on the adjacency relationship between candidate edge points and strong edge points, without fully considering the geometric continuity and directional consistency of edges. This makes it prone to generating incorrect connections under noise interference, affecting the smoothness and integrity of the contour, and consequently causing difficulties for subsequent contour-based defect analysis. Summary of the Invention

[0004] This invention provides a method and system for real-time monitoring of food production lines based on image processing, aiming to solve the limitations of edge detection algorithms in complex food image processing in related technologies.

[0005] In a first aspect, the present invention provides a method for real-time monitoring of a food production line based on image processing, comprising the following steps:

[0006] S1. Obtain the original image of the food to be monitored, convert it to grayscale, and smooth it using an anisotropic diffusion model inversely proportional to the diffusion coefficient and gradient magnitude to obtain the preprocessed image.

[0007] S2, calculate the gradient magnitude and gradient direction of each pixel in the preprocessed image;

[0008] S3. For any pixel in the preprocessed image, calculate the fractal dimension and local phase consistency of the pixel's window region. Based on these two feature values, obtain an adjustment coefficient from a preset lookup table. Use this adjustment coefficient to adjust a preset baseline threshold to obtain a dynamic high threshold T. high Using a preset low threshold ratio coefficient to adjust the dynamic high threshold T high Adjustments are made to obtain a dynamic low threshold T low ;

[0009] S4, the gradient magnitude is higher than its corresponding dynamic high threshold T high Pixels that are identified as strong edge points are set to have gradient magnitudes between their corresponding dynamic low thresholds T. low With dynamic high threshold T high Pixels between points are identified as candidate edge points;

[0010] S5. For any candidate edge point, the connection contribution is calculated by comprehensively considering its gradient direction similarity, gradient magnitude and geometric collinearity with strong edge points in its eight neighborhoods. When the cumulative connection contribution exceeds the preset threshold, the candidate edge point is determined as the final edge point.

[0011] S6 connects all strong edge points with the final edge point to form the food edge contour, represents the food edge contour as an ordered coordinate point sequence and calculates its local curvature; by performing a one-dimensional wavelet transform on the local curvature sequence, locates energy anomaly points in the high-frequency sub-band and maps them back to the food edge contour, thereby determining the location of the food defect.

[0012] Preferably, the anisotropic diffusion model is the Perona-Malik diffusion model, and the formula for calculating the diffusion coefficient c is as follows: , where |▽I | for pixels ( The gradient magnitude after t iterations, where K is the gradient adjustment constant.

[0013] Preferably, in S3, the differential box counting method is used. Within a window area of ​​a preset size centered on the target pixel, multi-size box coverage counting is performed on the three-dimensional surface composed of gray values ​​within the window area, and linear fitting is performed in a double logarithmic coordinate system. The slope of the fitted line is used as the fractal dimension of the window area.

[0014] Preferably, a logarithmic Gabor wavelet is used to perform multi-scale, multi-directional filtering on a window region of a preset size, and the local phase consistency is obtained by calculating the energy-weighted average of the filtering responses at each scale.

[0015] Preferably, in S3, the baseline threshold T of the preprocessed image is calculated using the Otsu method. baseFor any pixel, the adjustment coefficient μ is indexed from a preset two-dimensional lookup table based on the fractal dimension and local phase consistency of its window region; the dynamic high threshold T of this pixel is... high =μ×T base Dynamic low threshold T low =λ×T high , where λ is a preset low threshold ratio coefficient, with a value ranging from 0.4 to 0.6.

[0016] Preferably, in S5, for any candidate edge point p, traverse the strong edge points q in its eight neighborhoods, calculate the connection contribution C(p,q) between the candidate edge point p and the strong edge point q, and accumulate all C(p,q), where C(p,q) is calculated by the following formula: In the formula, θ p and θ q M represents the gradient directions of candidate edge point p and strong edge point q. q M represents the gradient magnitude of a strong edge point q. max The maximum gradient magnitude of the preprocessed image. Let be the angle between the tangent direction of the edge at candidate edge point p and the connection vector from candidate edge point p to strong edge point q, wherein the tangent direction is orthogonal to the gradient direction of candidate edge point p. , , To satisfy the preset weight of sum to 1.

[0017] Preferably, in S6, for any point in the ordered coordinate point sequence P, the approximate values ​​of its first and second derivatives are calculated using the central difference method to further obtain the curvature value.

[0018] Preferably, in S6, a multi-level discrete wavelet transform is performed on the local curvature sequence to obtain a high-frequency detail coefficient sequence with a specified number of layers; the median absolute deviation of the high-frequency detail coefficient sequence is calculated; coefficient points in the sequence whose absolute values ​​exceed a preset multiple of the median absolute deviation are identified as outliers and mapped back onto the contour to determine the defect location.

[0019] Preferably, in S1, the original image is an RGB format image.

[0020] Secondly, the present invention provides a real-time monitoring system for a food production line based on image processing, including a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned real-time monitoring method for a food production line based on image processing is implemented.

[0021] By adopting the above technical solution, the beneficial effects of the present invention are as follows:

[0022] Compared with existing technologies, this invention provides more refined edge determination criteria for each pixel in the preprocessed image by combining the texture complexity and structural saliency features of the window region of each pixel. This effectively addresses the challenges posed by complex backgrounds and uneven lighting in the original image, effectively suppressing noise and filtering out false edges while preserving realistic and subtle edge details to the greatest extent possible. During the edge connection process, multiple constraints, such as gradient direction, gradient magnitude, and geometric collinearity, provide more comprehensive criteria for edge connection determination, generating more complete, continuous, and smooth food contours and significantly reducing contour breaks and burrs. Attached Figure Description

[0023] Figure 1 This is a flowchart of a real-time monitoring method for food production lines based on image processing.

[0024] Figure 2 This is a structural framework diagram of a real-time monitoring system for a food production line based on image processing. Detailed Implementation

[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Those skilled in the art should understand that the embodiments described below are only some, not all, of the embodiments disclosed. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0026] An embodiment of the image processing-based real-time monitoring method for food production lines provided by this invention:

[0027] like Figure 1 As shown, the real-time monitoring method for a food production line based on image processing includes the following steps:

[0028] S1: Obtain the original image of the food to be monitored, convert it to grayscale, and smooth it using an anisotropic diffusion model inversely proportional to the diffusion coefficient and gradient magnitude to obtain the preprocessed image.

[0029] Cameras deployed above the food conveyor belt continuously capture images of the food at fixed time intervals, obtaining raw images of the food to be monitored. The raw images are color images in RGB format. Each frame of the color image is converted to grayscale, becoming a single-channel grayscale image. To smooth noise in the grayscale image while maintaining edge sharpness, an anisotropic diffusion equation is applied to iteratively process the grayscale image. The diffusion coefficient function is set to the reciprocal of the gradient magnitude, resulting in strong diffusion in flat areas with small gradient magnitudes, effectively filtering out noise, while weak diffusion in edge areas with large gradient magnitudes, avoiding edge blurring.

[0030] In an optional embodiment, an anisotropic diffusion model with a diffusion coefficient inversely proportional to the gradient magnitude is used for smoothing. Specifically, the Perona-Malik diffusion model is adopted, and the formula for calculating the diffusion coefficient c is as follows:

[0031] ;

[0032] Among them |▽I | for pixels ( The gradient magnitude after t iterations, where K is the gradient adjustment constant.

[0033] For example, for a preprocessed image containing distinct edges and uniform regions, the gradient adjustment constant K can be set to 30. In an edge region with a large pixel gradient magnitude, such as a gradient magnitude of 90, the calculated diffusion coefficient c is approximately 0.1, which is small. Therefore, the smoothing diffusion effect is weak in this area, protecting the edge from blurring. Conversely, in a uniform region with a small pixel gradient magnitude, such as a gradient magnitude of 5, the calculated diffusion coefficient c is approximately 0.97, close to 1. This means that the smoothing diffusion effect is strong in this area, effectively filtering out random noise. By setting the number of iterations N, for example, to 15, the smoothing process is repeated 15 times. Each iteration continues to suppress noise and preserve edges based on the previous processing result. This iterative approach makes the smoothing effect more refined and controllable. The final preprocessed image eliminates most of the interference noise while retaining the clear contour information crucial for subsequent edge detection.

[0034] S2 calculates the gradient magnitude and gradient direction of each pixel in the preprocessed image.

[0035] For example, a 3x3 Sobel operator is used to perform a convolution operation on the preprocessed image, and the gradient Gx in the horizontal direction and the gradient Gy in the vertical direction are calculated respectively. For each pixel in the preprocessed image, its gradient magnitude is obtained by calculating the square root of the sum of the squares of Gx and Gy, and its gradient direction is obtained by calculating the arctangent of Gy and Gx.

[0036] S3. For any pixel in the preprocessed image, calculate the fractal dimension and local phase consistency of the pixel's window region. Based on these two feature values, obtain an adjustment coefficient from a preset lookup table. Use this adjustment coefficient to adjust a preset baseline threshold to obtain a dynamic high threshold T. high Using a preset low threshold ratio coefficient to adjust the dynamic high threshold T high Adjustments are made to obtain a dynamic low threshold T low .

[0037] In an optional embodiment, the differential box counting method is used. Within a window of a preset size centered on the target pixel, the three-dimensional surface composed of gray values ​​in the window area is covered by multiple-size boxes for counting, and linear fitting is performed in a double logarithmic coordinate system. The slope of the fitted line is used as the fractal dimension of the window area.

[0038] The window region of the preset size is filtered by a logarithmic Gabor wavelet at multiple scales and in multiple directions. The local phase consistency is obtained by calculating the energy-weighted average of the filtering responses at each scale.

[0039] The two features calculated in this embodiment are used to describe the local characteristics of pixels from different perspectives. The fractal dimension of the window region is used to quantify the texture complexity and roughness of the local region of the preprocessed image. For example, within a 16x16 pixel window centered on the target pixel, boxes of different sizes with side lengths of 2, 4, and 8 are used to cover the three-dimensional surface composed of gray values ​​within the window. For a region with complex texture, such as a rough fabric surface, the number of boxes that need to be covered increases rapidly as the box size decreases, and the slope of the straight line fitted in the double logarithmic coordinates, i.e., the fractal dimension, may be 2.8. For a smooth metal surface, its fractal dimension value may only be 2.2. Local phase consistency is used to measure the saliency of a pixel as an edge feature. The 16x16 pixel window is filtered using logarithmic Gabor wavelets at 4 scales and 6 directions. If a pixel is located on a sharp edge, then the phase of its Fourier components will be highly consistent in the filtered responses at different scales and directions, and the calculated energy-weighted average, i.e., phase consistency, will be a high value close to 1. Conversely, if a pixel is located in an area with unstructured features or on a noisy area, its phase will be randomly distributed, and the calculated phase consistency value will be very low, for example, below 0.2. The combination of these two features can more comprehensively describe the local information of a pixel.

[0040] In an optional embodiment, the baseline threshold T of the preprocessed image is calculated using the Otsu method. base For any pixel, the adjustment coefficient μ is indexed from a preset two-dimensional lookup table based on the fractal dimension and local phase consistency of its window region; the dynamic high threshold T of this pixel is... high =μ×T base Dynamic low threshold T low =λ×T high , where λ is a preset low threshold ratio coefficient, with a value ranging from 0.4 to 0.6.

[0041] By analyzing the preprocessed image using Otsu's method, a global baseline threshold is obtained, for example, T is calculated. baseThe value is 120. This value can serve as a basic reference, but it doesn't adapt well to local variations within the preprocessed image. For any pixel in the preprocessed image, the fractal dimension and local phase consistency of the window region calculated in the previous step are used to look up the corresponding adjustment coefficient μ in a pre-defined two-dimensional lookup table. For example, a pixel located in a complex texture region might have a fractal dimension of 2.7 and a phase consistency of 0.4, resulting in a μ value of 1.4. Another pixel located on a clear contour might have a fractal dimension of 2.3 and a phase consistency of 0.9, resulting in a μ value of 0.9. Therefore, the dynamic high threshold T for the former... high It was adjusted to 1.4 × 120 = 168, while the latter's T high The threshold is then adjusted to 0.9 × 120 = 108. If the low threshold ratio coefficient λ is set to 0.5, the dynamic low thresholds corresponding to these two points are 84 and 54, respectively. This method results in a higher threshold in textured areas, making it less likely to misidentify textures as edges, while the threshold is lower in real edge areas, ensuring complete edge detection.

[0042] S4, the gradient magnitude is higher than its corresponding dynamic high threshold T high Pixels that are identified as strong edge points are set to have gradient magnitudes between their corresponding dynamic low thresholds T. low With dynamic high threshold T high The pixels between them are identified as candidate edge points.

[0043] Iterate through each pixel in the preprocessed image and compare its gradient magnitude G calculated in the second step with the dynamic high threshold T determined for that point in the third step. high and dynamic low threshold T low If G is greater than T high If G is between T, then mark the pixel as a strong edge point; low and T high If G is between T, then mark it as a candidate edge point; if G is less than T low If the point is not an edge point, then it is considered a non-edge point and is suppressed.

[0044] S5. For any candidate edge point, the connection contribution is calculated by comprehensively considering the similarity of its gradient direction, gradient magnitude, and geometric collinearity with strong edge points in its eight neighborhoods. When the cumulative connection contribution exceeds a preset threshold, the candidate edge point is determined as the final edge point.

[0045] For each candidate edge point, examine its eight neighboring pixels. If a strong edge point exists in the neighborhood, calculate three components for each strong edge point: first, the difference in their gradient directions (the smaller the difference, the higher the similarity); second, the gradient magnitude of the strong edge point (the larger the magnitude, the higher the contribution weight); and third, examine whether the candidate point, the strong edge point, and another point extending from the strong edge point are approximately on a straight line to determine geometric collinearity. Sum these three components with weights to obtain the connection contribution of the strong edge point to the candidate edge point. Accumulate the connection contributions from all strong edge points in the eight neighborhoods. If the sum exceeds a preset connection judgment threshold, the candidate edge point is confirmed as a real edge point, i.e., the final edge point.

[0046] In an optional embodiment, the connectivity contribution is calculated as follows: for any candidate edge point p, traverse the strong edge points q in its eight neighborhoods, calculate the connectivity contribution C(p,q) between p and q, and sum all C(p,q); where C(p,q) is calculated by the following formula:

[0047] ;

[0048] In the formula, θ p and θ q M represents the gradient directions of candidate edge point p and strong edge point q. q M represents the gradient magnitude of a strong edge point q. max The maximum gradient magnitude of the preprocessed image. Let be the angle between the tangent direction of the edge at candidate edge point p and the connection vector from candidate edge point p to strong edge point q, wherein the tangent direction is orthogonal to the gradient direction of candidate edge point p. , , To satisfy the preset weight of sum to 1.

[0049] This embodiment is used to determine whether a candidate edge point should be accepted as a true edge point. The determination is based on the association strength between the candidate edge point and its neighbors that have been identified as strong edge points. For example, there is a candidate edge point p, and a strong edge point q appears in its eight neighboring pixels. Weights are assigned. It is 0.5. It is 0.3. The value is 0.2. Three aspects are analyzed to calculate the connection contribution. First, the similarity of gradient directions: if the gradient direction of candidate edge point p is 30 degrees and the gradient direction of strong edge point q is 35 degrees, they are very close, so the result of the first term is close to 0.5, indicating that they are likely to belong to the same continuous edge. Second, the strength of neighbors: assuming the maximum gradient magnitude of the preprocessed image is 250, and the gradient magnitude of strong edge point q is 200, then the result of the second term is: 0.3 × 200 ÷ 250 = 0.24, which indicates that strong edge point q is a significant strong edge point with a higher connection value. Third, the continuity of geometric position: if the vector direction from candidate edge point p to strong edge point q is almost consistent with the edge tangent direction at candidate edge point p, with an angle close to 0 degrees, then the result of the third term is close to 0.2. Adding these three terms together, the connection contribution between candidate edge point p and strong edge point q is 0.94. By accumulating the contributions of candidate edge point p with all strong edge neighbors, if the sum exceeds a preset threshold, candidate edge point p will be confirmed as a real edge, thus achieving reliable edge connection.

[0050] S6 connects all strong edge points with the final edge point to form the food edge contour, represents the food edge contour as an ordered coordinate point sequence and calculates its local curvature; by performing a one-dimensional wavelet transform on the local curvature sequence, locates energy anomaly points in the high-frequency sub-band and maps them back to the food edge contour, thereby determining the location of the food defect.

[0051] All strong edge points are grouped together with the confirmed final edge points to form a binary edge map. A contour tracking algorithm, such as Moore's Neighborhood Tracking, is used to connect the edge pixels, forming one or more closed or open ordered point sequences composed of (x,y) coordinates; this is the edge contour of the food. For each point in the contour sequence, several points before and after it are taken, and a circle is fitted using these points. The reciprocal of the circle's radius is the local curvature of that point, thus obtaining a one-dimensional local curvature sequence. Discrete wavelet transform is applied to this curvature sequence to examine its high-frequency detail components. Points with energy or amplitude far exceeding the average level in the detail components are identified as energy anomalies. These points typically correspond to sharp corners or breaks in the contour, i.e., food defects. The indices of these anomalies in the curvature sequence are recorded, and the corresponding coordinate points in the contour coordinate sequence are found based on these indices; these coordinate points are the precise locations of the food surface defects.

[0052] In an optional embodiment, for any point p in the ordered coordinate point sequence P i =( i , i The first derivative is calculated using the central difference method. , ) and second derivative ( , Approximate values ​​of ) and substitute them into the curvature formula. This allows us to obtain each curvature value that constitutes the local curvature sequence.

[0053] The purpose of this embodiment is to quantify the geometry of the contour into a series of curvature values, thereby enabling the location of anomalies on the contour, such as sharp corners or dents, by analyzing these values. Curvature describes the degree of bending of a curve; the curvature of straight sections is close to zero, while the curvature at sharp turns is very large. For example, consider an ordered sequence of contour points obtained from the previous step, containing three consecutive points p. i-1 The coordinates are (20, 30), p i The coordinates are (22, 31), p i+1 The coordinates are (24, 30). Use the central difference method to estimate p. i The first and second derivatives of a point. Its first derivative components. ≈24-20÷2=2, ≈30 - 30 ÷ 2 = 0. Second derivative components. ≈24-2×22+20=0, ≈30-2×31+30=-2. Substituting these derivative values ​​into the curvature formula, we can calculate p. i The curvature value of the point is approximately 0.5. If the contour has a sharp indentation at this point, such as p... i+1 If the coordinates become (23, 35), the calculated curvature value will increase dramatically, possibly exceeding 5.0. By performing this calculation on every point on the contour, a local curvature sequence that reflects the geometric changes of the contour can be obtained.

[0054] In an optional embodiment, the local curvature sequence is subjected to multi-level discrete wavelet transform to obtain a high-frequency detail coefficient sequence with a specified number of levels; the median absolute deviation of the high-frequency detail coefficient sequence is calculated; coefficient points in the sequence whose absolute values ​​exceed a preset multiple of the median absolute deviation are identified as outliers and mapped back onto the contour to determine the defect location.

[0055] One-dimensional wavelet transform is used to analyze the curvature signal to identify abrupt changes caused by defects. Wavelet transform excels at locating instantaneous singularities in a signal, which corresponds precisely to geometric defects on the contour. The local curvature sequence obtained in the previous step is decomposed into three levels. After decomposition, the high-frequency detail coefficients of the second level are focused on, as these coefficients effectively reflect sharp changes in curvature. Assume that most values ​​in the high-frequency detail coefficient sequence fluctuate between -0.2 and 0.2, but a coefficient value as high as 3.5 appears at a certain position, corresponding to a peak in the original curvature sequence. The median absolute deviation of the entire high-frequency detail coefficient sequence is calculated, and the value may be 0.15. A detection threshold is set to four times the median absolute deviation, i.e., 0.6. Then, the entire high-frequency detail coefficient sequence is traversed, and the absolute value of 3.5 is found to be much greater than 0.6, thus identifying it as an energy anomaly. Based on the position of this anomalous coefficient in the sequence, its index in the original contour coordinate point sequence can be mapped back, thereby accurately locating the defect on the contour.

[0056] An embodiment of the image processing-based real-time monitoring system for food production lines provided by this invention:

[0057] like Figure 2 As shown, the image processing-based real-time monitoring system for food production lines includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the aforementioned image processing-based real-time monitoring method for food production lines.

[0058] The image processing-based real-time monitoring system for food production lines also includes other components well-known to those skilled in the art, such as communication interfaces. Their setup and functions are known in the art and will not be described in detail here.

[0059] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device. Any application or module described in this invention can be implemented using computer-readable / executable instructions stored or otherwise maintained by such a computer-readable medium.

[0060] In addition, in the description of this specification, "multiple" means at least two, such as two, three or more, etc., unless otherwise expressly and specifically defined.

Claims

1. A method for real-time monitoring of a food production line based on image processing, characterized in that, Includes the following steps: S1. Obtain the original image of the food to be monitored, convert it to grayscale, and smooth it using an anisotropic diffusion model inversely proportional to the diffusion coefficient and gradient magnitude to obtain the preprocessed image. S2, calculate the gradient magnitude and gradient direction of each pixel in the preprocessed image; S3. For any pixel in the preprocessed image, calculate the fractal dimension and local phase consistency of the pixel's window region. Based on these two feature values, obtain an adjustment coefficient from a preset lookup table. Use this adjustment coefficient to adjust a preset baseline threshold to obtain a dynamic high threshold T. high Using a preset low threshold ratio coefficient to adjust the dynamic high threshold T high Adjustments are made to obtain a dynamic low threshold T low ; S4, the gradient magnitude is higher than its corresponding dynamic high threshold T high Pixels that are identified as strong edge points are set to have gradient magnitudes between their corresponding dynamic low thresholds T. low With dynamic high threshold T high Pixels between points are identified as candidate edge points; S5. For any candidate edge point p, traverse the strong edge points q in its eight neighborhoods, calculate the connection contribution C(p,q) between the candidate edge point p and the strong edge point q, and sum all C(p,q), where C(p,q) is calculated by the following formula: In the formula, θ p and θ q M represents the gradient directions of candidate edge point p and strong edge point q. q M represents the gradient magnitude of a strong edge point q. max The maximum gradient magnitude of the preprocessed image. Let be the angle between the tangent direction of the edge at candidate edge point p and the connection vector from candidate edge point p to strong edge point q. The tangent direction is orthogonal to the gradient direction of candidate edge point p. , , To satisfy the preset weights that sum to 1; When the cumulative connection contribution exceeds a preset threshold, the candidate edge point is determined as the final edge point. S6, connect all strong edge points with the final edge point to form the food edge contour, represent the food edge contour as an ordered coordinate point sequence and calculate its local curvature; perform multi-level discrete wavelet transform on the local curvature sequence to obtain a high-frequency detail coefficient sequence of a specified number of levels; calculate the median absolute deviation of the high-frequency detail coefficient sequence; identify coefficient points in the sequence whose absolute value exceeds a preset multiple of the median absolute deviation as outliers and map them back onto the contour to determine the defect location; wherein, for any point in the ordered coordinate point sequence P, the central difference method is used to calculate the approximate values ​​of its first and second derivatives to further obtain the curvature value.

2. The real-time monitoring method for food production lines based on image processing according to claim 1, characterized in that, The anisotropic diffusion model is the Perona-Malik diffusion model, and its diffusion coefficient c is calculated using the following formula: , where |▽I | for pixels ( The gradient magnitude after t iterations, where K is the gradient adjustment constant.

3. The real-time monitoring method for food production lines based on image processing according to claim 1, characterized in that, In S3, the differential box counting method is adopted. Within a window area of ​​a preset size centered on the target pixel, multi-size box coverage counting is performed on the three-dimensional surface composed of gray values ​​within the window area, and linear fitting is performed in a double logarithmic coordinate system. The slope of the fitted line is used as the fractal dimension of the window area.

4. The real-time monitoring method for food production lines based on image processing according to claim 3, characterized in that, Logarithmic Gabor wavelets are used to perform multi-scale, multi-directional filtering on a window region of a preset size. The local phase consistency is obtained by calculating the energy-weighted average of the filtering responses at each scale.

5. The real-time monitoring method for food production lines based on image processing according to claim 1, characterized in that, In S3, the baseline threshold T of the preprocessed image is calculated using the Otsu method. base For any pixel, the adjustment coefficient μ is indexed from a preset two-dimensional lookup table based on the fractal dimension and local phase consistency of its window region; the dynamic high threshold T of this pixel is... high =μ×T base Dynamic low threshold T low =λ×T high , where λ is a preset low threshold ratio coefficient, with a value ranging from 0.4 to 0.

6.

6. The real-time monitoring method for food production lines based on image processing according to claim 1, characterized in that, In S1, the original image is an RGB format image.

7. A real-time monitoring system for a food production line based on image processing, characterized in that, It includes a memory and a processor, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the image processing-based real-time monitoring method for food production lines as described in any one of claims 1-6 is implemented.

Citation Information

Patent Citations

  • X-ray-based intelligent food detection system

    CN116630425A

  • Seasoning packet packaging integrity detection method and system based on machine vision

    CN119068270A