Food water content calculation method and device based on visual image, equipment and medium

Through visual image processing technology, the surface gloss and texture features of food are extracted, a feature vector matrix is ​​constructed and a mapping model is established, which solves the problems of rapid, non-destructive and accurate detection of food moisture content in existing technologies. It is suitable for fields such as food processing and warehousing.

CN120747952AInactive Publication Date: 2025-10-03DONGGUAN SONGSHAN LAKE CENT HOSPITAL (DONGGUAN SHILONG PEOPLES HOSPITAL DONGGUAN THIRD PEOPLES HOSPITAL DONGGUAN INST OF CARDIOVASCULAR DISEASES)
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510862110.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-10-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies are unable to quickly, non-destructively, and accurately detect the water content of various foods, and there are problems with high equipment costs and complex detection processes.

Method used

Through a visual image-based method, standardized preprocessing technology is used to remove light interference and noise, extract surface gloss and texture eigenvalues, construct a eigenvector matrix and determine the feature weights, establish a mapping relationship model between moisture content and visual features, and use a deep neural network for real-time detection.

Benefits of technology

It realizes rapid, non-contact real-time detection of the moisture content of various foods, reduces detection costs, improves detection accuracy and efficiency, and is suitable for fields such as food processing and warehousing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120747952A_ABST
    Figure CN120747952A_ABST
Patent Text Reader

Abstract

The invention relates to a food water content calculation method and device based on a visual image, equipment and a medium. First, food image data is collected, and first image data is obtained by using a standardized preprocessing technology. Secondly, extracting surface glossiness and texture feature values from the first image data, segmenting the image by using a feature detection algorithm, marking a key region related to the water content, and forming a visual feature set; thirdly, the relevance of all elements in the visual feature set is analyzed, food types are distinguished through a classification rule, feature weight distribution of different types of food is determined, and optimization of feature description is achieved; and finally, based on the optimized feature description, establishing a mapping relation model between the water content and the visual features, substituting a newly input food image into the model, predicting the water content, and outputting a real-time detection result. An efficient and convenient detection means is provided for the fields of food processing, storage and the like, the detection cost is reduced, and the production efficiency and the product quality control capability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing technology, and in particular relates to a method, device, equipment and medium for calculating the water content of food based on visual images. Background Art

[0002] In food industry production, quality inspection, and clinical medical diet management scenarios, accurate determination of food moisture content is a key link in ensuring product quality and controlling dietary nutrients. Traditional detection methods such as drying and weighing methods require sample destruction and have long detection cycles. Karl Fischer titration methods have problems such as chemical reagent contamination and complex operations. Among optical detection technologies, near-infrared spectroscopy relies on professional instruments, and hyperspectral imaging technology has cumbersome data processing and high equipment costs. Although existing visual inspection technologies have made progress, such as patent CN2023103694511, which uses convolutional neural networks to analyze food images, this method does not fully consider the impact of food processing status on moisture content, and does not optimize feature weights for different food types. It is impossible to achieve fast, non-destructive, accurate, and widely applicable moisture content calculations for various types of food. Summary of the Invention

[0003] Based on this, it is necessary to provide a food moisture content calculation method, device, equipment and medium based on visual images that can quickly and non-contactly detect the moisture content of various foods in real time to address the above technical problems.

[0004] In a first aspect, the present application provides a method for calculating the water content of food based on visual images, comprising:

[0005] Food image data is acquired, and standardized preprocessing is performed to remove light interference, smooth noise and blur areas to obtain first image data.

[0006] Surface gloss and texture feature values ​​are extracted from the first image data, and key areas are segmented and labeled using a feature detection method to obtain a set of visual features related to moisture content.

[0007] The correlation of the visual feature set is analyzed to construct a feature vector matrix, and the classification rules are used to distinguish food types to determine the feature weight distribution and obtain the optimized feature description.

[0008] Based on the optimized feature description, a mapping relationship model between water content and visual features is established to predict the water content of new input food images and obtain real-time detection results.

[0009] In one embodiment, surface gloss and texture feature values ​​are extracted from the first image data, and key areas are segmented and labeled using a feature detection method to obtain a set of visual features related to moisture content, including:

[0010] Grayscale conversion and normalization processing are performed on the first image data, a local adaptive threshold algorithm is used to extract surface gloss eigenvalues, and a gray level co-occurrence matrix method is used to extract texture eigenvalues.

[0011] The key areas of food in the image are identified based on the extracted eigenvalues, and the key areas are segmented using the watershed segmentation algorithm to obtain a set of segmented areas.

