A contour extraction method for dynamic sequence images
By employing a method of first-frame baseline localization and batch iterative extraction, combined with asymmetric dynamic search and physical quantity conversion, the problems of low efficiency and insufficient robustness in contour extraction of dynamic sequence images are solved, achieving efficient and accurate contour extraction and visualization output.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA UNIV OF MINING & TECH
- Filing Date
- 2026-04-17
- Publication Date
- 2026-06-26
AI Technical Summary
Existing contour extraction methods for dynamic sequence images are inefficient, fail to fully utilize dynamic features leading to insufficient robustness, and are prone to contour breakage and misidentification in scenarios with blurred target edges and high environmental noise.
A method combining first-frame baseline positioning with batch iterative extraction is adopted. The ratio of inner and outer diameters is calculated by static calibration images, global parameters are initialized, and the target contour is extracted frame by frame using an asymmetric dynamic search strategy. High-throughput, fully automatic contour extraction is achieved through gap interpolation correction and physical quantity conversion.
It achieves high-throughput fully automatic contour extraction of dynamic sequence images, reduces redundant computation overhead, improves recognition robustness and basic positioning accuracy, simplifies user operation, and adapts to observation scenarios of various dynamic moving targets.
Smart Images

Figure CN122289719A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing and visual measurement technology, and specifically relates to a contour extraction method for dynamic sequence images. Background Technology
[0002] Contour extraction from dynamic image sequences is a core technology in fields such as fluid mechanics experiments, microscale motion observation, and industrial visual inspection. Especially in scenarios such as capillary dynamic wetting, high-speed particle motion tracking, and dynamic cell morphology analysis, high-throughput and high-precision extraction of target contours from hundreds to thousands of consecutive images is required. Traditional contour extraction methods often treat single static images as independent processing units and commonly use edge detection algorithms such as Canny and Sobel to perform full-image pixel traversal recognition for each frame. This not only requires manual adjustment of detection thresholds and cropping of regions of interest frame by frame, resulting in high labor costs and extremely low processing efficiency, but also fails to utilize the temporal continuity of target motion in dynamic sequences. In scenarios with blurred target edges and high environmental noise, contour breakage and misidentification problems are prone to occur. Even if some improved solutions introduce batch processing logic, they are merely simple repetitions of the single-frame processing flow, without designing adaptive search strategies specifically for the target motion direction. This fails to improve recognition robustness while reducing computational load, making it difficult to meet the data analysis needs of high-throughput dynamic experiments.
[0003] Chinese Patent CN119027442A discloses an adaptive contour extraction method, including steps S1: selecting representative images; S2: constructing a quality evaluation function; S3: smoothing the quality function; S4: determining a low contrast threshold; S5: calculating a reference contrast; S6: determining a high contrast threshold based on the reference contrast; and S7: batch contour extraction. This invention selects representative images and performs detailed algorithmic analysis on them to obtain high-quality, robust contour extraction algorithm parameters, which can be used for all images requiring contour extraction, resulting in high-quality contour extraction effects. Furthermore, while achieving excellent results, it does not introduce additional time consumption during batch processing, and the entire process is automated without manual intervention, improving performance without affecting execution efficiency and saving labor costs. The aforementioned method covers all contours to be tested using a uniform detection threshold, resulting in an overly broad scope and weak targeting, leading to wasted retrieval resources and low efficiency. Therefore, how to provide a contour extraction method that can adapt to the characteristics of dynamic sequence images and balance processing efficiency and extraction accuracy has become a technical problem urgently needing to be solved by those skilled in the art. Summary of the Invention
[0004] The present invention aims to solve the technical problems of low processing efficiency and insufficient robustness in contour extraction of dynamic sequence images in the prior art, and to provide a contour extraction method for dynamic sequence images that can balance processing efficiency and extraction accuracy.
[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0006] A contour extraction method for dynamic sequence images includes the following steps:
[0007] S1. Calculate the ratio of inner and outer diameters of the target under test after refractive index correction based on the static calibration image;
[0008] S2. Initialization and Parameter Configuration: Read the list of dynamic sequence images and configure global processing parameters;
[0009] S3. First frame baseline contour extraction: Process the first frame of valid image, locate the motion area of the target to be measured, extract the baseline contour, and determine the pixel physical conversion coefficient;
[0010] S4. Batch Frame Adaptive Contour Extraction: Based on the contour results of the preceding frames, an asymmetric dynamic search strategy is used to extract the target contours frame by frame from the subsequent sequence images.
[0011] S5. Gap Interpolation Correction: Interpolate and fill in the gaps in the extracted contours to ensure contour continuity;
[0012] S6. Physical quantity conversion and visualization output: Convert pixel-level contours into physical dimensions and output visualization results of the changes in the shape of the target under test.
[0013] By adopting the above technical solution, the overhead of repeated calculation in subsequent frames is greatly reduced by the first frame reference positioning, and the recognition robustness in complex scenes is improved by combining asymmetric dynamic search with motion continuity features. Overall, high-throughput and fully automatic extraction of dynamic sequence image contours is achieved without manual frame-by-frame intervention, and it can be adapted to observation scenarios of various dynamic moving targets.
[0014] Furthermore, the pre-calibration execution steps specifically include:
[0015] S11. Read the static calibration image of the target under test with a preset outer diameter, and generate a binary edge image using Canny edge detection;
[0016] S12. Scan the binary image line by line, identify the left and right edges of the outer diameter and the left and right edges of the inner diameter of each line, and calculate the pixel width of the outer diameter and the pixel width of the inner diameter of each line.
[0017] S13. Take the maximum outer diameter pixel value and the maximum inner diameter pixel value of all rows, calculate the original inner and outer diameter ratio, and multiply it by the refractive index of the medium to be tested to obtain the capillary inner and outer diameter ratio in the meniscus image. Only retain the calibration result as a global parameter for subsequent use.
[0018] By adopting the above technical solution, the ratio of inner and outer diameters with refractive index correction is calculated through static calibration images, decoupling the calibration process from subsequent dynamic sequence processing. Only one calibration is needed to support the processing of all sequence images. This avoids redundant calculations for subsequent frame-by-frame identification of the pipe wall, eliminates optical distortion errors in transparent media scenarios through refractive index correction, ensures the accuracy of inner diameter region positioning, and outputs only the calibration ratio as a global parameter, reducing the storage overhead of intermediate variables.
[0019] Furthermore, the initialization and parameter configuration execution steps specifically include:
[0020] S21. Configure the storage path for dynamic sequence images and read the file list of sequence images;
[0021] S22. Set the starting sequence number of valid images. This sequence number corresponds to the position of the first image in the sequence where the complete target to be tested appears. Invalid frames before this sequence are skipped directly in subsequent processing.
[0022] By adopting the above technical solution, invalid frames without targets can be skipped directly by pre-configuring the starting sequence number of valid images. There is no need to judge whether the target appears frame by frame in subsequent processing. This simplifies the batch processing process and avoids the interference of invalid frames on subsequent contour extraction. All sequences can be screened by setting parameters once according to the time when the target appears in the experiment, which reduces the threshold for use and the cost of manual adjustment.
[0023] Furthermore, the execution steps for extracting the reference contour of the first frame specifically include:
[0024] S31. Perform edge detection on the first frame of valid image to generate a binary image. Sum the binary image row by row to obtain the row pixel count vector. Calculate the mode of the vector as the typical width of the target region. Extract all row indices that are equal to the mode. Determine the first continuous row interval by analyzing the difference between adjacent indices, which is used as the vertical range of the target motion.
[0025] S32. Generate a column index vector with the same width as the image. Replace the values of edge pixels in the binary image with their column indices by dot product operation. Extract the column index information of edge pixels from the continuous row interval determined in S31. After matrix reconstruction, calculate the average column index by column to obtain the column indices of the left and right edges of the outer diameter of the target region. At the same time, calculate the outer diameter pixel width.
[0026] S33. Based on the calibrated inner and outer diameter ratio obtained from the pre-calibration, and combined with the outer diameter pixel width identified in S32, the pixel width and starting position of the inner diameter are adaptively calculated using the parity judgment rule, and the inner diameter region matrix is cropped from the original binary image.
[0027] S34. Set a mask for the inner diameter region matrix along the forward direction of the dynamic target to be measured, retain the backward region, replace the value of each edge pixel in the retained region with the row index of that pixel, and extract the maximum value of each column as the reference contour of the first image.
[0028] S35. Based on the known actual outer diameter of the target and the outer diameter pixel width obtained in S32, calculate the conversion factor between pixels and physical size as a global parameter.
[0029] By adopting the above technical solution, through a series of matrix operations such as row summation mode analysis, column index dot product operation, and parity adaptive correction, the entire process of motion area positioning, inner and outer diameter boundary recognition, and reference contour extraction can be automatically completed without manual annotation. The obtained inner diameter area boundary and pixel physical conversion coefficient can be used as global fixed parameters for all subsequent frames to reuse, which fundamentally avoids the computational redundancy of repeatedly recognizing the background area in subsequent frames, while ensuring that the reference benchmark of all frames is completely unified.
[0030] Furthermore, the parity determination rule in S33 specifically includes:
[0031] S331. Calculate the initial pixel width of the inner diameter based on the ratio of the inner and outer diameters after calibration and the pixel width of the outer diameter obtained in S32.
[0032] S332. Determine the parity of the outer diameter pixel width: If half of the outer diameter pixel width is equal to its integer value, then the number of outer diameter pixels is even; otherwise, it is odd.
[0033] S333. Determine the parity of the initial pixel width of the inner diameter: If half of the initial pixel width of the inner diameter is equal to its integer value, then the initial pixel count of the inner diameter is even; otherwise, it is odd.
[0034] S334. If the parity of the number of pixels on the outer diameter is the same as that of the initial number of pixels on the inner diameter, then the final pixel width of the inner diameter is the initial pixel width of the inner diameter; if the parity is different, then the final pixel width of the inner diameter is the initial pixel width of the inner diameter plus 1, ensuring that the centers of the inner and outer diameters coincide.
[0035] By adopting the above technical solution, the parity of the inner diameter pixel width is adaptively adjusted to ensure that the pixel centers of the inner and outer diameters completely coincide, avoiding the problem of inner diameter region offset caused by the difference in the number of pixels. The inner diameter region can be accurately cropped without the need for an additional center alignment algorithm, eliminating system errors at the hardware pixel level and improving the basic positioning accuracy of contour extraction.
[0036] Furthermore, the execution steps of the batch frame adaptive contour extraction specifically include:
[0037] S41. Adaptive search width calculation: Based on the row index values of each column of the contour extracted in the previous frame, calculate the fluctuation amplitude of the contour, and adaptively determine the width of the strip search area in the current frame accordingly. The forward search width along the motion direction is greater than the backward search width in the opposite motion direction.
[0038] S42. Dynamic strip mask construction: Taking the outline position of the previous frame as the center, traverse each column of the current frame image, retain the area from the forward search range to the backward search range of the column, set the pixels outside the area to 0, and generate a dynamic strip search mask.
[0039] S43. Weighted matrix transformation: For the binary image after masking, the value of each effective edge pixel is replaced with its row index by a dot product operation, and the region with a value of 0 is set to the null value NaN.
[0040] S44. Extreme value extraction: Extract the minimum value along the column direction of the weighted matrix to obtain the target contour position in the current frame;
[0041] S45. Iterative processing: Save the contour position of the current frame as the reference for the next frame processing, and repeat steps S41-S44 to complete the contour extraction of all sequence images.
[0042] By adopting the above technical solution, the range of edge detection is reduced from the entire image to a narrow band area by using a dynamic strip search mask based on the fluctuation amplitude of the preceding frame. This not only significantly reduces the amount of computation per frame, but also effectively eliminates noise interference outside the search area. At the same time, by iteratively updating the reference contour, the temporal continuity of the sequence image is fully utilized, eliminating the need to relocate the target area for each frame, thus achieving fully automatic and efficient extraction of batch images.
[0043] Furthermore, the adaptive search width calculation formula in S41 is as follows:
[0044] Based on the row index values of each column of the meniscus contour extracted from the previous frame. ,in, ; Calculate the fluctuation amplitude of the meniscus profile, and adaptively determine the width of the strip search region for the current frame accordingly:
[0045] The formula for calculating the profile fluctuation amplitude is: ;
[0046] The formula for calculating the forward search width (along the direction of motion) is: ;
[0047] The formula for calculating the backward search width (in the reverse direction of motion) is: ;
[0048] Where the weight coefficients satisfy This allows for a greater forward search range than the backward search range along the direction of motion.
[0049] By adopting the above technical solution, and through the asymmetric width design where the forward search weight is greater than the backward search weight, the dynamic target's movement trend is closely matched. This avoids both the missed contour detection caused by an excessively small search range and the redundant noise introduced by an excessively large search range. The differentiated setting of the weight coefficients is specifically adapted to the directional characteristics of the target's movement, thereby reducing the amount of computation and further improving the anti-interference ability of edge extraction.
[0050] Furthermore, the execution steps of the missing interpolation correction specifically include:
[0051] S51, Missing Value Detection: Traverse the batch frames adaptive contour extraction output target contour data and detect whether there is a missing value NaN;
[0052] S52, Neighbor Interpolation: For each null value location, find the two nearest valid contour values to that location, and calculate the mean of the two valid values to fill the null value;
[0053] S53. Continuity check: Perform a continuity check on the filled contour. If the difference between adjacent points exceeds a preset threshold, re-interpolate to ensure the continuity of the contour data.
[0054] By adopting the above technical solution, through a three-level processing logic of null value detection, nearest neighbor interpolation, and continuity verification, the problem of contour breakage caused by edge blurring and instantaneous noise is automatically repaired. The continuity of the contour in each frame can be guaranteed without manual completion. This avoids the impact of invalid data on subsequent analysis and preserves the true shape characteristics of the contour, without introducing additional shape distortion due to interpolation.
[0055] Furthermore, the execution steps for the physical quantity conversion and visualization output specifically include:
[0056] S61. Using the pixel and physical size conversion coefficients extracted from the first frame reference contour, convert all pixel-level contour data into physical size contours. When the target to be measured is a transparent medium, divide the lateral physical size by the refractive index of the medium to eliminate refraction error.
[0057] S62. Select key frames from the sequence images according to a preset time interval, stitch the original images of the key frames horizontally in chronological order, and overlay the extracted contours of the corresponding frames onto the original images.
[0058] S63. Mark the time nodes and physical dimensions of the outline on the stitched image, and output a visual comparison diagram of the morphological change process of the dynamic target under test.
[0059] By adopting the above technical solution, through automatic conversion between pixels and physical size and refractive index correction, the physical size contour that can be directly used for experimental analysis is directly output without the need for subsequent secondary conversion. At the same time, through keyframe stitching and contour overlay, the dynamic change process of the target shape is intuitively presented, which not only improves the efficiency of data analysis, but also provides intuitive visualization support for the display and verification of experimental results.
[0060] Furthermore, the input parameters of the method only include: the actual outer diameter of the target under test, the refractive index of the medium under test, the effective image start number, and the Canny edge detection threshold. There is no need to adjust the parameters frame by frame, and the processing time for a sequence of 787 images does not exceed 30 seconds.
[0061] By adopting the above technical solution, and by limiting the number of global input parameters to only 4 without the need for frame-by-frame adjustment, the barrier to entry for using the method is greatly reduced. Ordinary users do not need to master complex image processing knowledge to complete high-throughput sequence processing. At the same time, the clear processing efficiency indicators ensure the practicality of the method, which can meet the batch data analysis needs of large-scale dynamic experiments and avoid the problems of high labor costs and long processing cycles of traditional methods.
[0062] The beneficial effects of this invention are as follows:
[0063] 1. This invention breaks the technical bias of traditional contour extraction methods by combining first-frame baseline positioning with batch iterative extraction through a technical architecture that enables independent processing of each frame. It allows the common steps such as background region identification and physical conversion coefficient calculation in sequential images to be performed only once to support the processing of all frames, greatly reducing the overhead of repeated calculations. This enables high-throughput fully automatic processing of dynamic sequential images without the need for manual adjustment of parameters frame by frame, and significantly improves the data analysis efficiency of large-scale dynamic experiments.
[0064] 2. This invention reduces the edge detection range of each frame from the entire image to a narrow band region that matches the motion trend by combining an asymmetric dynamic search strategy based on the target motion trend. This reduces unnecessary computation and specifically eliminates environmental noise interference outside the search area. At the same time, it makes full use of the temporal continuity of sequential images, using the contour result of the previous frame as the search benchmark for the next frame. It can still maintain high recognition robustness in complex scenes such as blurred edges and fluctuating lighting, and effectively reduces the probability of misidentification and breakage of contours.
[0065] 3. This invention eliminates system positioning deviations caused by refractive errors in transparent media and parity differences between inner and outer diameter pixels at the hardware pixel level by combining pre-refractive index calibration with a parity adaptive correction mechanism. The calibration process is completely decoupled from the dynamic processing flow. Only one static calibration is needed to obtain globally universal inner and outer diameter ratio parameters. Precise cropping of the inner diameter region can be achieved without additional center alignment and distortion correction algorithms, thereby fundamentally improving the basic positioning accuracy of contour extraction.
[0066] 4. This invention, through a combination of gap interpolation correction and automatic conversion of physical quantities, automatically repairs contour gaps caused by instantaneous noise and ensures data continuity. At the same time, it directly outputs physical size contours and visual comparison results that can be used for experimental analysis, without the need for subsequent secondary data processing and format conversion. It balances data accuracy and ease of use, greatly reducing the threshold for using the method. Ordinary users do not need to master complex image processing expertise to complete the analysis of batch sequences. Attached Figure Description
[0067] Figure 1 This is a flowchart of the method of the present invention;
[0068] Figure 2 This is a schematic diagram of the meniscus contour extraction process in a capillary with an inner diameter of 3.67 mm in one embodiment of the present invention.
[0069] Figure 3 This is a diagram illustrating the ascent process of ultrapure water in a capillary tube with an inner diameter of 3.67 mm and its meniscus shape in one embodiment of the present invention.
[0070] Figure 4 This is a diagram illustrating the rising process of ultrapure water in a capillary tube with an inner diameter of 2.04 mm and its meniscus shape in one embodiment of the present invention.
[0071] Figure 5 This is a diagram showing the rising process of ultrapure water in a capillary tube with an inner diameter of 3.04 mm and its meniscus shape in one embodiment of the present invention. Detailed Implementation
[0072] The present invention will now be described in further detail with reference to the accompanying drawings and specific preferred embodiments.
[0073] In the description of this invention, it should be understood that the terms "left side," "right side," "upper part," "lower part," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. "First," "second," etc., do not indicate the importance of the components, and therefore should not be construed as a limitation of this invention. The specific dimensions used in this embodiment are only for illustrating the technical solution and do not limit the scope of protection of this invention.
[0074] Reference Figure 1 , Figure 2 and Figure 3 As can be seen, the present invention discloses a contour extraction method for dynamic sequence images, including the following steps:
[0075] S1. Pre-calibration: Calculate the ratio of inner and outer diameters of the target in the image based on the static calibration image;
[0076] S2. Initialization and Parameter Configuration: Read the list of dynamic sequence images and configure global processing parameters;
[0077] S3. First frame baseline contour extraction: Process the first frame of valid image, locate the motion area of the target to be measured, extract the baseline contour, and determine the pixel physical conversion coefficient;
[0078] S4. Batch Frame Adaptive Contour Extraction: Based on the contour results of the preceding frames, an asymmetric dynamic search strategy is used to extract the target contours frame by frame from the subsequent sequence images.
[0079] S5. Gap Interpolation Correction: Interpolate and fill in the gaps in the extracted contours to ensure contour continuity;
[0080] S6. Physical quantity conversion and visualization output: Convert pixel-level contours into physical dimensions and output visualization results of the changes in the shape of the target under test.
[0081] Specifically, in step S1, S11, read the static calibration image of the target to be measured with a preset outer diameter, and generate a binary edge image using Canny edge detection;
[0082] S12. Scan the binary image line by line, identify the left and right edges of the outer diameter and the left and right edges of the inner diameter of each line, and calculate the pixel width of the outer diameter and the pixel width of the inner diameter of each line.
[0083] S13. Take the maximum outer diameter pixel value and the maximum inner diameter pixel value of all rows, calculate the original inner and outer diameter ratio, multiply it by the refractive index of the medium to be tested to obtain the inner and outer diameter ratio in the image, and retain only the calibration result as a global parameter for subsequent use.
[0084] In step S2, the initialization and parameter configuration steps specifically include:
[0085] S21. Configure the storage path for dynamic sequence images and read the file list of sequence images;
[0086] S22. Set the starting sequence number of valid images. This sequence number corresponds to the position of the first image in the sequence where the complete target to be tested appears. Invalid frames before this sequence are skipped directly in subsequent processing.
[0087] In step S3, the specific steps for extracting the reference contour of the first frame include:
[0088] S31. Perform edge detection on the first frame of valid image to generate a binary image. Sum the binary image row by row to obtain the row pixel count vector. Calculate the mode of the vector as the typical width of the target region. Extract all row indices that are equal to the mode. Determine the first continuous row interval by analyzing the difference between adjacent indices, which is used as the vertical range of the target motion.
[0089] S32. Generate a column index vector with the same width as the image. Replace the values of edge pixels in the binary image with their column indices by dot product operation. Extract the column index information of edge pixels from the continuous row interval determined in S31. After matrix reconstruction, calculate the average column index by column to obtain the column indices of the left and right edges of the outer diameter of the target region. At the same time, calculate the outer diameter pixel width.
[0090] S33. Based on the calibrated inner and outer diameter ratio obtained from the pre-calibration, and combined with the outer diameter pixel width identified in S32, the pixel width and starting position of the inner diameter are adaptively calculated using the parity judgment rule, and the inner diameter region matrix is cropped from the original binary image.
[0091] S34. Set a mask for the inner diameter region matrix along the forward direction of the dynamic target to be measured, retain the backward region, replace the value of each edge pixel in the retained region with the row index of that pixel, and extract the maximum value of each column as the reference contour of the first image.
[0092] S35. Based on the known actual outer diameter of the target and the outer diameter pixel width obtained in S32, calculate the conversion factor between pixels and physical size as a global parameter.
[0093] The parity determination rules in step S33 specifically include:
[0094] S331. Calculate the initial pixel width of the inner diameter based on the ratio of the inner and outer diameters after calibration and the pixel width of the outer diameter obtained in S32.
[0095] S332. Determine the parity of the outer diameter pixel width: If half of the outer diameter pixel width is equal to its integer value, then the number of outer diameter pixels is even; otherwise, it is odd.
[0096] S333. Determine the parity of the initial pixel width of the inner diameter: If half of the initial pixel width of the inner diameter is equal to its integer value, then the initial pixel count of the inner diameter is even; otherwise, it is odd.
[0097] S334. If the parity of the number of pixels on the outer diameter is the same as that of the initial number of pixels on the inner diameter, then the final pixel width of the inner diameter is the same as the initial pixel width of the inner diameter.
[0098] If the parity is different, the final inner diameter pixel width is the initial inner diameter pixel width plus 1, ensuring that the centers of the inner and outer diameters coincide.
[0099] In step S4, the specific steps for batch frame adaptive contour extraction include:
[0100] S41. Adaptive search width calculation: Based on the row index values of each column of the contour extracted in the previous frame, calculate the fluctuation amplitude of the contour, and adaptively determine the width of the strip search area in the current frame accordingly. The forward search width along the motion direction is greater than the backward search width in the opposite motion direction.
[0101] S42. Dynamic strip mask construction: Taking the outline position of the previous frame as the center, traverse each column of the current frame image, retain the area from the forward search range to the backward search range of the column, set the pixels outside the area to 0, and generate a dynamic strip search mask.
[0102] S43. Weighted matrix transformation: For the binary image after masking, the value of each effective edge pixel is replaced with its row index by a dot product operation, and the region with a value of 0 is set to the null value NaN.
[0103] S44. Extreme value extraction: Extract the minimum value along the column direction of the weighted matrix to obtain the target contour position in the current frame;
[0104] S45. Iterative processing: Save the contour position of the current frame as the reference for the next frame processing, and repeat steps S41-S44 to complete the contour extraction of all sequence images.
[0105] The formula for calculating the adaptive search width in step S41 is:
[0106] Based on the row index values of each column of the meniscus contour extracted from the previous frame. ; Calculate the fluctuation amplitude of the meniscus profile, and adaptively determine the width of the strip search region for the current frame accordingly:
[0107] The formula for calculating the profile fluctuation amplitude is: ;
[0108] The formula for calculating the forward search width (along the direction of motion) is: ;
[0109] The formula for calculating the backward search width (in the reverse direction of motion) is: ;
[0110] Wherein, the weight coefficients satisfy This allows for a greater forward search range than the backward search range along the direction of motion.
[0111] In step S5, the specific steps for performing gap interpolation correction include:
[0112] S51, Missing Value Detection: Traverse the batch frames adaptive contour extraction output target contour data and detect whether there is a missing value NaN;
[0113] S52, Neighbor Interpolation: For each null value location, find the two nearest valid contour values to that location, and calculate the mean of the two valid values to fill the null value;
[0114] S53. Continuity check: Perform a continuity check on the filled contour. If the difference between adjacent points exceeds a preset threshold, re-interpolate to ensure the continuity of the contour data.
[0115] In step S6, the specific steps for performing physical quantity conversion and visualization output include:
[0116] S61. Using the pixel and physical size conversion coefficients extracted from the first frame reference contour, convert all pixel-level contour data into physical size contours. When the target to be measured is a transparent medium, divide the lateral physical size by the refractive index of the medium to eliminate refraction error.
[0117] S62. Select key frames from the sequence images according to a preset time interval, stitch the original images of the key frames horizontally in chronological order, and overlay the extracted contours of the corresponding frames onto the original images.
[0118] S63. Mark time nodes and physical dimension information of the outline on the stitched image, and output a visual comparison image of the morphological change process of the dynamic target under test. The output image is annotated with time and height through Origin.
[0119] The input parameters only include: the actual outer diameter of the target under test, the refractive index of the medium under test, the starting number of the effective image, and the Canny edge detection threshold. There is no need to adjust the parameters frame by frame, and the processing time for a sequence of 787 images is no more than 30 seconds.
[0120] In one embodiment, refer to Figure 2 and Figure 3As can be seen, in the microfluidic capillary wetting experiment, the target is the rising meniscus of ultrapure water inside a glass capillary with an inner diameter of 3.67 mm and a refractive index of 1.333. The experiment uses a 2000fps high-speed camera to acquire 787 consecutive images from the time the meniscus enters the field of view until it rises to a steady state. The specific execution process is as follows:
[0121] First, pre-calibration is performed by acquiring static images of an empty capillary tube without liquid. Canny edge detection is used to identify the inner and outer edges of the tube wall. The original inner-outer diameter ratio is calculated and multiplied by the refractive index of ultrapure water to obtain the calibrated ratio, which is then used as a global parameter. Parameter configuration is then performed, setting the starting number of valid images to 17 and the Canny edge detection threshold to [0, 0.5]. A list of all sequence image files is read. When processing the first valid image, the binary image is summed row by row to obtain the row pixel vector. The row interval corresponding to the mode is taken as the vertical motion range. The left and right boundaries of the outer diameter of the tube wall are identified by column index dot product. Combined with the calibrated inner-outer diameter ratio, the inner diameter width is adjusted to make the centers of the inner and outer diameters coincide after parity judgment. After cropping the inner diameter area, the front edge is set along the upward direction. The maximum row index of each column is extracted from the mask as the baseline contour. At the same time, the pixel physical conversion coefficient is calculated based on the known actual outer diameter of the capillary. In subsequent frame-by-frame processing, the search width is calculated based on the fluctuation amplitude of the contour of the previous frame. A dynamic strip mask is generated by setting the forward search coefficient to 0.75 and the backward coefficient to 0.35. The minimum value of each column is extracted only within the mask area by weighting the row index as the contour of the current frame. After iterative processing of all sequences, the null values in the contour are filled with the average of the two nearest valid values and the continuity is checked. Finally, the pixel-level contour is converted into physical size. A key frame is selected every 50 frames and horizontally stitched together to overlay the contours and output a visual comparison image of the meniscus rising process. The whole process does not require adjusting parameters frame by frame and automatically completes the extraction of all contours.
[0122] Reference Figure 2 Therefore, Figure 2 (a) is a binary diagram of the capillary inner diameter;
[0123] (b) To apply a mask to the crescent-facing region in the first valid image;
[0124] (c) is the first effective meniscus profile extracted;
[0125] (d) shows the remaining meniscus contours extracted (taking the 92nd frame image as an example).
[0126] Taking the meniscus contour extraction during the liquid level rise process inside a capillary as an example, the contour extraction method for dynamic sequence images provided by the present invention will be described in detail.
[0127] A series of meniscus images were acquired using a high-speed camera, showing the ultrapure water rising from a horizontal plane to a steady state within a capillary. The capillary had an outer diameter of 6.52 mm and an inner diameter of 3.67 mm, and the camera frame rate was set to 500 fps.
[0128] In the image preprocessing stage, the sequence image file is first read and the starting sequence number of the valid images is set. In this embodiment, the 17th frame image is defined as the first valid image.
[0129] The borosilicate glass capillary tube has a nominal outer diameter of 6.52 mm, an inner diameter of 3.67 mm, an ultrapure water temperature of 20℃, and a refractive index of 1.333.
[0130] Images were acquired using a 500fps high-speed camera with a resolution of 680×480 pixels, and a total of 787 frames of complete sequence images were captured from the moment the crescent entered the field of view to the moment it rose to a steady state.
[0131] Module 1: System Calibration Module (Basic Calibration) Execution Process
[0132] Static calibration images of an empty capillary are acquired, and the Canny edge detection algorithm is used to generate binary edge images. The left and right edges of the outer and inner walls of the capillary in each row are scanned and identified line by line. The original inner-outer diameter ratio is calculated by taking the maximum outer diameter pixel value and the maximum inner diameter pixel value of all rows. The original ratio is multiplied by the refractive index of ultrapure water, 1.333, to complete optical distortion correction. Finally, the inner-outer diameter ratio after calibration is obtained as 0.7452. At the same time, combined with the known actual outer diameter of the capillary, 6.52 mm, the pixel-to-physical size conversion coefficient is calculated to be 23.2 μm / pixel. This is used as a globally fixed parameter for subsequent modules to call. Only one calibration is needed to support the uniformity of the measurement benchmark for all sequence images.
[0133] Module 2: Dynamic Contour Tracking Module (Core Recognition) Execution Flow
[0134] First frame initialization: Set the starting number of the effective image to 17 (corresponding to the frame position where the meniscus first appears completely in the field of view). When processing the first effective image, sum the rows of the binary image to obtain the row pixel count vector. Take the continuous row interval corresponding to the mode as the vertical observation range of the capillary. Combine the inner and outer diameter ratio obtained by calibration to locate the effective observation area of the inner diameter. Extract the meniscus contour of the first frame as the initial reference.
[0135] Temporal continuous tracking: The subsequent 770 frames of images are processed frame by frame using a "prediction-correction" strategy: Centered on the row index of each column of the meniscus in the previous frame, the asymmetric search window is adaptively set according to the fluctuation amplitude of the contour in the previous frame. The forward search coefficient along the upward direction of the meniscus is set to 0.75, and the backward search coefficient in the opposite direction of motion is set to 0.35. The search window only covers the narrow band area above and below the contour, without the need for full image traversal. The edge extreme values are extracted within the search area to obtain the contour of the current frame, which is saved as the tracking reference for the next frame. The entire sequence processing is completed iteratively.
[0136] Data integrity assurance: Traversing the contour data of all frames, a total of 12 contour breaks and missing values caused by instantaneous reflection and bubble interference were detected. The average of the two nearest valid values was used for interpolation to fill the gaps, and the continuity of the interpolated data was checked. If the difference between adjacent points exceeded 3 pixels, the interpolation was re-interpolated. Finally, the spatiotemporal continuity error of all contour data was less than 1 pixel.
[0137] Module 3: Physical Mapping and Scientific Visualization Module (Result Output) Execution Flow
[0138] Two-dimensional coordinate correction: Multiply the vertical coordinate of all pixel-level contours by the pixel-to-physical conversion factor to obtain millimeter-level height values, and divide the horizontal coordinate by the refractive index of ultrapure water 1.333 to eliminate the lateral optical offset of the water-glass interface, resulting in a meniscus contour coordinate set that fully conforms to physical reality.
[0139] Spatiotemporal fusion presentation: Select 10 key frame original images and stitch them horizontally in chronological order. Superimpose the physical size outline of the corresponding frame onto the original image. Simultaneously label the time node and maximum height value of the meniscus for each key frame to generate a comparison chart of the evolution of the meniscus rising process, intuitively presenting the trend of morphological changes.
[0140] Data product output: Synchronously export the physical coordinate dataset of each frame of the meniscus, including fields such as frame number, corresponding physical time, height values of each column of the meniscus, maximum height, and estimated contact angle. This dataset can be directly imported into subsequent dynamic analysis tools for in-depth research on contact angle relaxation laws and rise velocity decay characteristics.
[0141] With an Intel Core i7-1165G7 processor and 32GB of memory, the total processing time was 27 seconds. No manual adjustment of parameters frame by frame was required, which is more efficient than the traditional frame-by-frame manual annotation method.
[0142] A for loop iterates through multiple image files starting from a given index, applying the Canny edge detection algorithm to each image for contour recognition, generating a binary image. In practical processing, the Canny algorithm's dual thresholds need to be adjusted based on image features to balance edge continuity and noise suppression. Testing showed that setting the dual threshold range to [0, 0.5] effectively extracts the meniscus contour with minimal noise interference. In the generated binary image, pixel values at edges are marked as 1, and pixel values outside edges are marked as 0, laying the foundation for subsequent contour extraction.
[0143] For a single upward movement of liquid within the same capillary tube, the geometric positions of its inner and outer diameters remain fixed, while the meniscus moves along the inner diameter region. Therefore, it is only necessary to identify and locate the position of the inner diameter in the first valid image, and use it as the reference for extracting the meniscus contour in the next frame.
[0144] The specific process is as follows:
[0145] First, in the preprocessed binary image, locate a continuous row region with uniformly distributed edges. This region should contain clear features of the inner and outer capillary wall edges.
[0146] A dot product is performed on the row region, and the value of each edge pixel is assigned the row index corresponding to that pixel. All elements greater than zero are extracted and reshaped into a matrix representing the number of rows and columns corresponding to the edge region. Based on this matrix, the average of the first and last column elements is calculated to obtain the column index position of the capillary outer diameter contour in the image. To ensure that the geometric centers of the inner and outer diameters are consistent and to eliminate possible center offsets, the number of inner diameter pixels is corrected based on the parity of the outer diameter. The specific process is as follows:
[0147] The number of pixels in the outer diameter is calculated based on the outer diameter index contour, and the number of pixels in the inner diameter is calculated based on the number of pixels in the outer diameter and the ratio coefficient between the inner and outer diameters.
[0148] Calculate half the outer diameter width and its rounded result. If the two are equal, the number of pixels in the outer diameter is even; if they are not equal, the number of pixels in the outer diameter is odd.
[0149] Calculate half of the initial width of the inner diameter and its rounded result: if they are equal, it means the number of pixels in the inner diameter is even; if they are not equal, it means the number of pixels in the inner diameter is odd.
[0150] When the number of pixels in the outer diameter and the number of initial pixels in the inner diameter are both odd or even, the number of pixels in the inner diameter is the calculated number of initial pixels in the inner diameter.
[0151] When the parity of the outer diameter pixel count and the initial inner diameter pixel count are different, the inner diameter pixel count is the calculated initial inner diameter pixel count plus 1.
[0152] The inner diameter index matrix is calculated based on the number of pixels in the inner diameter and the number of pixels in the outer diameter. The region defined by this inner diameter index matrix is the key region for meniscus motion, and the binary image of this region is shown below. Figure 2 As shown in (a).
[0153] Based on the inner diameter index matrix, a mask is applied to the front-facing region of the meniscus to eliminate interference, thus retaining only the rear-facing region of the meniscus (see...). Figure 2 (b)). Then, the value of each edge point within this region is replaced with its corresponding row index, and the maximum row coordinate of each column is extracted to obtain the position of the meniscus in that column. This position becomes the reference contour for extracting the meniscus contour in the next frame. The binary image of this reference contour is shown below. Figure 2 As shown in (c).
[0154] For the extraction of the meniscus contour from the remaining valid images, an adaptive extraction strategy is adopted, and the specific steps are as follows:
[0155] First, based on the row index values of each column of the meniscus contour extracted from the previous frame, the fluctuation amplitude of the meniscus contour is calculated, and the width of the strip search region for the current frame is adaptively determined accordingly. The specific calculation formula is as follows:
[0156] The formula for calculating the profile fluctuation amplitude is:
[0157] The formula for calculating the forward search width (along the direction of motion) is: ;
[0158] The formula for calculating the backward search width (in the reverse direction of motion) is: ;
[0159] Where the weight coefficients satisfy This is to ensure that the forward search range along the direction of motion is greater than the backward search range;
[0160] Centered on the outline position of the previous frame, traverse each column of the current frame image, retain the area from the forward search range to the backward search range of that column, and set the pixels outside the area to 0 to form a dynamic strip search mask.
[0161] For the masked binary image, the value of each valid edge pixel is replaced with its row index by a dot product operation, and regions with a value of 0 are set to the null value NaN.
[0162] Finally, the minimum value of each column of the row index matrix is extracted as the contour position of the meniscus in the current frame. The extracted contour position of the current frame is saved as the reference for processing the next frame, and steps S2-S4 are repeated to achieve continuous tracking and contour extraction of the dynamic target. Taking the 92nd frame image as an example, the binary image of the meniscus obtained using the adaptive extraction method is as follows: Figure 2As shown in (d), this algorithm fully utilizes matrix operations, avoids loop structures, and achieves adaptive and efficient extraction of the meniscus contour.
[0163] During batch extraction, edge points in a certain column of the image may not be detected due to poor image quality, resulting in missing data at the corresponding locations of the meniscus contour. To address this, an interpolation algorithm is introduced to fill in the missing values: first, it checks if there are any empty values in the meniscus data; if so, for each empty value location, it finds the two nearest valid values and fills in the missing value with the average of these two valid values. This method effectively ensures the continuity and integrity of the meniscus contour data.
[0164] The input meniscus image sequence is filtered and stitched together in chronological order. The extracted meniscus contours are then overlaid onto the corresponding images, outputting a visualization of the meniscus morphological changes, such as... Figure 2 As shown.
[0165] Through the above meniscus extraction process, the pixel dimensions of the inner and outer diameters of the capillary and the meniscus contour data at different times can be obtained, providing a reliable basis for the quantitative analysis of subsequent experimental data.
[0166] In one embodiment, refer to Figure 4 As can be seen, in this embodiment, the target under test is an ultrapure water meniscus rising inside a borosilicate glass capillary tube with a nominal inner diameter of 2.04 mm and an outer diameter of 3.99 mm. The refractive index of ultrapure water at 20°C is 1.333. A high-speed camera at 1000 fps is used to acquire 426 consecutive images from the time the meniscus enters the field of view until it rises to a steady state. The specific execution process is as follows:
[0167] Pre-calibration stage: Acquire static calibration images of empty capillaries without liquid, use Canny edge detection (threshold [0, 0.5]) to identify the inner and outer edges of the tube wall, calculate the original inner and outer diameter ratio and multiply it by the refractive index of ultrapure water to obtain the calibrated inner and outer diameter ratio of 0.6590. Combined with the known actual outer diameter of the capillary of 3.99 mm, the pixel-to-physical size conversion coefficient is calculated to be 40.3 μm / pixel, which is used as a global fixed parameter.
[0168] Parameter configuration stage: Set the effective image starting number to 13 (corresponding to the frame position where the meniscus first appears completely in the field of view), fix the Canny edge detection threshold to [0, 0.5], read the list of all sequence image files, and skip the first 12 frames that have no target images.
[0169] First frame baseline extraction stage: When processing the 13th frame of valid image, the binary image is summed row by row to obtain the row pixel count vector. The continuous row interval corresponding to the mode is taken as the vertical observation range of the capillary. The left and right boundaries of the outer diameter of the tube wall are identified by column index dot product. Combined with the ratio of inner and outer diameters after calibration, the inner diameter pixel width is adjusted by parity judgment. First, the outer diameter pixel width is calculated: Pixels (odd number) are then used to recalculate the initial inner diameter pixel width: After cropping the inner diameter region using pixels (odd number, consistent with the parity of the outer diameter, no correction required), a forward mask is set along the upward direction, and the maximum row index of each column is extracted as the baseline contour.
[0170] Batch frame tracking stage: The subsequent 413 frames are processed frame by frame using an asymmetric dynamic search strategy: Centered on the row index of each column of the meniscus in the previous frame, the asymmetric search window is adaptively set according to the fluctuation range of the contour in the previous frame (the average fluctuation range in this embodiment is 11 pixels). The forward search coefficient along the upward direction of the meniscus is set to 0.85, and the backward search coefficient in the opposite direction of motion is set to 0.55. The search window only covers the upper and lower contours. Pixel forward range, The pixel backward range does not require full image traversal; the edge extrema are extracted within the search area to obtain the current frame contour, which is saved as the tracking reference for the next frame, and the entire sequence processing is completed iteratively.
[0171] Post-processing and output stage: Traversing the contour data of all frames, a total of 7 contour breaks caused by instantaneous reflection were detected. The breaks were filled by interpolation of the mean of the two nearest valid values. After the continuity was verified, the pixel-level contours were converted into physical dimensions. 20 key frames were selected and stitched horizontally. The contours were superimposed and the time nodes and physical dimensions were marked. The meniscus coordinate dataset of each frame was exported synchronously.
[0172] The total time was 16 seconds under the conditions of Intel Core i7-1165G7 processor and 32GB memory. No manual adjustment of parameters frame by frame was required. Compared with the traditional frame-by-frame manual annotation method, the efficiency was effectively improved, which met the quantitative research requirements of the rapid wetting process of low surface tension fluid.
[0173] In one embodiment, refer to Figure 5 As can be seen, this embodiment is applied to the meniscus of ultrapure water inside a borosilicate glass capillary tube with a nominal inner diameter of 3.04 mm and an outer diameter of 5.02 mm. The refractive index of ultrapure water at 20°C is 1.333. A low-speed camera at 200 fps is used to acquire 297 consecutive images from the start of the liquid's descent to its emptying. The specific execution process is as follows:
[0174] Pre-calibration stage: Acquire calibration images of capillary tubes filled with ultrapure water, use Canny edge detection (threshold [0, 0.5]) to identify the inner and outer edges of the tube wall, calculate the original inner and outer diameter ratio and multiply it by the refractive index of ultrapure water to obtain the calibrated inner and outer diameter ratio of 0.7915. Combined with the known actual outer diameter of the capillary tube of 5.02 mm, the pixel-to-physical size conversion coefficient is calculated to be 22.7 μm / pixel, which is used as a global fixed parameter.
[0175] Parameter configuration stage: Set the effective image starting number to 13 (corresponding to the first frame position where the liquid level begins to fall), fix the Canny edge detection threshold to [0, 0.5], and read the list of all sequence image files.
[0176] First frame baseline extraction stage: When processing the 13th valid image, the binary image is summed row by row to obtain the row pixel count vector. The continuous row interval corresponding to the mode is taken as the vertical observation range of the capillary. The left and right boundaries of the outer diameter of the tube wall are identified by the column index dot product. Combined with the calibrated inner and outer diameter ratio, the inner diameter pixel width is adjusted by parity judgment as follows:
[0177] First, calculate the outer diameter pixel width: Pixels (odd number);
[0178] Next, calculate the initial inner diameter pixel width: After cropping the inner diameter region using pixels (odd number, consistent with the parity of the outer diameter, no correction required), a forward mask is set along the descending direction to extract the minimum row index of each column as the baseline contour.
[0179] Batch frame tracking stage: The subsequent 284 frames of images are processed frame by frame using an asymmetric dynamic search strategy: Centered on the row index of each column of the meniscus in the previous frame, the asymmetric search window is adaptively set according to the fluctuation range of the contour in the previous frame (the average fluctuation range in this embodiment is 28 pixels). Since the liquid surface descends slowly and occasionally rebounds slightly, the forward search coefficient along the descent direction is set to 0.25 and the backward search coefficient in the opposite direction of motion is set to 0.40. The search window only covers the forward range of 7 pixels above and below the contour and the backward range of 11 pixels, effectively eliminating noise interference from droplets adhering to the pipe wall. The edge extreme values are extracted within the search area to obtain the contour of the current frame, which is saved as the tracking reference for the next frame. The entire sequence processing is completed iteratively.
[0180] Post-processing and output stage: Traversing the contour data of all frames, a total of 3 contour breaks caused by the occlusion of adhering droplets were detected. The breaks were filled by interpolation of the mean of the two nearest valid values. After the continuity was verified, the pixel-level contours were converted into physical dimensions. 13 key frame images were selected and horizontally stitched together. The contours were superimposed and the time nodes and physical dimensions were labeled. The meniscus coordinate dataset of each frame was exported synchronously.
[0181] With an Intel Core i7-1165G7 processor and 32GB of memory, the total time was 11 seconds. No manual adjustment of parameters frame by frame was required, which is more efficient than the traditional frame-by-frame manual annotation method.
[0182] This invention establishes a baseline contour using the first image and then employs an adaptive batch extraction strategy for subsequent images. This avoids manual parameter adjustment and intervention for each image, significantly reducing the time and labor costs of contour extraction from dynamic image sequences. Verification has shown that, under the same test conditions (787 images, 680×480 pixel resolution, Intel Core i7-1165G7 processor, 32GB memory), it can fully meet the needs of high-throughput experimental data analysis.
[0183] This invention combines the movement direction of the target under test and sets an asymmetric strip-shaped search area (the forward area is larger than the backward area) near the reference contour. It fully considers the movement trend of the target in the time series and effectively avoids problems such as contour breakage, mis-extraction or tracking loss caused by poor image quality, blurred edges or noise, thereby improving the robustness and accuracy of measurement.
[0184] This invention addresses the edge loss problem that may occur during the extraction process by introducing an interpolation filling mechanism based on nearby valid values. This mechanism can automatically repair gaps in the contour data, ensuring that the final dynamic target contour sequence is continuous and complete, and providing a reliable data foundation for subsequent dynamic analysis or morphological reconstruction.
[0185] The method of this invention is not limited to specific types of dynamic targets, and can be widely applied to multiple fields such as liquid surface tracking in fluid mechanics, particle motion analysis in materials science, and cell morphology observation in biomedicine, demonstrating good versatility and promotional value.
[0186] Working principle: First, by pre-calculating the refractive index correction ratio of the inner and outer diameters through static calibration, the calibration process is decoupled from dynamic processing, eliminating optical distortion errors of transparent media in one step. This avoids redundant calculations for subsequent frame-by-frame identification of pipe / channel boundaries. Simultaneously, by using row summation, mode analysis, and column index multiplication of the first effective image, the moving region is automatically located and the baseline contour is extracted. Common steps such as background recognition and physical conversion are performed only once and reused as global parameters, fundamentally reducing redundant calculation overhead. Second, considering the directional motion of dynamic targets, an asymmetric dynamic search strategy is designed. Centered on the contour position of the previous frame, a wider search range is set along the direction of motion, compressing the pixel range of edge detection in each frame from the entire image to a narrow band region, thus providing targeted edge detection. This approach eliminates environmental noise interference from outside the target area, avoids missed detections by adhering to the target's movement trend, and fully utilizes the temporal dimension features of the sequence images through iterative updates of the baseline contour. It eliminates the need to relocate the target every frame and maintains robustness even in complex scenes with blurred edges and fluctuating lighting. Finally, it eliminates pixel layer center offset errors through an even / odd parity adaptive correction mechanism, and automatically repairs contour breaks caused by instantaneous noise with a gap interpolation correction logic. The final output is a directly usable physical size contour and visualization result. There is no need for manual frame-by-frame parameter adjustment or secondary data processing. The entire solution requires only 4 global input parameters to complete the fully automatic processing of hundreds to thousands of frames of sequences, improving processing efficiency by two orders of magnitude compared to traditional methods, and is suitable for the data analysis needs of high-throughput dynamic experiments.
[0187] The above description is merely an 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, or improvements made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A contour extraction method for dynamic sequence images, characterized by, Includes the following steps: S1. Pre-calibration: Calculate the ratio of inner and outer diameters of the target under test after refractive index correction based on the static calibration image; S2. Initialization and Parameter Configuration: Read the list of dynamic sequence images and configure global processing parameters; S3. First frame reference contour extraction: Process the first frame of valid image, locate the inner diameter region of the target under test based on the inner and outer diameter ratio after refractive index correction, extract the reference contour, and determine the pixel physical conversion coefficient. S4. Batch frame adaptive contour extraction: Based on the contour results of the preceding frame, an asymmetric dynamic search strategy is adopted to extract the target contour frame by frame in the subsequent sequence images. The asymmetric dynamic search strategy is as follows: the search width is determined based on the fluctuation amplitude of the contour of the preceding frame, and the forward search width along the motion direction of the target to be measured is greater than the backward search width in the opposite motion direction. S5. Gap Interpolation Correction: Interpolate and fill in the gaps in the extracted contours to ensure contour continuity; S6. Physical quantity conversion and visualization output: Convert pixel-level contours into physical dimensions and output visualization results of the changes in the shape of the target under test.
2. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The specific steps for performing the pre-calibration include: S11. Read the static calibration image of the target under test with a preset outer diameter, and generate a binary edge image using Canny edge detection; S12. Scan the binary image line by line, identify the left and right edges of the outer diameter and the left and right edges of the inner diameter of each line, and calculate the pixel width of the outer diameter and the pixel width of the inner diameter of each line. S13. Take the maximum outer diameter pixel value and the maximum inner diameter pixel value of all rows, calculate the original inner and outer diameter ratio, multiply it by the refractive index of the medium to be tested to obtain the calibrated inner and outer diameter ratio, and retain only the calibration result as a global parameter for subsequent use.
3. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The initialization and parameter configuration execution steps specifically include: S21. Configure the storage path for dynamic sequence images and read the file list of sequence images; S22. Set the starting sequence number of valid images. This sequence number corresponds to the position of the first image in the sequence where the complete target to be tested appears. Invalid frames before this sequence are skipped directly in subsequent processing.
4. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The specific steps for extracting the reference contour of the first frame include: S31. Perform edge detection on the first frame of valid image to generate a binary image. Sum the binary image row by row to obtain the row pixel count vector. Calculate the mode of the vector as the typical width of the target region. Extract all row indices that are equal to the mode. Determine the first continuous row interval by analyzing the difference between adjacent indices, which is used as the vertical range of the target motion. S32. Generate a column index vector with the same width as the image. Replace the values of edge pixels in the binary image with their column indices by dot product operation. Extract the column index information of edge pixels from the continuous row interval determined in S31. After matrix reconstruction, calculate the average column index by column to obtain the column indices of the left and right edges of the outer diameter of the target region. At the same time, calculate the outer diameter pixel width. S33. Based on the calibrated inner and outer diameter ratio obtained from the pre-calibration, and combined with the outer diameter pixel width identified in S32, the pixel width and starting position of the inner diameter are adaptively calculated using the parity judgment rule, and the inner diameter region matrix is cropped from the original binary image. S34. Set a mask for the inner diameter region matrix along the forward direction of the dynamic target to be measured, retain the backward region, replace the value of each edge pixel in the retained region with the row index of that pixel, and extract the maximum value of each column as the reference contour of the first image. S35. Based on the known actual outer diameter of the target and the outer diameter pixel width obtained in S32, calculate the conversion factor between pixels and physical size as a global parameter.
5. The contour extraction method for dynamic sequence images according to claim 4, characterized in that, The parity determination rules in S33 specifically include: S331. Calculate the initial pixel width of the inner diameter based on the ratio of the inner and outer diameters after calibration and the pixel width of the outer diameter obtained in S32. S332. Determine the parity of the outer diameter pixel width: If half of the outer diameter pixel width is equal to its integer value, then the number of outer diameter pixels is even; otherwise, it is odd. S333. Determine the parity of the initial pixel width of the inner diameter: If half of the initial pixel width of the inner diameter is equal to its integer value, then the initial pixel count of the inner diameter is even; otherwise, it is odd. S334. If the parity of the number of pixels on the outer diameter is the same as that of the initial number of pixels on the inner diameter, then the final pixel width of the inner diameter is the initial pixel width of the inner diameter; if the parity is different, then the final pixel width of the inner diameter is the initial pixel width of the inner diameter plus 1, ensuring that the centers of the inner and outer diameters coincide.
6. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The specific steps for batch frame adaptive contour extraction include: S41. Adaptive search width calculation: Based on the row index values of each column of the contour extracted in the previous frame, calculate the fluctuation amplitude of the contour, and adaptively determine the width of the strip search area in the current frame accordingly. The forward search width along the motion direction is greater than the backward search width in the opposite motion direction. S42. Dynamic strip mask construction: Taking the outline position of the previous frame as the center, traverse each column of the current frame image, retain the area from the forward search range to the backward search range of the column, set the pixels outside the area to 0, and generate a dynamic strip search mask. S43. Weighted matrix transformation: For the binary image after masking, the value of each effective edge pixel is replaced with its row index by a dot product operation, and the region with a value of 0 is set to the null value NaN. S44. Extreme value extraction: Extract the minimum value along the column direction of the weighted matrix to obtain the target contour position in the current frame; S45. Iterative processing: Save the contour position of the current frame as the reference for the next frame processing, and repeat steps S41-S44 to complete the contour extraction of all sequence images.
7. The contour extraction method for dynamic sequence images according to claim 6, characterized in that, The formula for calculating the adaptive search width in S41 is as follows: Based on the row index values of each column of the target contour extracted from the previous frame. ,in,( =1,2,…, , (This refers to the number of image columns); calculate the fluctuation amplitude of the meniscus contour, and adaptively determine the width of the strip search region for the current frame based on this amplitude. The formula for calculating the profile fluctuation amplitude is: ; The formula for calculating the forward search width is: ; The formula for calculating the backward search width is: ; Wherein, the weight coefficients satisfy This is to ensure that the forward search range along the direction of motion is greater than the backward search range; in, For the amplitude of contour fluctuation, The height of the crescent moon. This is the width of the forward search; This is the width of the backward search; Forward search weight coefficient; This represents the backward search weight coefficient.
8. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The specific steps for performing the gap interpolation correction include: S51, Missing Value Detection: Traverse the batch frames adaptive contour extraction output target contour data and detect whether there is a missing value NaN; S52, Neighbor Interpolation: For each null value location, find the two nearest valid contour values to that location, and calculate the mean of the two valid values to fill the null value; S53. Continuity check: Perform a continuity check on the filled contour. If the difference between adjacent points exceeds a preset threshold, re-interpolate to ensure the continuity of the contour data.
9. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The specific steps for performing the physical quantity conversion and visualization output include: S61. Using the pixel and physical size conversion coefficients extracted from the first frame reference contour, convert all pixel-level contour data into physical size contours. When the target to be measured is a transparent medium, divide the lateral physical size by the refractive index of the medium to eliminate refraction error. S62. Select key frames from the sequence images according to a preset time interval, stitch the original images of the key frames horizontally in chronological order, and overlay the extracted contours of the corresponding frames onto the original images. S63. Mark the time nodes and physical dimensions of the outline on the stitched image, and output a visual comparison diagram of the morphological change process of the dynamic target under test.
10. The contour extraction method for dynamic sequence images according to claim 1, characterized in that, The input parameters of the method include only: the actual outer diameter of the target under test, the refractive index of the medium under test, the starting number of the effective image, and the Canny edge detection threshold.
Citation Information
Patent Citations
Self-adaptive contour extraction method
CN119027442A