Liquid column layering feature accurate positioning method based on multi-color space fusion

By employing a precise positioning method based on the layered features of liquid columns through multi-color space fusion, the problems of strong hardware dependence and insufficient adaptability are solved, enabling high-precision and robust measurement of transparent column liquids, applicable to fields such as petroleum product analysis, chemical experiments, and medical testing.

CN121837048APending Publication Date: 2026-04-10CHINA JILIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-12
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies for measuring layered liquids within transparent cylinders suffer from problems such as strong hardware dependence, limited pixel calibration methods, single image processing strategies, and insufficient adaptability, resulting in insufficient measurement accuracy and stability, making it difficult to meet the automation needs of modern industry and scientific research.

Method used

A precise positioning method based on liquid column layering features using multi-color space fusion is adopted. The pixel calibration relationship is established by identifying the scale lines in the image. The optimal color spaces such as YCrCb, HLS, and HSV, as well as image enhancement methods, are used to achieve pure image measurement, reduce hardware dependence, and improve positioning accuracy and robustness.

Benefits of technology

It achieves pure image measurement without motion control hardware, improves positioning accuracy by 35% to 50%, significantly enhances robustness, adapts to different lighting and environmental changes, improves the repeatability and traceability of measurement results, and is suitable for various transparent cylindrical liquid measurement scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121837048A_ABST
    Figure CN121837048A_ABST
Patent Text Reader

Abstract

The invention discloses a liquid column layering feature accurate positioning method based on multi-color space fusion. According to the method, an image containing a transparent liquid column, liquid column layering features and a ruler is obtained, target liquid column extraction, liquid column inclination correction, pixel calibration based on the ruler, multi-target area coarse positioning and accurate positioning based on multi-color space fusion are carried out in sequence, and finally the target position is calculated through double-image coordinate simultaneous operation and target feature selection. For targets with different color features, optimal color space conversion such as YCrCb, HLS, HSV and the like and corresponding image enhancement methods are adopted, and accurate positioning is realized by combining adaptive target detection and a continuity verification algorithm. According to the method, motion control hardware and a precise displacement measurement device are not needed, pixel calibration is established by recognizing the scale lines in the image, and pure image measurement is achieved. The method has good robustness under different conditions, and can be widely applied to transparent liquid column measurement in the fields of petrochemical engineering, medical examination, chemical analysis and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of image processing and computer vision technology, specifically to a method for precise localization of liquid column layering features based on multi-color space fusion. Background Technology

[0002] Precise measurement of layered liquids within transparent columns has significant applications in petrochemicals, medical testing, and chemical analysis. For example, hydrocarbon component analysis of petroleum products requires measuring the positions of various color rings within the adsorption column to calculate the content of aromatics, alkenes, and saturated hydrocarbons; blood testing requires measuring the thickness of different liquid layers such as serum and plasma within centrifuge tubes; and chemical reaction monitoring requires real-time measurement of changes in the reactant interfaces within test tubes. Traditional manual visual reading methods suffer from high subjectivity, low efficiency, and poor repeatability, making it difficult to meet the requirements of modern industry and scientific research for measurement accuracy and automation. Existing technologies typically use industrial cameras to acquire images of the liquid column, and image processing algorithms to identify target locations and calculate target feature heights. However, existing methods face the following technical bottlenecks:

[0003] (1) Hardware dependence leads to high costs. In addition, the calibration and standardization process of hardware equipment is cumbersome and requires high technical skills from operators. Existing methods generally use motion control mechanisms to drive the camera to move in order to expand the measurement range, and rely on hardware equipment such as grating rulers and encoders to measure displacement to establish the coordinate mapping relationship between two images. Such solutions have high hardware costs, complex systems, and difficult maintenance. Moreover, mechanical wear will cause the measurement accuracy to gradually decrease, which limits the promotion and application of the technology.

[0004] (2) Insufficient robustness of image processing algorithms. Existing methods typically employ a single color space combined with simple threshold segmentation in the target localization stage. The distinguishability of targets with different color features varies greatly in the same color space, and a single color space is difficult to simultaneously take into account the feature representation of multiple targets; fixed threshold or single adaptive threshold methods are highly sensitive to factors such as changes in illumination, differences in liquid transparency, and background interference, resulting in insufficient localization accuracy and stability in complex environments.

[0005] (3) The coordinate calibration method has great limitations. The existing methods mainly rely on the displacement provided by the hardware displacement measurement device to establish the mapping relationship between pixel coordinates and physical coordinates. There is a lack of effective means to perform pixel calibration based on the image's own features. This means that when the hardware equipment fails, the displacement measurement is inaccurate, or independent image analysis is required, it is impossible to establish a reliable coordinate mapping relationship, which affects the accuracy and traceability of the measurement results.

[0006] (4) Insufficient adaptability and versatility. The processing parameters of existing methods are often manually set for specific application scenarios. When faced with different samples and different lighting conditions, the parameters need to be readjusted, resulting in low automation. This not only increases the difficulty of use, but also limits the promotion and application of the method in different fields and scenarios.

[0007] Therefore, there is an urgent need to develop a precise positioning method for liquid column layering features that is hardware-independent, performs pixel calibration based on image features, adopts a multi-color space fusion strategy to improve positioning accuracy, has adaptive processing capabilities, and good versatility. Summary of the Invention

[0008] This invention addresses the problems of strong hardware dependence, limited pixel calibration methods, single image processing strategies, and insufficient adaptability in existing technologies by providing a precise positioning method for liquid column layering features based on multi-color space fusion. This method is entirely based on image processing algorithms, requiring no motion control hardware or precision displacement measurement devices. It establishes pixel calibration relationships by identifying scale lines in the image, achieving pure image measurement. By selecting the optimal color space and enhancement strategy for targets with different color features, it significantly improves positioning accuracy and robustness, and can be widely applied to various transparent cylindrical liquid measurement scenarios.

[0009] To achieve the above objectives, the present invention adopts the following technical solution: a method for precise localization of liquid column layering features based on multi-color space fusion, comprising the following steps:

[0010] S1: Acquire dual images of the liquid column

[0011] A first image is acquired in a first position state, and a second image is acquired in a second position state, resulting in dual images. Both the first and second images include the transparent cylinder and its internal layered liquid, as well as a scale for calibration reference. The first and second position states refer to different relative positions of the camera or the transparent cylinder, which can be achieved by moving the camera or the transparent cylinder. Preferably, there is a certain overlap between the two images to ensure that all targets are completely covered and to facilitate subsequent coordinate establishment.

[0012] S2: Liquid column tilt correction

[0013] The first image and the second image are respectively subjected to target transparent cylinder detection and tilt correction to obtain a first corrected image and a second corrected image; the tilt correction includes: detecting the edge contour of the transparent cylinder, calculating the tilt angle of the cylinder's central axis relative to the vertical direction of the image, and performing a rotation transformation on the image so that the cylinder's central axis is parallel to the vertical direction of the image.

[0014] S3: Scale-based pixel calibration

[0015] The first and second corrected images are respectively identified by scale, scale line and scale value, the pixel coordinates of the upper scale line and the corresponding actual scale value, the pixel coordinates of the lower scale line and the corresponding actual scale value, and the first pixel equivalent of the first corrected image and the second pixel equivalent of the second corrected image are calculated.

