An online detection method and system for food foreign matter

By constructing a two-dimensional pixel attenuation matrix and an edge expansion thickness distribution map, the gradient centripetal convergence degree and foreign object feature value are calculated, solving the problem of accuracy in foreign object detection in food inspection, and realizing the accurate detection of food overlap and foreign objects with high efficiency.

CN123175987APending Publication Date: 2026-11-27JIANGSU LULUTONG FOOD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611673367.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-28
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies cannot effectively distinguish between parallel slopes formed by overlapping normal food and isolated peaks caused by real internal foreign objects, resulting in poor anomaly detection.

Method used

By constructing a two-dimensional pixel attenuation matrix, the absolute physical channel number of the attenuation matrix of a single food item is obtained. Combined with the background attenuation data within the sliding pulse window, an edge expansion thickness distribution map is generated. The gradient centripetal convergence degree and foreign object feature value are calculated to confirm the foreign object region.

Benefits of technology

It improves the accuracy of foreign object detection, accurately distinguishes between parallel overlapping thickness interference and centripetal abrupt change in foreign object morphology, and reduces false alarms and missed detections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123175987A_ABST
    Figure CN123175987A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of X-ray foreign matter detection, in particular to an online detection method and system for food foreign matter. According to the X-ray attenuation data of different pixels in a two-dimensional pixel attenuation matrix, a single food attenuation matrix is constructed to obtain its absolute physical channel number; combined with the background attenuation data of each absolute physical channel number in each sliding pulse window, an edge outer expansion thickness distribution map is obtained; according to the local thickness gradient vector of each pixel in the edge outer expansion thickness distribution map and the position distribution of each pixel and other pixels in the neighborhood range, the gradient centripetal convergence degree of each pixel is obtained; combined with the element fluctuation characteristics of other pixels in the neighborhood range of each pixel in the edge outer expansion thickness distribution map, the foreign matter characteristic value of each pixel is obtained, and the foreign matter area is confirmed. By accurately distinguishing the parallel overlapping thickness interference and the centripetal sudden change form of foreign matter, the foreign matter characteristic value during food detection is obtained, and the accuracy of foreign matter detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of X-ray foreign object detection technology, specifically to an online detection method and system for food foreign objects. Background Technology

[0002] In food processing workshops, online detection equipment based on the principle of X-ray transparency attenuation is used to perform X-ray scanning on continuously operating bulk foods to intercept hard foreign objects. In real continuous production line scenarios, bulk foods are randomly scattered on conveyor belts, and frequent squeezing and overlapping between adjacent foods are inevitable. Traditional methods rely on preset absolute thickness thresholds for foreign object detection. If the threshold is too low, thin foreign objects will be missed, and if it is too high, normally overlapping foods will be falsely detected over a large area.

[0003] In existing technologies, conventional spot extraction operators such as edge detection, Laplacian operator, or second derivative high-pass filtering are typically introduced to extract isolated bright spots with abrupt changes. However, conventional operators only focus on the steepness of the magnitude of the numerical change. When two pieces of meat with steep edges overlap, their parallel overlapping edges will also generate extremely strong gradient magnitudes and second derivative responses. This makes it impossible to distinguish between the parallel slope formed by the overlap of normal food and the isolated peaks caused by real internal foreign objects, thus causing a large number of false alarms and poor anomaly detection. Summary of the Invention

[0004] To address the technical problem of poor anomaly detection in existing technologies, which cannot distinguish between parallel slopes formed by overlapping normal food particles and isolated spikes caused by actual internal foreign objects, the present invention aims to provide an online detection method and system for food foreign objects. The specific technical solution adopted is as follows: This invention proposes an online detection method for foreign objects in food, the method comprising: Continuous X-ray attenuation data of the food conveyor belt passing through each sensor channel and the cumulative pulse value of the corresponding photoelectric encoder are obtained, and a two-dimensional pixel attenuation matrix is ​​constructed with the sensor channel number as the horizontal axis and the cumulative pulse value as the vertical axis. Based on the X-ray attenuation data of different pixels in the two-dimensional pixel attenuation matrix, a single food attenuation matrix is ​​constructed to obtain its absolute physical channel number; a sliding pulse window is constructed based on the cumulative pulse value, and the background attenuation data of each absolute physical channel number in each sliding pulse window is obtained based on the X-ray attenuation data of each absolute physical channel number in each sliding pulse window. Based on the deviation of the X-ray attenuation data of each pixel in the single food attenuation matrix from the background attenuation data of the absolute physical channel number within the sliding pulse window where the pixel is located, the edge expansion thickness distribution map is obtained; for each pixel in the single food attenuation matrix, the gradient centripetal convergence degree of each pixel is obtained based on the local thickness gradient vector of each pixel in the edge expansion thickness distribution map and the position distribution of each pixel and other pixels in the neighborhood. Based on the element fluctuation characteristics of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel, as well as the gradient centripetal convergence degree, the foreign object feature value of each pixel is obtained, and the confirmed foreign object region is obtained.

