Andu andu meat freshness detection method based on color constancy and integrated intelligent vision
By constructing a cascaded architecture for color correction and freshness recognition, and by optimizing the convolutional neural network using a latent diffusion generative model and deep metric learning, the problem of insufficient discrimination ability of giant salamander meat freshness detection in complex light source environments and the deterioration transition stage is solved, achieving high-precision and stable freshness detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-08
- Publication Date
- 2026-07-03
Smart Images

Figure CN122336413A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of food safety testing and computer vision technology, specifically relating to an intelligent detection method and system for the freshness of giant salamander meat that combines generative diffusion model color correction with integrated intelligent visual discrimination. Background Technology
[0002] The giant salamander (also known as the Chinese giant salamander) has unique meat and high nutritional value, and its freshness is typically transported long distances from production to consumption. However, during distribution and sales, it is difficult to achieve efficient and non-destructive accurate assessment of its freshness. While traditional physicochemical testing methods have high accuracy, they suffer from drawbacks such as complex procedures, long cycles, and destructive processes, making them unsuitable for real-time monitoring applications. Current mainstream methods mostly rely on sensory evaluation or portable sensors, but in complex lighting environments (such as fresh food lights), they are easily affected by ambient light interference, leading to color distortion and errors in freshness determination.
[0003] Furthermore, detection methods based on a single deep learning model often suffer from insufficient discriminative ability when processing samples in the transitional stage of deterioration (such as those in a slightly less fresh state) due to overlapping features between classes, which reduces the overall detection accuracy and stability.
[0004] Therefore, constructing a giant salamander meat freshness detection system that is resistant to light source interference and has high discrimination ability has important industrial application value. Summary of the Invention
[0005] The purpose of this invention is to provide a method for detecting the freshness of giant salamander meat in response to light source interference, aiming to solve the problems of thin film color signal shift and sample identification difficulties during the transition stage under complex lighting conditions.
[0006] The technical solution adopted in this invention is to construct a cascaded architecture for color correction and freshness recognition. This architecture includes: a color correction stage, which maps the original image to be detected to a standard color space to eliminate nonlinear color shift interference from ambient light sources; and a freshness intelligent judgment stage, which receives the standard color image and uses a cascaded recognition model to output the freshness level of the giant salamander meat.
[0007] As a preferred embodiment, the color correction process specifically involves: constructing a framework based on a latent diffusion generation model. Specifically, by introducing spatial structure priors as generation constraints, a virtual reference color chart with standard light source attributes is synthesized within the image mask region; the light source features of the virtual reference color chart are extracted, and adaptive diagonal white balance gain compensation is performed based on the light source chromaticity deviation, thereby achieving chromaticity reconstruction of the image.
[0008] As a preferred embodiment, the intelligent freshness discrimination process specifically involves: using a convolutional neural network optimized by deep metric learning as a feature extractor, optimizing the high-dimensional feature space through additive angle margin constraints to achieve intra-class compact representation of freshness features; mapping the extracted high-dimensional feature vectors to the classification decision layer, and using XGBoost to fit the nonlinear classification boundary to achieve high-precision automated discrimination of the freshness level of giant salamander meat.
[0009] This invention provides a method for detecting the freshness of giant salamander meat based on color constancy and integrated intelligent vision. It has the following beneficial effects:
[0010] 1. Strong anti-interference capability: The color correction module can adaptively compensate for color deviation under extreme light sources (such as fresh food lights), realizing color restoration in multi-light source environments.
[0011] 2. High recognition accuracy: The ArcFace loss function explicitly widens the distance between features of different freshness levels in the hyperspherical space, significantly improving the model's ability to capture samples with blurred boundaries.
[0012] 3. Robustness of judgment: The ensemble learning classifier solves the problem of insufficient fitting of non-linear features by the linear classification layer of CNN, and significantly reduces the misclassification rate of freshness judgment. Attached Figure Description
[0013] Figure 1 This is a flowchart illustrating the overall process architecture of the detection system provided by the present invention.
[0014] Figure 2 A flowchart for generating virtual color cards based on ControlNet structural constraints in a color correction model;
[0015] Figure 3 A schematic diagram of the feature extraction network structure based on the optimized GoogLeNet;
[0016] Figure 4 A comparison of the distribution of features before and after optimization in the hyperspherical space (T-SNE visualization).
[0017] Figure 5 A schematic diagram of the cascade reasoning for detecting the freshness of giant salamander meat. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019]
Example 1
[0020] This embodiment is used to construct training and testing data with physicochemical basis, specifically including sample collection, physicochemical index measurement and multimodal image acquisition process.
[0021] 1. Sampling and Storage Monitoring: Giant salamander muscle tissue was obtained and divided into samples within a predetermined mass range (e.g., 20 ± 0.5 g), and placed in a container. A prepared dual-modal intelligent indicator film (including a pH-sensitive colorimetric film and a ratiometric fluorescent film) was fixed to the top of the container, forming a headspace monitoring architecture. Subsequently, sampling and monitoring were performed at a set constant temperature (e.g., 25 ± 0.5 ℃) according to a predetermined time series (e.g., multiple time points within 0 to 44 h).
[0022] 2. Physicochemical Indicators and Classification: At each sampling point, the volatile basic nitrogen (TVB-N) content of the samples was simultaneously measured. Strictly adhering to relevant national food safety standards, samples with TVB-N ≤ 12 mg / 100 g were classified as fresh; those with 12 mg / 100 g < TVB-N ≤ 20 mg / 100 g were classified as partially fresh; and those with TVB-N > 20 mg / 100 g were classified as spoiled.
[0023] 3. Multi-light source image acquisition: Imaging equipment is used to acquire thin film images under different light source conditions, including standard light source, light sources with different color temperatures, and light sources with high color deviation. Fluorescence images under ultraviolet excitation are also acquired in a dark chamber. During acquisition, the built-in automatic retouching algorithm of the image acquisition equipment is turned off, and the raw format (such as DNG format) data without image signal processor (ISP) compression is output.
[0024]
Example 2
[0025] This example provides a method for detecting the freshness of giant salamander meat based on color constancy and integrated intelligent vision, such as... Figure 1 As shown, it mainly includes an image acquisition module, a color correction module, a feature extraction module, and an intelligent decision-making module. Its overall workflow is as follows: First, the image acquisition module parses the acquired raw RAW image; then, it determines the image imaging mode. For visible light modal images, the color correction module uses a generative diffusion model to eliminate color cast interference from complex environmental light sources (such as fresh food lights), outputting a standard color image with normalized illumination; next, the feature extraction module maps this standard image into a high-discrimination, high-dimensional feature vector; finally, the intelligent decision-making module, based on this vector, uses an ensemble learning classifier to output the corresponding freshness determination result of the giant salamander meat.
[0026]
Example 3
[0027] In this embodiment, the specific processing logic of the image acquisition module in Embodiment 2 is described in detail:
[0028] First, acquire RAW format image files (such as DNG format) of the sample under the target light source without processing by the camera's built-in microprocessor. Directly read the underlying raw data of the image, turn off automatic white balance (AWB) and gamma brightness compensation algorithm, thereby converting the optical signal captured by the sensor into floating-point tensor data in linear radiometric space, and uniformly scaling it to a preset resolution (such as 512×512).
[0029] Subsequently, modal adaptive branch judgment is performed. The global average brightness of the original linear image is calculated. If the average brightness is lower than a preset fluorescence threshold (e.g., average brightness < 15), it is determined to be a fluorescence modal image, and the system directly skips the subsequent generative color correction process to retain the initial fluorescence signal; if the average brightness is higher than the threshold, it is determined to be a visible light modal image, and the color constancy correction process is entered.
[0030]
Example 4
[0031] like Figure 2 The diagram shows the flowchart for generating a virtual color card based on ControlNet structural constraints in the color correction model. This module is built upon the Stable Diffusion Inpainting 1.5 network and the Conditional Control Network (ControlNet). Its specific architecture construction, fine-tuning training, and online inference process are as follows:
[0032] 1. Model Architecture Construction: The model consists of a variational autoencoder (VAE), a denoising backbone network (U-Net), and ControlNet working together. During network construction, the VAE is responsible for compressing the image into a low-dimensional latent space; ControlNet independently receives the edge wireframe map of the standard reference color card within the preset mask region (such as extraction by the Canny operator) as input, extracts high-frequency physical edge features, and injects multi-scale structural prior features layer by layer into the decoder of U-Net through zero convolutional layers; the denoising U-Net receives the stitched multi-channel input and performs denoising prediction under the structural constraints of ControlNet.
[0033] 2. End-to-end fine-tuning training strategy: During the training phase, the values of the standard color card template are multiplied with the true value vector of the illumination features of the sample, and exposure alignment is performed in combination with the average brightness of the mask area to generate the ideal color response target; at the model input end, the mask coverage area is replaced with a random Gaussian noise matrix to remove local color cues; during training, the parameters of the VAE, text encoder and conditional control network are frozen, and only the U-Net denoising network is iteratively updated using the mean squared error (MSE) loss function.
[0034] 3. Online Inference and Gated Correction: During the inference phase, a single-step deterministic inference strategy is used to synthesize a virtual reference color chart reflecting the current ambient light distribution within the masked area, while maintaining its array geometry. Using a spatially constrained median sampling algorithm, the neutral grayscale color block at the bottom of the virtual color chart is precisely anchored, and a set ratio (e.g., 35%) of inward shrinkage is performed to eliminate boundary interference. The physical chromaticity of the core area is extracted and L2 normalized to obtain the ambient light source chromaticity vector. Finally, the Euclidean distance between this vector and the standard pure white light vector is calculated: if it is less than a preset deviation threshold (e.g., 0.08), it is determined to be a normal light source and the original image is retained; if it exceeds the threshold, a diagonal transformation model is used to perform white balance gain compensation (limiting the gain coefficient to the range of 0.5 to 2.5), outputting a standard color image with normalized illumination.
[0035]
Example 5
[0036] like Figure 3 The diagram shows the feature extraction network structure. This embodiment uses a deep convolutional neural network (preferred as GoogLeNet, truncated to the Inception 4e module), removing its terminal linear classification layer and configuring it as a deep feature extractor. An ArcFace additive angular margin metric loss layer is connected to the network output. The feature scaling factor s = 50 and the angular margin m = 0.30 are set. This loss function maps the classification task to a high-dimensional hyperspherical space, performing joint parameter optimization. During the inference phase, the high-dimensional vector output from the network's global average pooling layer is extracted, and after L2 normalization, the discriminative feature vector is obtained.
[0037] like Figure 4 As shown, (A) is the T-SNE feature distribution in the early stage of training, where the samples are diffuse and overlapping; (B) is the feature distribution after optimization by ArcFace in this embodiment, where features of different freshness levels are clustered into dense clusters with clear inter-class separation boundaries, proving that the structure of this embodiment effectively enhances the ability to distinguish transitional samples.
[0038]
Example 6
[0039] like Figure 5 The diagram shows the cascaded reasoning process for detecting the freshness of giant salamander meat.
[0040] The system receives the L2-normalized high-dimensional feature vector output from Example 5 and inputs it into a pre-trained Extreme Gradient Boosting Tree (XGBoost) decision model. To address the risk of overfitting caused by high-dimensional features, the XGBoost model incorporates strong regularization constraints (including an L2 regularization coefficient λ=20 and an L1 regularization coefficient α=0.8) and sets a random sampling rate for the feature subspace (e.g., 0.2). After receiving the feature vector, the model constructs multiple classification and regression trees to fit the nonlinear decision boundary in the high-dimensional space, adaptively outputting the freshness level (fresh, less fresh, or spoiled) of the tested meat product.
[0041]
Example 7
[0042] To further verify the actual technical effect of the technical solution proposed in this invention, this embodiment uses a multi-source thin-film image dataset of giant salamander meat to conduct comparative tests on the core modules of this invention.
[0043] 1. Performance comparison of classification models before and after optimization
[0044] To evaluate the discrimination accuracy of the improved architecture in the task of grading the freshness of giant salamander meat, this embodiment uses a dataset of thin film images of giant salamander meat freshness under standard lighting conditions (i.e., excluding interference from extreme color-biased light sources) as the sample set for model training and testing. The specific performance index comparison results are shown in Table 1.
[0045] Table 1. Performance comparison of classification models before and after optimization
[0046] Model Accuracy (%) F1 score GoogLeNet 93.5 93.4 GoogLeNet-ArcFace 96.4 96.2 GoogLeNet-ArcFace-XGBoost 98.7 99.0
[0047] As shown in Table 1, compared to the basic convolutional neural network, the accuracy is improved to 96.4% after introducing the ArcFace loss function; further, by adding XGBoost to form a cascaded architecture, the accuracy and F1 score reach 98.7% and 99.0%, respectively. This data indicates that the present invention achieves high-precision recognition by combining angular constraints and nonlinear decision-making.
[0048] 2. Comparison of system performance before and after color constancy correction
[0049] Table 2 Comparison of system performance before and after color constancy correction.
[0050] Model Accuracy (%) F1 score Categorization only 91.7 92.0 Color correction + classification 95.8 96.0
[0051] As shown in Table 2, under complex uncontrolled light source conditions, the classification model achieves a recognition accuracy of 91.7% without color correction. However, after preprocessing using the correction model based on latent diffusion networks and conditional control networks proposed in this invention, the overall system accuracy improves to 95.8%. This data indicates that this invention, through illumination normalization processing, can effectively restore the physical color rendering signal affected by ambient light color shift, thereby ensuring the accuracy of the backend classification.
[0052] The above description is merely a specific embodiment and preferred embodiment of the present invention, and the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for detecting the freshness of giant salamander meat based on color constancy and integrated intelligent vision, characterized in that, Includes the following steps: S1. Acquire the original image data of the giant salamander meat to be tested and the indicator film on the top of the packaging; S2. Input the original image data into the color constancy correction model to eliminate the color deviation interference of the ambient light source and obtain a standard color image with illumination normalization; S3. Input the standard color image into a feature extraction network based on the improved GoogLeNet to extract feature vectors. S4. Input the feature vector into the ensemble learning decision model and output the freshness grade judgment result of the meat product to be tested.
2. The method according to claim 1, characterized in that, The indicator film includes anthocyanin-based colorimetric sensing film and ratiometric fluorescent film; the acquisition of raw image data in step S1 specifically includes: reading RAW format images that have not been processed by the camera's built-in algorithm, turning off automatic white balance and gamma compensation, and converting the resolved optical signal into a floating-point tensor in linear radiometric space.
3. The method according to claim 1, characterized in that, The color constancy correction model includes a latent diffusion local redrawing network and a conditional control network. Step S2 specifically includes: calculating the global brightness mean of the original image; if it is lower than a set fluorescence threshold, it is determined to be a fluorescence modality image, and subsequent correction is skipped while retaining the original signal; if it is higher than the fluorescence threshold, it enters the subsequent generative correction process; using an edge detection operator to extract the geometric wireframe of the standard reference color card within a preset mask area, and using it as a structural prior input to the conditional control network; using the latent diffusion local redrawing network to generate a virtual reference color card reflecting the current ambient light within the mask area, while keeping the geometric shape of the color card unchanged; extracting the ambient light chromaticity vector from the neutral grayscale color block of the virtual reference color card and performing L2 normalization processing; calculating the Euclidean distance between the chromaticity vector and the standard pure white light vector; if it exceeds a preset deviation threshold, a diagonal transformation model is used to perform white balance gain compensation on the original image, and the standard color image is output; if it is lower than the preset deviation threshold, the original color output is retained.
4. The method according to claim 3, characterized in that, The fine-tuning training process of the color constancy correction model includes: multiplying the standard color card template with the real illumination feature vector of the sample, and performing brightness alignment according to the mean brightness of the original image mask area to construct an ideal color response target; at the model input end, replacing the color card area covered by the mask with random Gaussian noise to erase local color cues; freezing the weights of the variational autoencoder, text encoder, and conditional control network, performing gradient calculation only on the denoising backbone network, and minimizing the mean square error between the predicted noise and the actual noise by adding noise and predicting noise at random sampling time steps to complete the parameter update.
5. The method according to claim 1, characterized in that, In step S3, the feature extraction network based on the improved GoogLeNet is a convolutional neural network with the terminal linear classification layer removed. This network uses GoogLeNet, which retains the basic convolutional layers and 7 Inception modules, as the baseline model. During the training phase, the ArcFace loss function is introduced for joint optimization to map the classification task to a high-dimensional hyperspherical space, thereby compressing the distribution radius of similar samples and expanding the corner margins of dissimilar samples. During the inference phase, the vector output by the global average pooling layer of this network is extracted and then normalized by L2 to obtain the feature vector.
6. The method according to claim 1, characterized in that, The ensemble learning decision model in step S4 is the XGBoost model; this model receives the feature vector output in step S3, and by constructing multiple classification and regression trees, it fits the nonlinear decision boundary in the feature space to determine the freshness level of the meat as fresh, slightly fresh, or spoiled.
7. The method for detecting the freshness of giant salamander meat based on color constancy and integrated intelligent vision according to claim 1, characterized in that, include: The image acquisition module is used to acquire raw image data of the giant salamander meat to be tested and the indicator film on the top of the packaging; The color correction module is used to input the original image data into the color constancy correction model to eliminate the color bias interference from the ambient light source and output a standard color image; the feature extraction module is used to input the standard color image into the feature extraction network to extract feature vectors; the intelligent decision-making module is used to input the feature vectors into the ensemble learning decision model and output the freshness grade judgment result of the meat product to be tested.