[0016] The formula for calculating the first pixel equivalent is: K1 = (V up1 - V down1 ) × 10 / (Y down1 - Y up1 )

[0017] The formula for calculating the second pixel equivalent is: K2 = (V up2 - V down2 ) × 10 / (Y down2 - Y up2 )

[0018] Where K1 is the first pixel equivalent, in mm / pixel; K2 is the second pixel equivalent, in mm / pixel; V up1 V down1 These are the actual scale values ​​of the upper and lower scale lines in the first calibration image, respectively, in cm; Y up1 Y down1 These are the pixel Y-coordinates of the upper and lower scale lines in the first corrected image, respectively, in pixels; V up2 V down2 These are the actual scale values ​​of the upper and lower scale lines in the second calibration image, respectively, in cm; Y up2 Y down2 These are the pixel Y coordinates of the upper and lower scale lines in the second corrected image, respectively, in pixels;

[0019] S4: Coarse localization of multi-target feature regions

[0020] A sliding window detection strategy is used to coarsely locate the target transparent cylinders in the first and second corrected images, respectively, detecting multiple target feature regions. These target feature regions include, but are not limited to, a first color ring region, a second color ring region, a third color ring region, and a liquid front region. The purpose of coarse localization is to quickly determine the approximate location and range of each target, providing processing area for subsequent precise localization, reducing computational load, and improving processing efficiency. For different application scenarios, the type and number of target feature regions can be adjusted according to actual needs.

[0021] S5: Precise positioning of liquid column layering features based on multi-color space fusion

[0022] For each target feature region coarsely located, perform color space-based optimal selection transformation, image enhancement processing, binarization, and morphological operations to achieve precise localization of the liquid column layered target features:

[0023] For the first color wheel region: YCrCb color space conversion is performed and the Cr channel is extracted. Gamma correction, adaptive histogram equalization, and sharpening enhancement are then performed sequentially. Binarization and morphological operations are then performed. A top-down line-by-line scanning method is adopted, combined with adaptive target color detection and continuity verification algorithms, to determine the pixel coordinates of the topmost pixel in the first color wheel. The Cr channel in the YCrCb color space is sensitive to red features. Gamma correction is used to adjust the image brightness distribution. Adaptive histogram equalization enhances local contrast, and sharpening enhances edge features. The top-down scanning method is used because it is usually necessary to detect the upper position of the color wheel.

[0024] For the second color wheel region: HLS color space conversion is performed and the S channel is extracted. Adaptive histogram equalization and Gaussian blur processing are then performed sequentially, followed by binarization and morphological operations. A bottom-up line-by-line scanning method is adopted, combined with adaptive target color detection and continuity verification algorithms, to determine the pixel coordinates of the first brightest point of the second color wheel. The S (saturation) channel of the HLS color space is sensitive to the vividness of the color and is suitable for detecting color wheels with high saturation. Gaussian blur is used to smooth noise. The bottom-up scanning method is used because it is necessary to detect the bright position where the color wheel first appears.

[0025] For the third color wheel region: HSV color space conversion is performed, the S channel is extracted, saturation enhancement is applied, and the regions are merged back to the BGR color space. Then, YCrCb color space conversion is performed, and the Cb channel is extracted. Binarization and morphological operations are then performed. A bottom-up line-by-line scanning method is adopted, combined with adaptive target color detection and continuity verification algorithms, to determine the pixel coordinates of the first brightest point in the third color wheel. The Cb channel of YCrCb is sensitive to the blue-yellow direction, making it suitable for detecting yellow-green features. Combining it with saturation enhancement in the HSV space can better extract composite color features such as yellow-green.

[0026] For the liquid front region: after grayscale and contrast enhancement processing, binarization and morphological operations are performed. A bottom-up line-by-line scanning method is adopted, combined with adaptive target detection and continuity verification algorithms, to determine the pixel coordinates at the abrupt change in the liquid front.

[0027] S6: Dual Image Coordinate System and Target Feature Selection

[0028] Based on the pixel coordinates of each target in the first and second corrected images, and combined with the corresponding pixel equivalents, the actual physical coordinates of the targets in each image are calculated respectively. For targets that appear in both images, a priority selection strategy is adopted. For targets that appear only in a single image, the target feature pixel coordinates in that image are directly used. Thus, the positions of the top of the first color ring, the first brightest point of the second color ring, the first brightest point of the third color ring, and the abrupt change at the liquid front are obtained in the unified physical world coordinate system.

[0029] Preferably, the liquid column tilt correction in step S2 employs a multi-method fusion edge detection algorithm, specifically including:

[0030] S21: Use the trained deep learning detection model to locate the target transparent cylinder in the image. When a single transparent cylinder is detected, directly select the cylinder as the target transparent cylinder. When multiple transparent cylinders are detected, calculate the distance between the X coordinate of the center of each cylinder and the X coordinate of the center of the image, select the cylinder with the smallest distance as the target transparent cylinder, obtain the bounding rectangle region of the target transparent cylinder and expand it into the full height region of the image.

[0031] S22: The columnar region is grayscaled, contrast enhancement is performed using contrast-limited adaptive histogram equalization, and then filtering and noise reduction are performed.

[0032] S23: The edge of the cylinder is extracted by combining multiple binarization methods. Multiple binary images are obtained by using adaptive thresholding and fixed thresholding methods respectively. The final binary image is obtained by fusion through logical operations. After performing morphological operations on the final binary image, the edge contour of the cylinder is extracted by contour detection algorithm.

[0033] S24: Perform edge detection on the binary image, then use Hough transform to detect straight lines, filter out valid straight lines with a length greater than a preset threshold, find the longest straight line as the main line, filter out similar straight lines with an angle difference less than a preset angle threshold from all valid straight lines, calculate the weighted average of the angles of the similar straight lines, with the weight being the square of the line length, and obtain the tilt angle of the column edge line.

[0034] S25: Perform rotation correction on the image based on the tilt angle, calculate the size of the bounding box after rotation, adjust the translation component of the rotation matrix to keep the image centered, use affine transformation for rotation, and if the image height increases after rotation, crop to restore the original height so that the cylinder is strictly vertical in the image.

[0035] Preferably, the scale lines and scale value recognition in step S3 employs a deep learning-based method for target detection and recognition, specifically including:

[0036] S31: Use a trained deep learning detection model to detect the image, identify the integer value scale line labels, and obtain the pixel coordinates of the scale line labels;

[0037] S32: Filter all detection boxes from the detection results and sort them by Y coordinate. Select the detection box with the smallest Y coordinate as the upper scale line and the detection box with the largest Y coordinate as the lower scale line. Read the corresponding actual scale value and center Y coordinate respectively.

[0038] S33: Based on the difference between the pixel coordinates of the scale lines read above and the difference between the actual scale values, calculate the pixel equivalent of the image and establish a direct mapping relationship between pixel coordinates and actual physical world coordinates.

[0039] Preferably, the coarse localization of the multi-target region in step S4 employs a sliding window detection strategy, specifically including:

[0040] S41: Set the cropping height and overlap height parameters, calculate the effective height as the cropping height minus the overlap height, calculate the number of cropping blocks based on the image height and effective height, and divide the large-sized corrected cylindrical image into multiple overlapping cropping image blocks along the vertical direction.

[0041] S42: For each cropped image patch, multiple trained deep learning detection models are used to detect the target. The multiple detection models are used to detect the first color ring, the second color ring, the third color ring, and the liquid front, respectively. Each model is set with a different confidence threshold.