[0005] Furthermore, the method for constructing the attenuation matrix of a single food item and obtaining its absolute physical channel number includes: In the two-dimensional pixel attenuation matrix, pixels whose X-ray attenuation data is greater than or equal to the preset unobstructed reference threshold are regarded as food pixels; the smallest outer rectangle of the connected region formed by all food pixels is used to form a single food attenuation matrix. The sensor channel number corresponding to each column in the attenuation matrix of a single food item is used as the absolute physical channel number.

[0006] Furthermore, the method for obtaining the background attenuation data includes: For the first sliding pulse window, the background attenuation data of the absolute physical channel number is set to the preset unobstructed reference threshold; Each subsequent sliding pulse window is analyzed sequentially. Pixels whose X-ray attenuation data under each absolute physical channel number is less than the preset unobstructed baseline threshold are taken as effective unobstructed pixels. The average X-ray attenuation data of all effective unobstructed pixels under each absolute physical channel number is obtained as the background attenuation data of each absolute physical channel number. If no valid unobstructed pixels exist, set the background attenuation data corresponding to the absolute physical channel number to the background attenuation data corresponding to the previous sliding pulse window.

[0007] Furthermore, the method for obtaining the edge outward thickness distribution map includes: The difference between the X-ray attenuation data of each pixel in the attenuation matrix of a single food block and the background attenuation data of the absolute physical channel number within the sliding pulse window of the pixel is obtained. The maximum value between the difference and the preset difference threshold is selected as its own attenuation data. Starting from the top and bottom edge pixels of the matrix composed of its own attenuation data, a preset number of pixels are continuously copied and expanded outward to generate an intermediate matrix; the left and right edge pixels of the intermediate matrix are continuously copied and expanded outward to generate a preset number of pixels to form an edge expansion thickness distribution map.

[0008] Furthermore, the method for obtaining the local thickness gradient vector includes: For each pixel in the attenuation matrix of a single food piece, obtain the first difference between the elements of each pixel and the adjacent pixels in the right column in the edge expansion thickness distribution map, obtain the second difference between the elements of each pixel and the adjacent pixels in the down column in the edge expansion thickness distribution map, and construct a local thickness gradient vector from the first difference and the second difference.

[0009] Furthermore, the method for obtaining the gradient centripetal convergence degree includes: Calculate the difference between the coordinates of other pixels in the neighborhood of each pixel relative to each pixel in the edge expansion thickness distribution map, and use it as the center pointing vector; The mean cosine of the angle between the center pointing vector and the local thickness gradient vector of all other pixels in the neighborhood is obtained as the gradient centripetal convergence degree of each pixel.

[0010] Furthermore, the method for obtaining the foreign object feature value includes: For the attenuation matrix of a single food piece, the standard deviation of the elements of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel is obtained as the local thickness fluctuation value. The maximum value between the gradient centripetal convergence of each pixel and the preset convergence lower limit is selected, and the product between the maximum value and the local thickness fluctuation value is calculated as the foreign object feature value of each pixel.

[0011] Furthermore, the method for obtaining the confirmed foreign object area includes: If the foreign object feature value of a pixel is greater than the preset foreign object threshold, the corresponding pixel is taken as a valid pixel; the connected region formed by all adjacent valid pixels is taken as a candidate foreign object region. If the number of valid pixels in a candidate foreign object region is greater than or equal to a preset threshold, the corresponding candidate foreign object region is selected as the confirmed foreign object region.

[0012] Furthermore, the method for obtaining the sliding pulse window includes: When the cumulative pulse value acquired in real time reaches an integer multiple of the preset fixed pulse increment constant, a segmentation node is generated; the cumulative pulse values ​​between adjacent segmentation nodes form a range, which is used as a sliding pulse window.

[0013] The present invention also proposes an online detection system for food foreign objects, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of any one of the online detection methods for food foreign objects.