[0012] The image annotation tool is combined with manual verification and semantic segmentation algorithm to annotate the segmented region set, and a set of annotated regions with clear attributes of each region is obtained.

[0013] A multi-scale feature fusion algorithm is used to extract visual feature values ​​related to water content, including color, shape, texture, etc., from the annotated area set to generate an initial visual feature set.

[0014] The principal component analysis algorithm is used to reduce the dimension of the initial visual feature set, remove redundant features, and obtain the visual feature set.

[0015] In one embodiment, the correlation of the visual feature set is analyzed to construct a feature vector matrix, and the classification rules are used to distinguish food types to determine feature weight distribution to obtain an optimized feature description, including:

[0016] The Pearson correlation coefficient algorithm is used to perform correlation analysis on each eigenvalue in the visual feature set to obtain the feature correlation matrix.

[0017] Redundant features are eliminated based on the feature correlation matrix, and key principal components are selected to construct the feature vector matrix.

[0018] The eigenvector matrix data is input into the pre-trained food classification model to obtain different food types.

[0019] For each food type, the analytic hierarchy process combined with the information gain algorithm was used to determine the weight distribution of each visual feature for water content calculation.

[0020] A dynamic weight adjustment factor is introduced according to the processing status of the food type, and the eigenvalues ​​that deviate from the preset threshold are weightedly corrected and the weight distribution is adjusted. The final optimized weight is calculated to generate the optimized feature description.

[0021] In one embodiment, the final optimization weight is calculated by the following formula:

[0022]

[0023] in, represents the final optimized weight of the i-th visual feature, represents the weight of the kth feature calculated based on the hierarchical analysis method, represents the weight of the kth feature calculated based on the information gain algorithm, β represents the fusion coefficient, and λ i represents the dynamic weight adjustment factor of the i-th feature, represents the deviation of the i-th feature in the j-th food, f i represents the actual detection value of the i-th feature, μ j represents the mean value of the feature in the jth food, σ j represents the standard deviation of the characteristic in the jth food category.

[0024] In one embodiment, a mapping relationship model between moisture content and visual features is established based on the optimized feature description, and moisture content is predicted for new input food images to obtain real-time detection results, including:

[0025] Based on the optimized feature description, a deep neural network architecture is adopted to construct a mapping relationship model between water content and visual features.

[0026] The newly input food image is preprocessed, the visual features are extracted and converted into an optimized feature description format for input into the mapping relationship model, and the moisture content prediction value is obtained through forward propagation calculation.

[0027] The predicted values ​​of each moisture content are combined with the food type and sample weight to generate the final real-time detection results.

[0028] In one embodiment, the method further comprises:

[0029] The predicted water content value is compared with the actual measured value, and the prediction error is calculated.

[0030] The back propagation algorithm is combined with the prediction error to update the parameters of the mapping relationship model and dynamically optimize the mapping relationship model.

[0031] In one embodiment, standardization preprocessing is performed to remove illumination interference, smooth noise, and blur areas to obtain first image data, including:

[0032] The food image data is converted into grayscale, and the histogram equalization algorithm is used to enhance the image contrast to obtain the enhanced image.

[0033] The enhanced image is illuminated by using a retinal cortex theory algorithm to obtain an illumination compensated image.

[0034] The illumination compensation image is processed using a bilateral filtering algorithm to smooth the noise and blur areas to obtain a bilateral filtered image.

[0035] The bilateral filtered image is normalized in size and format to obtain standardized first image data.

[0036] In a second aspect, the present application further provides a device for calculating the water content of food based on visual images, the device comprising:

[0037] The image acquisition and processing module is used to obtain food image data, and use standardized preprocessing to remove light interference, smooth noise and fuzzy areas to obtain first image data.

[0038] The feature extraction and optimization module is used to extract surface gloss and texture feature values ​​from the first image data, use feature detection methods to segment and mark key areas, and obtain a set of visual features related to water content; it is also used to analyze the correlation of the visual feature set to construct a feature vector matrix, use classification rules to distinguish food types, determine feature weight distribution, and obtain an optimized feature description.

[0039] The prediction model building module is used to establish a mapping relationship model between water content and visual features based on the optimized feature description, predict the water content of new input food images, and obtain real-time detection results.

[0040] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the above method when executing the computer program.

[0041] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, which implements the above method when executed by a processor.