[0042] S43: Map the detection result coordinates in each cropped image block back to the corresponding calibration image coordinate system. The Y coordinate of the detection box in the calibration image is equal to the Y coordinate in the cropped block plus the initial Y coordinate offset of the cropped block.

[0043] S44: Perform non-maximum suppression deduplication on the detection results of each category, set the IoU threshold, sort all detection boxes of the same category in descending order of confidence, and retain the detection boxes with the highest confidence and whose IoU with the retained boxes is less than the threshold to obtain the final target region of interest.

[0044] Preferably, the adaptive target detection algorithm and continuity verification algorithm in step S5 are:

[0045] The adaptive target detection algorithm performs a statistical analysis of the proportion of black and white pixels in the first row of the image after binarization and morphological operations, defining the pixel type with the high proportion as background pixels and the pixel type with the low proportion as target pixels.

[0046] The continuity verification algorithm sets a target pixel threshold and a consecutive valid row count threshold. During the row-by-row scanning process, when the proportion of target pixels in multiple consecutive rows exceeds the target pixel threshold, it is determined to be a valid target position.

[0047] Preferably, in step S6, for targets appearing in both images, the preferred selection strategy is as follows:

[0048] The detection confidence, region integrity, and image sharpness of the target are compared in the first and second corrected images. The target feature in the image with the best overall evaluation is selected as the final physical coordinates of the target. The region integrity is evaluated by determining whether the target feature is cropped by the image boundary. The image sharpness is evaluated by calculating the gradient magnitude or Laplacian variance of the target region.

[0049] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of any of the methods described above.

[0050] Compared with the prior art, the present invention has the following beneficial effects:

[0051] (1) This invention is based entirely on image processing algorithms and does not require hardware devices such as motion control mechanisms, grating rulers, and encoders. This reduces system costs, simplifies system structure, improves system reliability, and eliminates the problem of decreased accuracy due to mechanical wear.

[0052] (2) This invention calculates pixel equivalents by identifying scale lines in images and establishes a direct mapping relationship between pixel coordinates and physical world coordinates. It does not require external hardware measurement devices and realizes pure image measurement, which improves the independence and traceability of measurement.

[0053] (3) The present invention adopts the optimal color space such as YCrCb, HLS and HSV and corresponding image enhancement methods for targets with different color characteristics, and realizes multi-color space fusion positioning. Compared with the single color space method, the positioning accuracy is improved by 35% to 50%, and the robustness is significantly enhanced.

[0054] (4) The adaptive target color detection algorithm and continuity verification algorithm of the present invention can automatically adapt to different image contrast conditions and noise levels without manual parameter adjustment, thereby improving the repeatability and reproducibility of measurement results. Under conditions of ±30% change in excitation illumination, ±40% change in ambient illuminance, and ±30% change in sample concentration, the positioning error remains within ±0.2mm.

[0055] (5) This invention has good versatility and scalability, and can be applied to transparent column liquid measurement tasks in multiple fields such as petroleum product analysis, chemical experiments, medical testing, and industrial quality inspection. It is suitable for columns of different sizes, different types of scales, and different quantities and colors of target layers. Attached Figure Description

[0056] Figure 1 This is an overall flowchart of the method of the present invention;

[0057] Figure 2 This is a schematic diagram illustrating the principle of liquid column tilt correction in this invention.

[0058] Figure 3 This is a schematic diagram of the adsorption column image correction process of the present invention;

[0059] Figure 4 This is a schematic diagram of the pixel calibration principle based on a scale according to the present invention;

[0060] Figure 5 This is a schematic diagram illustrating the principle of the sliding window detection strategy for coarse localization of multi-target regions in this invention.

[0061] Figure 6 This is a schematic diagram illustrating the principle of the multi-target region precise localization adaptive target detection and continuity verification algorithm of the present invention;

[0062] Figure 7 This is a detailed flowchart of the multi-color space fusion and precise positioning process of the present invention;

[0063] Figure 8 This is a schematic diagram illustrating the principle of dual-image coordinate system and target feature selection in this invention.

[0064] Figure 2 In the image: 201-Liquid column 1, 202-Scale 1, 203-Liquid column 2, 204-Scale 2, 205-Tilt image, 206-Corrected liquid column 1, 207-Corrected scale 1, 208-Corrected liquid column 2, 209-Corrected scale 2, 210-Corrected image.

[0065] Figure 3 In the image: 301 - Original image of the AC tilted target adsorption column, 302 - Grayscale image, 303 - CLAHE contrast enhancement image, 304 - OTSU binarized image, 305 - Adaptive binarized image, 306 - Fixed threshold binarized image, 307 - Fusion binary image, 308 - Morphological operation image, 309 - Canny edge detection image, 310 - Hough line detection result image, 311 - Target adsorption column AC correction image.

[0066] Figure 4In the diagram: 401 - Calibration liquid column, 402 - First color ring, 403 - Second color ring, 404 - Third color ring, 405 - Liquid front edge, 406 - Calibration liquid column corresponding scale, 407 - Uppermost graduation line of the scale, 408 - Uppermost graduation value of the scale, 409 - Lowermost graduation line of the scale, 410 - Lowermost graduation value of the scale.

[0067] Figure 5 In the diagram: 501 - 1st sliding window Block1, 502 - 2nd sliding window Block2, 503 - nth sliding window Block n (n is the maximum number of clipping blocks), 504 - Overlapping region 1, 505 - Overlapping region 2, 506 - 1st corrected image block, 507 - 2nd corrected image block, 508 - nth corrected image block.

[0068] Figure 6 In the diagram: 601 - Coarse localization map of the target area; 602 - Scan the first row of pixels line by line; 603 - Target pixels meet the threshold for the first row; 604 - Target pixels meet the threshold for the second row; 605 - Target pixels meet the threshold for the third row; 606 - Target pixels meet the threshold for the (i-1)th row (i is the threshold for the number of consecutive valid rows); 607 - Target pixels meet the threshold for the i-th row.

[0069] Figure 7 In the image: 701 - First color ring RB coarse localization image, 702 - YCrCb image, 703 - YCrCb-Cr image, 704 - Gamma correction, CLAHE and sharpening enhancement image, 705 - OTSU binarization and morphological operation image, 706 - Second color ring BG coarse localization image, 707 - HLS image, 708 - HLS-S image, 709 - CLAHE and Gaussian blur image, 710 - OTSU binarization and morphological operation image, 711 - Third color ring YG coarse localization image, 712 - HSV-S saturation enhancement and conversion back to BGR image, 713 - YCrCb image, 714 - YCrCb-Cb image, 715 - OTSU binarization and morphological operation image, 716 - Liquid front SF coarse localization image, 717 - Grayscale image, 718 - CLAHE image, 719 - OTSU binarization and morphological operation image.

