Liquid volume prediction method, electronic device, and computer-readable storage medium
By generating a target weight map related to pixel gradients and combining it with a volume prediction model, the problem of balancing efficiency and accuracy in bottled wine liquid volume detection is solved, achieving efficient and high-precision liquid volume measurement.
Patent Information
- Application Number
- CN202511341871.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-19
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-09-19
AI Technical Summary
Existing technologies struggle to achieve both high efficiency and high accuracy in the detection of liquid volume in bottled wine. Traditional methods are either inefficient or lack sufficient precision, failing to meet the full inspection requirements of high-speed production lines.
By acquiring the original images of the container and its internal liquid, a target weight map with a positive correlation trend with the pixel value gradient is generated. Then, a pre-trained volume prediction model is used for non-contact detection to output the predicted liquid volume.
It significantly improves detection efficiency, meeting the real-time requirements of full inspection on the production line. At the same time, by focusing on key areas such as the bottle outline and liquid surface boundary, it effectively suppresses interference factors and improves the accuracy and stability of volume prediction.
Smart Images

Figure CN120833343B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a liquid volume prediction method, electronic device, and computer-readable storage medium. Background Technology
[0002] In the production of bottled wine, accurate measurement of liquid volume is a crucial step in ensuring product quality. Insufficient volume can lead to customer complaints, while overfilling reduces company profits. Therefore, precise control over the volume is of paramount importance.
[0003] Traditional methods for detecting the volume of bottled wine mainly include manual sampling and weighing, machine vision-based liquid level detection, and non-contact physical sensing methods (such as ultrasonic and microwave technologies). Manual sampling and weighing requires opening the bottle to take a sample, weighing it, and deducting the container weight to estimate the net weight of the wine, which is then converted into volume. This method is inefficient, with a sampling rate generally below 0.1%, making real-time monitoring and 100% inspection difficult. Machine vision methods photograph the bottle and identify the liquid level, then combine this with a pre-stored bottle geometry model to calculate the volume. It has the advantages of being non-contact and online, but is sensitive to bottle material, labeling, and lighting conditions. Non-contact physical methods, such as ultrasonic or microwave sensing, utilize the propagation characteristics of waves in different media to infer the liquid level height. They have a certain penetration capability, but are still affected by bottle wall structure, liquid composition, and external electromagnetic interference.
[0004] However, traditional methods for detecting the volume of bottled wine suffer from a trade-off between efficiency and accuracy. Specifically, if efficiency is prioritized (e.g., by using high-speed online vision or sensor scanning), the accuracy and stability of the measurement will inevitably be sacrificed due to factors such as bottle reflection, foam, bottle shape differences, and signal interference. If measurement precision is prioritized (e.g., by performing precise manual re-inspection or slowing down data acquisition), the efficiency cannot meet the full inspection requirements of high-speed production lines.
[0005] Therefore, improving the accuracy and efficiency of liquid volume detection in bottled wine has become an urgent technical problem to be solved. Summary of the Invention
[0006] The main objective of this application is to provide a liquid volume prediction method, electronic device, and computer-readable storage medium, aiming to solve the technical problem of how to improve the accuracy and efficiency of liquid volume detection in bottled wine.
[0007] To achieve the above objectives, this application provides a liquid volume prediction method, which includes:
[0008] Obtain the original image to be predicted, wherein the original image is an image containing the container and the liquid inside the container;
[0009] Generate a target weight map corresponding to the original image, wherein, at the same pixel position, the weights in the target weight map and the pixel value gradients in the original image show a positive correlation trend.
[0010] The target weight map and the original image are input into a pre-trained volume prediction model, and the predicted volume of liquid in the container is output.
[0011] In one embodiment, the step of generating the target weight map corresponding to the original image includes:
[0012] The original image is subjected to Fourier transform processing to obtain a frequency domain image;
[0013] The frequency domain graph is subjected to high-pass filtering to obtain a high-frequency component graph;
[0014] The high-frequency component map is subjected to inverse Fourier transform to obtain the edge intensity map;
[0015] A target weight map is generated based on the edge intensity map, wherein, at the same pixel location, the weight in the weight map and the pixel value in the edge intensity map show a positive correlation trend.
[0016] In one embodiment, the step of generating a target weight map based on the edge intensity map includes:
[0017] The edge intensity map is normalized to obtain an initial weight map;
[0018] The initial weighted graph is subjected to max pooling to obtain a pooled graph;
[0019] The target weight map is obtained by fusing the pooling graph and the weight map.
[0020] In one embodiment, the step of generating a target weight map based on the edge intensity map includes:
[0021] The edge intensity map is then normalized and pixel value amplified sequentially to obtain an initial weight map;
[0022] The initial weighted graph is subjected to max pooling to obtain a pooled graph;
[0023] The target weight map is obtained by fusing the pooling graph and the weight map.
[0024] In one embodiment, before the step of performing Fourier transform processing on the original image to obtain a frequency domain image, the method further includes:
[0025] The original image is subjected to median filtering to obtain a denoised image;
[0026] Obtain the grayscale histogram corresponding to the denoised image, and determine the grayscale threshold based on the grayscale histogram;
[0027] The pixel value of the target pixel in the denoised image is reset to a preset value to obtain the preprocessed original image, wherein the target pixel is the pixel in the denoised image whose grayscale pixel value is greater than the grayscale threshold;
[0028] Based on the preprocessed original image, the step of performing Fourier transform processing on the original image to obtain a frequency domain image is performed.
[0029] In one embodiment, the step of determining the grayscale threshold based on the grayscale histogram includes:
[0030] Identify a first gray value and a second gray value in the gray-scale histogram, wherein the first gray value is the gray value corresponding to the maximum number of pixels in the gray-scale histogram, and the second gray value is the gray value corresponding to the second largest number of pixels in the gray-scale histogram;
[0031] Select a grayscale threshold between the second grayscale value and the first grayscale value.
[0032] In one embodiment, before the step of inputting the target weight map and the original image into a pre-trained volume prediction model and outputting the volume of the liquid inside the container, the method further includes:
[0033] Obtain a training dataset and a volume prediction model to be trained, wherein the training dataset includes multiple training images and volume labels corresponding to each training image;
[0034] Generate a training weight map corresponding to each training image, and average the weights in each training weight map to obtain the average weight corresponding to each training image.
[0035] Each of the training images and each of the training weight maps are input into the volume prediction model to obtain the predicted volume corresponding to each of the training images;
[0036] Calculate the original loss value between the predicted volume and the volume label corresponding to each of the training images;
[0037] The weighted loss value is obtained by weighting and fusing the original loss values based on the average weights corresponding to each training image;
[0038] The volume prediction model is iteratively optimized based on the weighted loss value until the preset training termination condition is met, thus obtaining the trained volume prediction model.
[0039] In one embodiment, the step of obtaining the original image to be predicted includes:
[0040] X-rays are emitted from an X-ray source onto the container to be inspected;
[0041] The X-rays that have passed through the container are converted into visible light by a scintillator screen;
[0042] The visible light is focused onto the camera using a high-resolution detector optics assembly;
[0043] The camera captures the focused visible light to obtain the original image to be predicted.
[0044] In addition, to achieve the above objectives, this application also provides an electronic device, the electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the liquid volume prediction method as described above.
[0045] In addition, to achieve the above objectives, this application also provides a readable storage medium, which is a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps of the liquid volume prediction method as described above.
[0046] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the liquid volume prediction method described above.
[0047] One or more technical solutions proposed in this application have at least the following technical effects:
[0048] This application has found through research that high-frequency component regions, such as the outline edge of a container (e.g., a wine bottle) and the liquid surface boundary inside the container, are key locations that actually affect the accuracy of liquid volume measurement. These high-frequency component regions are often represented as areas with large pixel value gradients in images.
[0049] Based on the above findings, this application embodiment acquires original images of the container and its internal liquid, generates a target weight map with a positive correlation to the pixel value gradient, and then directly outputs the liquid volume using a trained volume prediction model. This effectively solves the technical challenge of balancing efficiency and accuracy in traditional detection methods. Specifically, by utilizing image information and the volume prediction model for non-contact high-speed detection, detection efficiency is significantly improved, meeting the real-time requirements of full inspection on the production line. Simultaneously, by constructing a weight map guided by pixel gradients, the model can adaptively focus on key areas such as the bottle outline and liquid surface boundary, effectively suppressing interference from factors such as bottle reflection, label patterns, foam, and bottle shape differences, greatly improving the accuracy and stability of volume prediction, thereby achieving high-precision liquid volume measurement. Thus, when using the liquid volume prediction method provided in this application embodiment to detect the liquid volume of bottled wine, a balance between high accuracy and high efficiency can be achieved, providing reliable technical support for lean quality control and metrological compliance on the production line. Attached Figure Description
[0050] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0051] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is a flowchart illustrating the first embodiment of the liquid volume prediction method of this application;
[0053] Figure 2 This is a schematic diagram of an X-ray imaging system involved in an embodiment of the liquid volume prediction method of this application;
[0054] Figure 3 This is a schematic diagram of the original image involved in an embodiment of the liquid volume prediction method of this application;
[0055] Figure 4 This is a schematic grayscale histogram of an embodiment of the liquid volume prediction method of this application.
[0056] Figure 5 This is a schematic diagram of a preprocessed image related to an embodiment of the liquid volume prediction method of this application;
[0057] Figure 6 This is a schematic diagram of the initial weighting graph involved in an embodiment of the liquid volume prediction method of this application;
[0058] Figure 7 This is a schematic diagram of the target weighting graph involved in an embodiment of the liquid volume prediction method of this application;
[0059] Figure 8 This is a schematic diagram of the prediction results for volume prediction using the original image;
[0060] Figure 9 This is a schematic diagram illustrating the prediction results of volume prediction for an image processed by pixel value resetting.
[0061] Figure 10 This is a schematic diagram of the volume prediction results using the volume prediction method of this application;
[0062] Figure 11 This is a schematic diagram of the hardware operating environment of the liquid volume prediction method device in the embodiments of this application.
[0063] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0064] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, 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.
[0065] The amount of bottled wine dispensed at the factory directly affects the quality of the product. Insufficient quantity can easily lead to customer complaints and unnecessary losses, while excessive quantity will affect the company's profits. In the face of fierce market competition, precise control of the wine quantity is crucial for achieving lean production and ensuring superior quality.
[0066] The mainstream methods for detecting the volume of bottled wine currently include manual sampling and weighing, machine vision level detection, and non-contact physical sensing methods (such as ultrasound and microwave). However, each of these methods has significant drawbacks. Manual sampling and weighing requires destructive sampling, relying on manual weighing to calculate net content. This is inefficient, with a sampling coverage rate typically less than 0.1%, making it difficult to reflect real-time fluctuations on the production line. Furthermore, it is prone to operational errors leading to inaccurate results, failing to meet the full inspection requirements of high-speed production lines. While machine vision level detection enables non-contact online detection, its accuracy and stability are affected by ambient light and label patterns when identifying transparent liquids, reflective glass bottles, dark-colored or irregularly shaped bottles. This is especially true in cases of foam or bottle wall adhesion, where level interpretation becomes more difficult. Additionally, this method cannot directly obtain volume and requires conversion based on bottle volume. While ultrasonic or microwave sensing methods can penetrate some packaging materials, ultrasonic signals are easily attenuated at multi-layered media interfaces and are sensitive to changes in bottle wall thickness and liquid composition. Microwave methods are easily interfered with by metal caps or labels. Both require high-precision calibration and have limited adaptability to complex bottle shapes. In summary, none of these liquid volume detection methods can achieve a balance between high accuracy and high efficiency.
[0067] Based on this, the main solution of this application is: to obtain the original image to be predicted, wherein the original image is an image containing a container and the liquid inside the container; to generate a target weight map corresponding to the original image, wherein at the same pixel position, the weight in the target weight map and the pixel value gradient in the original image are positively correlated; to input the target weight map and the original image into a pre-trained volume prediction model, and to output the prediction result of the liquid volume inside the container.
[0068] This application utilizes image information and a volume prediction model for non-contact, high-speed detection, significantly improving detection efficiency and meeting the real-time requirements of full-scale inspection on production lines. Simultaneously, by constructing a pixel gradient-guided weight map, the model adaptively focuses on key areas such as the bottle outline and liquid surface boundary, effectively suppressing interference from factors like bottle reflections, label patterns, foam, and bottle shape differences. This greatly improves the accuracy and stability of volume prediction, achieving high-precision liquid volume measurement. Therefore, when using the liquid volume prediction method provided in this application to detect the liquid volume of bottled wine, a balance between high accuracy and high efficiency can be achieved, providing reliable technical support for lean quality control and metrological compliance on the production line.
[0069] It should be noted that the execution subject of the liquid volume prediction method in this application can be a computing service device with data processing, network communication and program running functions, such as a server, tablet computer, personal computer, mobile phone, etc., or an electronic device that can realize the above functions. The embodiments of the liquid volume prediction method in this application do not impose specific limitations on this.
[0070] Based on this, this application proposes a liquid volume prediction method according to a first embodiment, referring to... Figure 1 As shown, the liquid volume prediction method includes the following steps S10~S30:
[0071] Step S10: Obtain the original image to be predicted, wherein the original image is an image containing the container and the liquid inside the container;
[0072] The original image is an image of the liquid volume to be predicted, which includes the container body and the liquid inside the container. The container can be made of various materials and shapes, including but not limited to glass bottles, plastic bottles, or irregularly shaped bottles; the liquid inside the container includes but is not limited to alcoholic beverages, soft drinks, edible oils, or other liquid foods and industrial liquids, etc. This embodiment does not limit the specific types of containers and liquids.
[0073] In one possible implementation, the step of acquiring the original image to be predicted includes:
[0074] Step S101: X-rays are emitted from an X-ray source onto the container to be inspected;
[0075] The X-ray source can be a microfocus pulsed X-ray source to provide sub-millimeter spatial resolution and accurately capture details while ensuring safety.
[0076] The X-ray source can emit X-rays at an angle perpendicular to the container surface, ensuring that the X-rays can penetrate the container uniformly and reducing image distortion and shadows caused by angular deviations.
[0077] Step S102: The X-rays passing through the container are converted into visible light by a scintillator screen;
[0078] The scintillator screen is installed between the container and the camera, maintaining a certain distance from the container to avoid the impact of X-ray scattering on image quality.
[0079] Step S103: Focus the visible light onto the camera using the high-resolution detector optical components;
[0080] The high-resolution detector's optical components may include multiple high-precision lenses and apertures for adjusting and focusing visible light. The lenses may be made of low-dispersion, high-transmittance optical materials, effectively reducing chromatic aberration and light attenuation.
[0081] The high-resolution detector's optical components can directly focus or magnify visible light onto the camera.
[0082] Step S104: The camera captures the focused visible light to obtain the original image to be predicted.
[0083] This camera can be a CCD (Charge-Coupled Device) camera, which receives and records a visible light image focused by optical components. The camera converts the light signal into a digital electrical signal, ultimately generating a high-contrast, high-resolution digital grayscale image, which is the original image to be predicted. This image visually reflects the internal structure and liquid level of the container, where differences in brightness correspond to differences in X-ray absorption rates of different parts of the object being detected.
[0084] Furthermore, after acquiring the original image, preprocessing operations can be performed on the image, such as grayscale conversion, filtering and denoising, and image enhancement, to suppress environmental noise, unify the image format, and highlight key features such as the container outline and liquid surface edge, providing a clearer and more stable image foundation for subsequent analysis.
[0085] Step S20: Generate a target weight map corresponding to the original image, wherein, at the same pixel position, the weights in the target weight map and the pixel value gradients in the original image are positively correlated.
[0086] A target weight map corresponding to the original image is generated. At the same pixel location, the weight of the target weight map at that pixel location is positively correlated with the pixel value gradient of the original image at that pixel location. That is, the larger the pixel value gradient, the higher the corresponding weight is usually. Finally, the weights of all pixels are combined into a target weight map with the same size as the original image. This target weight map can highlight the key regions in the image that have an important impact on liquid volume prediction, providing more valuable information for subsequent volume prediction models.
[0087] Pixel gradient refers to the rate of change of grayscale or color values between adjacent pixels in an image. It characterizes the intensity of local brightness variations or edge strength at a given pixel location. Mathematically, it is typically obtained by calculating the partial derivatives (or differences) of the image function in the horizontal and vertical directions. Its magnitude reflects the likelihood that the point belongs to a high-frequency feature such as an edge, contour, or texture. Regions with larger gradient values often correspond to high-frequency components that are crucial to volume, such as container boundaries or liquid level lines.
[0088] This positive correlation can be either strictly positive or approximately positive. Strictly positive correlation means there is a precise mathematical relationship between the weights and the pixel value gradient; for example, the weights and pixel value gradients have a linear or exponential relationship, and changes in the pixel value gradient cause the weights to change according to a fixed pattern. Approximately positive correlation means that overall, the weights increase as the pixel value gradient increases, but there may be local fluctuations or deviations.
[0089] Step S30: Input the target weight map and the original image into the pre-trained volume prediction model, and output the predicted volume of the liquid in the container.
[0090] After obtaining the target weight map, the target weight map and the original image are fed together as input into a pre-trained volume prediction model, which then outputs the predicted volume of liquid inside the container. This volume prediction model can be a deep learning model such as VGG16 (Visual Geometry Group 16) or U-Net (Convolutional Networks for Biomedical Image Segmentation). This embodiment does not impose specific limitations on this model. Trained with a large number of samples, this model can predict volume values based on the structural information highlighted in the weight map.
[0091] By using a dual-channel input of the original image and the target weight map, the model can simultaneously utilize the global contextual information of the original image and the key local features focused on by the weight map. The original image provides information on color, texture, and the overall environment, while the target weight map acts as an attention-guided mechanism, indicating high-frequency areas crucial for volume calculation, such as the container outline and liquid surface boundaries, causing the model to prioritize these high-value areas. This multi-source information fusion significantly enhances the model's feature extraction capabilities and judgment criteria: it avoids overfitting to irrelevant backgrounds or interfering textures (such as label patterns) in the original image, and effectively suppresses visual interference from bottle reflections, foam, liquid droplets clinging to the bottle walls, and complex bottle shapes, further improving prediction robustness.
[0092] Furthermore, considering that the container may not be a regular shape, calculating the liquid surface through modeling will introduce new errors. Based on this, the model in this embodiment directly establishes a mapping between the image and the volume of the wine, thereby enabling the wine volume to be obtained directly from the original image, which can avoid the error introduced by calculating the volume from the liquid surface.
[0093] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter. Based on this, the step of generating the target weight map corresponding to the original image includes:
[0094] Step A10: Perform Fourier transform processing on the original image to obtain a frequency domain image;
[0095] The Fourier transform is used to convert the original image from the spatial domain to the frequency domain. The Fourier transform decomposes the signal in an image into components of different frequencies, allowing for a clearer observation of the image's frequency distribution in the frequency domain. The frequency domain plot obtained through the Fourier transform clearly shows the distribution of different frequency components in the image, providing a foundation for subsequent high-pass filtering.
[0096] Step A20: Perform high-pass filtering on the frequency domain graph to obtain a high-frequency component graph;
[0097] A high-pass filter is applied to the frequency domain image to preserve high-frequency components while suppressing low-frequency components. High-frequency components typically correspond to areas with large pixel value gradients, such as edges, contours, and details, while low-frequency components mainly consist of the image background and large-scale smooth areas. High-pass filtering highlights high-frequency features, resulting in a high-frequency component map. The design of the high-pass filter can be adjusted according to specific needs to effectively extract high-frequency components.
[0098] Step A30: Perform inverse Fourier transform on the high-frequency component map to obtain the edge intensity map;
[0099] The high-frequency component map undergoes an inverse Fourier transform (IFT) to convert it back from the frequency domain to the spatial domain. The IFT restores the high-frequency components in the frequency domain to the spatial information of the image, yielding an edge intensity map. The pixel values in the edge intensity map reflect the edge intensity at each location in the image, i.e., the magnitude of the pixel value gradient. The edge intensity map clearly displays key features such as edges and contours in the image, providing crucial information for subsequent target weight map generation.
[0100] Step A40: Generate a target weight map based on the edge intensity map, wherein, at the same pixel location, the weight in the weight map and the pixel value in the edge intensity map show a positive correlation trend.
[0101] A target weight map is generated based on the pixel values in the edge intensity map. At the same pixel location, there is a positive correlation between the weight in the target weight map and the pixel value in the edge intensity map; that is, the greater the edge intensity, the higher the corresponding weight.
[0102] As a first implementation method, the target weight map can be obtained by normalizing the edge intensity map.
[0103] The purpose of normalizing the edge intensity map is to linearly transform its pixel values to a uniform, predefined range (usually [0,1]), eliminating absolute intensity differences caused by factors such as lighting conditions and imaging device variations, and ensuring the stability and consistency of subsequent processing. Specifically, a min-max normalization method can be used, which involves subtracting the minimum value of the entire image from the original value of each pixel, and then dividing by the difference between the maximum and minimum values. In the initial weight map obtained after normalization, the value of each pixel represents the relative salience of the edge intensity at that location; a higher value indicates a more prominent edge feature, providing standardized basic data for the subsequent generation of attention weights.
[0104] As a second implementation method, the edge intensity map can be normalized and pixel value amplified sequentially to obtain the target weight map.
[0105] The edge intensity map is normalized to adjust the pixel values in the edge intensity map to a uniform range, usually [0, 1].
[0106] Next, the normalized image undergoes pixel value magnification to further enhance the saliency of key volume prediction regions (such as container outlines and liquid surface boundaries). Pixel value magnification can be achieved through simple linear magnification (e.g., 1 + 4 * normalized value) or non-linear magnification, with the specific method chosen based on actual needs. This magnification process more sharply highlights high-frequency features such as edges and contours in the image, effectively suppresses interference from uniform regions, and better facilitates feature information that the model's attention can focus on.
[0107] As a third implementation, the step of generating a target weight map based on the edge intensity map includes:
[0108] Step B10: Normalize the edge intensity map to obtain an initial weight map;
[0109] Step B20: Perform max pooling on the initial weight graph to obtain a pooled graph;
[0110] Max pooling is performed on the initial weighted graph. This operation uses a sliding window of a predefined size (e.g., 5×5) and takes the maximum value in the window as the output, thereby generating the pooled graph.
[0111] Max pooling enhances the robustness of key features by aggregating local neighborhood information, preserving salient features such as strong edges while suppressing subtle noise or isolated erroneous responses. It also introduces a spatial diffusion effect, similar to the "dilation" operation in morphological processing, where high-weight (high-energy) edge regions in the original image extend their influence to surrounding areas. This means that not only are true edges preserved, but also neighboring regions that may belong to the same structure but have weaker responses are assigned higher values, thus more completely outlining continuous regions important for volume prediction (such as the entire edge of a bottle, not just sharp corners), while reducing image detail redundancy and model computational complexity.
[0112] Step B30: Merge the pooling graph and the weight graph to obtain the target weight graph.
[0113] The pooling map and the initial weight map are fused to generate the final target weight map. Fusion strategies can employ pixel-wise weighted summation, element-wise multiplication, or adaptive feature stitching. This fusion leverages the complementary advantages of both types of information: the pooling map provides a more stable and complete outline of key regions (high robustness), while the initial weight map preserves finer original edge details and high spatial resolution (high accuracy). The resulting target weight map more accurately and comprehensively highlights all key regions in the image that significantly influence liquid volume prediction (such as the container's outer wall and the liquid surface boundary), providing the volume prediction model with higher information density and stronger anti-interference capabilities.
[0114] It should be noted that by setting the kernel size and stride of the max pooling operation, the size of the pooling image and the initial weight image can be kept consistent, thus facilitating pixel-level fusion between the two. For example, setting the stride of the max pooling operation to 1 and selecting an appropriate padding method, such as padding='SAME', can maintain the output image size unchanged while achieving neighborhood feature aggregation.
[0115] As a fourth implementation, the step of generating a target weight map based on the edge intensity map includes:
[0116] Step C10: Normalize and amplify the pixel values of the edge intensity map sequentially to obtain the initial weight map;
[0117] Step C20: Perform max pooling on the initial weight graph to obtain a pooled graph;
[0118] Step C30: Merge the pooling graph and the weight graph to obtain the target weight graph.
[0119] By fusing the two types of information, the complementary advantages of each can be fully utilized: the pooling map provides a more stable and complete outline of key regions (high robustness), while the initial weight map preserves finer original edge details and high spatial resolution (high accuracy). The resulting target weight map can more accurately and comprehensively highlight all key regions in the image that have an important impact on liquid volume prediction (such as the outer wall of the container and the liquid surface boundary), providing the volume prediction model with input guidance that has higher information density and stronger anti-interference ability.
[0120] Based on the first and / or second embodiments of this application, in the third embodiment of this application, the content that is the same as or similar to the first and second embodiments described above can be referred to the above description and will not be repeated hereafter. Based on this, before the step of performing Fourier transform processing on the original image to obtain the frequency domain image, the method further includes:
[0121] Step D10: Perform median filtering on the original image to obtain a denoised image;
[0122] Median filtering is applied to the original image to remove noise. Median filtering is a non-linear filtering technique that removes noise by replacing the value of each pixel with the median value of its neighborhood. Specifically, a window (typically 3x3 or 5x5) is slid across the original image, the median value of the pixels within the window is calculated, and this median value is assigned to the pixel at the center of the window. Median filtering is effective at removing random noise such as salt-and-pepper noise, while also preserving image edges and details relatively well. The image obtained after median filtering is called a denoised image.
[0123] It should be noted that if the original image is not grayscale, it can be converted to grayscale, and this step is performed based on the grayscale converted original image.
[0124] Step D20: Obtain the grayscale histogram corresponding to the denoised image, and determine the grayscale threshold based on the grayscale histogram;
[0125] Obtain the grayscale histogram corresponding to the denoised image. This histogram is a statistical representation of the image's grayscale distribution, with the horizontal axis representing the grayscale level and the vertical axis representing the frequency (number of pixels) of the corresponding grayscale level. By analyzing the morphological characteristics of the grayscale histogram (such as whether it has bimodal, multimodal, or specific distributions), the separation ability between the foreground (target region) and background in the image can be quantitatively assessed. Therefore, an optimal grayscale threshold can be selected based on this histogram. For example, Otsu's method can be used, which automatically calculates the optimal threshold by maximizing the inter-class variance, effectively distinguishing between the background and target regions; or the threshold can be determined based on the valley position of the bimodal characteristic of the grayscale histogram.
[0126] Step D30: Reset the pixel value of the target pixel in the denoised image to a preset value to obtain the preprocessed original image, wherein the target pixel is the pixel in the denoised image whose grayscale pixel value is greater than the grayscale threshold;
[0127] Based on a determined grayscale threshold, pixel-level reconstruction is performed on the denoised image: all pixels in the denoised image with grayscale values greater than the threshold are identified and located, and these points are defined as target pixels (usually corresponding to bright background areas or regions of interest in the image). Subsequently, the grayscale values of all target pixels are uniformly reset to a preset constant value, such as 0, i.e., black. This operation significantly suppresses background interference and enhances the contrast between the container and liquid areas and the background, allowing subsequent processing algorithms to focus more on the target object. The image obtained after this pixel value reset operation is the preprocessed original image, which retains key structural information while having a better signal-to-noise ratio and more prominent target features.
[0128] Step D40: Based on the preprocessed original image, perform the Fourier transform process on the original image to obtain the frequency domain image.
[0129] Based on the preprocessed original image, a Fourier transform is performed. The Fourier transform converts the image from the spatial domain to the frequency domain, decomposing the signal in the image into components of different frequencies.
[0130] In one possible implementation, the step of determining the grayscale threshold based on the grayscale histogram includes:
[0131] Step E10: Identify the first gray value and the second gray value in the gray-scale histogram, wherein the first gray value is the gray value corresponding to the maximum number of pixels in the gray-scale histogram, and the second gray value is the gray value corresponding to the second largest number of pixels in the gray-scale histogram.
[0132] Peak analysis and feature recognition are performed on the grayscale histogram corresponding to the denoised image. The grayscale histogram represents the pixel distribution of each grayscale level in the image. By traversing and analyzing the statistical data of the grayscale histogram, the grayscale level with the global maximum number of pixels is located and defined as the first grayscale value. This peak usually corresponds to the most widely distributed area in the image, such as the background under uniform lighting. Subsequently, the grayscale level with the second largest number of pixels in the grayscale histogram is identified and defined as the second grayscale value. The first and second grayscale values together indicate the two most important grayscale distribution areas in the image, such as the background area and the target container area, respectively, providing a key basis for subsequent adaptive thresholding segmentation.
[0133] Step E20: Select a grayscale threshold between the second grayscale value and the first grayscale value.
[0134] Based on the identified first and second grayscale values, an optimal grayscale threshold is selected within the interval formed by the two. Specifically, the threshold selection strategy can be implemented according to any of the following methods:
[0135] Valley location method: If there is a clear valley between the first gray value and the second gray value in the gray histogram, the gray value corresponding to the valley is directly selected as the threshold to achieve the best separation of the two types of regions.
[0136] Weighted selection method: If the grayscale histogram distribution is relatively flat and there are no obvious troughs, the weighted calculation can be performed based on the ratio of the number of pixels corresponding to the two peaks, so that the threshold is more inclined to the side with fewer pixels, thereby optimizing the segmentation effect.
[0137] The grayscale threshold selected by the above method can effectively segment the image into foreground (target area) and background, or distinguish object areas with different salience, providing an accurate segmentation basis for subsequent pixel value resetting.
[0138] Based on the first, second, and / or third embodiments of this application, in the fourth embodiment of this application, the content that is the same as or similar to the above-described embodiments one, two, and three can be referred to the above description and will not be repeated hereafter. Furthermore, before the step of inputting the target weight map and the original image into a pre-trained volume prediction model and outputting the volume of the liquid in the container, the method further includes:
[0139] Step F10: Obtain the training dataset and the volume prediction model to be trained, wherein the training dataset includes multiple training images and volume labels corresponding to each training image;
[0140] Step F20: Generate a training weight map corresponding to each training image, and average the weights in each training weight map to obtain the average weight corresponding to each training image.
[0141] For each training image, a corresponding training weight map is generated using the same method as in step S20. These weight maps highlight key regions in the training image that significantly influence liquid volume prediction. Next, the average weight of each training weight map is calculated by averaging all weight values. A higher average weight indicates richer and clearer key features such as edges and contours in the training image.
[0142] Step F30: Input each of the training images and each of the training weight maps into the volume prediction model to obtain the predicted volume corresponding to each of the training images;
[0143] Each training image and its corresponding training weight map are input into the volume prediction model. The model extracts and maps learned features to output the predicted liquid volume for each training image.
[0144] Step F40: Calculate the original loss value between the predicted volume and the volume label corresponding to each training image;
[0145] A suitable loss function, such as Mean Absolute Error (MAE) or Mean Squared Error (MSE), can be used to calculate the difference between the predicted volume and the true volume label of each training sample. This difference value is the original loss value for that sample. This value directly reflects the model's prediction error for that sample under the current training state.
[0146] Step F50: Based on the average weights corresponding to each training image, the original loss values are weighted and fused to obtain a weighted loss value;
[0147] The calculated average weights of each training image are used as weighting coefficients for the corresponding original loss values. A weighted average of the original losses for all samples is then applied to obtain the final weighted loss value used for updating the model parameters in this round. The calculation formula can be expressed as:
[0148]
[0149] Among them, L i The original loss is the loss corresponding to the i-th training image. The average weight is set to N, where N is the total number of training images. This step assigns a larger weight to training samples with more significant features and higher quality in the loss function, thereby guiding the model to prioritize learning the features of these "high-quality" samples, accelerating convergence and improving generalization ability.
[0150] Step F60: Iteratively optimize the volume prediction model based on the weighted loss value until the preset training termination condition is met, and obtain the trained volume prediction model.
[0151] Using a weighted loss value as the optimization objective, the parameters of the volume prediction model can be iteratively optimized using the backpropagation algorithm. In each iteration, the model parameters are updated based on the gradient of the weighted loss value, gradually reducing the model's prediction error. The training process continues until preset training termination conditions are met, such as reaching the maximum number of iterations, the loss value converging to a certain range, or performance on the validation set no longer improving. Finally, a trained volume prediction model is obtained, which can achieve image-based liquid volume prediction.
[0152] For example, to help understand the technical concept or principle of the liquid volume prediction method after combining this embodiment with the first, second, and third embodiments described above, a specific embodiment is now listed. In this specific embodiment, the liquid volume prediction process includes:
[0153] I. Reference Figure 2 As shown, in an X-ray imaging system based on a scintillator screen, high-resolution detector optics, and a CCD camera, the container to be inspected (such as an opaque bottle like a wine bottle) is transported to the inspection area via a conveyor belt. An X-ray source emits X-rays from one side, which penetrate the bottle. Based on the difference in X-ray absorption between the bottle's material and the internal liquid, a projected image reflecting the internal structure is formed. Subsequently, the X-rays are converted into visible light by the scintillator screen on the other side, then focused and magnified by a high-resolution optical lens, and finally captured as a digital image by the CCD camera, thus obtaining the original image to be predicted. The original image obtained in this specific embodiment is shown below. Figure 3 As shown, it includes a wine bottle, the wine inside the bottle, and the air in the portion of the bottle that is not full of wine.
[0154] 2. Preprocessing the original image. Specifically, median filtering is used to denoise the obtained original image to obtain a denoised image. Then, the gray-level histogram corresponding to the denoised image is obtained. In this specific embodiment, the obtained gray-level histogram is as follows: Figure 4 As shown, Figure 4 The horizontal axis represents the grayscale value, and the vertical axis represents the number of pixels.
[0155] Third, select a threshold based on the image's grayscale histogram, and set the pixel values above the threshold to zero. This achieves the goal of setting the pixel values of the background and the air in the bottle to zero, while retaining the pixel value information related to the bottle and liquid, resulting in the following: Figure 5 The image shown is the preprocessed image.
[0156] Fourth, scale the preprocessed image to a certain size, such as 224×224, and then perform Fourier transform, high-pass filtering, inverse Fourier transform, and normalization on the preprocessed image in sequence to obtain the following result: Figure 6 The initial weight map is shown.
[0157] V. Neighborhood Analysis: Max Pooling is applied to the initial weight graph with a window size of ksize=5, strides=1, and padding='SAME' to obtain a pooled graph. The initial weight graph and the pooled graph are then merged to obtain the following: Figure 7 The target weight graph is shown. In this specific implementation, the target weight graph = 1 + 4 * initial weight graph + 2 * pooling graph.
[0158] 6. Using a dual-channel structure, the scaled-up original image and the target weight map are input into the pre-trained volume prediction model, and the volume prediction result is output.
[0159] It should be noted that the above examples are only used to help understand this embodiment and do not constitute a limitation on the liquid volume prediction process of this embodiment. Any simple modifications based on this technical concept are within the protection scope of this application.
[0160] Based on the first, second, third, and / or fourth embodiments of this application, a fifth embodiment of this application is proposed, in which the prediction accuracy and efficiency of the liquid volume prediction method in this application are tested through experiments.
[0161] A. After applying median filtering to the training image, the image is directly scaled to 224×224 pixels. The scaled image is then fed into the convolutional neural network (CNN) model for training, resulting in a trained CNN model. Similarly, during prediction, the original image is median filtered, scaled to 224×224 pixels, and then input into the pre-trained CNN model. The prediction result is as follows. Figure 8 As shown in the figure, the horizontal axis represents the actual volume, the vertical axis represents the predicted volume, and the average deviation of the prediction results is 86.54 ml.
[0162] B. After applying median filtering to the training image, the image undergoes thresholding to reset pixel values, and then it is scaled to 224×224 pixels. The scaled image is then fed into the convolutional neural network model for training, resulting in a trained convolutional neural network model. Similarly, during prediction, the original image is median filtered, thresholded to reset pixel values, scaled to 224×224 pixels, and then input into the pre-trained convolutional neural network model. The prediction result is as follows. Figure 9 As shown in the figure, the horizontal axis represents the actual volume, the vertical axis represents the predicted volume, and the average deviation of the prediction results is 9.05 ml.
[0163] C. After median filtering of the training image, the image undergoes thresholding to reset pixel values, and then it is scaled to 224×224. The scaled image is then subjected to Fourier transform, high-pass filtering, inverse Fourier transform, normalization (to obtain the initial weight map), max pooling (to obtain the pooling map), and fusion of the initial weight map and the pooling map to obtain the target weight map. The scaled image and the target weight map are then fed into the convolutional neural network model for training, resulting in a trained convolutional neural network model. Similarly, during prediction, the scaled original image and the corresponding target weight map are input into the pre-trained convolutional neural network model, and the prediction results are as follows. Figure 10 As shown in the figure, the horizontal axis represents the actual volume, the vertical axis represents the predicted volume, and the average deviation of the prediction results is 7.97 ml.
[0164] The above comparison shows that the liquid volume prediction method in this application embodiment, namely method C, has high prediction accuracy.
[0165] Furthermore, the liquid volume prediction method in this application embodiment can perform real-time analysis and prediction at a rate exceeding 15,000 bottles / hour, exhibiting high prediction efficiency.
[0166] Furthermore, embodiments of this application also propose an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the liquid volume prediction method as described above.
[0167] refer to Figure 11 The diagram illustrates a structural schematic of an electronic device suitable for implementing the embodiments of this application. The electronic devices in the embodiments of this application may also include, but are not limited to, mobile terminals such as mobile phones, servers, laptops, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 11 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0168] like Figure 11As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. While electronic devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0169] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0170] The electronic device provided in this application, employing the liquid volume prediction method described in the above embodiments, can solve the technical problem of how to improve the accuracy and efficiency of liquid volume detection in bottled wine. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the liquid volume prediction method provided in the above embodiments, and other technical features of the electronic device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0171] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0172] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0173] In addition, to achieve the above objectives, this application also provides a readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the liquid volume prediction method in the above embodiments.
[0174] The computer-readable storage medium provided in this application embodiment may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0175] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.
[0176] The aforementioned computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquire an original image to be predicted, wherein the original image is an image containing a container and liquid within the container; generate a target weight map corresponding to the original image, wherein, at the same pixel location, the weights in the target weight map and the pixel value gradient in the original image are positively correlated; input the target weight map and the original image into a pre-trained volume prediction model, and output a prediction result of the liquid volume within the container.
[0177] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0178] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0179] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the modules themselves.
[0180] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described liquid volume prediction method, thereby solving the technical problem of how to improve the accuracy and efficiency of bottled wine liquid volume detection. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the liquid volume prediction method provided in the above embodiments, and will not be repeated here.
[0181] Furthermore, embodiments of this application also propose a computer program product, including a computer program that, when executed by a processor, implements the steps of the liquid volume prediction method as described above.
[0182] The specific implementation of the computer program product in this application is basically the same as the embodiments of the liquid volume prediction method described above, and will not be repeated here.
[0183] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0184] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0185] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software sensor. This computer software sensor is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause an electronic device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0186] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method of liquid volume prediction, characterized by, The liquid volume prediction method comprises the following steps: Obtain a training data set and a volume prediction model to be trained, wherein the training data set comprises a plurality of training images and volume labels corresponding to each training image; Generate a training weight map corresponding to each training image, and average the weights in each training weight map to obtain an average weight corresponding to each training image; Input each training image and each training weight map into the volume prediction model to obtain a predicted volume corresponding to each training image; Calculate the original loss value between the predicted volume and the volume label corresponding to each training image; Weightedly fuse each original loss value based on the average weight corresponding to each training image to obtain a weighted loss value; Iteratively optimize the volume prediction model based on the weighted loss value until a preset training end condition is met, and obtain the trained volume prediction model; Obtain an original image to be predicted, wherein the original image is an image containing a container and liquid in the container; Generate a target weight map corresponding to the original image, wherein the weight in the target weight map and the pixel value gradient in the original image at the same pixel position have a positive correlation trend; Input the target weight map and the original image into the pre-trained volume prediction model to output a prediction result of the liquid volume in the container.
2. The liquid volume prediction method of claim 1, wherein, The step of generating a target weight map corresponding to the original image comprises: Perform Fourier transform processing on the original image to obtain a frequency domain image; Perform high-pass filtering processing on the frequency domain image to obtain a high-frequency component image; Perform inverse Fourier transform processing on the high-frequency component image to obtain an edge intensity image; Generate a target weight map based on the edge intensity image, wherein the weight in the weight map and the pixel value in the edge intensity image at the same pixel position have a positive correlation trend.
3. The liquid volume prediction method of claim 2, wherein, The step of generating a target weight map based on the edge intensity image comprises: Perform normalization processing on the edge intensity image to obtain an initial weight map; Perform maximum pooling operation processing on the initial weight map to obtain a pooling image; Fuse the pooling image and the weight map to obtain a target weight map.
4. The liquid volume prediction method of claim 2, wherein, The step of generating a target weight map based on the edge intensity image comprises: Perform normalization and pixel value amplification processing on the edge intensity image in sequence to obtain an initial weight map; Perform maximum pooling operation processing on the initial weight map to obtain a pooling image; Fuse the pooling image and the weight map to obtain a target weight map.
5. The liquid volume prediction method of claim 2, wherein, Before the step of performing Fourier transform processing on the original image to obtain a frequency domain image, the method further comprises: Perform median filtering processing on the original image to obtain a denoised image; Obtain a gray scale histogram corresponding to the denoised image, and determine a gray scale threshold based on the gray scale histogram; Reset the pixel value of a target pixel point in the denoised image to a preset value to obtain a preprocessed original image, wherein the target pixel point is a pixel point in the denoised image whose gray scale pixel value is greater than the gray scale threshold; The step of performing the Fourier transform on the original image to obtain a frequency domain image is based on the preprocessed original image.
6. The liquid volume prediction method of claim 5, wherein, The step of determining a grayscale threshold based on the grayscale histogram comprises: identifying a first grayscale value and a second grayscale value in the grayscale histogram, wherein the first grayscale value is a grayscale value corresponding to the maximum number of pixels in the grayscale histogram, and the second grayscale value is a grayscale value corresponding to the second largest number of pixels in the grayscale histogram; selecting a grayscale threshold between the second grayscale value and the first grayscale value.
7. The liquid volume prediction method according to any one of claims 1 to 6, wherein, The step of obtaining the original image to be predicted comprises: emitting X-rays from an X-ray source to a container to be detected; converting the X-rays that have passed through the container into visible light through a scintillator screen; focusing the visible light to a camera through a high-resolution detector optical assembly; capturing the focused visible light through the camera to obtain the original image to be predicted.
8. An electronic device, comprising: comprise: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the liquid volume prediction method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a liquid volume prediction program, and the liquid volume prediction program, when executed by a processor, implements the steps of the liquid volume prediction method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Face image processing method and device, electronic device and storage medium
CN110689500A