[0014] The present invention has the following beneficial effects: This invention constructs a single-piece food attenuation matrix based on the X-ray attenuation data of different pixels in a two-dimensional pixel attenuation matrix, obtaining its absolute physical channel number to prevent the single-piece food attenuation matrix from confusing the physical position on the actual production line in subsequent calculations. A sliding pulse window is constructed based on the accumulated pulse value. According to the X-ray attenuation data of each absolute physical channel number within different sliding pulse windows, the background attenuation data of each absolute physical channel number within each sliding pulse window is obtained, reflecting the background attenuation level of the channel itself when there is no food target. The edge expansion thickness is obtained based on the deviation of the X-ray attenuation data of each pixel in the single-piece food attenuation matrix relative to the background attenuation data of the absolute physical channel number within the sliding pulse window where the pixel is located. The distribution map reflects the pure food thickness characteristics after eliminating dynamic environmental noise and ensuring safe buffering at the edges. For each pixel in the attenuation matrix of a single food piece, the gradient centripetal convergence degree of each pixel is obtained based on the local thickness gradient vector of each pixel in the edge expansion thickness distribution map and the positional distribution of each pixel and other pixels in its neighborhood, reflecting the degree to which the thickness tends towards the center from the surrounding area. Based on the element fluctuation characteristics of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel and the gradient centripetal convergence degree, the foreign object feature value of each pixel is obtained, reflecting the probability of the presence of real hard foreign objects with high confidence after removing overlapping slope interference and underlying electrical noise, thus confirming the foreign object area. This invention improves the accuracy of foreign object detection by accurately distinguishing between parallel overlapping thickness interference and the centripetal abrupt change morphology of foreign objects and obtaining foreign object feature values ​​during food detection. Attached Figure Description

[0015] Figure 1 This is a flowchart of an online detection method for foreign objects in food provided in one embodiment of the present invention. Detailed Implementation

[0016] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0017] The following description, in conjunction with the accompanying drawings, details the specific scheme of the online detection method and system for foreign objects in food provided by this invention.

[0018] Please see Figure 1 The diagram illustrates a flowchart of an online detection method for foreign objects in food according to an embodiment of the present invention, specifically including: Step S1: Obtain the X-ray attenuation data of the food conveyor belt as it passes through each sensor channel, and the cumulative pulse value of the corresponding photoelectric encoder, and construct a two-dimensional pixel attenuation matrix with the sensor channel number as the horizontal axis and the cumulative pulse value as the vertical axis.

[0019] In an embodiment of the present invention, due to the continuous accumulation of dirt on the conveyor belt and the heating of the sensor X-ray tube, the attenuation value of the bottom environment exhibits a unidirectional upward drift. Therefore, the dynamically changing bottom environment values ​​are analyzed, and continuous data streams from the external X-ray sensor array and the conveyor belt photoelectric encoder are received.

[0020] It should be noted that X-rays vertically penetrate the bulk food on the conveyor belt. Different components have different physical densities and thicknesses, causing the X-rays to attenuate to varying degrees after penetration. Based on the exponential absorption and attenuation physical characteristics of X-rays, the received X-ray projection intensity is logarithmically transformed, converting the exponential attenuation curve into a linear numerical distribution. Every time the conveyor belt advances a certain distance, the photoelectric encoder outputs a new cumulative pulse, driving the X-ray sensor array to acquire data. Therefore, the cumulative pulse corresponds to the attenuation data output by all sensor channels. A two-dimensional pixel attenuation matrix is ​​constructed with the sensor channel number as the horizontal axis and the cumulative pulse value as the vertical axis.

[0021] Step S2: Based on the X-ray attenuation data of different pixels in the two-dimensional pixel attenuation matrix, construct a single food attenuation matrix to obtain its absolute physical channel number; construct a sliding pulse window based on the cumulative pulse value, and obtain the background attenuation data of each absolute physical channel number in each sliding pulse window based on the X-ray attenuation data of each absolute physical channel number in different sliding pulse windows.

[0022] When bulk food passes by on the conveyor belt, the thicker and denser the food, the greater the attenuation data compared to empty transport; therefore, an attenuation matrix for a single piece of food is constructed based on the X-ray attenuation data of different pixels in the two-dimensional pixel attenuation matrix.

[0023] Preferably, in one embodiment of the present invention, the method for constructing a single food attenuation matrix, obtaining its absolute physical channel number, and extracting the initial pulse value includes: In the two-dimensional pixel attenuation matrix, pixels whose X-ray attenuation data is greater than or equal to the preset unobstructed reference threshold are regarded as food pixels; the smallest outer rectangle of the connected region formed by all food pixels is used to form a single food attenuation matrix. The sensor channel number corresponding to each column in the attenuation matrix of a single food item is used as the absolute physical channel number.

[0024] It should be noted that, in the embodiments of the present invention, the preset unobstructed reference threshold represents the highest normal attenuation value generated by X-rays penetrating the clean conveyor belt and air during the no-load operation phase of the equipment; the minimum outer rectangle algorithm is used to obtain the minimum outer rectangle of the connected region formed by all food pixels; the specific means are well known to those skilled in the art and will not be described in detail here.