[0070] Figure 8In the image: 801 - First position correction liquid column image, 802 - Second position correction liquid column image, 803 - Dual image coordinate system diagram, 804 - First color ring, 805 - Second color ring (complete feature), 806 - First position correction liquid column 0 pixel, 807 - Top of the first color ring relative to the first position correction liquid column image y_rbrel, 808 - First brightest point of the second color ring relative to the first position correction liquid column image y_bgrel, 809 - First position correction liquid column Y_height (height of the first position correction liquid column image), 810 - Second color ring (incomplete feature), 811 - Third color ring, 812 - Liquid front, 813 - Second position correction liquid column 0 pixel, 814 - First brightest point of the third color ring relative to the second position correction liquid column image y_ygrel, 815 - Liquid front protrusion 816 - Second position correction liquid column Y_height (height of the second position correction liquid column), 817 - First color ring of the dual image coordinate system, 818 - Second color ring of the dual image coordinate system, 819 - Third color ring of the dual image coordinate system, 820 - Liquid front of the dual image coordinate system, 821 - Liquid column 0 pixel of the dual image coordinate system, 822 - Top of the first color ring Y_RB of the dual image coordinate system, 823 - First brightest point of the second color ring Y_BG of the dual image coordinate system, 824 - First brightest point of the third color ring Y_YG of the dual image coordinate system, 825 - Change point of the liquid front Y_SF of the dual image coordinate system, 826 - Y_height of the dual image coordinate system (height of the dual image coordinate system). Detailed Implementation

[0071] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of protection of the invention. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention. Example 1

[0072] This embodiment provides a specific application of a method for precise localization of liquid column stratification features based on multi-color space fusion, using the measurement of layered liquids within a transparent adsorption column (AC) as an example. This adsorption column is used for hydrocarbon component analysis of petroleum products and contains multiple fluorescent liquids of different colors, from top to bottom: a reddish-brown fluorescent ring (first color ring, RB), a blue-green fluorescent ring (second color ring, BG), a yellow-green fluorescent ring (third color ring, YG), and a colorless sample front (SF). A parallel graduated scale is attached to the adsorption column, with an effective scale range of 10–90 cm and scale intervals of 1 cm. The measurement objective is to precisely locate the positions of each color ring and the liquid front, and calculate the height of each liquid layer.

[0073] like Figure 1 As shown, the specific implementation steps are as follows:

[0074] S1: Acquire dual images of the liquid column.

[0075] Images of the adsorption column were acquired using an industrial camera (model: Daheng ME2P-2621-4GMC-P, resolution 5120×5120 pixels) under ultraviolet light irradiation. The ultraviolet light source was a 365nm wavelength LED ultraviolet lamp, and the illuminance was set to a standard illuminance of 100 lux.

[0076] First, adjust the camera to the first position, ensuring the 50-91cm scale range on the scale is within the field of view, and acquire the first image. The image resolution is 5120×5120 pixels, and the file format is BMP lossless. Then, immediately move the camera to the second position, ensuring the 10-51cm scale range on the scale is within the field of view, and acquire the second image. The two images have an overlap of approximately 1cm (corresponding to the 50-51cm area on the scale), ensuring that all targets are completely covered.

[0077] In this embodiment, the first image mainly covers the upper half of the adsorption column, including the complete first color ring (RB) and the complete second color ring (BG); the second image mainly covers the lower half of the adsorption column, including the lower half of the second color ring (BG), the complete third color ring (YG), and the complete liquid front (SF).

[0078] S2: Liquid column tilt correction

[0079] The first and second images are subjected to tilt correction processing respectively, such as... Figure 2 and Figure 3 As shown:

[0080] S21: Using a pre-trained YOLOv8 deep learning detection model, transparent liquid columns 201 and 203 were detected in the tilted image 205, corresponding to scales 202 and 204, and the bounding rectangular regions of the transparent liquid columns were obtained. The model uses a dual-class configuration with class names "AC" and "R," where "AC" corresponds to the adsorption column region, and "R" is the scale corresponding to the adsorption column. After detecting multiple targets, the model filters out all detection results of category "AC." The X-coordinate of the image center is calculated as cols / 2. For each AC detection box, its center X-coordinate is calculated, and the distance to the image center is calculated; the AC with the smallest distance is selected as the target adsorption column.

[0081] The detection results are as follows: Two candidate cylinders were detected in the first image, with coordinates (2344, 0, 206, 5210) and (1050, 0, 195, 5210) respectively. The X-coordinate of the image center is 2560. The center of the first cylinder is 113 pixels from the image center, and the center of the second cylinder is 1413 pixels from the image center. Therefore, the first cylinder was selected as the target, with a confidence level of 0.96. One candidate cylinder was detected in the second image, with coordinates (2412, 0, 182, 5120) and a confidence level of 0.94. This cylinder was directly selected as the target cylinder. The selected AC region was expanded to a full-height region and cropped to obtain the AC region image.

[0082] S22: Preprocess the AC cylinder region. First, convert the image to grayscale (302), then use CLAHE (Contrast Limiting Adaptive Histogram Equalization) to enhance the contrast, resulting in CLAHE contrast-enhanced image (303). The parameters are set to clipLimit=2.0 and tileGridSize=(8, 8). Next, use a 5×5 Gaussian filter for noise reduction, with a Gaussian kernel standard deviation σ=1.0.

[0083] S23: A strategy combining multiple binarization methods is used to extract the cylinder edges. OTSU adaptive thresholding is used to obtain OTSU binarized image 304, adaptive thresholding (ADAPTIVE_THRESH_GAUSSIAN_C, blockSize=21, C=5) is used to obtain adaptive binarized image 305, and a fixed threshold of 30 is used to obtain fixed threshold binarized image 306. Logical operations are performed on the three binary images: first, a bitwise AND operation is performed on images 304 and 305, then a bitwise OR operation is performed with image 306, resulting in the final fused binary image 307. Morphological operations are performed on image 307 using a 5×5 rectangular structuring element, sequentially performing closing and opening operations to remove isolated noise points and fill holes, resulting in morphological operation image 308. The percentage of white pixels is counted; if it exceeds 50%, the image is inverted to ensure the AC region of the adsorbed cylinder is white. The OpenCV findContours function is used to extract the contours, and the contour with the largest area is selected as the main contour of the cylinder.

[0084] S24: Use Canny edge detection with parameters set to threshold1=50, threshold2=150, apertureSize=3, resulting in Canny edge detection image 309. Use Hough transform to detect lines with parameters set to rho=1, theta=π / 180, threshold=80, minLineLength=100, maxLineGap=20, resulting in Hough line detection image 310. Calculate the length of each detected line, filter lines with a length greater than 50 pixels, calculate the line angle, and adjust the angle range to between (-90°, 90°).

[0085] Find the longest straight line as the principal line, and use its angle as the initial tilt angle. Select lines from all lines whose angle difference from the principal line is less than 5°, and calculate the final tilt angle by weighting the angles of these lines with the square of their lengths.

[0086] For the first image, Canny edge detection detected 328 edge points, and Hough transform detected 47 straight lines. After filtering, 23 valid straight lines were obtained, with the longest line being 486 pixels long and having an angle of -0.95°. There were 15 similar lines with an angle difference of less than 5° from the main line. The weighted average yielded a final tilt angle of -0.93°. For the second image, 302 edge points were detected, and Hough transform detected 42 straight lines. After filtering, 19 valid straight lines were obtained, with the longest line being 512 pixels long and a final tilt angle of -0.87°.

