Method for predicting shelf life of chilled beef based on machine vision technology
Through machine vision technology and support vector regression model, combined with effective accumulated temperature calculation, the accuracy problem of cold fresh beef shelf life prediction is solved, rapid and accurate prediction under different temperature conditions is achieved, and the effect of cold chain management is improved.
Patent Information
- Application Number
- CN202410631494.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-09-03
AI Technical Summary
It is difficult to accurately predict the shelf life of cold fresh beef under different temperature conditions with existing technology, especially under variable temperature conditions. Traditional methods have the problems of strong subjectivity and inaccurate prediction.
Using a method based on machine vision technology, by acquiring and processing images of cold fresh beef, extracting multi-channel color parameters of muscle tissue, and building a support vector regression model, combined with calculation of effective accumulated temperature, rapid and accurate prediction of shelf life can be achieved.
It achieves rapid and accurate prediction of the shelf life of cold fresh beef under constant and variable temperature conditions, provides more comprehensive cold chain management support, and ensures product quality and food safety.
Smart Images

Figure CN118587699A
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of data processing, and in particular relates to a method for predicting the shelf life of fresh beef based on machine vision technology. Background Art
[0002] With the continuous growth of my country's economy and the improvement of people's living standards, consumers are paying more and more attention to food quality and safety, especially the requirements for the hygiene quality and freshness of fresh food are more stringent. Chilled fresh beef is favored by consumers because of its rich nutrition, unique taste and low fat content. However, during storage and transportation, beef is easily affected by problems such as lipid oxidation, protein decomposition and microbial growth, which leads to quality degradation and shortened shelf life. For consumers, sensory characteristics such as color are the main basis for judging the freshness of food. However, the human eye visual judgment method has the problem of strong subjectivity and it is difficult to accurately evaluate the specific remaining shelf life. The traditional kinetic shelf life model needs to select representative food quality indicators, and then study the law of quality change based on the relevant kinetic principles of chemistry or microbiology, so as to construct a food shelf life prediction model.
[0003] As research on meat inspection continues to deepen and mature, machine vision technology has been proven to be a quality inspection tool with great potential, and its application in meat color, marbling, tenderness and freshness has gradually expanded. Machine vision technology usually starts with image analysis based on the color and texture features of the target image in order to achieve a rapid and accurate assessment of meat quality. However, most research focuses on the tenderness, marbling, quality grade and freshness grade of meat.
[0004] Most shelf life studies use models to predict food freshness and shelf life changes under constant temperature conditions, and there is a lack of shelf life studies under variable temperature conditions. At the same time, existing machine vision technology research on beef freshness detection is usually limited to qualitative judgment of freshness grade. However, simple freshness grade judgment cannot accurately reflect the slight changes in beef shelf life, and there is still a lack of research on shelf life prediction. Summary of the invention
[0005] The purpose of the present invention is to provide a method for predicting the shelf life of fresh beef based on machine vision technology, so as to realize the prediction of the shelf life of fresh beef under constant temperature conditions and variable temperature conditions.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A method for predicting the shelf life of fresh beef based on machine vision technology comprises the following steps:
[0008] Obtaining the shelf life of fresh beef under different storage conditions, wherein the storage conditions include constant temperature conditions and variable temperature conditions;
[0009] Build a machine vision system to collect images of fresh beef under different storage conditions and at different storage periods;
[0010] Segment the collected fresh beef images into muscle tissue images and extract the multi-channel color parameters of the muscle tissue;
[0011] The temperature history experienced by the fresh beef during image acquisition is converted into effective accumulated temperature, and the remaining effective accumulated temperature is calculated in combination with the shelf life under the corresponding storage conditions;
[0012] Build and train a support vector regression model for the remaining effective accumulated temperature of fresh beef based on color parameters;
[0013] The trained model is used to predict the remaining effective accumulated temperature under color parameters and convert it into the remaining shelf life of fresh beef.
[0014] Preferably, the machine vision system includes a dark box, a light source, an aluminum foil reflective film and a camera, the light source is arranged on the top of the dark box, the aluminum foil reflective film is arranged on the inner wall of the dark box, and the camera is arranged at the top opening of the dark box.
[0015] Preferably, the segmentation of the muscle tissue image is to extract the region of interest after reconstructing the acquired image under image correction.
[0016] Preferably, the image reconstruction under the image correction includes: pixel unification, grayscale, image noise reduction, background removal, and image reconstruction in sequence.
[0017] Preferably, the image reconstruction is to obtain a color image by performing a mask multiplication operation with the original image after filling the internal gaps of the image and smoothing the image edges.
[0018] Preferably, the multi-channel color parameters include 9 channel component values of RGB, L*a*b* and HSI color models.
[0019] Preferably, the effective accumulated temperature is calculated as:
[0020]
[0021] Where K is the effective accumulated temperature, N' is the storage time, T is the storage temperature under constant temperature conditions, n is the number of temperature changes under variable temperature conditions, and T i is the temperature recorded by the temperature monitor for the i-th time under variable temperature conditions, N is the duration corresponding to the temperature recorded by the temperature monitor for the i-th time under variable temperature conditions, and C is the relative zero temperature.
[0022] Preferably, the remaining effective accumulated temperature KR The effective accumulated temperature threshold K′ minus the effective accumulated temperature K experienced by the fresh beef sample. The calculation formula for the effective accumulated temperature threshold is:
[0023]
[0024] Where, J represents the shelf life threshold of fresh beef under different storage conditions, j is the storage days index, T j Indicates temperature.
[0025] Preferably, the remaining effective accumulated temperature output by the model is converted into the remaining shelf life through the remaining shelf life conversion formula.
[0026] SL R =K R / (TC)
[0027] In the formula, K R is the remaining effective accumulated temperature, T is the storage temperature for the next period of time, SL R Remaining shelf life.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] The present invention processes the image of fresh beef through machine vision technology to accurately extract the color parameters of muscle tissue, and builds an SVR model for predicting the remaining effective accumulated temperature based on color parameters through machine learning technology, thereby realizing rapid, accurate and non-destructive prediction of the remaining shelf life under constant temperature and variable temperature conditions, providing more comprehensive support for cold chain management, and being able to more accurately predict the changes in the shelf life of fresh beef under different temperature conditions, thus helping to ensure product quality and food safety. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a specific flow chart in an embodiment of the present invention.
[0031] Figure 2 This is a graph showing the changes in freshness indicators of fresh beef under different constant temperature storage conditions.
[0032] Figure 3 This is a graph showing the changes in freshness indicators of fresh beef under variable temperature storage conditions.
[0033] Figure 4 This is a structural diagram of the machine vision system.
[0034] Figure 5 Schematic diagram of the image processing process in step 3.
[0035] Figure 6 Schematic diagram of a binary image.
[0036] Figure 7 This is the effect diagram of the opening operation processing.
[0037] Figure 8 This is the effect diagram of mask processing.
[0038] Fig. 9 This is a graph showing the changes in color parameters of fresh beef under different constant temperature conditions.
[0039] Fig.10 This is a graph showing the changes in color parameters of fresh beef under variable temperature conditions.
[0040] Fig.11 The following are comparison charts of the prediction results of the model during the training process, where (a) is a comparison chart of the prediction results of the training set and the actual results, and (b) is a comparison chart of the prediction results of the test set and the actual results.
[0041] Fig.12 This is a graph showing the shelf life prediction results of fresh beef under variable temperature storage conditions. DETAILED DESCRIPTION
[0042] A method for predicting the shelf life of fresh beef based on machine vision technology comprises the following steps:
[0043] Step 1, obtaining the shelf life of fresh beef under different storage conditions. Specifically, the freshness index of the fresh beef under different constant temperature conditions and different variable temperature conditions is tested during the storage period, and the shelf life of the fresh beef under different constant temperature storage conditions and different variable temperature storage conditions is determined according to the freshness index.
[0044] In the present invention, the detection of freshness indexes of chilled fresh beef includes the determination of chemical indexes and the determination of microbial indexes.
[0045] (1) Determination of chemical indicators
[0046] Malondialdehyde TBA was determined by the spectrophotometric method in GB5009.181-2016 "Determination of malondialdehyde in food". Volatile basic nitrogen TVB-N was determined by the automatic Kjeldahl method in GB5009.228-2016 "Determination of volatile basic nitrogen in food".
[0047] (2) Determination of microbial indicators
[0048] The total colony count adopts the method of GB4789.2--2016 "Determination of total colony count in food microbiology examination".
[0049] In this embodiment, the TBA, TVBN and total bacterial count of the fresh beef at 4°C, 2°C and 0°C during the storage period were tested every two days. The test results are as follows: Figure 2As shown in the figure, the TBA, TVBN and total bacterial count of fresh beef under variable temperature conditions were tested every day during the storage period. The variable temperature condition here is to change the storage temperature every 24 hours, and the storage temperature changes according to the cycle of 4-2-0-2-4℃. The test results are shown in the figure. Figure 3 As shown; the shelf life of fresh beef is determined according to the freshness index: 8 days for storage at 4℃, 12 days for storage at 2℃, 16 days for storage at 0℃, and 11 days for storage at variable temperature.
[0050] Step 2: Use the constructed machine vision system to collect images of fresh beef under different storage conditions and at different storage periods.
[0051] In this embodiment, the machine vision system is as follows Figure 4 As shown, it includes a dark box, a light source, an aluminum foil reflective film and a camera. Here, the dark box uses a D65 light source that complies with the International Illumination Commission's regulations and has a real light rate distribution close to that of daylight. Two LED (3.6W) light strips are arranged in parallel and placed on the top of the dark box. The aluminum foil reflective film is set around the inner wall and top of the dark box to ensure uniform lighting without dead angles. The camera is set at the opening at the top of the dark box.
[0052] In this embodiment, images of fresh beef at 4°C, 2°C, and 0°C are collected every two days, and images of fresh beef under variable temperature conditions (the storage temperature is changed every 24 hours, and the storage temperature changes according to a cycle of 4-2-0-2-4°C) are collected every day, and the time of image collection is fixed.
[0053] Step 3, after reconstructing the acquired image under image correction, extract the region of interest to accurately segment the muscle tissue image.
[0054] Combination Figure 5 As shown, in the present invention, the image reconstruction under the image correction includes the following steps:
[0055] (1) Pixel unification
[0056] Although the directly acquired image has high definition, the pixels are too large and not uniform, which leads to slow subsequent image processing. Therefore, it is necessary to unify the pixels of the acquired image. Specifically, the imresize function in MATLAB is used to unify the pixels of the beef image to 1000×1000, which can effectively reduce the amount of calculation.
[0057] (2) Grayscale processing
[0058] Compared with color images, grayscale images that have been grayed out remove a lot of the original redundant color information, thereby effectively simplifying the image pixel matrix and improving the speed of subsequent image processing. Therefore, in the image preprocessing stage, the original RGB image is converted into a grayscale image to facilitate subsequent image denoising and background removal operations to improve the overall processing efficiency.
[0059] (3) Image Noise Reduction
[0060] The grayscale image can maintain the image quality and improve the accuracy of subsequent image analysis and color parameter extraction after denoising. Specifically, the medfilt2 function in MATLAB is used to perform median filtering denoising on the grayscale image.
[0061] (4) Background removal
[0062] Although the overall color of each sample image tends to be uniform after grayscale conversion and image noise reduction, there are still differences and changes that are difficult to distinguish with the naked eye. The subsequent muscle tissue color parameter extraction process also needs to be carried out in the cold fresh beef color image. Therefore, in order to better highlight the color characteristics of the beef, the image background needs to be further subtracted. Specifically, the grayscale histogram-based Otsu's binarization method is used to eliminate the background area in the image; in the present invention, the denoised image is processed by Otsu's binarization, and the effect is as shown in the attached figure. Figure 6 shown.
[0063] (5) Image reconstruction
[0064] The binary image after background removal uses opening operation (erosion and expansion) to fill the gaps inside the image and smooth the edges. The effect after opening operation to fill the internal gaps and smooth the edges is as follows Figure 7 As shown; the binary image after the opening operation is used to perform a mask multiplication operation with the original color image to obtain a beef color image with the background removed, as shown Figure 8 shown.
[0065] In the present invention, the region of interest is processed in a targeted manner, which can focus on the key information in the image, remove redundant information in the image, and greatly improve the efficiency of the algorithm. Specifically, the threshold segmentation method is used to remove fat and fascia tissue in the image, and only focus on the muscle tissue of fresh beef.
[0066] Step 4: extract the multi-channel color parameters of the muscle tissue image.
[0067] In this embodiment, in order to comprehensively consider the characteristics of different color models, the channel component values of RGB, L*a*b* and HSI color models are extracted from the muscle tissue image obtained in step 3, and a total of 9 color features are formed to form color parameters containing 9 channels. In the present invention, the color parameters of fresh beef under different temperature conditions and different storage times (days) are obtained through step 4. In this embodiment, the RGB, L*a*b* and HSI values extracted from fresh beef muscle tissue at constant temperatures of 4°C, 2°C and 0°C are as follows: Fig. 9 As shown in Figure 2; Under variable temperature conditions (the storage temperature is changed every 24 hours, and the storage temperature changes according to the cycle of 4-2-0-2-4°C), the RGB, L* a*b* and HSI values of the fresh beef muscle tissue extracted are shown in Figure 2; Under variable temperature conditions (the storage temperature is changed every 24 hours, and the storage temperature changes according to the cycle of 4-2-0-2-4°C), the RGB, L* a*b* and HSI values Fig.10 shown.
[0068] Step 5: Convert the temperature history experienced by the fresh beef during image acquisition into effective accumulated temperature, and calculate the remaining effective accumulated temperature in combination with the shelf life under corresponding storage conditions.
[0069] The effective accumulated temperature is calculated by the following formula:
[0070]
[0071] Where K is the effective accumulated temperature in h·°C, N′ is the storage time, T is the storage temperature under constant temperature conditions, n is the number of temperature changes, and T i is the temperature recorded by the temperature monitor for the i-th time under variable temperature conditions, in °C; N is the duration corresponding to the temperature recorded by the temperature monitor for the i-th time under variable temperature conditions, i.e. the storage time, in h; C is the relative zero temperature (biological zero, i.e. the temperature at which the temperature drops so low that certain physiological activities of organisms stop).
[0072] The remaining effective accumulated temperature indicates how much effective accumulated temperature needs to be accumulated in the remaining time to reach a certain growth or activity threshold. R The effective accumulated temperature threshold K′ minus the effective accumulated temperature K experienced by the fresh beef sample. The effective accumulated temperature threshold is calculated based on the shelf life threshold time of fresh beef under different storage temperature conditions. The specific formula is as follows:
[0073]
[0074] Where, J represents the shelf life threshold of fresh beef under different storage temperature conditions, j is the storage days index, T j In the calculation of the remaining effective accumulated temperature under the variable temperature condition of this embodiment, J = 11, j = 1, 2, 3 ... 11, T 1,5,9 =4, T 2,4,6,8,10 =2, T 3,7,11= 0. In the calculation of the remaining effective accumulated temperature under constant temperature conditions, J = 8 at 4°C, T j Both are 4; J = 12 at 2°C, T j Both are 2; J = 16 at 0°C, T j Both are 0.
[0075] In the present invention, the acquisition of the relative zero temperature includes the following steps:
[0076] (a) The Gompertz curve is corrected by the change of the total number of cold fresh beef colonies with storage time under different constant temperature conditions, and the parameter value λ in each corrected Gompertz curve is obtained, that is, the lag period λ of the microorganism under constant temperature conditions. The specific formula of the Gompertz curve is as follows:
[0077] N(t)=N0+(N max -N0)×{exp[-exp[μ max ×e×(λ-t) / (N max -N0)]]}
[0078] Where, N(t) is the total number of colonies at time t, in days; λ is the lag period, in days; N max is the maximum total number of colonies, in log 10 CFU / g; N0 is the total number of initial colonies, unit log 10 CFU / g; μ max is the maximum specific growth rate of microorganisms.
[0079] (b) Use the square root formula to solve for the lowest growth temperature T observed in the colony min , taking this temperature as the relative zero temperature, the specific formula is as follows, and the calculation results are shown in Appendix 2:
[0080]
[0081] Where, T is the storage temperature, unit K; b λ is the reaction rate constant; T min The lowest growth temperature observed for the colony, in K.
[0082] Taking this embodiment as an example, by fitting the Gompertz curve and correcting it, the hysteresis period λ under the constant temperature storage condition is obtained as shown in Table 1 below, and T is obtained by solving the square root formula min It is -268.3382K (-4.81℃), and this temperature is used as the zero-point temperature in the effective accumulated temperature.
[0083] Table 1:
[0084]
[0085] Step 5 of the present invention is to construct a data set, in which each data sample includes a color parameter and an effective accumulated temperature and a remaining effective accumulated temperature corresponding to the color parameter; by constructing the data set, a data basis is provided for the model training in step 6. In this embodiment, the parameters of fresh beef under different constant temperature storage conditions are obtained through step 5 as shown in Table 2, and the parameters of fresh beef under variable temperature storage conditions are shown in Table 3.
[0086] Table 2:
[0087]
[0088] Table 3:
[0089]
[0090] Step 6: Use the information fusion method to fuse the color parameter information with the storage temperature information, build a support vector regression model for the remaining effective accumulated temperature of fresh beef based on color parameters, and train it.
[0091] In the present invention, the SVR model in machine learning is used as the shelf life prediction model. The model has strong nonlinear fitting ability, generalization ability, ability to adapt to small sample data sets, and robustness and flexibility to outliers. The model takes color parameters and effective accumulated temperature as input and residual effective accumulated temperature as output. It should be noted here that both the input value and the output value need to be processed by data normalization.
[0092] The training of the model consists of the following steps:
[0093] (6.1) Determination of kernel function: Gaussian kernel function is used as the kernel function, and a 5-fold cross-validation combined with a grid search method is used to find the optimal penalty parameter c and kernel function parameter g of the Gaussian kernel function. This specific implementation method is a conventional technical means in this field and will not be elaborated here.
[0094] (6.2) Model training: The data set is divided into training set and test set, and the LIBSVM toolbox in MATLAB software is used for training.
[0095] In the present invention, the selection of parameters c and g directly affects the performance and generalization ability of the SVR model. Therefore, by selecting appropriate C and g values in the optimization process, the optimization results of these parameters are used as the basis of the model, so that the SVR model built based on these parameters can achieve the best performance on both the training set and the test set, which can improve the prediction accuracy and generalization ability of the model while reducing the risk of overfitting. In this embodiment, the SVR model is adjusted, wherein the data set is divided into a training set and a test set in a ratio of 4:1, and a Gaussian function is used as the kernel function. The model penalty factor c and the radial kernel parameter g are optimized by the grid search method and the 5-fold cross-validation method, and the obtained c value is 56 and the g value is 2; the prediction results of the model here are as follows Fig.11 As shown in the figure, the predicted value of a certain fresh beef in the test set during the storage period is selected under constant temperature condition and compared with the true value, and the result is Fig.11 (b) The predicted value of a piece of fresh beef in the test set during the storage period under variable temperature conditions is compared with the actual value. Fig.11 (c) By Fig.11 (a), (b), and (c) show that the errors between the model prediction results and the actual results are relatively small.
[0096] Step 6: Use the trained model to predict the remaining effective accumulated temperature under color parameters and convert it into the remaining shelf life of fresh beef.
[0097] In step 6 of the present invention, since the output of the model is the remaining effective accumulated temperature, and the remaining effective accumulated temperature cannot intuitively reflect the remaining shelf life of the chilled fresh beef, it is necessary to convert it through the remaining shelf life conversion formula:
[0098] SL R =K R / (TC)
[0099] Among them, SL R is the remaining shelf life, K R is the remaining effective accumulated temperature, and T is the storage temperature for the next period of time.
[0100] Table 4 shows the change in the remaining shelf life of fresh beef under constant temperature storage conditions predicted by the trained model, and compares it with the change in the remaining shelf life of fresh beef obtained by the kinetic model using TVB-N as an indicator. It can be seen from Table 4 that the average absolute error predicted by the SVR model is smaller.
[0101] Table 4:
[0102]
[0103] Fig.12The remaining shelf life change curve of fresh beef under variable temperature storage conditions predicted by the trained model and the remaining shelf life change curve of fresh beef obtained by the kinetic model using TVB-N as an indicator are shown in Table 5. The prediction results of the two methods are shown in Table 5. Fig.12 It can be seen from Table 5 that the remaining shelf life predicted by the two methods are very close, and the absolute error of the SVR model is smaller. Therefore, the remaining effective accumulated temperature prediction model based on effective accumulated temperature and color parameters can be used as a tool to predict the remaining shelf life of fresh beef under different storage conditions.
[0104] Table 5:
[0105]
Claims
1. A method for predicting the shelf life of fresh beef based on machine vision technology, characterized in that: The following steps are involved: Obtaining the shelf life of fresh beef under different storage conditions, wherein the storage conditions include constant temperature conditions and variable temperature conditions; Build a machine vision system to collect images of fresh beef under different storage conditions and at different storage periods; Segment the collected fresh beef images into muscle tissue images and extract the multi-channel color parameters of the muscle tissue; The temperature history experienced by the fresh beef during image acquisition is converted into effective accumulated temperature, and the remaining effective accumulated temperature is calculated in combination with the shelf life under the corresponding storage conditions; Build and train a support vector regression model for the remaining effective accumulated temperature of fresh beef based on color parameters; The trained model is used to predict the remaining effective accumulated temperature under color parameters and convert it into the remaining shelf life of fresh beef.
2. The method for predicting the shelf life of fresh beef based on machine vision technology according to claim 1, characterized in that: The machine vision system includes a dark box, a light source, an aluminum foil reflective film and a camera. The light source is arranged on the top of the dark box, the aluminum foil reflective film is arranged on the inner wall of the dark box, and the camera is arranged at the opening on the top of the dark box.
3. The method for predicting the shelf life of fresh beef based on machine vision technology according to claim 1, characterized in that: The segmentation of the muscle tissue image is to extract the region of interest after reconstructing the acquired image under image correction.
4. The method for predicting the shelf life of fresh beef based on machine vision technology as claimed in claim 3, characterized in that: The image reconstruction under the image correction includes: pixel unification, grayscale, image noise reduction, background removal, and image reconstruction.
5. The method for predicting the shelf life of fresh beef based on machine vision technology as claimed in claim 4, characterized in that: The image reconstruction is to fill the internal gaps of the image and smooth the image edges, and then obtain a color image by performing a mask multiplication operation with the original image.
6. The method for predicting the shelf life of fresh beef based on machine vision technology according to claim 1, characterized in that: The multi-channel color parameters include 9 channel component values of RGB, L*a*b* and HSI color models.
7. The method for predicting the shelf life of fresh beef based on machine vision technology according to claim 1, characterized in that: The calculation of the effective accumulated temperature is: Where K is the effective accumulated temperature, N' is the storage time, T is the storage temperature under constant temperature conditions, n is the number of temperature changes under variable temperature conditions, and T i is the temperature recorded by the temperature monitor for the i-th time under variable temperature conditions, N is the duration corresponding to the temperature recorded by the temperature monitor for the i-th time under variable temperature conditions, and C is the relative zero temperature.
8. The method for predicting the shelf life of fresh beef based on machine vision technology according to claim 1, characterized in that: The remaining effective accumulated temperature K R The effective accumulated temperature threshold K′ minus the effective accumulated temperature K experienced by the fresh beef sample. The calculation formula for the effective accumulated temperature threshold is: Where, J represents the shelf life threshold of fresh beef under different storage conditions, j is the storage days index, T j Indicates temperature.
9. The method for predicting the shelf life of fresh beef based on machine vision technology according to claim 1, characterized in that: The remaining effective accumulated temperature output by the model is converted into the remaining shelf life through the remaining shelf life conversion formula. SL R =K R / (T-C) In the formula, K R is the remaining effective accumulated temperature, T is the storage temperature for the next period of time, S LR is the remaining shelf life, and C is the relative zero temperature.