[0025] It should be noted that, in order to prevent the attenuation matrix of a single food item from confusing the physical location on the actual production line in subsequent calculations, the sensor channel number corresponding to each column is obtained as the absolute physical channel number.

[0026] The cumulative pulse value of the photoelectric encoder is equivalent to the conveyor belt running distance, and the dirt on the conveyor belt surface is proportional to the conveyor belt running distance. Based on the cumulative pulse value, a sliding pulse window is constructed to specifically analyze the dirt accumulated on the local conveyor belt and the sensor heating noise.

[0027] Preferably, in one embodiment of the present invention, the method for obtaining the sliding pulse window includes: When the cumulative pulse value acquired in real time reaches an integer multiple of the preset fixed pulse increment constant, a segmentation node is generated; the cumulative pulse values ​​between adjacent segmentation nodes form a range, which is used as a sliding pulse window.

[0028] It should be noted that, in the embodiments of the present invention, the preset fixed pulse increment constant is determined based on the extreme blockage condition of the production line and the noise floor drift tolerance; in actual engineering implementation, the preset fixed pulse increment constant is usually set to the total number of pulses corresponding to one full rotation of the conveyor belt under no-load conditions.

[0029] Due to the adhesion of dirt on the conveyor belt surface and the heat generated by the X-ray emission tube, the attenuation data in the unobstructed background area will slowly increase. Therefore, the attenuation data of each X-ray sensor channel within the sliding pulse window is analyzed to independently update the background attenuation baseline of the corresponding channel. Based on the X-ray attenuation data of each absolute physical channel number within different sliding pulse windows, the background attenuation data of each absolute physical channel number within each sliding pulse window is obtained.

[0030] Preferably, in one embodiment of the present invention, the method for obtaining background attenuation data includes: For the first sliding pulse window, the background attenuation data of the absolute physical channel number is set to the preset unobstructed reference threshold; Each subsequent sliding pulse window is analyzed sequentially. Pixels whose X-ray attenuation data under each absolute physical channel number is less than the preset unobstructed baseline threshold are taken as effective unobstructed pixels. The average X-ray attenuation data of all effective unobstructed pixels under each absolute physical channel number is obtained as the background attenuation data of each absolute physical channel number. If no valid unobstructed pixels exist, set the background attenuation data corresponding to the absolute physical channel number to the background attenuation data corresponding to the previous sliding pulse window.

[0031] Based on this, if there are no valid unobstructed pixels, it means that the conveyor belt above the corresponding absolute physical channel number is always completely obscured by dense food. In this case, in order to avoid forcibly mixing the extremely high attenuation data of the food area into the background noise statistics, which would cause the background baseline to rise abnormally or even swallow up the normal food features, the background attenuation data of the corresponding absolute physical channel number is set to the background attenuation data of the previous sliding pulse window. The background attenuation data reflects the background attenuation level of the channel itself when there is no food target. The larger the background attenuation data, the thicker the dirt on the conveyor belt of the absolute physical channel number or the more serious the sensor light emission attenuation.

[0032] Step S3: Based on the deviation of the X-ray attenuation data of each pixel in the single food attenuation matrix from the background attenuation data of the absolute physical channel number within the sliding pulse window where the pixel is located, obtain the edge expansion thickness distribution map; for each pixel in the single food attenuation matrix, based on the local thickness gradient vector of each pixel in the edge expansion thickness distribution map, and the position distribution of each pixel and other pixels in the neighborhood, obtain the gradient centripetal convergence degree of each pixel.

[0033] Background attenuation data reflects the background attenuation level of the channel itself when there is no food target. By analyzing the deviation of the X-ray attenuation data of each pixel in the attenuation matrix of a single food block relative to the background attenuation data of the absolute physical channel number within the sliding pulse window of the pixel, it is helpful to quantify and retain the relative attenuation data that characterizes the material of the food itself. Furthermore, in order to prevent step artifacts and array out-of-bounds collapse during subsequent processing, the food edge is extended. Based on the deviation of the X-ray attenuation data of each pixel in the attenuation matrix of a single food block relative to the background attenuation data of the absolute physical channel number within the sliding pulse window of the pixel, the edge extension thickness distribution map is obtained.