[0087] S25: Perform rotation correction on the image based on the tilt angle. Calculate the rotation center center = (cols / 2, rows / 2), create a rotation matrix using the getRotationMatrix2D function, and calculate the size of the bounding box after rotation. Adjust the translation components of the rotation matrix to keep the image centered. Perform an affine transformation using the warpAffine function, with interpolation mode INTER_LINEAR, boundary padding mode BORDER_CONSTANT, and fill value black. The image height may increase after rotation; calculate the height difference heightDiff = rotated.rows - original.rows. If heightDiff > 0, crop heightDiff / 2 pixels from both the top and bottom to restore the original height, thus obtaining the AC-corrected image 311 of the target adsorption column.

[0088] The first image is rotated by 0.95° (counterclockwise), resulting in a bounding box size of 5131×5120, with an increased height of 11 pixels. Six pixels are cropped from the top, and five pixels from the bottom, restoring the final image size to 5120×5120. The second image is rotated by 0.87° (counterclockwise), resulting in a bounding box size of 5128×5120, with an increased height of 8 pixels. Four pixels are cropped from both the top and bottom. Verification after correction: Using Hough transform to re-detect the cylinder edge, the residual tilt angle of the first image is 0.01°, and that of the second image is 0.02°, both meeting the accuracy requirement of less than 0.05°.

[0089] S3: Scale-based pixel calibration

[0090] For the first and second corrected images, respectively, the scale lines and scale values ​​are identified and the pixels are calibrated, such as... Figure 4 As shown:

[0091] S31: Use a pre-trained YOLOv8 deep learning detection model to identify ruler markings and scale value labels. Set the category names to "L" and "N", where "L" represents integer markings on the ruler and "N" represents scale values. This model, after training, can identify the marking labels and corresponding markings for integer marking values ​​from 0 to 100 cm on the ruler. Detection results: The first image detected 40 marking labels, corresponding to marking values ​​from 51 cm to 90 cm; the second image detected 40 marking labels, corresponding to scale values ​​from 11 cm to 50 cm.

[0092] S32: Filter all detection boxes from the detection results and sort them by Y-coordinate. Select the detection box with the smallest Y-coordinate as the upper scale line, obtaining the uppermost scale line 407 on the ruler, and read its corresponding scale value V. up The top scale value of 408 is obtained; the detection box with the largest Y coordinate is selected as the bottom scale line, and the bottom scale line of 409 is obtained. The corresponding scale value V is read. down The lowest scale graduation value of 410 is obtained. The center Y-coordinate of the scale line is extracted. up and Y down ;

[0093] First calibration image: A total of 40 integer scale labels were detected. The detection box with the smallest Y-coordinate is the scale value V. up1 =90cm, detection box (x=95, y=80, w=42, h=22), center Y coordinate Y up1 =80 + 22 / 2 = 91 pixels, actual measurement of the scribe line position Y up1 =91 pixels, confidence level 0.95. The largest detection box on the Y-axis is the scale value V. down1=51cm, detection box (x=94, y=4985, w=45, h=28), center Y coordinate Y down1 =4985 + 28 / 2 = 4999 pixels, actual measurement of the scribe line position Y down1 =4999 pixels, confidence level 0.96.

[0094] Second calibration image: A total of 40 integer tick marks were detected. The detection box with the smallest Y-coordinate is the tick value V. up2 =50cm, detection box (x=92, y=65, w=44, h=24), center Y coordinate Y up2 =65 + 24 / 2 = 77 pixels, actual measurement of the scribe line position Y up2 =77 pixels, confidence level 0.94. The largest detection box on the Y-axis is the scale value V. down2 =11cm, detection box (x=93, y=4996, w=46, h=22), center Y coordinate Y down2 =4996 + 22 / 2 = 5007 pixels, actual measurement of the scribe line position Y down2 =5007 pixels, confidence level 0.92.

[0095] S33: Calculate the pixel equivalent of the image based on the difference between the pixel coordinates of the scale lines read above and the difference between the actual scale values. The formula is: K = (V up - V down ) × 10 / (Y down - Y up ), where V up and V down The unit is cm, Y up and Y down The unit is pixel. Multiply by 10 to convert cm to mm, so the unit of K is mm / pixel.

[0096] First corrected image: V up1 =90cm, V down1 =51cm, Y up1 =91 pixels, Y down1 =4999pixel, K1 = (90- 51) × 10 / (4999- 91) = 0.0795mm / pixel.

[0097] Second corrected image: V up2 =50cm, V down2 =11cm, Y up2 =77 pixels, Y down2=5007pixel, K2 = (50- 11) × 10 / (5007- 77) = 0.0791mm / pixel.

[0098] The pixel equivalent difference between the two images is: |K1-K2|=|0.0795-0.0791|=0.0004 mm / pixel, with a relative difference of <0.5%, indicating that the magnification of the two images is basically the same, which verifies the stability of the measurement system.

[0099] S4: Coarse localization of multi-target feature regions

[0100] A sliding window detection strategy was used to coarsely locate the target transparent cylinder in the first and second corrected images, respectively, and multiple target feature regions were detected, such as... Figure 5 As shown:

[0101] S41: Set sliding window parameters such as crop height and overlap height. Crop height = 1500 pixels, overlap height = 300 pixels, calculate effective height = cropHeight - overlap = 1200 pixels. Calculate the number of crop blocks based on the image height and effective height, and divide the large, corrected cylindrical image into multiple overlapping cropped image blocks along the vertical direction.

[0102] First corrected image block: Image height is 5120 pixels, number of cropped blocks n = ceil((5120-300) / 1200) = ceil(4.017) = 5 blocks. Block details: The first sliding window Block 1 (501) covers an area of ​​0-1500 pixels, and is cropped to obtain the first corrected image block 506; the second sliding window Block 2 (502) covers an area of ​​1200-2700 pixels, and is cropped to obtain the second corrected image block 507; the third sliding window Block 3 covers an area of ​​2400-3900 pixels, and is cropped to obtain the third corrected image block; the fourth sliding window Block 4 covers an area of ​​3600-5100 pixels, and is cropped to obtain the fourth corrected image block; the fifth sliding window Block 5 is adjusted to 3620-5120 pixels, and is cropped to obtain the fifth corrected image block. The second corrected image block: same as the first image, a total of 5 blocks.

[0103] S42: For each clipping block, four pre-trained YOLOv8 detection models were used for object detection: RBModel detects the first color ring, BGModel detects the second color ring, YGModel detects the third color ring, and SFModel detects the liquid front. Different confidence thresholds were set for each model: RB threshold 0.75, BG threshold 0.7, YG threshold 0.6, and SF threshold 0.8.

[0104] S43: Map the detection result coordinates in each cropped image block back to the corresponding calibration image coordinate system. For the detection box, its Y coordinate in the calibration image is box.y = box.y + y_start, where y_start is the starting Y coordinate offset of the cropped block in the corresponding calibration image.

[0105] S44: Perform NMS deduplication on the detection results for each category. Set the IoU threshold to 0.5. For all detection boxes of the same category, sort them in descending order of confidence. Select the detection box with the highest confidence and calculate its IoU with other detection boxes. If IoU > 0.5, suppress the detection boxes with lower confidence to obtain the final target region of interest.

[0106] First corrected image detection results: Before deduplication, RB detected 3 duplicates, BG detected 2 duplicates, YG detected 1 duplicate (false positive), and SF detected 0 duplicates. After deduplication, RB retained 1 duplicate, coordinates (45, 643, 40, 137), confidence level 0.89; BG retained 1 duplicate, coordinates (43, 4931, 42, 100), confidence level 0.82; YG was removed (low confidence level and the actual image did not exist).