[0042] The above-described method, device, computer equipment, and storage medium for calculating food moisture content based on visual images first collect food image data and then employ standardized preprocessing techniques to eliminate illumination variations, smooth image noise, and repair blurred areas to obtain first image data. Next, surface gloss and texture feature values ​​are extracted from the first image data. A feature detection algorithm is then used to segment the image, annotate key areas related to moisture content, and form a visual feature set. Next, the correlations between elements in the visual feature set are analyzed to construct a feature vector matrix. Classification rules are then used to distinguish food types, determine feature weight distributions for different food types, and optimize feature descriptions. Finally, based on the optimized feature descriptions, a mapping model between moisture content and visual features is established. A newly input food image is substituted into the model to predict its moisture content and output real-time detection results. This method effectively extracts visual features related to moisture content, avoiding detection bias caused by single features. Compared to traditional detection methods, this method eliminates the need for complex physical detection equipment and enables rapid, non-contact, real-time moisture content detection of a variety of foods. This provides an efficient and convenient detection method for food processing, warehousing, and other fields, reducing detection costs and improving production efficiency and product quality control. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0044] Figure 1 A flowchart of a method for calculating the water content of food based on visual images provided in an embodiment of the present invention;

[0045] Figure 2 This is a structural block diagram of a device for calculating the moisture content of food based on visual images provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0047] In one embodiment, Figure 1 As shown, the present application provides a method for calculating the water content of food based on visual images, which may include the following steps:

[0048] Step S101: Acquire food image data, and use standardized preprocessing to remove light interference, smooth noise and fuzzy areas to obtain first image data.

[0049] Specifically, high-resolution image acquisition equipment is used to photograph various types of food from multiple angles to obtain rich food image data. This data covers information such as the shape, color, and surface details of different foods, but due to the influence of the shooting environment, there are problems such as uneven lighting, noise interference, and blur in some areas. To solve these problems, a standardized preprocessing process is adopted. First, the image brightness distribution is adjusted through algorithms such as histogram equalization to eliminate light interference, so that images taken under different lighting conditions have a consistent brightness baseline. Then, methods such as Gaussian filtering are used to smooth image noise. This method is based on the weighted average characteristics of the Gaussian function and can effectively reduce the impact of random noise on image quality. For blurred areas, an image restoration algorithm is used to reconstruct the blurred parts by referring to the texture and structure information of similar surrounding areas. After this series of operations, clear and standardized first image data is obtained.

[0050] Step S102 : extracting surface gloss and texture feature values ​​from the first image data, segmenting and marking key areas using a feature detection method, and obtaining a visual feature set related to moisture content.

[0051] Based on the first image data, digital image processing techniques are used to extract surface gloss and texture feature values ​​that are closely related to the moisture content of the food. Surface gloss can be obtained by calculating the distribution of reflected light intensity in specific areas of the image. Foods with different moisture contents have different surface light reflectance properties, which can be used as a basis for determining moisture content. Texture feature value extraction utilizes algorithms such as the gray-level co-occurrence matrix. This matrix describes the spatial distribution relationship between pairs of pixels of different grayscale levels in an image, reflecting characteristics such as the texture thickness and direction of the food surface. Changes in moisture content will cause corresponding changes in the food texture. After feature extraction, feature detection methods such as edge detection and threshold segmentation are used to segment and annotate areas in the image that may be closely related to moisture content, such as the edges of the food and areas with significant internal texture changes. The features of these areas are aggregated to form a set of visual features related to moisture content.

[0052] Step S103 , analyzing the correlation of the visual feature set to construct a feature vector matrix, using classification rules to distinguish food types to determine feature weight distribution, and obtaining an optimized feature description.

[0053] Specifically, the correlations between the acquired visual feature sets are analyzed in depth. By calculating correlation coefficients between features and other methods, the interplay of different features in reflecting food moisture content is understood. Based on this, a feature vector matrix is ​​constructed, with each visual feature as a dimension of the vector, and the feature values ​​of each food sample forming a row of data in the matrix. Classification rules, such as decision trees and support vector machines, are used to distinguish different types of food. Due to their unique characteristics, the correlation patterns between moisture content and visual features vary between different foods, and classification algorithms can exploit these differences. During the classification process, the importance of each feature in reflecting moisture content for different food types is determined, known as the feature weight distribution. For example, for foods with smooth surfaces, the weight of surface gloss features may be higher, while for foods with rich textures, the weight of texture features may be higher. This process results in an optimized feature description that more accurately reflects the relationship between different food types and moisture content.

[0054] Step S104: A mapping relationship model between water content and visual features is established based on the optimized feature description, and the water content of the newly input food image is predicted to obtain a real-time detection result.