[0034] Preferably, in one embodiment of the present invention, the method for obtaining the edge outward thickness distribution map includes: The first step is to obtain the difference between the X-ray attenuation data of each pixel in the attenuation matrix of a single food block and the background attenuation data of the absolute physical channel number within the sliding pulse window of the pixel. The maximum value between the difference and the preset difference threshold is selected as its own attenuation data. It should be noted that, in the embodiments of the present invention, since the background attenuation data reflects the background attenuation level of the channel itself when there is no food target, the actual measurement value will only be superimposed on this additional attenuation caused by the food. Therefore, if the difference is negative, it is a pseudo-value caused by background estimation error or noise and does not have the ability to characterize the food material. Therefore, the preset difference threshold is set to 0. The self-attenuation data reflects the relative attenuation value that has been removed from the dynamically changing underlying environment values ​​and retains the relative attenuation value that characterizes the material of the food itself. Due to the physical absorption law of X-rays, the degree of attenuation of X-rays after penetrating an object is proportional to the density and thickness of the object. Therefore, physically, the relative attenuation value after removing the background attenuation characterizes the relative thickness characteristics of the food.

[0035] The second step involves taking the top and bottom edge pixels of the matrix composed of its own attenuation data as the starting point, continuously copying and expanding outwards by a preset number of pixels to generate an intermediate matrix; then, using the left and right edge pixels of the intermediate matrix as the starting point, continuously copying and expanding outwards by a preset number of pixels to form an edge expansion thickness distribution map.

[0036] It should be noted that if food is subsequently inspected and the image is moved to the actual physical edge of the food, half of it may fall outside the edge. If zeros are directly added, it will artificially create a huge step cliff, causing extremely strong false edge gradient false alarms. If the image is directly truncated, it will cause array addressing out-of-bounds crashes when searching for neighboring pixels. Therefore, image edge filling is performed, that is, the edge pixels are copied and expanded. In the embodiments of the present invention, the minimum physical radius of the foreign object target to be intercepted set at the production site is obtained in advance, divided by the actual side length parameter of a single sensor, and rounded up as the preset number of expanded pixels.

[0037] As an example, assume that the matrix formed by the self-attenuation data is... With a preset quantity of 1, the resulting intermediate matrix is: Extending the edge matrix outwards from the left and right edges yields the edge thickness distribution map. ; where, for any pixel in the attenuation matrix of a single food item, the row and column order constitutes the coordinates as The corresponding coordinates in the edge expansion thickness distribution map are: .

[0038] Based on this, the outer edge of the food is replicated with the same gentle values ​​as the boundary, which essentially acts as a safety buffer and helps to eliminate the risk of computational crashes caused by addressing out of bounds.

[0039] The edge-expanded thickness distribution map reflects the pure food thickness characteristics after eliminating dynamic environmental noise and ensuring a safe buffer at the edges. Since the parallel slope gradients generated by food overlap have the same direction, the centripetal convergence is smaller. On the other hand, the isolated peak gradients generated by foreign objects point to the center, resulting in a higher centripetal convergence. Therefore, the local thickness gradient vector and pixel position distribution are analyzed to eliminate the thickness interference from parallel overlaps and quantify the gradient centripetal convergence. For each pixel in the attenuation matrix of a single food block, the gradient centripetal convergence of each pixel is obtained based on the local thickness gradient vector of each pixel in the edge-expanded thickness distribution map and the position distribution of each pixel with other pixels in the neighborhood.

[0040] Preferably, in one embodiment of the present invention, the method for obtaining the local thickness gradient vector includes: For each pixel in the attenuation matrix of a single food piece, obtain the first difference between the elements of each pixel and the adjacent pixels in the right column in the edge expansion thickness distribution map, obtain the second difference between the elements of each pixel and the adjacent pixels in the down column in the edge expansion thickness distribution map, and construct a local thickness gradient vector from the first difference and the second difference.

[0041] It should be noted that the element of a pixel in the edge expansion thickness distribution map refers to the element value of the pixel at the corresponding row and column position in the edge expansion thickness distribution map; the thickness difference vector is constructed by forward difference in the right neighbor and lower neighbor directions, which is equivalent to calculating the discrete gradient of the thickness distribution map. The direction of the local thickness gradient vector reflects the objective direction of the fastest increase in thickness value.

[0042] Preferably, in one embodiment of the present invention, the method for obtaining the gradient centripetal convergence degree includes: Calculate the difference between the coordinates of other pixels in the neighborhood of each pixel relative to each pixel in the edge expansion thickness distribution map, and use it as the center pointing vector; It should be noted that the coordinates of a pixel in the edge thickness distribution map are determined by the row and column order of the pixel's corresponding position in the edge thickness distribution map. For example, if the pixel is in row 1 and column 3, the coordinates would be... In one embodiment of the present invention, a circular region with a radius of a preset number of pixels is constructed as the neighborhood range of each pixel, with each pixel as the center. The neighborhood range does not include the center pixel. The preset number is the preset number of extended pixels obtained above. In other embodiments of the present invention, the size of the neighborhood range can be set according to specific circumstances, and is not limited or described here.

[0043] The mean cosine of the angle between the center pointing vector and the local thickness gradient vector of all other pixels in the neighborhood is obtained as the gradient centripetal convergence degree of each pixel.