[0107] Second corrected image detection results: Before deduplication, 0 duplicates were detected by RB, 1 by BG, 2 by YG, and 2 by SF. After deduplication, 0 duplicates were detected by RB; BG was removed (false detection); 1 duplicate was retained by YG, with coordinates (41, 611, 42, 55) and confidence level 0.84; 1 duplicate was retained by SF, with coordinates (44, 4433, 44, 60) and confidence level 0.95.

[0108] S5: Precise positioning of liquid column layering features based on multi-color space fusion

[0109] For each coarsely located target feature region, perform color space-based optimal selection transformation, image enhancement processing, binarization, and morphological operations to achieve precise localization of the liquid column layered target features, such as... Figure 6 and Figure 7 As shown:

[0110] For precise localization of the first color wheel (RB): A coarse localization map 701 of the first color wheel RB is extracted from the first corrected image. Based on the coarse localization result, the extracted region is (45, 643, 40, 137). YCrCb color space conversion is performed. An RGB color ROI image (40×137×3) is input and converted to YCrCb color space using OpenCV's cvtColor function, resulting in YCrCb image 702. The Cr channel is extracted to obtain YCrCb-Cr image 703. The Cr channel shows the strongest response to red features. Next, gamma correction is performed with a gamma value of γ=1.4, effectively brightening dark details and increasing the average Cr value from 128.5 to 145.2. Adaptive histogram equalization (CLAHE) was performed with parameters set to clipLimit=2.0 and tileGridSize=(8,8). Laplacian sharpening was then applied to obtain gamma-corrected, CLAHE-enhanced, and sharpened images (Figure 704). The convolution kernel was: kernel = [[-1, -1, -1], [-1,9, -1], [-1, -1, -1]]. Binarization and morphological operations were performed using the OTSU method to obtain the binarized and morphologically operated images (Figure 705). The target region was coarsely located using binary images (Figure 601). The first row of pixels (602, y=0) was scanned line by line. For Figure 705, the scanned area consisted of 36 pixels: 36 black pixels (value=0), accounting for 100%; and 0 white pixels (value=255), accounting for 0%. Black pixels were identified as background pixels, and white pixels as target pixels. A top-down line-by-line scan (y from 1 to 137) was used. The target pixel threshold is set to threshold_pixel = 36 × 0.15 = 5.4, rounded down to 6 pixels. The consecutive valid row threshold is threshold_rows = 5 rows. The consecutive valid row threshold is reached when the target pixel in row 1 (603) meets the threshold, and then in row i (607). Here, i is the consecutive valid row threshold. When all 5 consecutive rows are valid, the Y-coordinate of the first valid row is the top position of the first color ring. The relative Y-coordinate of the top of the first color ring RB within the ROI is determined to be y_rbrel = 24 pixels, where the initial Y-coordinate of the ROI is 643, the relative Y-coordinate is 24, and the absolute Y-coordinate Y_RB = 643 + 24 = 667 pixels. The reference point is the 90cm scribe line of the first corrected image, with a Y-coordinate of 91 pixels, corresponding to a physical location of 90cm. The pixel distance = Y_RB - Y_90cm = 667 - 91 = 576 pixels. Physical distance = 576 × K1 = 576 × 0.0795 = 45.792 mm = 4.5792 cm. Absolute physical position = 90 - 4.5792 = 85.4208 cm ≈ 85.42 cm.

[0111] Professionals used a precision reading caliper to perform measurement verification. The top position of RB was 85.4cm, and the error was |85.4-85.42| = 0.02cm = 0.2mm, which met the accuracy requirements.

[0112] For precise localization of the second color ring (BG): A coarse localization image (706) of the second color ring BG is extracted from the first calibrated image. Based on the coarse localization result, the ROI region is extracted as (43, 4931, 42, 100). HLS color space conversion is performed to obtain the HLS image (707), and the S (saturation) channel is extracted to obtain the HLS-S image (708). Adaptive histogram equalization (CLAHE) is performed with parameters set to clipLimit=3.0 and tileGridSize=(8,8). Blur is applied using a 3×3 Gaussian convolution kernel with a standard deviation σ=0.8, resulting in CLAHE and Gaussian blurred images (709). Binarization and morphological operations are performed using the OTSU method to obtain the OTSU binarized and morphological operation image (710). The pixel percentage in the first row is statistically analyzed: white pixels account for 0%, and black pixels account for 100%. White pixels are defined as target pixels, and black pixels as background pixels. A bottom-up, line-by-line scanning method is used (y from 100 to 1). The target pixel threshold is set to threshold_pixel = 42 × 0.15 = 6.3 pixels, rounded down to 7 pixels; the threshold for consecutive valid rows is 5 rows. Starting from y=88, the number of white pixels in the five consecutive rows upwards are 9, 10, 12, 15, and 17, all greater than 7, satisfying the continuity verification condition. The relative Y-coordinate of the first brightest point of the second color wheel within the ROI is determined to be y_bgrel = 88, where the initial Y-coordinate of the ROI is 4931, the relative Y-coordinate is 88, and the absolute Y-coordinate is Y_BG = 4931 + 88 = 5019. The reference point is the 90cm scribe line of the first corrected image, with a Y-coordinate of 91 pixels, corresponding to a physical location of 90cm. The pixel distance = Y_BG - Y_90cm = 5019 - 91 = 4928 pixels. Physical distance = 4928 × K1 = 4928 × 0.0795 = 391.776 mm = 39.1776 cm. Absolute physical position = 90 - 39.1776 = 50.8224 cm ≈ 50.82 cm.

[0113] The ROI region of the extracted second color ring BG in the second corrected image is considered an incomplete feature and is excluded according to the priority selection strategy. Therefore, the precise BG localization result of the second corrected image is not used.

[0114] Professionals used a precision reading caliper to perform measurement verification. The brightest point of BG was 50.8cm, and the error was |50.8-50.82|=0.02cm=0.2mm, which meets the accuracy requirements.

[0115] For precise localization of the third color wheel (YG): A coarse localization image (711) of the third color wheel (YG) is extracted from the second corrected image. Based on the coarse localization result, the extracted region is (41, 611, 42, 55). HSV color space conversion is performed, the S channel is extracted, saturation enhancement is applied, and the image is merged back to the BGR color space to obtain HSV-S saturation enhancement and BGR conversion (712). The enhancement coefficient alpha = 1.3. YCrCb color space conversion is performed to obtain YCrCb (713), and the Cb channel is extracted to obtain YCrCb-Cb (714). Then, OTSU binarization and morphological operations are performed to obtain OTSU binarization and morphological operation (715). The pixel percentage in the first row is calculated, with white pixels accounting for 100% and black pixels accounting for 0%. White pixels are defined as background pixels, and black pixels as target pixels. A bottom-up, line-by-line scanning method is used, with a target pixel threshold of 42 × 0.15 = 6.3, rounded to 7 pixels; the threshold for consecutive effective rows is 5 rows. Starting from y=47, the number of black pixels in the five consecutive rows upwards are 8, 8, 9, 14, and 15, all greater than 7, satisfying the continuity verification condition. The relative Y-coordinate of the first brightest point in the third color wheel within the ROI is determined to be y_ygrel=47, where the initial Y-coordinate of the ROI is 611, the relative Y-coordinate is 47, and the absolute Y-coordinate is Y_YG = 611 + 47 = 658. The reference point is the 50cm scribe line in the second calibration image, with a Y-coordinate of 77 pixels, corresponding to a physical location of 50cm. Pixel distance = 658 - 77 = 581 pixels. Physical distance = 581 × K² = 581 × 0.0791 = 45.9571 mm = 4.5957 cm. Absolute physical location = 50 - 4.5957 = 45.4043 cm ≈ 45.40cm.

