Food spoilage detection method and system based on artificial intelligence image recognition
Through a food spoilage detection method based on artificial intelligence image recognition, using depth cameras and high-frequency component analysis, the problems of long detection cycle, low efficiency and inaccurate positioning in existing technologies are solved, and real-time and accurate detection and management of food spoilage are achieved.
Patent Information
- Application Number
- CN202510259883.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-03-06
AI Technical Summary
Existing food spoilage detection methods have long detection cycles, low efficiency, and their accuracy is greatly affected by subjective factors. They are difficult to accurately locate the spoiled area and cannot provide detailed information on the degree and scope of spoilage.
A method based on artificial intelligence image recognition is used to obtain grayscale images of food through a depth camera, and sliding window segmentation and high-frequency component extraction are performed. Combined with Gaussian smoothing and binarization technology, the probability of spoilage is calculated using difference analysis of high-frequency components and neighborhood pixels. Circular processing and iterative optimization are used to determine the spoiled area, and the degree of spoilage and treatment measures are established.
It realizes the real-time and precise positioning and degree assessment of food spoilage detection, improves the detection sensitivity and accuracy, reduces the interference of environmental factors, and provides full-process management and refined processing suggestions.
Smart Images

Figure CN120198377B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of food safety detection, and in particular to a food spoilage detection method and system based on artificial intelligence image recognition. Background Art
[0002] Food spoilage is a significant issue in food safety management. Traditional methods for detecting food spoilage rely primarily on sensory evaluation, such as observing food color, odor, and texture, or chemical testing methods, such as pH measurement and microbial culture. These methods often suffer from long detection cycles, low efficiency, and significant subjective influences on accuracy.
[0003] With the development of computer vision and artificial intelligence technologies, it has become possible to detect food spoilage using image recognition. Existing image recognition-based food spoilage detection methods mostly rely on simple color and texture feature analysis, such as detecting color changes or the appearance of specific mold spots on the food surface to determine whether the food has spoiled. While these methods offer improvements over traditional methods, they still have significant shortcomings in detection accuracy and positioning precision. Existing methods are particularly ineffective in detecting localized or early-stage spoilage, making it difficult to accurately locate the spoiled area and susceptible to interference from factors such as ambient lighting and differences in food appearance.
[0004] Furthermore, existing methods typically only provide a binary judgment (spoiled or not spoiled), failing to provide more detailed information such as the degree and scope of spoilage, hindering subsequent refined processing and management. Therefore, an intelligent method that can accurately detect and locate food spoilage areas is urgently needed to improve food safety management. Summary of the Invention
[0005] The proposed food spoilage detection method and system based on artificial intelligence image recognition aims to address the existing technology's inability to effectively handle missing and delayed dynamic data. By adaptively weighting and calculating a progressive driving safety index, the method and system achieve real-time, accurate safety warnings. The purpose of this invention is to provide a food spoilage detection method and system based on artificial intelligence image recognition, aiming to address technical issues such as low detection accuracy and difficulty in accurately locating spoiled areas in existing food spoilage detection technologies.
[0006] The present invention provides a food spoilage detection method based on artificial intelligence image recognition, comprising:
[0007] The image acquisition step includes: receiving a grayscale image of the food to be inspected, and establishing a sliding window of the grayscale image to divide the grayscale image into a plurality of image blocks;
[0008] The feature extraction step includes: extracting high-frequency components of the image block, and determining the deterioration probability of the image block based on the high-frequency components;
[0009] The region identification step includes: determining a suspected metamorphic region according to the metamorphic probability, detecting a metamorphic region in the suspected metamorphic region, and determining a position of the metamorphic region.
[0010] Preferably, the image acquisition step specifically includes:
[0011] Acquire the grayscale image through a depth camera;
[0012] Install the depth camera directly above the grayscale image and facing the grayscale image, so that the captured grayscale image is parallel to the capture plane;
[0013] Binarizing the grayscale image on the acquisition plane;
[0014] Perform Gaussian smoothing on the binarized image.
[0015] Preferably, the feature extraction step specifically includes:
[0016] Obtaining a high-frequency component of the image block through filtering and derivation operations;
[0017] Determine the neighborhood pixel points of the central pixel point of the image block according to the high-frequency component;
[0018] The difference between the pixel value of the neighborhood pixel point and the pixel value of the central pixel point is calculated, and the deterioration probability is obtained according to the difference in the pixel values.
[0019] Preferably, the step of obtaining the high-frequency component of the image block by filtering and derivation operations is specifically as follows:
[0020] Performing a convolution operation on the image block using a Gaussian kernel to obtain a convolution result;
[0021] Calculating a pixel mean of the image block;
[0022] The difference between the image block and the convolution result is used as the high-frequency component of the image block.
[0023] Preferably, determining the neighborhood pixel points of the central pixel point of the image block according to the high-frequency component specifically includes:
[0024] Determine the sum of high-frequency components of all pixels in the image block according to the high-frequency components;
[0025] The pixel point corresponding to the maximum value of the sum of the high-frequency components is used as the central pixel point;
[0026] Neighborhood pixels of the central pixel are selected according to the size of the image block and the size of the grayscale image.
[0027] Preferably, the calculating the difference between the pixel value of the neighborhood pixel point and the pixel value of the central pixel point, and obtaining the deterioration probability according to the pixel value difference is specifically as follows:
[0028] Calculating the absolute value of the difference between the pixel value of the neighborhood pixel point and the pixel value of the central pixel point;
[0029] Dividing the absolute value by a preset threshold;
[0030] The division result is used as the exponent of an exponential function, and the exponential function value is calculated as the deterioration probability corresponding to the neighborhood pixel position.
[0031] Preferably, the region identification step specifically includes:
[0032] determining a deteriorated region of the central pixel, and determining a suspected deteriorated region from the deteriorated region;
[0033] The distance between the edge of the image block and the center point of the suspected deteriorated area is used as the central angle of the circle, and the pixels of the suspected deteriorated area are used as the radius to form a circle to obtain a new suspected deteriorated area;
[0034] New metamorphic areas are identified through iteration.
[0035] Preferably, the step of taking the distance between the edge of the image block and the center point of the suspected deteriorated area as the central angle and the pixel points of the suspected deteriorated area as the radius to form a circle specifically includes:
[0036] Determining a central angle formed by an edge of the image block and a center point of the suspected deteriorated region;
[0037] Draw a circular area with the center point of the suspected deteriorated area as the center and the distance from the pixel point of the suspected deteriorated area to the center as the radius;
[0038] The circular area is regarded as a new suspected metamorphic area.
[0039] Preferably, the method further comprises:
[0040] determining a degree of deterioration of the food based on the deterioration area, wherein the degree of deterioration includes deterioration, slight deterioration, possible deterioration, and non-deterioration;
[0041] The treatment measures for the food are determined according to the degree of deterioration of the food, and the treatment measures include harmless treatment, harmless treatment, suspended treatment, and destruction.
[0042] A food spoilage detection system based on artificial intelligence image recognition for executing the method comprises:
[0043] An image acquisition module is used to receive a grayscale image of the food to be inspected and establish a sliding window of the grayscale image to divide the grayscale image into a plurality of image blocks;
[0044] a feature extraction module, configured to extract high-frequency components of the image block and determine a deterioration probability of the image block based on the high-frequency components;
[0045] a region identification module, configured to determine a suspected deteriorated region based on the deterioration probability, detect a deteriorated region in the suspected deteriorated region, and determine a position of the deteriorated region;
[0046] The feature extraction module includes: a high-frequency component extraction unit, configured to obtain the high-frequency component of the image block through filtering and derivative operations; a central pixel determination unit, configured to determine the neighborhood pixels of the central pixel of the image block based on the high-frequency component; and a deterioration probability calculation unit, configured to calculate the difference between the pixel value of the neighborhood pixels and the pixel value of the central pixel, and to obtain the deterioration probability based on the difference in the pixel values.
[0047] The present invention has the following beneficial effects:
[0048] 1. By using a sliding window to segment image blocks and extract high-frequency components, this method can accurately detect subtle changes on the food surface, improving the sensitivity and accuracy of spoilage detection, making it particularly suitable for early spoilage detection.
[0049] 2. Based on the difference analysis of pixel values between the central pixel and the neighboring pixels, combined with the exponential function model to calculate the probability of deterioration, the system can quantify the degree of deterioration, no longer limited to simple binary judgment.
[0050] 3. The_Adoption uses circular processing and iterative optimization methods to determine suspected metamorphic areas, which can accurately locate the position and scope of the metamorphic areas and provide an accurate basis for subsequent targeted treatment.
[0051] 4. Through the depth camera and specific installation arrangement, combined with binarization and Gaussian smoothing preprocessing, the image quality is significantly improved and the interference of environmental factors on the detection results is reduced.
[0052] 5. A mechanism for grading the degree of deterioration and recommending treatment measures has been established, realizing full-process management from detection to treatment, and improving the intelligence and refinement of food safety management. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 This is a flow chart of the food spoilage detection method based on artificial intelligence image recognition of the present invention;
[0054] Figure 2 Schematic diagram of extracting high-frequency components of image blocks in the present invention;
[0055] Figure 3 Schematic diagram of the relationship between the central pixel and the neighboring pixel points in the present invention;
[0056] Figure 4 This is a schematic diagram of the optimization of suspected deteriorated areas based on circular processing in the present invention;
[0057] Figure 5 The figure is a structural block diagram of the food spoilage detection system based on artificial intelligence image recognition of the present invention. DETAILED DESCRIPTION
[0058] To further illustrate the technical means and effects employed by the present invention to achieve its intended objectives, the following detailed description, along with the accompanying drawings and preferred embodiments, includes a detailed description of the specific implementations, structures, features, and effects thereof. In the following description, references to "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
[0059] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0060] like Figure 1 As shown, the present invention provides a food spoilage detection method based on artificial intelligence image recognition, which includes an image acquisition step, a feature extraction step and a region recognition step.
[0061] During the image acquisition step, a grayscale image of the food to be inspected is received and a sliding window is created to segment the grayscale image into several image blocks. Preferably, the present invention uses a sliding window size of 32×32 pixels with a step size of 16 pixels to ensure a balance between image segmentation precision and computational efficiency. This allows even very localized areas of deterioration on the food surface to be captured and subsequently analyzed.
[0062] In the feature extraction step, the high-frequency components of the image block are extracted, and the probability of spoilage of the image block is determined based on these high-frequency components. High-frequency components can effectively reflect image details such as edges and textures, which are often important visual features of food spoilage. By analyzing high-frequency components, the present invention can capture subtle changes that are imperceptible to the naked eye, thereby detecting signs of spoilage early.
[0063] In the region identification step, suspected spoiled areas are determined based on the spoilage probability, spoiled areas are detected within the suspected spoiled areas, and the locations of the spoiled areas are determined. This method not only determines whether food is spoiled but also accurately identifies the location and extent of the spoiled areas, providing precise guidance for subsequent processing.
[0064] Furthermore, if Figure 2 As shown, the image acquisition step specifically includes: acquiring the grayscale image through a depth camera; installing the depth camera directly above the grayscale image and facing the grayscale image so that the acquired grayscale image is parallel to the acquisition plane; binarizing the grayscale image on the acquisition plane; and performing Gaussian smoothing on the binarized image.
[0065] The present invention uses a depth camera rather than a standard camera because it can simultaneously capture depth information in an image, which is significantly advantageous for detecting unevenness on food surfaces (often an early sign of spoilage). The depth camera is preferably a high-definition camera with a resolution of at least 1920×1080 pixels to ensure sufficient detail is captured.
[0066] The depth camera's mounting position and angle significantly impact image quality. This method uses a camera mounted directly above the food, parallel to the surface, and preferably at a distance of 30-50 cm. This configuration minimizes image distortion and shadow interference, providing high-quality original images.
[0067] The image is binarized using the OTSU adaptive thresholding method, which automatically determines the optimal threshold based on the image's grayscale histogram to adapt to the color characteristics of different foods. The binarized image better highlights structural changes on the food surface, facilitating subsequent analysis.
[0068] Gaussian smoothing uses a Gaussian kernel with a standard deviation of σ = 1.5. This parameter has been verified through extensive experiments to effectively remove image noise while preserving deterioration-related details. The smoothed image is smoother and more coherent, reducing false positives in subsequent analysis.
[0069] Furthermore, the feature extraction step specifically includes: obtaining a high-frequency component of the image block through filtering and derivation operations; determining the neighborhood pixels of the central pixel of the image block based on the high-frequency component; calculating the difference between the pixel value of the neighborhood pixels and the pixel value of the central pixel, and obtaining the deterioration probability based on the difference in the pixel values.
[0070] This paper proposes a unique high-frequency component extraction method that effectively captures texture anomalies on food surfaces through a combination of Gaussian filtering and image derivation. Specifically, obtaining the high-frequency component of an image block through filtering and derivation involves convolving the image block with a Gaussian kernel to obtain a convolution result; calculating the pixel mean of the image block; and using the difference between the image block and the convolution result as the high-frequency component of the image block.
[0071] The extraction of high-frequency components can be expressed by the following mathematical formula:
[0072] HF=I-(I*G),
[0073] Where HF represents the high-frequency component, I represents the original image block, G represents the Gaussian convolution kernel, and * represents the convolution operation. The Gaussian convolution kernel G is defined as:
[0074]
[0075] Wherein, (i, j) represents the pixel position, and σ represents the Gaussian kernel radius, which is preferably between 1.5 and 2.0 in the present invention. σ values in this range can effectively filter out high-frequency noise while retaining characteristic information of food spoilage. Furthermore, the method of determining the neighborhood pixel points of the central pixel point of the image block based on the high-frequency components specifically includes: determining the sum of the high-frequency components of all pixels in the image block based on the high-frequency components; taking the pixel point corresponding to the maximum value of the sum of the high-frequency components as the central pixel point; and selecting the neighborhood pixel points of the central pixel point based on the size of the image block and the size of the grayscale image.
[0076] The calculation of the sum of high-frequency components can be expressed as:
[0077] S(i,j)=∑ (m,n)∈N(i,j) HF(m,n),
[0078] Where S(i,j) represents the sum of high-frequency components in the area centered at (i,j), N(i,j) represents the neighborhood of (i,j), and HF(m,n) represents the high-frequency component at position (m,n). The center pixel is selected using the maximum value rule:
[0079]
[0080] That is, the location with the largest sum of high-frequency components is selected as the central pixel. This method can automatically locate the point with the highest probability of deterioration, improving the system's sensitivity to small deteriorated areas.
[0081] The present invention dynamically selects the neighborhood range based on the image block size. For a 32×32 image block, a 3×3 or 5×5 neighborhood is typically selected. Neighborhood selection takes into account image boundary conditions. When the center pixel is close to the edge of the image, the neighborhood is adjusted accordingly.
[0082] Furthermore, the calculating of the difference between the pixel value of the neighborhood pixel point and the pixel value of the center pixel point and obtaining the deterioration probability based on the pixel value difference is specifically as follows: calculating the absolute value of the difference between the pixel value of the neighborhood pixel point and the pixel value of the center pixel point; dividing the absolute value by a preset threshold; using the division result as the exponent of an exponential function, and calculating the exponential function value as the deterioration probability corresponding to the neighborhood pixel point position.
[0083] The calculation of the deterioration probability adopts the exponential function model:
[0084]
[0085] Where P(i,j) represents the probability of deterioration at position (i,j), I(i,j) represents the pixel value at position (i,j), I(c) represents the pixel value of the central image point, T represents the threshold parameter, and |x| represents the absolute value of x.
[0086] The threshold parameter T is a key parameter that affects the sensitivity of the system. After a large number of experiments, the present invention determined that the optimal threshold range is between 15 and 25. When the T value is too small (such as less than 10), the system is too sensitive and may mistakenly judge normal texture changes as deterioration; when the T value is too large (such as greater than 30), the system sensitivity is insufficient and may miss certain deteriorated areas. In practical applications, this parameter can be appropriately adjusted according to the characteristics of different types of food. For example, for foods with complex surface textures (such as bread, cheese, etc.), a larger T value (20-25) should be selected; for foods with smooth surfaces (such as apples, bananas, etc.), a smaller T value (15-20) should be selected.
[0087] The advantage of the exponential function model over the linear model is that it can amplify tiny pixel differences and give a higher spoilage probability weight to differences exceeding the threshold, which is more in line with the characteristics of actual food spoilage.
[0088] Furthermore, the region identification step specifically includes: determining the deteriorated region of the central pixel point, and determining a suspected deteriorated region from the deteriorated region; using the distance between the edge of the image block and the center point of the suspected deteriorated region as the central angle of the circle, and using the pixel point of the suspected deteriorated region as the radius to perform circle processing to obtain a new suspected deteriorated region; and determining the new deteriorated region through iteration.
[0089] The present invention first determines the initial metamorphic area with a central pixel point with a high probability of metamorphism as the starting point. In order to make the boundary of the metamorphic area smoother and more realistic, a circular processing method is used to optimize the suspected metamorphic area. Specifically, the distance between the edge of the image block and the center point of the suspected metamorphic area is used as the center angle of the circle, and the pixel point of the suspected metamorphic area is used as the radius for the circular processing. Specifically, it includes: determining the center angle formed by the edge of the image block and the center point of the suspected metamorphic area; drawing a circular area with the center point of the suspected metamorphic area as the center of the circle and the distance from the pixel point of the suspected metamorphic area to the center of the circle as the radius; and using the circular area as a new suspected metamorphic area.
[0090] The mathematical model of circle processing is as follows:
[0091] First calculate the distance from point (i, j) to the center of the circle (c x ,c y ) distance:
[0092]
[0093] Calculate the central angle of a circle:
[0094] θ(i,j)=arctan2(jc y ,ic x ),
[0095] Determine whether a point is inside the circle:
[0096] IsInCircle(i,j)=(d(i,j)≤r),
[0097] Among them, (c x ,c y ) represents the coordinates of the center of the circle, r represents the radius, θ(i,j) represents the center angle of the circle, and IsInCircle(i,j) represents the judgment result.
[0098] The advantage of this method is that it eliminates jagged edges, smoothes region boundaries, and accounts for the radial diffusion characteristics typically exhibited by metamorphic regions. The iterative optimization mechanism allows the system to dynamically adjust the boundaries of metamorphic regions, adapting to irregularly shaped metamorphic regions and improving the accuracy of region positioning.
[0099] In practice, the number of iterations is usually set to 3 to 5 to ensure the accuracy of the region boundaries while avoiding over-computation. Each iteration is terminated when the area change rate of the metamorphic region is less than 5% or the maximum number of iterations is reached.
[0100] Furthermore, the method of the present invention also includes: determining the degree of deterioration of the food based on the deteriorated area, wherein the degree of deterioration includes deterioration, slight deterioration, possible deterioration and non-deterioration; determining the treatment measures for the food according to the degree of deterioration of the food, wherein the treatment measures include harmless treatment, harmless treatment, suspended treatment and destruction.
[0101] The degree of deterioration is determined based on the following factors: the area percentage of the deteriorated area, the average deterioration probability of the deteriorated area, and the maximum deterioration probability of the deteriorated area. The specific criteria are as follows:
[0102] Deterioration: The deteriorated area accounts for more than 10% of the total area, or the maximum deterioration probability exceeds 0.9;
[0103] Slightly deteriorated: The deteriorated area accounts for 5%-10%, and the maximum deterioration probability is between 0.7-0.9;
[0104] Possible deterioration: The deteriorated area accounts for 1%-5% of the total area, and the maximum deterioration probability is between 0.5-0.7;
[0105] Undeteriorated: The deteriorated area accounts for less than 1%, and the maximum deterioration probability is less than 0.5.
[0106] According to different degrees of deterioration, the present invention recommends corresponding treatment measures:
[0107] Spoiled food should be destroyed immediately to prevent health risks caused by accidental ingestion;
[0108] Slightly spoiled food should be treated to be harmless, such as removing the spoiled parts before reuse;
[0109] Food that may be spoiled should be temporarily handled, monitored more closely, and subsequent measures should be determined based on evolving circumstances;
[0110] Unspoiled food can be used normally without special handling.
[0111] like Figure 5 As shown, the present invention also provides a food spoilage detection system based on artificial intelligence image recognition, which includes an image acquisition module, a feature extraction module and a region recognition module.
[0112] The image acquisition module receives a grayscale image of the food to be inspected and creates a sliding window around it to divide it into several image blocks. The image acquisition module includes a depth camera, an image preprocessing unit, and a sliding window segmentation unit. The depth camera captures the original image, the image preprocessing unit performs binarization and Gaussian smoothing, and the sliding window segmentation unit segments the preprocessed image into several image blocks.
[0113] The feature extraction module is used to extract the high-frequency components of the image block and determine the deterioration probability of the image block based on the high-frequency components. The feature extraction module includes: a high-frequency component extraction unit, which is used to obtain the high-frequency components of the image block through filtering and derivative operations; a center pixel determination unit, which is used to determine the neighborhood pixels of the center pixel of the image block based on the high-frequency components; and a deterioration probability calculation unit, which is used to calculate the difference between the pixel values of the neighborhood pixels and the pixel value of the center pixel, and to obtain the deterioration probability based on the difference in pixel values.
[0114] The region identification module is used to determine suspected metamorphic regions based on the metamorphic probability, detect metamorphic regions within the suspected metamorphic regions, and determine the locations of the metamorphic regions. The region identification module includes an initial region determination unit, a circular processing unit, and an iterative optimization unit. The initial region determination unit determines initial suspected metamorphic regions based on the metamorphic probability. The circular processing unit performs circular optimization on the suspected metamorphic regions. The iterative optimization unit determines the final metamorphic regions through multiple iterations.
[0115] In addition, the system can also be equipped with a spoilage degree judgment module and a treatment measure recommendation module. The spoilage degree judgment module determines the degree of spoilage of food based on the characteristics of the spoiled area, and the treatment measure recommendation module recommends corresponding treatment measures based on the degree of spoilage.
[0116] The system adopts a modular design with clear interfaces between functional modules, facilitating system maintenance and upgrades. The system can be flexibly deployed in a variety of scenarios, including food production lines, storage facilities, retail terminals, and smart homes, to meet diverse application needs.
[0117] Through multi-level innovation, the present invention has achieved a technological leap from macroscopic judgment to microscopic positioning, from single features to high-frequency component analysis, from binary judgment to probabilistic model, and from static detection to dynamic iterative optimization, forming a complete, efficient and accurate food spoilage detection technology system, which has important application value and broad development prospects in the field of food safety.
[0118] Further embodiments of the food spoilage detection method and system based on artificial intelligence image recognition of the present invention include:
[0119] Example 1: Cheese spoilage detection
[0120] In this embodiment, the system and method of the present invention are applied to the detection of cheese product spoilage. Cheese spoilage is usually manifested by surface mold, color change, or structural abnormalities, which are very suitable for accurate identification using the high-frequency component analysis method of the present invention.
[0121] During implementation, the cheese to be inspected is placed on a testing platform, with the depth camera positioned 35 centimeters above the cheese. Ambient lighting is controlled between 200 and 300 lux to ensure image quality. The system first acquires a grayscale image of the cheese surface with a resolution of 1920 × 1080 pixels. The image is segmented using a 32 × 32 sliding window with a step size of 16 pixels.
[0122] For foods with relatively complex surface structures, such as cheese, in this example, the standard deviation parameter σ for Gaussian smoothing was adjusted to 2.0, and the threshold parameter T for calculating spoilage probability was set to 22. These parameters were selected based on the test results of a large number of cheese samples and effectively balance detection sensitivity and false positive rate.
[0123] Experimental results demonstrate that the method presented in this paper can accurately detect early-stage mold spots on cheese surfaces as small as 2 mm in diameter, significantly exceeding the 3-5 mm detection limit of traditional methods. In particular, when the cheese surface shows slight depressions but has not yet exhibited significant color change, traditional color analysis methods often struggle to identify early-stage spoilage. However, the method presented in this paper effectively captures these subtle texture changes through high-frequency component analysis, enabling early detection of spoilage signs 24-48 hours in advance.
[0124] In actual application at a food processing company, this system tested 1,000 blocks of cheddar cheese. Compared with traditional manual inspection and simple image analysis methods, it improved detection accuracy by 23.5%, reduced missed detection rates by 18.7%, and lowered false positive rates by 15.3%. Crucially, this method accurately identified the boundaries of spoiled areas, enabling the company to more effectively remove spoiled portions, reducing product waste by approximately 20%.
[0125] Compared with existing technologies, the originality of this invention in cheese spoilage detection lies in: (1) it overcomes the limitations of traditional color analysis by extracting high-frequency components; (2) it replaces simple binary judgment with a quantitative assessment based on spoilage probability; and (3) it achieves precise localization of irregular spoiled areas through circular processing and iterative optimization. These innovations enable this method to cope with the complex characteristics of cheese spoilage and significantly improve detection performance.
[0126] Example 2: Bread mold detection
[0127] Bread is one of the foods most prone to mold. This example applies the present invention to the early detection of bread mold. Early signs of bread mold often manifest as subtle, localized changes in color and texture that are difficult to detect with the naked eye. However, these changes are often accompanied by slight abnormalities in the surface structure, making them well-suited for the present invention's detection method.
[0128] In this example, the detection system's depth camera is mounted 40 centimeters above the bread. The depth camera has a resolution of 2048 × 1536 pixels to capture more detail. To account for the uneven surface of the bread, the sliding window size is adjusted to 24 × 24 pixels with a step size of 12 pixels to better adapt to the undulations of the bread surface.
[0129] Because bread's surface texture is inherently complex, to prevent normal texture from being misidentified as spoiled, in this example, the standard deviation parameter σ for Gaussian smoothing was set to 1.8, and the threshold parameter T for calculating the spoilage probability was adjusted to 25. These parameters ensure that the system can distinguish between normal bread holes and abnormal, moldy textures.
[0130] Experiments have shown that for white bread, the system can detect mold spots as small as 1.5 mm in diameter, detecting signs of mold approximately 36 hours earlier than traditional methods. For whole-wheat bread, despite its more complex surface texture, the system can still detect early mold spots as small as 2.5 mm, providing an early warning approximately 24 hours in advance.
[0131] This system was tested against a traditional UV inspection system on a bakery's production line. The results showed that for 1,500 bread samples, the system achieved a 95.3% detection accuracy, significantly exceeding the 82.1% achieved by the traditional method. In particular, for mold located in the sunken areas of the bread, the traditional method had a 30% miss detection rate, while the system's miss rate was only 5.7%.
[0132] The synergistic mechanism of this system in bread mold detection is mainly reflected in the following aspects: the depth camera can obtain three-dimensional information of the bread surface, overcoming the limitations of traditional two-dimensional images in detecting mold in depressions; high-frequency component analysis can effectively capture texture anomalies caused by mold; the spoilage probability model can adapt to the texture differences in different parts of the bread surface; and circular processing and iterative optimization can accurately depict the boundaries of irregular moldy areas.
[0133] Compared with existing technologies, the originality of this method in bread mold detection lies in: (1) considering the impact of bread surface fluctuations on detection, using a depth camera to obtain three-dimensional information; (2) using adaptive sliding window parameters to balance detection accuracy and computational efficiency; and (3) achieving effective detection of mold in hidden locations. These innovations give this method a significant advantage in the field of bread mold detection.
[0134] Example 3: Meat spoilage detection
[0135] Meat spoilage is a significant issue in food safety. This example explores the application of the present invention in detecting beef spoilage. Meat spoilage is typically manifested by the production of mucus on the surface, darkening or greening of the color, and an abnormal odor. Changes in surface texture are a key indicator of early spoilage.
[0136] In this example, the detection system is equipped with a spectrally enhanced depth camera capable of simultaneously capturing image information in the visible and near-infrared bands. The camera is mounted 30 cm above the meat sample, and the ambient temperature is maintained at 4-6°C to simulate refrigerated storage conditions. Based on the surface characteristics of the meat, the sliding window size is set to 40×40 pixels, with a step size of 20 pixels.
[0137] Considering the high glossiness of meat surfaces, this embodiment optimizes image preprocessing: reflection suppression is performed before binarization, and a polarizing filter is used to reduce surface reflections. The standard deviation parameter σ of the Gaussian smoothing process is set to 1.6. The threshold parameter T for calculating the spoilage probability is adjusted to 18 to increase sensitivity to subtle signs of meat spoilage.
[0138] In the experiment, 50 fresh beef samples were placed in a 20°C environment and tested every two hours using the system. The results showed that the system could issue an alert at the first signs of spoilage (bacterial counts of approximately 10^4 CFU / g) that are invisible to the naked eye on the meat surface, detecting signs of spoilage approximately four to six hours earlier than traditional sensory evaluation.
[0139] Compared to microbial culture methods (which require 24-48 hours) and ATP fluorescence detection methods (which require complex sample processing and reagents), this system enables contactless, real-time, and automated meat spoilage detection. Compared to chemical sensor methods, this system offers significant advantages in detecting early spoilage while avoiding the sensor's susceptibility to environmental interference and the need for regular calibration.
[0140] The synergistic mechanism of this system in meat spoilage detection is mainly reflected in: combining depth information and near-infrared information for multimodal analysis; capturing subtle changes in meat surface texture through high-frequency component extraction; quantifying the spoilage risk of different surface areas using a spoilage probability model; and accurately depicting spoilage boundaries through circular processing and iterative optimization to avoid misjudging normal meat texture.
[0141] Compared with the existing technology, the originality of the present invention in meat spoilage detection lies in: (1) introducing spectral enhancement and reflection suppression technology to overcome the interference of surface reflection of meat on detection; (2) establishing a parameter optimization strategy adapted to the characteristics of meat; and (3) achieving earlier and more accurate spoilage detection than traditional methods without contacting the sample or using chemical reagents.
[0142] Example 4: Fruit and vegetable rot detection
[0143] This example explores the application of the present invention in detecting apple rot. Fruit rot typically begins internally, with surface changes lagging behind, making early detection challenging. Traditional methods rely primarily on color changes and hardness testing, making non-contact early detection difficult.
[0144] In this embodiment, the depth camera utilizes hyperspectral enhancement to capture near-infrared spectral information in the 800-1000nm band, which helps detect tissue changes beneath the fruit's surface. The camera is positioned 25cm from the apple surface, with ambient lighting controlled at 350-450 lux. To account for the curvature of the apple surface, the system employs adaptive sliding window technology. The window size is initially 28×28 pixels, but it dynamically adjusts based on depth information to accommodate the curved surface.
[0145] In this example, the standard deviation parameter σ for Gaussian smoothing is set to 1.2, and the threshold parameter T for calculating the spoilage probability is set to 16, given the smooth surface of the apple. These parameters make the system highly sensitive to subtle color and texture changes on the apple surface, while also accounting for the difference between natural spots and rot.
[0146] In the experiment, 100 apples were stored at room temperature, some of which were artificially inoculated with common rot pathogens. The system scanned and tested these apples daily. The results showed that for brown rot, the system could detect anomalies approximately 24-36 hours before visible symptoms appeared; for soft rot, the advance detection time was approximately 18-24 hours.
[0147] In a test at a fruit wholesale market, the system inspected 5,000 apples and achieved a 28.3% improvement in accuracy compared to traditional manual inspection and simple machine vision systems. In particular, the detection rate for early-stage rot increased by 41.5%. By accurately identifying rotten areas, the market was able to more efficiently grade and market apples, redirecting slightly rotten apples for processing, reducing losses by approximately 25%.
[0148] The synergistic mechanism of this system in fruit and vegetable rot detection is mainly reflected in the following: the combination of depth camera and hyperspectral technology can simultaneously obtain surface morphology and internal tissue information; adaptive sliding window technology overcomes the difficulty of surface detection; high-frequency component analysis can capture subtle texture changes caused by early rot; the spoilage probability model can distinguish between natural spots and disease symptoms; and circular processing and iterative optimization can accurately depict the boundaries of irregular rot areas.
[0149] Compared with the existing technology, the originality of the present invention in the detection of fruit and vegetable decay lies in: (1) the introduction of fusion analysis of hyperspectral and depth information realizes indirect detection of subsurface tissue changes; (2) the adaptive sliding window technology solves the problem of surface detection; (3) an accurate model is established to distinguish between natural spots and early decay; (4) non-contact and non-destructive early decay detection is realized.
[0150] Example 5: Grain mold detection
[0151] This example explores the application of the present invention in rice mold detection. Grain mold is often accompanied by the production of harmful substances such as aflatoxins, posing a serious threat to food safety. Traditional detection methods include chemical reagents and fluorescence detection, but these methods typically require sample preparation and specialized procedures, making them difficult to implement in batches and in real time.
[0152] In this example, the inspection system uses a macro-enhanced depth camera equipped with a 2x macro lens, capable of capturing minute details on the grain surface. The camera is positioned 20 cm above the grain sample, which is evenly spread on a black background, with a layer thickness of approximately 1-2 grains. The sliding window size is set to 20 × 20 pixels with a step size of 10 pixels to accommodate the small size of grain particles.
[0153] In this example, the standard deviation parameter σ for Gaussian smoothing was optimized to 1.3, and the threshold parameter T for calculating spoilage probability was set to 17, given the numerous grains and complex boundaries on the grain surface. Furthermore, the system introduced a boundary enhancement preprocessing step to highlight changes in grain boundaries, which is particularly important for detecting edge erosion in the early stages of mold.
[0154] In the experiment, 500g of rice samples were stored at 28°C and 85% relative humidity and tested every 12 hours using the system. The results showed that the system was able to detect abnormalities at the early stages of mold growth (when mold spores are just beginning to germinate), which is difficult to detect with the naked eye. This allowed the system to detect signs of mold approximately 36-48 hours earlier than traditional methods.
[0155] During a trial at a grain storage facility, the system regularly scanned and tested stored rice. Compared to traditional sampling and testing methods, the system achieved 100% batch coverage, increasing the early detection rate of mold from 60% to 93.5%, significantly reducing the loss of entire batches of grain due to localized mold.
[0156] The synergistic mechanism of this system in grain mold detection is mainly reflected in the following: the macro-enhanced depth camera can obtain high-resolution details of the grain surface; the boundary enhancement preprocessing highlights the changes in grain edges; the high-frequency component analysis can capture subtle texture anomalies caused by mold; the spoilage probability model can distinguish between normal and abnormal grains; and the circular processing and iterative optimization can accurately locate the moldy areas in the grain pile.
[0157] Compared with the existing technology, the originality of the present invention in grain mold detection lies in: (1) through macro imaging and boundary enhancement technology, it can accurately capture the tiny changes in grain particles; (2) it establishes a parameter optimization strategy that adapts to the characteristics of grains; (3) it realizes large-area, non-contact, and early mold detection of grain batches; (4) compared with traditional chemical detection methods, it significantly improves detection efficiency and coverage.
[0158] Example 6: Liquid Food Deterioration Detection
[0159] This example explores the application of the present invention in detecting milk spoilage. Detecting liquid food spoilage presents unique challenges because traditional image analysis primarily targets solid surfaces, while changes in liquids often manifest as turbidity, stratification, or the formation of surface films.
[0160] In this example, the detection system underwent special modifications: the depth camera was equipped with a polarizing filter to reduce reflections from the liquid surface; a side light source was added to highlight suspended particles and surface films in the liquid; and the camera was positioned 15 cm above the liquid surface, maintaining a vertical angle. Taking into account the characteristics of the liquid surface, the sliding window size was set to 36 × 36 pixels, with a step size of 18 pixels.
[0161] Because the liquid surface is relatively uniform, the standard deviation parameter σ of the Gaussian smoothing process in this example is set to 1.0 to preserve more detail. The threshold parameter T for the deterioration probability calculation is adjusted to 14 to increase sensitivity to subtle changes. Furthermore, the system incorporates a time series analysis function that detects slowly evolving patterns of change by comparing images of the same area at different time points.
[0162] In the experiment, fresh milk was packaged in transparent containers, left at room temperature, and tested every hour. The results showed that the system can detect subtle changes in surface texture at the early stages of rancidity (pH around 6.4, before obvious clots appear), identifying signs of spoilage approximately 3-4 hours earlier than traditional sensory evaluation.
[0163] In the quality inspection process of a dairy company, this system was compared with conventional pH testing and microbial count methods. In testing 300 milk samples, the system achieved a 90.2% sensitivity for detecting early spoilage, with 88.7% agreement with professional laboratory testing. However, the detection time was reduced from several hours using traditional methods to just a few minutes.
[0164] The synergistic mechanism of this system in liquid food spoilage detection is mainly reflected in the following: the design of polarization filter and side light source highlights the subtle changes on the liquid surface; high-frequency component analysis can capture texture changes caused by thin films or suspended particles formed on the surface; time series comparison can detect slowly developing spoilage processes; the spoilage probability model optimizes the unique change patterns of liquids; and circular processing and iterative optimization can accurately delineate the boundaries of irregular spoilage areas.
[0165] Compared with the existing technology, the originality of the present invention in liquid food spoilage detection lies in: (1) solving the problem of liquid surface reflection and uniformity through optical design; (2) introducing time series analysis to improve the detection ability of slow changes; (3) realizing non-contact, real-time, and automated spoilage detection of liquid food; (4) greatly improving detection efficiency and practicality compared with traditional chemical and microbiological detection methods.
[0166] Example 7: Detection of Deterioration of Frozen Food After Thawing
[0167] This example explores the application of the present invention in detecting the deterioration of frozen meat after thawing. Frozen food deteriorates faster after thawing and may deteriorate during the freeze-thaw process, which places higher demands on the detection system.
[0168] In this embodiment, the detection system has been enhanced with a temperature monitoring module to simultaneously record the food surface temperature. The depth camera incorporates thermal enhancement to capture even subtle temperature gradients. The camera is positioned 25 cm above the food surface, with the ambient temperature controlled at 10-15°C. Taking into account the moisture characteristics of the thawed food surface, the sliding window size is set to 32×32 pixels with a step size of 16 pixels.
[0169] Given the moist and glossy surface characteristics of thawed food, in this embodiment, the standard deviation parameter σ for Gaussian smoothing is set to 1.7, and the threshold parameter T for calculating spoilage probability is set to 20. Furthermore, the system incorporates a moisture distribution analysis function, which assists in identifying spoiled areas by detecting uneven surface moisture distribution.
[0170] In the experiment, 30 portions of frozen chicken were thawed at 4°C and then placed in a 20°C environment. The chickens were tested every hour. The results showed that the system could detect abnormalities as soon as microbial activity caused a slight change in surface gloss, revealing signs of spoilage approximately 2-3 hours earlier than traditional sensory evaluation.
[0171] In the semi-finished product testing phase at a food processing company, this system tested thawed meat raw materials. In a sample of 200 thawed samples, 92% of the samples identified by the system as showing early signs of spoilage were confirmed to have quality issues in subsequent microbiological testing, while 68% of these samples had no issues detected through conventional sensory testing.
[0172] The synergistic mechanism of this system in detecting spoilage of frozen food after thawing is mainly reflected in: the combination of temperature monitoring and image analysis can simultaneously consider thermal distribution anomalies and surface texture changes; the thermal sensitivity enhancement function can detect small temperature differences in spoiled areas; high-frequency component analysis can capture texture anomalies caused by uneven moisture distribution; the spoilage probability model takes into account the unique change characteristics of thawed food; and circular processing and iterative optimization can accurately locate spoiled areas on wet surfaces.
[0173] Compared with the existing technology, the originality of the present invention in detecting the deterioration of frozen food after thawing lies in: (1) combining temperature and image information for multi-parameter analysis; (2) considering the impact of the freeze-thaw process on the surface characteristics of food; (3) optimizing the detection parameters specifically for the deterioration characteristics of thawed food; (4) realizing rapid and accurate deterioration risk assessment of thawed food, providing a powerful tool for cold chain food quality control.
[0174] Through the aforementioned examples across seven different food categories, the present invention's food spoilage detection method and system based on AI image recognition demonstrates strong adaptability and superior performance. Each food type presents unique spoilage characteristics and detection challenges. Through parameter optimization and functional expansion, the present invention successfully addresses these diverse detection requirements.
[0175] The core value of this invention lies in:
[0176] Early Detection Capabilities: In all embodiments, the system can detect signs of food spoilage hours to days earlier than traditional methods, providing ample time for preventive measures.
[0177] Precise positioning function: Compared with traditional methods that only provide "deteriorated / non-deteriorated" judgments, this system can accurately identify the location and scope of the deteriorated area, making it possible to carry out targeted processing.
[0178] Diversified adaptability: Through parameter adjustment and functional module expansion, this system can adapt to various food testing needs, from solid to liquid, from flat to curved, and from single to complex.
[0179] Non-contact real-time detection: Compared with traditional methods that require sampling, reagents or professional operations, this system realizes non-contact, non-destructive and real-time detection, greatly improving the convenience of application.
[0180] Systematic risk management: Through deterioration degree classification and treatment recommendations, this system extends from detection to decision support, realizing systematic management of food safety.
[0181] The essential difference between the present invention and the existing technology is that it no longer focuses solely on macro features such as color changes, but deeply detects micro texture changes through high-frequency component analysis; it is no longer limited to simple binary judgment, but establishes a quantitative assessment based on a probability model; it no longer passively waits for obvious deterioration, but actively predicts the risk of deterioration; it no longer analyzes a single feature in isolation, but realizes multi-parameter collaborative judgment.
[0182] In summary, this invention provides an innovative solution for food spoilage detection that has both a solid theoretical foundation and broad practical value. It can play a significant role in all aspects of food production, distribution, retail, and household storage, improving food safety, reducing food waste, and creating significant economic and social benefits.
[0183] It should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A food spoilage detection method based on artificial intelligence image recognition, characterized in that: include: The image acquisition step includes: receiving a grayscale image of the food to be inspected, and establishing a sliding window of the grayscale image to divide the grayscale image into a plurality of image blocks; the feature extraction step includes: extracting high-frequency components of the image blocks, and determining the probability of deterioration of the image blocks based on the high-frequency components; the region identification step includes: determining suspected deterioration regions based on the deterioration probability, detecting deteriorated regions in the suspected deterioration regions, and determining the locations of the deteriorated regions; The feature extraction step specifically includes: obtaining a high-frequency component of the image block through filtering and derivative operations; determining neighboring pixels of a central pixel of the image block based on the high-frequency component; calculating a difference between a pixel value of the neighboring pixels and a pixel value of the central pixel, and obtaining the deterioration probability based on the difference in pixel values; The step of obtaining the high-frequency component of the image block by filtering and derivation operations specifically comprises: performing a convolution operation on the image block using a Gaussian kernel to obtain a convolution result; calculating a pixel mean of the image block; and taking a difference between the image block and the convolution result as the high-frequency component of the image block; Calculating the difference between the pixel value of the neighborhood pixel point and the pixel value of the center pixel point and obtaining the deterioration probability based on the pixel value difference specifically includes: calculating the absolute value of the difference between the pixel value of the neighborhood pixel point and the pixel value of the center pixel point; dividing the absolute value by a preset threshold; using the division result as the exponent of an exponential function, and calculating the exponential function value as the deterioration probability corresponding to the neighborhood pixel point position.
2. The method for detecting food spoilage based on artificial intelligence image recognition according to claim 1, characterized in that: The image acquisition step specifically includes: acquiring the grayscale image through a depth camera; installing the depth camera directly above the grayscale image and facing the grayscale image so that the acquired grayscale image is parallel to the acquisition plane; binarizing the grayscale image on the acquisition plane; and performing Gaussian smoothing on the binarized image.
3. The method for detecting food spoilage based on artificial intelligence image recognition according to claim 1, characterized in that: Determining the neighborhood pixel points of the central pixel point of the image block based on the high-frequency components specifically includes: determining the sum of the high-frequency components of all pixels in the image block based on the high-frequency components; taking the pixel point corresponding to the maximum value of the sum of the high-frequency components as the central pixel point; and selecting the neighborhood pixel points of the central pixel point based on the size of the image block and the size of the grayscale image.
4. The method for detecting food spoilage based on artificial intelligence image recognition according to claim 1, characterized in that: The region identification step specifically includes: determining the deteriorated region of the central pixel point, and determining a suspected deteriorated region from the deteriorated region; using the distance between the edge of the image block and the center point of the suspected deteriorated region as the central angle of the circle, and using the pixel point of the suspected deteriorated region as the radius to form a circle to obtain a new suspected deteriorated region; and determining the new deteriorated region through iteration.
5. The method for detecting food spoilage based on artificial intelligence image recognition according to claim 4, characterized in that: The method of using the distance between the edge of the image block and the center point of the suspected deteriorated area as the center angle of the circle and the pixel points of the suspected deteriorated area as the radius to draw a circle specifically includes: determining the center angle formed by the edge of the image block and the center point of the suspected deteriorated area; drawing a circular area with the center point of the suspected deteriorated area as the center of the circle and the distance from the pixel points of the suspected deteriorated area to the center of the circle as the radius; and using the circular area as a new suspected deteriorated area.
6. The method for detecting food spoilage based on artificial intelligence image recognition according to any one of claims 1 to 5, characterized in that: The method further includes: determining the degree of deterioration of the food based on the deteriorated area, wherein the degree of deterioration includes deteriorated, slightly deteriorated, possibly deteriorated, and not deteriorated; and determining treatment measures for the food according to the degree of deterioration of the food, wherein the treatment measures include no treatment required, harmless treatment, suspended treatment, and destruction.
7. A food spoilage detection system based on artificial intelligence image recognition for executing the method of claim 6, characterized in that: include: An image acquisition module is used to receive a grayscale image of the food to be inspected and establish a sliding window of the grayscale image to divide the grayscale image into a number of image blocks; a feature extraction module is used to extract high-frequency components of the image block and determine the spoilage probability of the image block based on the high-frequency components; a region identification module is used to determine a suspected spoiled region based on the spoilage probability, detect a spoiled region in the suspected spoiled region, and determine the position of the spoiled region; wherein the feature extraction module includes: a high-frequency component extraction unit, used to obtain the high-frequency component of the image block through filtering and derivation operations; a central pixel determination unit, used to determine the neighborhood pixels of the central pixel point of the image block based on the high-frequency components; a spoilage probability calculation unit, used to calculate the difference between the pixel value of the neighborhood pixels and the pixel value of the central pixel point, and obtain the spoilage probability based on the difference in pixel values.
Citation Information
Patent Citations
Food deterioration detection method and system based on image processing
CN118397617A