[0044] It should be noted that the cosine of the angle between vectors reflects the consistency of their tendencies. That is, the ratio of the dot product of the vectors to the product of their corresponding magnitudes is used as the cosine of the angle. The larger the cosine of the angle, the closer it is to 1, the more consistent the local thickness gradient vector is with the center pointing vector, and the greater the possibility of the existence of isolated hard clumps in the local area. When the neighborhood range is a parallel slope caused by normal food overlap, since the local thickness gradient vectors of the pixels in the neighborhood range are parallel and consistent, rather than pointing to the center together, their mean values ​​will cancel each other out and approach 0.

[0045] Step S4: Based on the element fluctuation characteristics of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel, as well as the gradient centripetal convergence degree, obtain the foreign object feature value of each pixel and obtain the confirmed foreign object region.

[0046] Weak electrical shot noise in purely flat areas can occasionally exhibit false centripetal direction. By analyzing the element fluctuation characteristics of pixels in the edge-expanding thickness distribution map within the neighborhood, the fluctuation amplitude of the absolute thickness of the local area can be reflected, which helps to eliminate orientation disorder artifacts caused by electrical noise from the underlying sensor in extremely thin or airy areas. Based on the element fluctuation characteristics of other pixels in the edge-expanding thickness distribution map within the neighborhood of each pixel, as well as the gradient centripetal convergence, the foreign object feature value of each pixel can be obtained.

[0047] Preferably, in one embodiment of the present invention, the method for obtaining foreign object feature values ​​includes: For the attenuation matrix of a single food piece, the standard deviation of the elements of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel is obtained as the local thickness fluctuation value. The maximum value between the gradient centripetal convergence of each pixel and the preset convergence lower limit is selected, and the product between the maximum value and the local thickness fluctuation value is calculated as the foreign object feature value of each pixel.

[0048] It should be noted that the elements of a pixel in the edge thickness distribution map refer to the element values ​​at the corresponding row and column positions in the edge thickness distribution map. The larger the standard deviation of the element, the larger the local thickness fluctuation value in the neighborhood range, the less likely it is to be a flat air background area, and the more likely there is a sharp absolute thickness difference. On the other hand, the gradient centripetal convergence reflects the possibility of the existence of isolated hard clumps in the local area. Therefore, the larger the local thickness fluctuation value, the larger the gradient centripetal convergence, the more likely there is a strong step difference in material thickness, and the larger the foreign object feature value.

[0049] Considering that a gradient centripetal convergence degree less than 0 indicates that the local area does not thicken towards the center, and the direction of thickness increase at the periphery is away from the center, presenting a pit shape with the thinnest center and thicker periphery, that is, in a physical scenario, it corresponds to a physical defect on the surface of normal food, not a high-density hard foreign object; in one embodiment of the present invention, in order to avoid causing data type underflow or meaningless negative feature residue, the preset convergence lower limit is set to 0, and the gradient centripetal convergence degree with a value greater than or equal to 0 is analyzed.

[0050] The foreign object characteristic value indicates that the interference from the overlapping slope and the electrical noise of the underlying layer have been removed, reflecting the probability of the existence of real hard foreign objects with high confidence; therefore, the foreign object area is confirmed.

[0051] Preferably, in one embodiment of the present invention, the method for identifying the foreign object region includes: The first step is to identify the pixel as a valid pixel if the foreign object feature value is greater than the preset foreign object threshold; and to identify the connected region formed by all adjacent valid pixels as a candidate foreign object region. It should be noted that the larger the foreign object characteristic value, the greater the probability of the presence of a real hard foreign object with high confidence. In one embodiment of the present invention, several batches of pure bulk food samples without any foreign objects are scanned in advance to obtain the foreign object characteristic value after sample processing, and the maximum value of the foreign object characteristic value among all pure bulk food samples is extracted. In industrial sites, the voltage microwave of the X-ray tube, the mechanical vibration of the conveyor belt, and the random changes in the surface humidity of the bulk food can cause the false centripetal characteristic value generated by the pure sample to fluctuate randomly within a small range. Therefore, in order to provide fault tolerance margin, absorb the random extreme values ​​of X-ray voltage fluctuation and environmental noise, and prevent false alarms from normal food, the maximum value of the preset proportion is increased, that is, the sum of the maximum value and the maximum value of the preset proportion is calculated as the preset foreign object threshold.

[0052] The electrical ripple and photon shot noise of the X-ray high-voltage generator can cause inherent random extreme value fluctuations in the background signal. In order to cover the underlying physical noise of the hardware and retain the characteristic distinguishability of low-density foreign objects to avoid missed detection, the preset ratio is set to 10% based on relevant historical experience. In other embodiments of the present invention, the size of the preset ratio can be set according to the specific situation, which is not limited or described here.