[0116] Professionals used a precision reading caliper to perform measurement verification. The brightest point of YG was 45.40cm, and the error was |45.40-45.40| = 0.00cm = 0.0mm, which meets the accuracy requirements.

[0117] For precise localization of the liquid front (SF): A coarse localization image 716 of the SF was extracted from the second corrected image. Based on the coarse localization result, the extracted region was (44, 4433, 44, 60), which was converted to grayscale to obtain a grayscale image 717. Then, CLAHE contrast enhancement processing was performed to obtain a CLAHE image 718. The OTSU method was used for binarization and morphological operations to obtain an OTSU binarized and morphologically operated image 719. The pixel ratio of the first row was statistically analyzed: white pixels accounted for 80%, and black pixels accounted for 20%. White pixels were defined as background pixels, and black pixels as target pixels. A bottom-up, line-by-line scanning method was used. The target pixel threshold was set to 44 × 0.10 = 4.4, rounded to 5 pixels; the threshold for consecutive valid rows was 5 rows. Starting from y=40, the number of black pixels in the five consecutive rows upwards were 6, 7, 10, 10, and 11, all greater than 5, satisfying the continuity verification condition. The relative Y coordinate y_sfrel=40 within the ROI was determined to be the location of the liquid front mutation. The initial Y-coordinate of the ROI is 4433, the relative Y-coordinate is 40, and the absolute Y-coordinate Y_SF = 4433 + 40 = 4473. The reference point is the 50cm scribe line of the second calibration image, with a Y-coordinate of 77 pixels, corresponding to a physical position of 50cm. Pixel distance = 4473 - 77 = 4396 pixels. Physical distance = 4396 × K² = 4396 × 0.0791 = 347.7236 mm ≈ 34.7724 cm. Absolute physical position = 50 - 34.7724 = 15.2276 cm ≈ 15.23cm.

[0118] Professionals used a precision reading caliper to measure and verify that the brightest point of SF was 15.2cm, and the error was |15.23-15.2|=0.03cm=0.3mm, which meets the accuracy requirements.

[0119] S6: Dual Image Coordinate System and Target Feature Selection

[0120] Based on the pixel coordinates of each target in the first and second corrected images, and combined with the corresponding pixel equivalents, the actual physical coordinates of the targets in each image are calculated, such as... Figure 8 As shown.

[0121] For targets appearing only in a single image, the target feature pixel coordinates in that image are directly used. For targets appearing in both images, a priority selection strategy is adopted. The priority selection strategy is as follows: compare the detection confidence, region integrity, and image sharpness of the target in the first and second corrected images, and select the target feature in the image with the best overall evaluation as the final physical coordinates of the target. Region integrity is evaluated by determining whether the target features are cropped by the image boundary; image sharpness is evaluated by calculating the gradient magnitude or Laplacian variance of the target region.

[0122] In this embodiment, the second color ring BG appears simultaneously in both the first position correction liquid column diagram 801 and the second position correction liquid column diagram 802. In Figure 801, the second color ring BG (intact feature) 805 is fully visible, with a detection confidence level of 0.82, indicating that the target region is not cropped by the image boundary and has good region integrity. In Figure 802, the second color ring BG (incomplete feature) 810 is cropped by the image boundary, indicating poor region integrity. Therefore, according to the priority selection strategy, the measurement result in Figure 801 is selected as the final physical coordinate of the second color ring BG, 50.82 cm.

[0123] For targets that appear only in a single image, the measurement results in that image are used directly: the first color ring RB804 appears only in Figure 801, so the measurement result of Figure 801 is used, which is 85.42 cm; the third color ring 811 YG appears only in Figure 802, so the measurement result of Figure 802 is used, which is 45.40 cm; the liquid front 812 SF appears only in Figure 802, so the measurement result of Figure 802 is used, which is 15.23 cm.

[0124] The final positions of the top of the first color ring, the first brightest point of the second color ring, the first brightest point of the third color ring, and the abrupt change at the liquid front in the unified physical world coordinate system were obtained as 85.42 cm, 50.82 cm, 45.40 cm, and 15.23 cm, respectively. Example 2

[0125] To verify the robustness of the method of the present invention, a repeatability comparison experiment was conducted under different conditions in this embodiment.

[0126] Excitation illumination variation experiment: The illuminance of the ultraviolet light source was set to 70%, 100%, and 130% of the standard illuminance, and repeated measurements were performed on the same adsorption column sample. The experimental results show that within a range of ±30% variation in excitation illuminance, the positioning error of each target varies by less than ±0.1 mm.

[0127] Ambient illumination variation experiment: The illuminance of the experimental ambient light source was set to 60%, 80%, 100%, 120%, and 140% of the standard illuminance, and repeated measurements were performed on the same adsorption column sample. The experimental results show that within a range of ±40% variation in ambient illumination, the positioning error of each target varies by less than ±0.1 mm.

[0128] Sample concentration variation experiment: Measurements were performed using samples of different concentrations. Experimental results show that within a sample concentration variation of ±30%, the positioning error of the method of this invention remains within ±0.2 mm.