[0055] Based on the optimized feature descriptions, regression analysis, neural network modeling, and other modeling methods are used to establish a mapping relationship model between food moisture content and visual features. In regression analysis, algorithms such as the least squares method are used to fit the linear or nonlinear relationship between moisture content and visual features. If a neural network is used, a network structure consisting of an input layer, a hidden layer, and an output layer is constructed. The input layer receives visual feature data, the hidden layer performs complex feature transformations and combinations on the data, and the output layer predicts the moisture content of the food. After the model is established, it is trained and optimized using a large number of food image samples with known moisture content, enabling the model to accurately capture the inherent connection between visual features and moisture content. When a new food image is input, the model automatically extracts the image's visual features and, based on the learned mapping relationship, predicts the moisture content of the food, rapidly obtaining real-time detection results.

[0056] The above-mentioned method for calculating food moisture content based on visual images first collects food image data and then uses standardized preprocessing techniques to eliminate illumination variations, smooth image noise, and repair blurred areas to obtain first image data. Next, surface gloss and texture feature values ​​are extracted from the first image data. A feature detection algorithm is then used to segment the image and annotate key areas related to moisture content to form a visual feature set. Next, the correlation between the elements in the visual feature set is analyzed to construct a feature vector matrix. Classification rules are then used to distinguish food types, determining the feature weight distribution for different food types and optimizing the feature description. Finally, based on the optimized feature description, a mapping model between moisture content and visual features is established. A newly input food image is substituted into the model to predict its moisture content and output real-time detection results. This method effectively extracts visual features related to moisture content, avoiding detection bias caused by single features. Compared to traditional detection methods, this method does not require complex physical detection equipment and can rapidly and non-contactly detect the moisture content of a variety of foods in real time. This provides an efficient and convenient detection method for food processing, warehousing, and other fields, reducing detection costs and improving production efficiency and product quality control.

[0057] In one embodiment, extracting surface gloss and texture feature values ​​from the first image data, segmenting and marking key areas using a feature detection method, and obtaining a set of visual features related to moisture content may include the following steps:

[0058] Step S201 , performing grayscale conversion and normalization processing on the first image data, using a local adaptive threshold algorithm to extract surface gloss eigenvalues, and using a gray level co-occurrence matrix method to extract texture eigenvalues.

[0059] Step S202 : identifying key areas of food in the image based on the extracted feature values, and segmenting the key areas using a watershed segmentation algorithm to obtain a set of segmented areas.

[0060] Preferably, due to the varying characteristics of different foods, the areas most closely related to water content vary, such as the skin of fruit and the concentrated muscle texture of meat. By analyzing the surface gloss eigenvalues ​​extracted previously, we can understand how different areas of the food surface reflect light. Changes in water content often affect these reflective properties, allowing us to preliminarily identify areas potentially related to water content. Texture eigenvalues ​​also provide important clues, such as texture thickness and direction changes. Under different water content conditions, the texture of food will exhibit different states, allowing us to further accurately locate key areas. After determining the key areas, a watershed segmentation algorithm is used for processing. The image is first grayscaled (skipped if already grayscale), denoised using Gaussian blur, and binarized using the Otsu method to separate the image into foreground and background. Morphological opening and dilation operations are then used to optimize the foreground and background. The foreground area is determined through a distance transform, and the background area is derived, yielding the unknown area between the foreground and background. After marking the foreground area, the watershed algorithm is applied to simulate the expansion of water from the local minimum and form a segmentation boundary at the "peak", thereby segmenting the key area and obtaining a set of segmented areas.

[0061] In step S203 , the segmented region set is annotated using an image annotation tool in combination with manual verification and a semantic segmentation algorithm to obtain an annotated region set with clear attributes of each region.

[0062] Step S204 : A multi-scale feature fusion algorithm is used on the set of labeled regions to extract visual feature values ​​related to water content, including color, shape, texture, etc., to generate an initial visual feature set.

[0063] Step S205 , using a principal component analysis algorithm to perform dimensionality reduction processing on the initial visual feature set, removing redundant features, and obtaining a visual feature set.

[0064] First, grayscale conversion is performed on the first image data, converting the color image into a grayscale image to simplify the data dimension. Normalization is also performed to unify the pixel value range and improve data stability. A local adaptive thresholding algorithm is used to extract surface gloss eigenvalues ​​based on the characteristics of local image regions. A gray-level co-occurrence matrix method is used to extract texture eigenvalues ​​by analyzing the spatial correlation of pixel grayscale levels. Second, key food regions within the image are located based on the extracted eigenvalues. A watershed segmentation algorithm is used to segment the key regions by simulating a water filling process, analogizing the image to a terrain surface. Image annotation tools and manual verification are then used to ensure annotation accuracy. A semantic segmentation algorithm is then introduced to annotate the segmented regions, forming a set of annotated regions with clear attributes for each region. Next, a multi-scale feature fusion algorithm is applied to the annotated region set to extract visual features related to water content, such as color, shape, and texture, at different scales to generate an initial visual feature set. Finally, principal component analysis is used to reduce the dimensionality of this initial set. Principal components are extracted through linear transformations and redundant features are removed to obtain a streamlined visual feature set.