[0053] The second step is to select candidate foreign object regions where the number of effective pixels is greater than or equal to a preset threshold, and then use the corresponding candidate foreign object regions as confirmed foreign object regions.

[0054] It should be noted that, in one embodiment of the present invention, the connected region area threshold used to filter out single-pixel electrical shot noise is used as a preset quantity threshold. Since real physical foreign objects have a certain spatial volume, they will cover multiple adjacent pixels under X-ray fluoroscopy, while the shot noise of the underlying sensor usually manifests as isolated single-pixel noise points. Based on relevant historical experience, the value range is set to 2-3. If the number of effective pixels in the candidate foreign object area is less than the preset quantity threshold, it reflects that the physical size of the candidate foreign object area is too small, which is usually the electrical single-pixel noise of the underlying layer and not a real foreign object area. If the number of effective pixels in the candidate foreign object area is greater than or equal to the preset quantity threshold, it indicates that the foreign object area has been confirmed.

[0055] Based on this, in another embodiment of the present invention, after the confirmed foreign object area is obtained, the foreign object is removed, including: calculating the average of the coordinates formed by the absolute physical channel number and the cumulative pulse value of all valid pixels, as the local geometric center coordinates of the confirmed foreign object area; since the width of a single sensor of the X-ray sensor array and the span of a single nozzle of the pneumatic valve rack are mechanically equivalent to 1:1, the horizontal physical number in the local geometric center coordinates of the confirmed foreign object area is the target nozzle number corresponding to the location of the foreign object center.

[0056] To eliminate the risk of instruction lag failure caused by system computation time, the system deployment must ensure that the time length represented by the spatial delay pulse constant is always greater than the maximum computation time from receiving data to extracting and calculating the feature matrix. This ensures that when the system issues an execution command, the real-time cumulative pulse count of the external conveyor belt has not yet reached the target execution pulse, thus allowing for lead time for the nozzle action. The spatial delay pulse constant is obtained by measuring the fixed physical distance from the X-ray scanning light strip position to the end pneumatic valve bracket position, dividing the fixed physical distance by the conveyor belt travel distance represented by a single pulse from the photoelectric encoder, and obtaining the spatial delay pulse constant. The sum of the longitudinal pulse value in the local geometric center coordinates of the confirmed foreign object area and the spatial delay pulse constant is used as the target pulse value for elimination, reflecting the absolute cumulative pulse value that the photoelectric encoder should output when the center of the foreign object moves directly below the corresponding nozzle.

[0057] Based on this, the system outputs an execution command containing the target nozzle number and the rejection execution target pulse value to the main control programmable logic controller (PLC) in the form of an electrical signal. The controller monitors the total number of pulses transmitted back by the photoelectric encoder in real time. When the total number of pulses in real time is equal to the rejection execution target pulse value, it triggers the pneumatic valve numbered with the target nozzle number to spray high-pressure gas, blowing the scattered food containing the confirmed foreign object area away from the conveyor belt, thus realizing the closed-loop processing of the entire food foreign object online detection and rejection pipeline.

[0058] In summary, this invention constructs a single-block food attenuation matrix based on the X-ray attenuation data of different pixels in a two-dimensional pixel attenuation matrix, obtaining its absolute physical channel number; combined with the background attenuation data of each absolute physical channel number within each sliding pulse window, it obtains an edge-expanding thickness distribution map; based on the local thickness gradient vector of each pixel in the edge-expanding thickness distribution map, and the positional distribution of each pixel and other pixels within its neighborhood, it obtains the gradient centripetal convergence degree of each pixel; combined with the element fluctuation characteristics of other pixels within the neighborhood of each pixel in the edge-expanding thickness distribution map, it obtains the foreign object feature value of each pixel, thus identifying the confirmed foreign object region. This invention improves the accuracy of foreign object detection by accurately distinguishing between parallel overlapping thickness interference and the centripetal abrupt change morphology of foreign objects, thereby obtaining foreign object feature values ​​during food detection.

[0059] The present invention also proposes an online detection system for foreign objects in food, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of an online detection method for foreign objects in food.

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

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

Claims