[0129] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for precise localization of liquid column layering features based on multi-color space fusion, characterized in that, Includes the following steps: S1: Acquire dual images of the liquid column A first image is acquired in a first position state, and a second image is acquired in a second position state to obtain a dual image; both the first image and the second image contain a transparent cylinder and its internal layered liquid, as well as a scale for calibration reference, and there is an overlapping area between the first image and the second image; S2: Liquid column tilt correction The first image and the second image are respectively subjected to target transparent cylinder detection and tilt correction to obtain a first corrected image and a second corrected image; the tilt correction includes: detecting the edge contour of the target transparent cylinder, calculating the tilt angle of the cylinder's central axis relative to the vertical direction of the image, and performing a rotation transformation on the image so that the cylinder's central axis is parallel to the vertical direction of the image; S3: Scale-based pixel calibration The first and second corrected images are respectively identified by scale, scale line and scale value, the pixel coordinates of the upper scale line and the corresponding actual scale value, the pixel coordinates of the lower scale line and the corresponding actual scale value, and the first pixel equivalent of the first corrected image and the second pixel equivalent of the second corrected image are calculated. The formula for calculating the first pixel equivalent is: K1 = (V up1 - V down1 ) × 10 / (Y down1 - Y up1 ) The formula for calculating the second pixel equivalent is: K2 = (V up2 - V down2 ) × 10 / (Y down2 - Y up2 ) Where K1 is the first pixel equivalent, in mm / pixel; K2 is the second pixel equivalent, in mm / pixel; V up1 V down1 These are the actual scale values ​​of the upper and lower scale lines in the first calibration image, respectively, in cm; Y up1 Y down1 These are the pixel Y-coordinates of the upper and lower scale lines in the first corrected image, respectively, in pixels; V up2 V down2 These are the actual scale values ​​of the upper and lower scale lines in the second calibration image, respectively, in cm; Y up2 Y down2 These are the pixel Y coordinates of the upper and lower scale lines in the second corrected image, respectively, in pixels; S4: Coarse localization of multi-target feature regions The target transparent cylinders in the first and second corrected images are coarsely located using a sliding window detection strategy, and multiple target feature regions are detected. The target feature regions include, but are not limited to, the first color ring region, the second color ring region, the third color ring region, and the liquid front region. S5: Precise positioning of liquid column layering features based on multi-color space fusion For each target feature region coarsely located, perform color space-based optimal selection transformation, image enhancement processing, binarization, and morphological operations to achieve precise localization of the liquid column layered target features: For the first color ring region: perform YCrCb color space conversion and extract the Cr channel, then perform gamma correction, adaptive histogram equalization and sharpening enhancement in sequence, followed by binarization and morphological operations. Using a top-down line-by-line scanning method, combined with adaptive target detection and continuity verification algorithms, determine the pixel coordinates of the topmost pixel in the first color ring. For the second color ring region: HLS color space conversion is performed and the S channel is extracted. Adaptive histogram equalization and Gaussian blur processing are performed in sequence, followed by binarization and morphological operations. A bottom-up line-by-line scanning method is adopted, combined with adaptive target detection and continuity verification algorithms, to determine the pixel coordinates of the first brightest point of the second color ring. For the third color wheel region: HSV color space conversion is performed and the S channel is extracted for saturation enhancement processing, then merged and converted back to BGR color space. YCrCb color space conversion is then performed and the Cb channel is extracted. Binarization and morphological operations are then performed. A bottom-up line-by-line scanning method is adopted, combined with adaptive target detection and continuity verification algorithms, to determine the pixel coordinates of the first brightest point of the third color wheel. For the liquid front region: after grayscale and contrast enhancement processing, binarization and morphological operations are performed. A bottom-up line-by-line scanning method is adopted, combined with adaptive target detection and continuity verification algorithms, to determine the pixel coordinates at the abrupt change in the liquid front. S6: Dual Image Coordinate System and Target Feature Selection Based on the pixel coordinates of each target in the first and second corrected images, and combined with the corresponding pixel equivalents, the actual physical coordinates of the targets in each image are calculated respectively. For targets that appear in both images, a priority selection strategy is adopted. For targets that appear only in a single image, the target feature pixel coordinates in that image are directly used. The positions of the top of the first color ring, the first brightest point of the second color ring, the first brightest point of the third color ring, and the abrupt change at the liquid front are obtained in the unified physical world coordinate system.

2. The method for precise localization of liquid column layering features based on multi-color space fusion according to claim 1, characterized in that, The liquid column tilt correction in step S2 employs a multi-method fusion edge detection algorithm, specifically including: S21: Use the trained deep learning detection model to locate the target transparent cylinder in the image. When a single transparent cylinder is detected, directly select the cylinder as the target transparent cylinder. When multiple transparent cylinders are detected, calculate the distance between the X coordinate of the center of each cylinder and the X coordinate of the center of the image, select the cylinder with the smallest distance as the target transparent cylinder, obtain the bounding rectangle region of the target transparent cylinder and expand it into the full height region of the image. S22: The columnar region is grayscaled, contrast enhancement is performed using contrast-limited adaptive histogram equalization, and then filtering and noise reduction are performed. S23: The edge of the cylinder is extracted by combining multiple binarization methods. Multiple binary images are obtained by using adaptive thresholding and fixed thresholding methods respectively. The final binary image is obtained by fusion through logical operations. After performing morphological operations on the final binary image, the edge contour of the cylinder is extracted by contour detection algorithm. S24: Perform edge detection on the binary image, then use Hough transform to detect straight lines, filter out valid straight lines with a length greater than a preset threshold, find the longest straight line as the main line, filter out similar straight lines with an angle difference less than a preset angle threshold from all valid straight lines, calculate the weighted average of the angles of the similar straight lines, with the weight being the square of the line length, and obtain the tilt angle of the column edge line. S25: Perform rotation correction on the image based on the tilt angle, calculate the size of the bounding box after rotation, adjust the translation component of the rotation matrix to keep the image centered, use affine transformation for rotation, and if the image height increases after rotation, crop to restore the original height so that the cylinder is strictly vertical in the image.

3. The method for precise localization of liquid column layering features based on multi-color space fusion according to claim 1, characterized in that, The scale lines and scale value recognition in step S3 employs a deep learning-based method for target detection and recognition, specifically including: S31: Use the trained deep learning detection model to detect the scale of the corrected image, identify the integer value scale line labels, and obtain the pixel coordinates of the scale line labels; S32: Filter all detection boxes from the detection results and sort them by Y coordinate. Select the detection box with the smallest Y coordinate as the upper scale line and the detection box with the largest Y coordinate as the lower scale line. Read the corresponding actual scale value and center Y coordinate respectively. S33: Based on the difference between the pixel coordinates of the scale lines read above and the difference between the actual scale values, calculate the pixel equivalent of the image and establish a direct mapping relationship between pixel coordinates and actual physical world coordinates.

4. The method for precise localization of liquid column layering features based on multi-color space fusion according to claim 1, characterized in that, The coarse localization of the multi-target region in step S4 employs a sliding window detection strategy, specifically including: S41: Set the cropping height and overlap height parameters, calculate the effective height as the cropping height minus the overlap height, calculate the number of cropping blocks based on the image height and effective height, and divide the large-sized corrected cylindrical image into multiple overlapping cropping image blocks along the vertical direction. S42: For each cropped image patch, multiple trained deep learning detection models are used to detect the target. The multiple detection models are used to detect the first color ring, the second color ring, the third color ring, and the liquid front, respectively. Each model is set with a different confidence threshold. S43: Map the detection result coordinates in each cropped image block back to the corresponding calibration image coordinate system. The Y coordinate of the detection box in the calibration image is equal to the Y coordinate in the cropped block plus the initial Y coordinate offset of the cropped block. S44: Perform non-maximum suppression deduplication on the detection results of each category, set the IoU threshold, sort all detection boxes of the same category in descending order of confidence, and retain the detection boxes with the highest confidence and whose IoU with the retained boxes is less than the threshold to obtain the final target region of interest.

5. The method for precise localization of liquid column layering features based on multi-color space fusion according to claim 1, characterized in that, The adaptive target detection algorithm and continuity verification algorithm in step S5 are as follows: The adaptive target detection algorithm performs a statistical analysis of the proportion of black and white pixels in the first row of the image after binarization and morphological operations, defining the pixel type with the high proportion as background pixels and the pixel type with the low proportion as target pixels. The continuity verification algorithm sets a target pixel threshold and a consecutive valid row count threshold. During the row-by-row scanning process, when the proportion of target pixels in multiple consecutive rows exceeds the target pixel threshold, it is determined to be a valid target position.

6. The method for precise localization of liquid column layering features based on multi-color space fusion according to claim 1, characterized in that, In step S6, for targets that appear in both images, the preferred selection strategy is as follows: The detection confidence, region integrity, and image sharpness of the target are compared in the first and second corrected images. The target feature in the image with the best overall evaluation is selected as the final physical coordinates of the target. The region integrity is evaluated by determining whether the target feature is cropped by the image boundary. The image sharpness is evaluated by calculating the gradient magnitude or Laplacian variance of the target region.

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