[0065] This embodiment systematically integrates image preprocessing, segmentation, labeling, and feature extraction technologies to achieve accurate extraction and optimization of food image features. Grayscale conversion and normalization improve data quality, while local adaptive thresholds and grayscale co-occurrence matrices ensure the accuracy of basic features. Watershed segmentation and semantic labeling achieve precise regional division and attribute recognition. Multi-scale feature fusion covers multi-dimensional information, and principal component analysis removes redundancy. Compared with a single feature extraction method, this process can comprehensively and efficiently extract visual features related to water content, effectively improving the accuracy and reliability of food water content detection, and meeting the food industry's demand for fast and accurate detection.

[0066] In one embodiment, analyzing the correlation of a set of visual features to construct a feature vector matrix, using classification rules to distinguish food types to determine feature weight distribution, and obtaining an optimized feature description may include the following steps:

[0067] Step S301 : Using the Pearson correlation coefficient algorithm, a correlation analysis is performed on each eigenvalue in the visual feature set to obtain a feature correlation matrix.

[0068] Step S302: Eliminate redundant features based on the feature correlation matrix, select key principal components and construct a feature vector matrix.

[0069] Step S303: Input the eigenvector matrix data into a pre-trained food classification model to obtain different food types.

[0070] Step S304: for each food type, the analytic hierarchy process combined with the information gain algorithm is used to determine the weight distribution of each visual feature for the calculation of the water content.

[0071] Step S305 , introducing a dynamic weight adjustment factor according to the processing status of the food type, performing weighted correction on the feature values ​​that deviate from the preset threshold and adjusting the weight distribution, and calculating the final optimized weight to generate the optimized feature description.

[0072] First, the Pearson correlation coefficient algorithm is used to analyze the correlation of each eigenvalue in the visual feature set. The linear correlation between each feature is calculated, forming a feature correlation matrix that visually displays the strength of the correlation between the features. Second, based on the feature correlation matrix, redundant features with excessive correlations are identified and removed. Key principal components that maximize data preservation are selected to construct an eigenvector matrix, streamlining the feature dimensions. Next, the eigenvector matrix is ​​input into a pre-trained food classification model, leveraging the model's classification capabilities to determine the food type. Then, for each food type, the analytic hierarchy process (AHP) and information gain algorithm are combined to quantify the contribution of each visual feature to the moisture content calculation and determine the corresponding weight distribution. Finally, a dynamic weight adjustment factor is introduced based on the processing state of the food type to weight and correct eigenvalues ​​that deviate from the preset threshold. The weight distribution is then readjusted to generate the final optimized feature description.

[0073] This embodiment achieves efficient optimization of visual features related to food moisture content and accurate weight allocation. The Pearson correlation coefficient is combined with principal component analysis to effectively remove redundant features and reduce data dimensions; the food classification model achieves accurate classification, providing a prerequisite for weight calculation; the hierarchical analysis method and information gain algorithm quantify the importance of features, and the dynamic weight adjustment factor combines the food processing status to improve the flexibility of weights. Compared with a single algorithm processing, it can more comprehensively and accurately determine the weights of each feature under different food types, provide high-quality input for the food moisture content prediction model, significantly improve the accuracy and reliability of the test results, and meet the food industry's demand for accurate moisture content detection.

[0074] In one embodiment, the final optimization weight can be calculated using the following formula:

[0075]

[0076] in, represents the final optimized weight of the i-th visual feature, represents the weight of the kth feature calculated based on the hierarchical analysis method, represents the weight of the kth feature calculated based on the information gain algorithm, β represents the fusion coefficient, and λ i represents the dynamic weight adjustment factor of the i-th feature, represents the deviation of the i-th feature in the j-th food, f i represents the actual detection value of the i-th feature, μ j represents the mean value of the feature in the jth food, σ j represents the standard deviation of the characteristic in the jth food category.

[0077] Preferably, Among them, ω AHP Represents the weight vector, which is solved using the eigenvalue decomposition method.

[0078] IG(f i )=H(y)-H(y|f i ), i=1,2,3,...,n, where f i represents the i-th feature, IG(f i ) represents the feature f i For the information gain of water content y, H(y) represents the marginal entropy, H(y|f i ) represents the conditional entropy.