1. An online detection method for foreign objects in food, characterized in that, The method includes: Continuous X-ray attenuation data of the food conveyor belt passing through each sensor channel and the cumulative pulse value of the corresponding photoelectric encoder are obtained, and a two-dimensional pixel attenuation matrix is ​​constructed with the sensor channel number as the horizontal axis and the cumulative pulse value as the vertical axis. Based on the X-ray attenuation data of different pixels in the two-dimensional pixel attenuation matrix, a single food attenuation matrix is ​​constructed to obtain its absolute physical channel number; a sliding pulse window is constructed based on the cumulative pulse value, and the background attenuation data of each absolute physical channel number in each sliding pulse window is obtained based on the X-ray attenuation data of each absolute physical channel number in each sliding pulse window. Based on the deviation of the X-ray attenuation data of each pixel in the single food attenuation matrix from the background attenuation data of the absolute physical channel number within the sliding pulse window where the pixel is located, the edge expansion thickness distribution map is obtained; for each pixel in the single food attenuation matrix, the gradient centripetal convergence degree of each pixel is obtained based on the local thickness gradient vector of each pixel in the edge expansion thickness distribution map and the position distribution of each pixel and other pixels in the neighborhood. Based on the element fluctuation characteristics of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel, as well as the gradient centripetal convergence degree, the foreign object feature value of each pixel is obtained, and the confirmed foreign object region is obtained.

2. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for constructing the attenuation matrix of a single food item and obtaining its absolute physical channel number includes: In the two-dimensional pixel attenuation matrix, pixels whose X-ray attenuation data is greater than or equal to the preset unobstructed reference threshold are regarded as food pixels; the smallest outer rectangle of the connected region formed by all food pixels is used to form a single food attenuation matrix. The sensor channel number corresponding to each column in the attenuation matrix of a single food item is used as the absolute physical channel number.

3. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the background attenuation data includes: For the first sliding pulse window, the background attenuation data of the absolute physical channel number is set to the preset unobstructed reference threshold; Each subsequent sliding pulse window is analyzed sequentially. Pixels whose X-ray attenuation data under each absolute physical channel number is less than the preset unobstructed baseline threshold are taken as effective unobstructed pixels. The average X-ray attenuation data of all effective unobstructed pixels under each absolute physical channel number is obtained as the background attenuation data of each absolute physical channel number. If no valid unobstructed pixels exist, set the background attenuation data corresponding to the absolute physical channel number to the background attenuation data corresponding to the previous sliding pulse window.

4. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the edge outward thickness distribution map includes: The difference between the X-ray attenuation data of each pixel in the attenuation matrix of a single food block and the background attenuation data of the absolute physical channel number within the sliding pulse window of the pixel is obtained. The maximum value between the difference and the preset difference threshold is selected as its own attenuation data. Starting from the top and bottom edge pixels of the matrix composed of its own attenuation data, a preset number of pixels are continuously copied and expanded outward to generate an intermediate matrix; the left and right edge pixels of the intermediate matrix are continuously copied and expanded outward to generate a preset number of pixels to form an edge expansion thickness distribution map.

5. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the local thickness gradient vector includes: For each pixel in the attenuation matrix of a single food piece, obtain the first difference between the elements of each pixel and the adjacent pixels in the right column in the edge expansion thickness distribution map, obtain the second difference between the elements of each pixel and the adjacent pixels in the down column in the edge expansion thickness distribution map, and construct a local thickness gradient vector from the first difference and the second difference.

6. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the gradient centripetal convergence degree includes: Calculate the difference between the coordinates of other pixels in the neighborhood of each pixel relative to each pixel in the edge expansion thickness distribution map, and use it as the center pointing vector; The mean cosine of the angle between the center pointing vector and the local thickness gradient vector of all other pixels in the neighborhood is obtained as the gradient centripetal convergence degree of each pixel.

7. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the foreign object feature value includes: For the attenuation matrix of a single food piece, the standard deviation of the elements of other pixels in the edge expansion thickness distribution map within the neighborhood of each pixel is obtained as the local thickness fluctuation value. The maximum value between the gradient centripetal convergence of each pixel and the preset convergence lower limit is selected, and the product between the maximum value and the local thickness fluctuation value is calculated as the foreign object feature value of each pixel.

8. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the confirmed foreign object region includes: If the foreign object feature value of a pixel is greater than the preset foreign object threshold, the corresponding pixel is taken as a valid pixel; the connected region formed by all adjacent valid pixels is taken as a candidate foreign object region. If the number of valid pixels in a candidate foreign object region is greater than or equal to a preset threshold, the corresponding candidate foreign object region is selected as the confirmed foreign object region.

9. The online detection method for foreign objects in food according to claim 1, characterized in that, The method for obtaining the sliding pulse window includes: When the cumulative pulse value acquired in real time reaches an integer multiple of the preset fixed pulse increment constant, a segmentation node is generated; the cumulative pulse values ​​between adjacent segmentation nodes form a range, which is used as a sliding pulse window.

10. An online detection system for foreign objects in food, the system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the online detection method for foreign objects in food as described in any one of claims 1 to 9.