[0079] This embodiment can accurately reflect the true contribution of each visual feature to the moisture content calculation, provide more reliable input parameters for the food moisture content prediction model, improve the accuracy and stability of the detection results, and has important practical value for application scenarios such as food quality control and processing technology optimization.

[0080] In one embodiment, a mapping relationship model between moisture content and visual features is established based on the optimized feature description, moisture content is predicted for a new input food image, and real-time detection results are obtained, which may include the following steps:

[0081] Step S401: Based on the optimized feature description, a deep neural network architecture is used to construct a mapping relationship model between water content and visual features.

[0082] Preferably, a deep neural network architecture is used to construct a mapping relationship model based on the obtained optimized feature description. Deep neural networks utilize automatic feature extraction and nonlinear mapping capabilities to abstract data layer by layer through a multi-layered neural structure. Various features from the optimized feature description are used as input, such as surface gloss and texture, which are related to moisture content. Using a network structure consisting of convolutional layers, pooling layers, and fully connected layers, the complex underlying relationship between visual features and moisture content is explored, thereby establishing a mapping relationship model that accurately reflects the relationship between the two.

[0083] Step S402 , preprocessing the newly input food image, extracting visual features and converting them into an optimized feature description format to input into a mapping relationship model, and obtaining a moisture content prediction value through forward propagation calculation.

[0084] Furthermore, the newly input food images must first undergo the same standard preprocessing process as the training data, including the use of the Retinex algorithm to remove lighting interference, and bilateral filtering to smooth noise and blurred areas, to ensure the consistency and standardization of the image data. Then, visual features such as surface gloss and texture are extracted using methods such as the gray-level co-occurrence matrix, and these original features are converted into an optimized feature description format based on the rules determined in advance. This format contains the key features that have been screened and weighted and their corresponding weights, which can more accurately represent the information related to the water content of the food image. After the conversion is completed, the data is input into the constructed mapping relationship model, and the water content prediction value is gradually output through the forward propagation calculation of the neurons in each layer of the model.

[0085] Step S403 : combining each moisture content prediction value with the food type and sample weight to generate a final real-time detection result.

[0086] Specifically, based on optimized feature descriptions, a deep neural network architecture is used to construct a mapping model between moisture content and visual features. New food images are first subjected to standardized preprocessing to extract visual features such as surface gloss and texture. These images are then converted into an optimized feature description format and fed into the mapping model. A forward propagation algorithm is then used to calculate moisture content predictions. Finally, the predictions are processed based on food type and sample weights to generate the final real-time detection results.

[0087] This embodiment implements automated processing from image data to moisture content prediction. By constructing a mapping relationship model through a deep neural network, it is able to efficiently learn the complex relationship between visual features and moisture content. New images are converted into an optimized feature description format for input, ensuring the compatibility of the data and model. Results are generated by combining food type and sample weights, improving the accuracy and reliability of predictions. This method does not require complex physical and chemical testing and can quickly and non-destructively complete food moisture content testing, providing a convenient and efficient technical means for scenarios such as food production and quality testing.

[0088] In one embodiment, the method may further include the following steps:

[0089] Step S501 : Compare the obtained water content prediction value with the actual measured value to calculate the prediction error.

[0090] Step S502 : using a back propagation algorithm in combination with prediction errors to update the parameters of the mapping relationship model and dynamically optimize the mapping relationship model.

[0091] Specifically, the predicted water content value is compared with the actual measured value, and the prediction error between the two is calculated. Using the backpropagation algorithm, the parameters of the mapping relationship model are updated based on the calculated prediction error, achieving dynamic optimization of the mapping relationship model.

[0092] This embodiment establishes a self-optimization mechanism by comparing predicted values ​​with actual values ​​and dynamically updating model parameters. The calculation of prediction errors provides a clear adjustment direction for model optimization. The backpropagation algorithm propagates the errors layer by layer and optimizes the parameters at each layer, enabling the model to continuously refine its learning of the mapping relationship between visual features and moisture content based on actual detection results. This effectively improves the model's prediction accuracy, allowing it to gradually adapt to complex scenarios such as different food types and processing conditions during continued use.

[0093] In one embodiment, using standardization preprocessing to remove illumination interference, smooth noise and blur areas to obtain first image data may include the following steps:

[0094] Step S601 , performing grayscale conversion on the food image data, and using a histogram equalization algorithm to enhance the image contrast to obtain an enhanced image.

[0095] Step S602 : performing illumination compensation on the enhanced image using a retinal cortex theory algorithm to obtain an illumination compensated image.

[0096] Step S603 : Process the illumination-compensated image using a bilateral filtering algorithm to smooth out noise and blur areas to obtain a bilateral filtered image.

[0097] Step S604 : normalize the size and format of the bilateral filtered image to obtain standardized first image data.

[0098] Specifically, the food image data undergoes grayscale conversion, histogram equalization, illumination compensation using the retinal cortex theory algorithm, bilateral filtering, size normalization, and format unification to obtain standardized first image data. The specific process is as follows: first, the food image data is converted to a grayscale image, then the image contrast is enhanced using the histogram equalization algorithm. Then, illumination compensation is performed on the enhanced image using the retinal cortex theory algorithm. The illumination-compensated image is then processed using the bilateral filtering algorithm to smooth noise and blurred areas. Finally, the bilaterally filtered image is size normalized and formatted.

[0099] This embodiment effectively improves image quality and data standardization through a multi-step collaborative operation. Grayscale conversion simplifies subsequent processing dimensions, histogram equalization enhances image detail, the retinal cortex theory algorithm addresses uneven illumination, bilateral filtering reduces noise while preserving image edge information, and size normalization and format unification ensure data consistency. This improves image clarity and feature expression, contributing to the accuracy and stability of the overall food water content calculation method.

[0100] In one embodiment, Figure 2As shown, the present application also provides a device for calculating the water content of food based on visual images, which may include:

[0101] The image acquisition and processing module 701 is used to obtain food image data, and use standardized preprocessing to remove light interference, smooth noise and blurred areas to obtain first image data.

[0102] The feature extraction and optimization module 702 is used to extract surface gloss and texture feature values ​​from the first image data, segment and mark key areas using feature detection methods, and obtain a set of visual features related to water content; it is also used to analyze the correlation of the visual feature set to construct a feature vector matrix, use classification rules to distinguish food types, determine feature weight distribution, and obtain an optimized feature description.

[0103] The prediction model building module 703 is used to establish a mapping relationship model between water content and visual features based on the optimized feature description, predict the water content of new input food images, and obtain real-time detection results.

[0104] In the aforementioned visual image-based food moisture content calculation device, the image acquisition and processing module acquires food image data and, through standardized preprocessing, removes illumination interference, smoothes noise, and generates first image data. The feature extraction and optimization module extracts surface gloss and texture feature values ​​from the first image data and uses feature detection methods to segment and annotate key areas to obtain a set of visual features related to moisture content. This module also performs correlation analysis on the visual feature set, constructs a feature vector matrix, and uses classification rules to distinguish food types and determine feature weight distribution, ultimately obtaining an optimized feature description. The prediction model construction module establishes a mapping relationship model between moisture content and visual features based on the optimized feature description, predicts moisture content for newly input food images, and generates real-time detection results. The image acquisition and processing module improves image quality through standardized preprocessing. The feature extraction and optimization module converts original features into optimized features, enhancing the correlation between features and moisture content. The prediction model construction module achieves intelligent moisture content prediction by establishing a mapping relationship model. The modules work together to quickly and non-destructively complete food moisture content testing. It has the advantages of high detection efficiency, wide applicability, and strong prediction accuracy, and can provide practical and effective technical support for scenarios such as food production and quality inspection.

[0105] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0106] In one embodiment, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method, apparatus, device, and medium for calculating the moisture content of food based on visual images as described above are implemented.

[0107] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0108] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the components described as separate parts may or may not be physically separated, and the parts displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. A person of ordinary skill in the art can understand and implement it without expending creative work.

[0109] The above-described embodiments merely represent several implementation methods of the embodiments of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person skilled in the art may make various modifications and improvements without departing from the concept of the embodiments of the present application, and these modifications and improvements fall within the scope of protection of the embodiments of the present application.

Claims

1. A method for calculating the water content of food based on visual images, characterized in that: The method comprises: Acquire food image data, and perform standardized preprocessing to remove light interference, smooth noise, and blur areas to obtain first image data; Extracting surface gloss and texture feature values ​​from the first image data, segmenting and marking key areas using a feature detection method, and obtaining a set of visual features related to moisture content; Analyzing the correlation of the visual feature set to construct a feature vector matrix, using classification rules to distinguish food types to determine feature weight distribution, and obtaining an optimized feature description; Based on the optimized feature description, a mapping relationship model between water content and visual features is established, and the water content of new input food images is predicted to obtain real-time detection results.

2. The method according to claim 1, characterized in that The extracting of surface gloss and texture feature values ​​from the first image data, segmenting and marking key areas using a feature detection method, and obtaining a visual feature set related to moisture content include: Performing grayscale conversion and normalization processing on the first image data, extracting surface gloss eigenvalues ​​using a local adaptive threshold algorithm, and extracting texture eigenvalues ​​using a gray-level co-occurrence matrix method; Identifying key areas of food in the image based on the extracted feature values, and segmenting the key areas using a watershed segmentation algorithm to obtain a set of segmented areas; Using an image annotation tool combined with manual verification and a semantic segmentation algorithm, the segmented region set is annotated to obtain an annotated region set with clear attributes of each region; A multi-scale feature fusion algorithm is used on the set of marked areas to extract visual feature values ​​related to water content, including color, shape, texture, etc., to generate an initial visual feature set; The principal component analysis algorithm is used to perform dimensionality reduction processing on the initial visual feature set, remove redundant features, and obtain a visual feature set.

3. The method according to claim 1, characterized in that The analysis of the correlation of the visual feature set to construct a feature vector matrix, the use of classification rules to distinguish food types to determine feature weight distribution, and the acquisition of optimized feature descriptions include: Using a Pearson correlation coefficient algorithm to perform correlation analysis on each of the feature values ​​in the visual feature set to obtain a feature correlation matrix; Eliminate redundant features based on the feature correlation matrix, select key principal components and construct a feature vector matrix; Inputting the eigenvector matrix data into a pre-trained food classification model to obtain different food types; For each food type, a hierarchical analysis method combined with an information gain algorithm is used to determine the weight distribution of each visual feature for calculating the water content; A dynamic weight adjustment factor is introduced according to the processing status of the food type, a weighted correction is performed on the feature value that deviates from the preset threshold and the weight distribution is adjusted, and the final optimized weight is calculated to generate an optimized feature description.

4. The method according to claim 3, characterized in that The final optimization weight is calculated by the following formula: in, represents the final optimized weight of the i-th visual feature, represents the weight of the kth feature calculated based on the hierarchical analysis method, represents the weight of the kth feature calculated based on the information gain algorithm, β represents the fusion coefficient, and λ i represents the dynamic weight adjustment factor of the i-th feature, represents the deviation of the i-th feature in the j-th food, f i represents the actual detection value of the jth feature, μ j represents the mean value of the feature in the jth food, σ j represents the standard deviation of the characteristic in the jth food category.

5. The method according to claim 1, wherein The method includes establishing a mapping relationship model between water content and visual features based on the optimized feature description, predicting the water content of a newly input food image, and obtaining a real-time detection result, including: Based on the optimized feature description, a deep neural network architecture is used to construct a mapping relationship model between water content and visual features; Preprocessing the newly input food image, extracting visual features and converting them into the optimized feature description format to input into the mapping relationship model, and obtaining the moisture content prediction value through forward propagation calculation; The water content prediction values ​​are combined with the food type and sample weight to generate the final real-time detection results.

6. The method according to claim 5, characterized in that The method further comprises: Comparing the obtained water content prediction value with the actual measured value to calculate the prediction error; The back propagation algorithm is combined with the prediction error to update the parameters of the mapping relationship model and dynamically optimize the mapping relationship model.

7. The method according to claim 1, characterized in that The standardized preprocessing is used to remove illumination interference, smooth noise and fuzzy areas to obtain first image data, including: Performing grayscale conversion on the food image data, and enhancing the image contrast using a histogram equalization algorithm to obtain an enhanced image; performing illumination compensation on the enhanced image using a retinal cortex theory algorithm to obtain an illumination compensated image; The illumination compensation image is processed using a bilateral filtering algorithm to smooth noise and blur areas to obtain a bilateral filtered image; The bilateral filtered image is normalized in size and format to obtain standardized first image data.

8. A device for calculating water content of food based on visual images, characterized in that: The device comprises: An image acquisition and processing module is used to obtain food image data, and use standardized preprocessing to remove light interference, smooth noise and fuzzy areas to obtain first image data; a feature extraction and optimization module, configured to extract surface gloss and texture feature values ​​from the first image data, segment and annotate key areas using a feature detection method, and obtain a visual feature set related to moisture content; further configured to analyze the correlation of the visual feature set to construct a feature vector matrix, distinguish food types using classification rules to determine feature weight distribution, and obtain an optimized feature description; The prediction model building module is used to establish a mapping relationship model between water content and visual features based on the optimized feature description, predict the water content of new input food images, and obtain real-time detection results.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Method and system for detecting water content of chicken manure based on hyperspectral imaging and image segmentation

    CN121483419A