An online calibration method and system for hydrological flow data

By setting velocity measurement lines in water surface videos to determine illumination status and perform image restoration, spatiotemporal images are constructed, and corner detection and clustering are performed. This solves the problems of window segmentation roughness and illumination interference, and improves the calculation accuracy of hydrological flow data.

CN121346947BActive Publication Date: 2026-03-20XIAN ERJI ENVIRONMENTAL PROTECTION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-16
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing spatiotemporal image velocity measurement methods do not consider the impact of window segmentation on accuracy when calculating texture angles, and illumination interference causes flow calculation errors, making it difficult to cope with complex illumination conditions.

Method used

By setting speed measurement line areas in water surface videos, we can determine the lighting conditions and perform image restoration, construct spatiotemporal images, perform corner detection and clustering, divide the data into multiple windows, construct weights for each window, and perform weighted texture angle calculations.

Benefits of technology

It effectively eliminates the impact of uneven lighting on video quality, achieves adaptive window partitioning, and improves the calculation accuracy of hydrological flow data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121346947B_ABST
    Figure CN121346947B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image processing, in particular to a kind of online calibration method and system of hydrological flow data, solve the technical problem that the low precision of flow calculation caused by window segmentation rough and illumination interference in prior art.The method comprises: collecting the water surface video in the river flow process, and setting the speed line area in the water surface video along the flow direction;According to the gray distribution of speed line area, illumination state is judged, and according to the judgment result, image restoration is carried out on the illumination abnormal area in the water surface video, to obtain the water surface video after restoration;Temporal-spatial image is constructed to the water surface video after restoration and corner point detection is carried out, the clustering is carried out to corner point to divide multiple windows, constructs window weight for each window;According to the window weight of each window, the texture angle of each window is weighted to obtain weighted texture angle, and the hydrological flow data is calculated according to the weighted texture angle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically to an online calibration method and system for hydrological flow data. Background Technology

[0002] Hydrological flow data serves as the foundation for hydrological research, and its accurate monitoring is crucial for flood disaster prevention and river management.

[0003] Traditional contact flow measurement methods rely on on-site operations, making it difficult to cope with the increasingly frequent challenges of major floods. In contrast, space-time image velocimetry (STIV) can obtain flow velocity simply by analyzing river video images. It has the advantages of low equipment cost and minimal safety risks, and has become an important technical direction for hydrological flow measurement.

[0004] However, existing spatiotemporal image velocity measurement methods use a fixed number of windows to calculate texture angles, without considering the impact of window segmentation on the accuracy of texture angle calculation. At the same time, when shooting water surface videos, they are easily affected by complex lighting, such as bright areas formed by sunlight reflection, dark areas caused by microorganisms and suspended matter, and shadows caused by buildings and trees, which will generate background noise, resulting in weak image contrast and black spots, which in turn lead to deviations in flow velocity estimation and errors in hydrological flow calculation. Summary of the Invention

[0005] To address the technical problem of low flow calculation accuracy caused by coarse window segmentation and illumination interference in existing technologies, the present invention aims to provide an online calibration method and system for hydrological flow data. The specific technical solution adopted is as follows:

[0006] Firstly, an online calibration method for hydrological flow data is provided, comprising: acquiring water surface videos during river flow, and setting velocity measurement line regions along the flow direction in the water surface videos; judging the illumination status based on the grayscale distribution of the velocity measurement line regions, and performing image restoration on the illumination abnormal areas in the water surface videos based on the judgment results to obtain restored water surface videos; constructing a spatiotemporal image of the restored water surface videos and performing corner detection, clustering the corner points to divide them into multiple windows, and constructing window weights for each window; the width of the spatiotemporal image represents the spatial length of the velocity measurement lines, and the height represents the number of frames in the time direction; weighting the texture angle of each window according to the window weight of each window to obtain a weighted texture angle, and calculating hydrological flow data based on the weighted texture angle; the texture angle is the angle formed by the direction of the image texture in the spatiotemporal image and the time coordinate axis.

[0007] Based on the above technical solution, in the online calibration method for hydrological flow data provided by this invention, the impact of uneven lighting phenomena such as reflections and shadows on video quality is effectively eliminated by judging the illumination state and image restoration based on the grayscale distribution of the velocity line area. Furthermore, adaptive window partitioning is achieved through corner detection and clustering, overcoming the coarseness problem of fixed window segmentation. Finally, by constructing window weights and weighting the texture angles of each window, the role of high-texture-quality areas is highlighted, thereby improving the final calculation accuracy of hydrological flow data throughout the entire process from image preprocessing and feature extraction to core calculation.

[0008] In conjunction with the first aspect above, in one possible implementation, the method for judging the illumination status based on the grayscale distribution of the speed measurement line area specifically includes: extracting the speed measurement line area from a single frame image of the water surface video; converting the speed measurement line area into a grayscale image and generating a grayscale histogram of the grayscale image; using the grayscale histogram to characterize the grayscale value distribution of the speed measurement line area; judging the illumination status based on the number of peaks and valleys in the grayscale histogram; if there are multiple peaks or multiple valleys, it is determined that there is uneven illumination; otherwise, it is determined that the illumination distribution is uniform.

[0009] In conjunction with the first aspect mentioned above, in one possible implementation, the method for image inpainting of abnormal lighting areas in a water surface video based on the judgment result to obtain a repaired water surface video specifically includes: dividing multiple gray-level intervals according to the valley values ​​of the gray-level histogram; using gray-level intervals to distinguish different lighting areas; merging pixels with gray-level values ​​belonging to the same interval and spatially continuous in a single frame image of the water surface video into windows to obtain multiple windows; comparing the degree of deviation of the gray-level mean of each window with the gray-level mean of the single frame image; when the degree of deviation exceeds a preset threshold, marking the corresponding window as an abnormal window; and for the abnormal window, selecting a preset image inpainting algorithm for repair based on the degree and direction of deviation.

[0010] In conjunction with the first aspect mentioned above, in one possible implementation, the method of selecting a preset image restoration algorithm to repair abnormal windows based on the degree and direction of deviation specifically includes: if the deviation direction is such that the gray-scale mean of the abnormal window is greater than the gray-scale mean of a single frame image, an adaptive histogram equalization algorithm is used for repair based on the degree of deviation; if the deviation direction is such that the gray-scale mean of the abnormal window is less than the gray-scale mean of a single frame image, an adaptive contrast enhancement algorithm is used for repair based on the degree of deviation.

[0011] In conjunction with the first aspect mentioned above, in one possible implementation, the method of constructing a spatiotemporal image and performing corner detection on the repaired water surface video, clustering the corners to divide them into multiple windows, and constructing window weights for each window specifically includes: extracting and arranging the velocity line region images of each frame in chronological order from the repaired water surface video to construct a spatiotemporal image; detecting corners in the spatiotemporal image using a corner detection algorithm; clustering the detected corners using a preset clustering algorithm to obtain multiple clusters; generating multiple windows for each cluster using a preset fitting algorithm; and determining the window weight of each window based on the number of corners, texture clarity, and signal-to-noise ratio in the multiple windows.

[0012] In conjunction with the first aspect above, in one possible implementation, the method for determining the window weight of each window based on the number of corner points, texture sharpness, and signal-to-noise ratio (SNR) across multiple windows specifically includes: determining the corner point number weight of the current window based on the number of corner points in the current window and the total number of corner points across multiple windows; determining the texture sharpness weight by analyzing the gradient changes in the image of the current window in the spatial and temporal directions based on the image texture of the current window; determining the SNR weight based on the pixel values ​​of signal and noise within the current window; and determining the window weight of the current window based on the corner point number weight, texture sharpness weight, and SNR weight.

[0013] In conjunction with the first aspect above, in one possible implementation, the method further includes: adjusting the window size according to the distribution state of corner points in each cluster; the distribution state includes corner point density or number of corner points.

[0014] In conjunction with the first aspect above, in one possible implementation, the method for calculating hydrological flow data based on weighted texture angles specifically includes: determining the pixel displacement of the velocity line in the time series based on the weighted texture angles; calculating the actual movement distance based on the pixel displacement and the actual distance represented by each pixel; and calculating the flow velocity based on the actual movement distance and the video frame rate.

[0015] In conjunction with the first aspect above, in one possible implementation, the method for acquiring water surface video during river flow specifically includes: acquiring river flow video; denoising the river flow video to obtain denoised video; converting each frame of the denoised video into a grayscale image, and performing image segmentation on the grayscale image to extract the mask of the water surface region; processing each frame of the image according to the mask of the water surface region, removing non-water surface regions, and generating a water surface video containing only the water surface region.

[0016] Secondly, an online calibration system for hydrological flow data is provided, comprising: a video acquisition module, an image restoration module, a window weighting module, and a data calibration module; the video acquisition module is used to acquire water surface videos during river flow and set velocity measurement line areas along the flow direction in the water surface videos; the image restoration module is used to determine the illumination status based on the grayscale distribution of the velocity measurement line areas, and to restore the images of abnormal illumination areas in the water surface videos based on the determination results, thereby obtaining restored water surface videos; the window weighting module is used to construct a spatiotemporal image of the restored water surface videos and perform corner detection, cluster the corner points to divide them into multiple windows, and construct window weights for each window; the width of the spatiotemporal image represents the spatial length of the velocity measurement line, and the height represents the number of frames in the time direction; the data calibration module is used to weight the texture angle of each window according to the window weight of each window to obtain a weighted texture angle, and to calculate hydrological flow data based on the weighted texture angle; the texture angle is the angle formed by the direction of the image texture in the spatiotemporal image and the time coordinate axis.

[0017] Thirdly, an online calibration device for hydrological flow data is provided, comprising: a processor and a storage medium; the storage medium includes instructions, and the processor is configured to execute the instructions to perform the actions described in the first aspect and any possible implementation thereof. This online calibration device for hydrological flow data can be an electronic device or a chip within an electronic device.

[0018] Fourthly, a computer-readable storage medium is provided, which stores instructions that, when executed on an online calibration device for hydrological flow data, cause the online calibration device for hydrological flow data to perform the actions described in the first aspect and any possible implementation thereof.

[0019] Fifthly, a computer program product containing instructions is provided that, when the computer program product is run on an online calibration device for hydrological flow data, causes the online calibration device for hydrological flow data to perform the actions described in the first aspect and any possible implementation thereof.

[0020] The present invention has the following beneficial effects:

[0021] By using illumination condition judgment and image inpainting based on the grayscale distribution of the velocity measurement line area, the impact of uneven illumination phenomena such as reflections and shadows on video quality is effectively eliminated. Furthermore, adaptive window partitioning is achieved through corner detection and clustering, overcoming the coarseness problem of fixed window segmentation. Finally, by constructing window weights and weighting the texture corners of each window, the role of high-texture-quality areas is highlighted, thereby improving the final calculation accuracy of hydrological flow data throughout the entire process from image preprocessing and feature extraction to core calculations. Attached Figure Description

[0022] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 A system structure diagram of an online calibration system for hydrological flow data provided in one embodiment of the present invention;

[0024] Figure 2 A flowchart illustrating an online calibration method for hydrological flow data, provided in one embodiment of the present invention;

[0025] Figure 3 A flowchart illustrating another online calibration method for hydrological flow data provided in an embodiment of the present invention;

[0026] Figure 4 A flowchart illustrating another online calibration method for hydrological flow data provided in an embodiment of the present invention;

[0027] Figure 5 A flowchart illustrating another online calibration method for hydrological flow data provided in one embodiment of the present invention;

[0028] Figure 6 This is a schematic diagram of the hardware structure of an online calibration device for hydrological flow data provided in one embodiment of the present invention. Detailed Implementation

[0029] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of an online calibration method and system for hydrological flow data proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0031] It should be noted that all mathematical formulas described in this manual include conventional numerical stability handling in their computer program implementation. Specifically, when the denominator term in a formula calculates to zero or close to zero in extreme cases, the system automatically introduces a non-zero positive number of the same dimension (e.g., 10^-6) and adds it to prevent program interruption or calculation divergence caused by division by zero, thus ensuring the continuity of data processing and the robustness of the system.

[0032] The following description, in conjunction with the accompanying drawings, details the specific scheme of the online calibration method and system for hydrological flow data provided by this invention.

[0033] Please see Figure 1 The diagram illustrates a system structure of an online calibration system for hydrological flow data according to an embodiment of the present invention. The online calibration system for hydrological flow data includes: a video acquisition module 1, an image restoration module 2, a window weight construction module 3, and a data calibration module 4.

[0034] Among them, the video acquisition module 1 is the data input source of the system, responsible for acquiring high-quality video of the river surface and the core reference velocity line area.

[0035] In some implementations, the video acquisition module 1 specifically includes two sub-modules: camera sub-module 11 and preprocessing sub-module 12.

[0036] The camera submodule 11 is used to collect video of the river flow using a high-definition camera fixed to the riverbank. During the collection process, a velocity measurement line area needs to be set along the direction of the river flow. At the same time, the camera needs to operate according to preset parameters (such as fixed acquisition frequency and acquisition duration) to ensure that the acquired video can fully reflect the dynamic changes of the water flow and avoid affecting the accuracy of subsequent calibration due to missing data.

[0037] The preprocessing submodule 12 is used to optimize the raw river flow video acquired by the camera submodule 11 and remove invalid interference information. The preprocessing submodule 12 may specifically include three units: a noise reduction unit, an image conversion and segmentation unit, and a water surface video generation unit.

[0038] The denoising unit is used to eliminate blurry noise caused by camera shake due to wind speed and bird interference by employing a preset denoising algorithm (such as median filtering), thus avoiding noise affecting image grayscale analysis and feature extraction.

[0039] The image conversion and segmentation unit first converts the denoised video frames from RGB (red, green, blue) images to grayscale images, and then uses a preset segmentation algorithm (such as the watershed algorithm) to perform binary segmentation on the grayscale images to generate a water surface region mask.

[0040] The water surface video generation unit uses the water surface area mask and the processed image of each frame to perform calculations, remove non-water surface areas, and obtain a single frame water surface image; then, all single frame water surface images are arranged in the order of image acquisition time to form a continuous water surface video.

[0041] The video acquisition module 1 ultimately outputs a video of the water surface containing the speed measurement line area. This video is directly transmitted to the image restoration module 2 as the object of processing for lighting condition judgment and image restoration.

[0042] Image restoration module 2 addresses potential lighting interference issues (such as sunlight reflection and building / tree shadows) in the water surface video output by video acquisition module 1. Through lighting judgment and precise restoration, it outputs a high-quality restored water surface video, eliminating image quality errors for subsequent window weight construction and flow calculation. Specifically, it includes two sub-modules: lighting status judgment sub-module 21 and lighting anomaly restoration sub-module 22.

[0043] The illumination status judgment submodule 21 is used to determine whether there is uneven illumination by taking the velocity line area in the water surface video as the analysis object. Specifically, it includes two units: the velocity line area extraction unit and the grayscale histogram analysis unit.

[0044] The velocity line region extraction unit is used to accurately crop out the preset velocity line region from each frame of the water surface image in the water surface video (analyzing only this region can focus on the core area of ​​the water flow and reduce the interference of non-core areas on the light judgment).

[0045] The grayscale histogram analysis unit is used to convert the extracted speed measurement line area from an RGB image to a grayscale image and generate a grayscale histogram of the grayscale image (the grayscale histogram is used to characterize the pixel distribution of different grayscale values ​​within the speed measurement line area); then the illumination status is determined based on the number of peaks and valleys in the grayscale histogram.

[0046] The lighting anomaly repair submodule 22 is used to repair water surface videos that are determined to have uneven lighting. It specifically includes three units: grayscale range division unit, abnormal window judgment unit, and scene-specific repair unit.

[0047] The grayscale interval division unit is used to divide multiple continuous grayscale intervals based on the valley values ​​(local minimum points) in the grayscale histogram. The division rule is to divide the grayscale value range into intervals from 0 to the first valley value, between adjacent valley values, and from the last valley value to the maximum grayscale value, with each interval corresponding to a region of a certain type of illumination feature.

[0048] The abnormal window determination unit is used to traverse the pixels within the speed measurement line area, merge pixels whose gray values ​​belong to the same gray range and are spatially continuous into a window, and then calculate the degree of deviation of the gray mean of each window from the overall gray mean of the single frame water surface image. When the deviation exceeds a preset threshold, the window is marked as an abnormal lighting window.

[0049] The scene-specific repair unit is used to select the corresponding preset repair algorithm based on the deviation direction of the abnormal window.

[0050] Image restoration module 2 outputs the restored water surface video, which is then transmitted to window weight construction module 3 as the original material for spatiotemporal image construction.

[0051] The window weight construction module 3 is used to construct a spatiotemporal image and dynamic window adapted to the water flow texture features based on the repaired water surface video output by the image repair module 2, and calculate the window weight to provide accurate spatial division and weight basis for subsequent texture corner optimization and flow calculation. It specifically includes 3 sub-modules: spatiotemporal image construction sub-module 31, corner detection and clustering sub-module 32, and window weight calculation sub-module 33.

[0052] The spatiotemporal image construction submodule 31 is used to convert time-series water surface videos into spatiotemporal images that have both time and space dimensions. Specifically, it includes two units: a velocity line image extraction unit and a spatiotemporal image generation unit.

[0053] The velocity line image extraction unit is used to extract the image of the velocity line area again from each frame of the repaired water surface video (ensuring that only the image information of the core motion area of ​​the water flow is retained).

[0054] The spatiotemporal image generation unit is used to arrange all extracted velocity line images in the order of image acquisition time to construct a spatiotemporal image.

[0055] The corner detection and clustering submodule 32 is used to achieve dynamic window partitioning (replacing the coarse method of fixed windows in the existing technology) through corner detection and clustering. Specifically, it includes three units: corner detection unit, corner clustering unit, and window fitting unit.

[0056] The corner detection unit is used to detect corners at the intersection of water flow textures in a spatiotemporal image using a preset corner detection algorithm.

[0057] The corner clustering unit is used to cluster the detected corners using a preset clustering algorithm, forming multiple clusters.

[0058] The window fitting unit is used to generate a corresponding window for each cluster by applying a preset fitting algorithm (such as the minimum outer circumference matrix fitting algorithm). This enables dynamic partitioning of areas with dense corner points into larger windows and areas with sparse corner points into smaller windows, ensuring that each window can accurately match the water flow texture features.

[0059] The window weight calculation submodule 33 is used to calculate the window weight based on the window's feature parameters (the weight value is used to characterize the importance of the window in texture angle calculation), and specifically includes two units: a weight parameter calculation unit and a window weight integration unit.

[0060] The weight parameter calculation unit is used to calculate three types of core parameters for each window: corner number parameter (the ratio of the number of corners in the current window to the total number of corners in all windows, reflecting the richness of texture information within the window), texture clarity parameter (calculated based on the gradient changes of the window image in the temporal and spatial directions, reflecting the clarity of the texture), and signal-to-noise ratio parameter (calculated based on the ratio of pixel signal to noise signal within the window, reflecting image quality).

[0061] The window weight integration unit is used to integrate the corner number parameter, texture clarity parameter, and signal-to-noise ratio parameter according to preset rules to obtain the window weight of each window.

[0062] The window weight construction module 3 ultimately outputs a spatiotemporal image, dynamically divided windows, and corresponding window weights. All three are transmitted to the data calibration module 4 as the core input for weighted texture angle calculation and hydrological flow calculation.

[0063] The data calibration module 4 is the core calculation module of the system. Based on the window weight, the output of module 3 is constructed. Through weighted texture angle optimization and flow velocity and flow rate calculation, accurate hydrological flow data is finally obtained to complete online calibration. It specifically includes two sub-modules: weighted texture angle calculation sub-module 41 and hydrological flow rate calculation sub-module 42.

[0064] The weighted texture angle calculation submodule 41 is used to optimize the texture angle through window weights to obtain a weighted texture angle that better matches the actual water flow motion. Specifically, it includes two units: the original texture angle acquisition unit and the weighted texture angle optimization unit.

[0065] The original texture angle acquisition unit is used to analyze the spatiotemporal image texture in each dynamic window using a preset texture angle detection algorithm (such as the gray-scale gradient tensor method) to obtain the original texture angle of each window (the original texture angle is the angle formed by the texture direction in the spatiotemporal image and the time coordinate axis, reflecting the initial movement direction of the water flow in the window).

[0066] The weighted texture angle optimization unit multiplies the original texture angle of each window by its corresponding window weight, and then calculates the average of the weighted results for all windows to obtain the weighted texture angle. The weighted texture angle can effectively highlight the contribution of high-weight windows (rich, clear texture, and low noise), suppress the error interference of low-weight windows, and more accurately reflect the actual direction of water flow.

[0067] The hydrological flow calculation submodule 42 is used to calculate flow velocity and hydrological flow based on weighted texture angle and to complete calibration. It specifically includes two units: a flow velocity calculation unit and a flow integration unit.

[0068] The flow velocity calculation unit is used to determine the direction of motion of the water flow texture in the spatiotemporal image based on the weighted texture angle, and calculates the water flow velocity in the velocity measurement line area by combining the preset pixel actual distance parameter (the actual spatial distance represented by each pixel) and the camera frame rate parameter (video acquisition frequency).

[0069] The flow integration unit is used to calculate the flow rate using a preset flow rate calculation method (such as the velocity area method), multiplying the flow velocity in the velocity measurement line area with the cross-sectional area of ​​the corresponding section of the river (preset river geometric parameters) to obtain the local flow rate of that section. Then, the local flow rates of all sections of the river are accumulated to obtain the final hydrological flow rate data.

[0070] The data calibration module 4 ultimately outputs accurate hydrological flow data, which is the result of the system's online calibration and can be directly used for decision support in scenarios such as flood disaster prevention and control and river management.

[0071] Please see Figure 2 The diagram illustrates a flowchart of an online calibration method for hydrological flow data according to an embodiment of the present invention. The online calibration method for hydrological flow data includes:

[0072] S1. Collect video of the river surface during the water flow process, and set up a velocity measurement line area along the direction of water flow in the video.

[0073] In some implementations, methods for acquiring video of the river surface during water flow can include: acquiring video of the river flow, denoising the video to obtain a denoised video, converting each frame of the denoised video into a grayscale image, segmenting the grayscale image, and extracting the mask of the water surface region. Finally, processing each frame based on the water surface region mask, removing non-water surface regions, and generating a video containing only the water surface region.

[0074] Specifically, high-definition cameras are used to capture raw video of the river's flow. The cameras must be fixed on the riverbank in a location with a clear view, with the lens facing the main flow direction to ensure complete coverage of the main water flow area. The capture parameters need to be preset, such as a capture duration of 15 seconds (adjustable according to water flow stability; shortened to 10 seconds for rapid flow and extended to 20 seconds for calm flow), and a capture frequency of 30 frames per second (fps) to ensure accurate dynamic capture of the water flow and avoid loss of detail due to a low frame rate.

[0075] The raw river flow video was denoised to eliminate noise caused by environmental interference (such as camera shake due to wind speed or birds flying across the screen). Specifically, a median filtering algorithm was used, which replaces the pixel value with the median grayscale value in the neighborhood of each pixel, effectively suppressing impulse noise and salt-and-pepper noise while preserving the edge information of the water surface texture. The resulting denoised video reduces errors in subsequent image analysis.

[0076] The denoised video is converted frame by frame into grayscale images (reducing redundant information in the RGB three channels and simplifying computation). Then, image segmentation is performed on the grayscale images to extract the water surface region. The segmentation can use the watershed algorithm: first, the grayscale image is binarized by a preset threshold (distinguishing between possible water surface and non-water surface regions). Then, based on the topological structure of the image, the grayscale image is regarded as a terrain surface, and the region is expanded starting from the local minimum value. Finally, an accurate water surface region mask is obtained. If the mask is a binary image, "1" represents the water surface region and "0" represents non-water surface regions such as riverbank vegetation and buildings.

[0077] The water surface area mask is multiplied pixel-by-pixel with each frame of the denoised grayscale image. Pixels corresponding to "1" in the mask (water surface area) are retained, while pixels corresponding to "0" (non-water surface area) are removed, resulting in a single-frame water surface image. Finally, all single-frame water surface images are arranged in chronological order to form a continuous water surface video.

[0078] Furthermore, in the generated water surface video, a straight line is drawn along the direction of the river flow as the velocity measurement line area. The velocity measurement line area needs to cover the main flow section of the river (avoiding backflow areas near the banks), and its length should not be less than 80% of the river width (to ensure representativeness). It serves as the benchmark area for determining illumination status, constructing spatiotemporal images, and calculating flow velocity in subsequent steps, directly affecting the accuracy of the final flow data.

[0079] S2. Based on the grayscale distribution of the velocity measurement line area, the illumination status is judged, and based on the judgment result, the image of the abnormal illumination area in the water surface video is repaired to obtain the repaired water surface video.

[0080] In some implementations, based on the water surface video and speed measurement line area, the speed measurement line area is first cropped from each frame of the water surface video and converted into a grayscale image. A grayscale histogram is generated to analyze the number of peaks and valleys to determine if the lighting is uniform. If the lighting is abnormal, continuous grayscale intervals are divided according to the valley values ​​of the grayscale histogram. Pixels with grayscale values ​​belonging to the same interval and spatially continuous are merged into a lighting analysis window. The deviation of the window's grayscale mean from the overall grayscale mean of the single-frame water surface image is calculated. If it exceeds a preset threshold, it is considered a window with abnormal lighting. Repair is then performed according to the direction of deviation: if the window's grayscale mean is higher than the overall mean, an adaptive histogram equalization algorithm is used to repair reflections; if it is lower than the overall mean, an adaptive contrast enhancement algorithm is used to repair shadows. Finally, all processed frames are integrated to obtain the repaired water surface video.

[0081] In other implementations, instead of relying on single-frame grayscale histograms, the illumination state can be determined by analyzing the brightness stability of the velocity measurement line region across consecutive frames. During restoration, region growing is used instead of valley interval division. This approach is suitable for scenes with gradual illumination changes (such as sunrise and sunset). Specifically, these include:

[0082] Calculate the average brightness value (i.e., the average grayscale value of each frame of grayscale image) of the velocity measurement line area in 5 consecutive frames of the water surface video (which can be adjusted according to the actual scene). If the difference between the average brightness values ​​of consecutive frames is less than the preset stable threshold (e.g., 5%), it is determined to be uniform lighting. If the difference between any two frames exceeds the stable threshold, it is determined to be abnormal lighting, and the frame with the brightness change and the corresponding area are located (the area with the brightness change is the area with abnormal lighting).

[0083] Then, using the normal-brightness neighboring pixels (i.e., pixels whose brightness matches the overall average) in the abnormal lighting area as seed points, a region growing algorithm is used to include pixels whose brightness difference between the seed point and its neighboring pixels is less than the growth threshold into the growing region. At the same time, the brightness of the growing region is dynamically adjusted to the normal range (referencing the brightness of the seed point) to avoid brightness gaps in the neighborhood. After repair, all frames are integrated to obtain the repaired water surface video.

[0084] Furthermore, one can move beyond the grayscale image analysis framework and utilize RGB-HSV (hue, saturation, value) color space conversion to extract the luminance channel (V channel) for separate illumination analysis. During restoration, the Retinex algorithm can be used instead of scene-specific equalization and enhancement, making it suitable for scenes with colored water surfaces (including those with complex color interference, such as algae covering the water surface).

[0085] Alternatively, instead of relying on traditional image features (grayscale histogram, brightness standard deviation), it can use a pre-trained deep learning model to classify lighting anomaly types and perform end-to-end repair, which is suitable for extreme lighting scenarios (such as rainstorm reflections and nighttime light interference).

[0086] S3. Construct a spatiotemporal image of the repaired water surface video and perform corner detection. Cluster the corners to divide them into multiple windows and construct window weights for each window.

[0087] In this context, the width of the spatiotemporal image represents the spatial length of the velocity measurement line, and the height represents the number of frames in the time direction.

[0088] In some implementations, the restored water surface video is used as input. First, velocity measurement line regions are extracted frame-by-frame from the water surface image, and these images are arranged vertically in chronological order of acquisition to construct a spatiotemporal image. Then, a pre-defined corner detection algorithm is used to identify corners at the intersections of water flow textures in the spatiotemporal image, outputting a set of corner coordinates. The corner density is positively correlated with changes in water flow velocity. Next, a pre-defined density clustering algorithm divides the set of corner coordinates into multiple corner clusters, and a pre-defined geometric fitting algorithm generates a corner window for each cluster. Finally, window weights are constructed based on three dimensions: corner quantity, texture clarity, and signal-to-noise ratio.

[0089] In other implementations, instead of relying on corner detection and clustering, a window can be divided by analyzing the texture frequency of the spatiotemporal image. The weights focus solely on texture sharpness, making it suitable for scenarios with uniform water flow texture distribution (such as slow-flowing rivers in plains). This simplifies the computation process. Specific implementations include:

[0090] Using a preset frequency analysis algorithm (such as Fourier transform), the texture frequency (i.e., the number of texture cycles per unit area, with high texture frequency in areas of fast flow and low frequency in areas of slow flow) of different regions of the spatiotemporal image is calculated. Regions are divided according to texture frequency (e.g., low frequency range of 1-3 cycles per pixel, mid-frequency range of 4-6 cycles per pixel, and high-frequency range of 7-9 cycles per pixel), and spatially continuous regions within the same frequency range are divided into frequency windows.

[0091] Then, the texture sharpness weight is calculated based on the edge intensity of the texture within the window (the grayscale difference between edge pixels and adjacent pixels). The higher the mean edge intensity, the greater the texture sharpness weight. By directly using the texture sharpness weight as the final weight of the window without calculating the corner number and signal-to-noise ratio weights, computational complexity can be reduced.

[0092] In addition, it can locate the flow velocity change area by calculating the motion vector of the velocity measurement line area in adjacent frames without relying on corner points or texture frequency, and divide the window, which is suitable for scenarios where the flow velocity changes in real time (such as the flood season).

[0093] S4. The texture angle of each window is weighted according to the window weight of each window to obtain the weighted texture angle, and the hydrological flow data is calculated based on the weighted texture angle.

[0094] One approach is to use the grayscale gradient tensor method to identify the texture corner of the window at each corner point, thereby obtaining the window texture corner at each corner point.

[0095] In some implementations, methods for calculating hydrological flow data based on weighted texture angles include: determining the pixel displacement of the velocity line over time based on the weighted texture angle; then calculating the actual movement distance based on the pixel displacement and the actual distance represented by each pixel; and finally calculating the flow velocity based on the actual movement distance and the video frame rate.

[0096] Specifically, if the distance traveled along the velocity line within time T is L, then the flow velocity v is expressed as:

[0097]

[0098] In the formula, the motion distance L, when mapped to the image plane coordinate system, can be represented as the movement of i pixels in k frames of the image, where the actual distance corresponding to each pixel is... (Unit: meters per pixel).

[0099] Time T can be expressed as the time interval between data collection. The time taken to capture k frames of an image (unit: seconds / frame). The reciprocal of the value is the frame rate (FPS) of image acquisition.

[0100] Combining the width of the spatiotemporal image with its spatial length and height with the number of frames, the ratio of the number of moving pixels *i* to the number of frames *k* is the weighted texture angle. The tangent value.

[0101] Therefore, the flow velocity v is expressed as:

[0102]

[0103] Furthermore, hydrological flow can be obtained by using the velocity-area method based on the flow velocity and the area of ​​the interval (the velocity-area method is a well-known technique in the field of geological surveys and will not be elaborated further).

[0104] Based on the above technical solution, by judging the illumination status and inpainting the image based on the grayscale distribution of the velocity measurement line area, the impact of uneven illumination phenomena such as reflections and shadows on video quality is effectively eliminated. Furthermore, adaptive window partitioning is achieved through corner detection and clustering, overcoming the coarseness problem of fixed window segmentation. Finally, by constructing window weights and performing weighted calculations on the texture corners of each window, the role of high texture quality areas is highlighted, thereby improving the final calculation accuracy of hydrological flow data throughout the entire process from image preprocessing and feature extraction to core calculations.

[0105] In one possible implementation, combining Figure 2 ,like Figure 3As shown, the method for judging the illumination status based on the grayscale distribution of the velocity measurement line area in S2 above can be specifically implemented through the following S21 to S23, which are explained in detail below:

[0106] S21. Extract the velocity measurement line region from a single frame image of the water surface video.

[0107] In some implementations, a single frame of the water surface image is selected from the video (to ensure representativeness of the analysis, the middle frame of the video can be selected first to avoid the influence of shooting shake that may exist at the beginning and end of the video). Based on the preset coordinate range of the velocity measurement line area, the velocity measurement line area is accurately extracted from the single frame of the water surface image through an image cropping algorithm. During extraction, it must be ensured that the area is completely contained within the water surface area (by verifying the water surface area mask to avoid cropping into non-water surface areas), so as to ensure that the subsequent grayscale analysis only reflects the water surface illumination characteristics and eliminates the interference of non-water surface areas such as riverbanks and vegetation.

[0108] S22. Convert the speed measurement line area into a grayscale image and generate a grayscale histogram of the grayscale image.

[0109] Among them, the gray-level histogram is used to characterize the gray-level value distribution of the velocity measurement line area.

[0110] In some implementations, the extracted speed measurement line area (RGB image) is converted to a grayscale image. This conversion can employ a weighted average method, where the grayscale value of each pixel is used. The calculation formula is:

[0111]

[0112] In the formula, R, G, and B are the pixel values ​​of the red, green, and blue channels of the RGB image, respectively. This method can preserve the brightness characteristics of the original image and simplify the three-channel data into a single channel (grayscale value range 0-255), reducing the amount of subsequent calculations.

[0113] For the converted grayscale image, a histogram statistical algorithm is used to generate a grayscale histogram. Specifically, the number of pixels corresponding to each grayscale value (0 to 255) in the grayscale image is counted, and a bar chart is drawn with grayscale values ​​on the horizontal axis and the number of pixels on the vertical axis to form a grayscale histogram. This histogram can intuitively represent the grayscale value distribution characteristics of the velocity measurement line area. For example, when the illumination is uniform, the grayscale values ​​are concentrated in a certain range, and the histogram shows a single-peak shape; when the illumination is uneven, the grayscale values ​​are scattered in multiple ranges, and the histogram shows a multi-peak shape.

[0114] S23. Determine the lighting status based on the number of peaks and valleys in the grayscale histogram.

[0115] In some implementations, the first derivative (gradient) of the generated grayscale histogram is calculated, and peaks and valleys are identified by the positive and negative changes in the gradient value: when the gradient value changes from positive to negative, the corresponding position is a peak (the number of pixels of this grayscale value is a local maximum, representing a concentrated area of ​​a certain type of brightness); when the gradient value changes from negative to positive, the corresponding position is a valley (the number of pixels of this grayscale value is a local minimum, representing a transition zone between two types of brightness areas).

[0116] If multiple peaks or valleys exist, uneven illumination is determined; otherwise, the illumination distribution is determined to be uniform. Specific analysis follows:

[0117] If the number of peak values ​​is 1 and the number of valley values ​​is 1, it means that the gray values ​​in the speed measurement line area are concentrated in a single range with no obvious brightness difference, and it is judged that the illumination distribution is uniform.

[0118] If the number of peak values ​​is ≥2 or the number of valley values ​​is ≥2 (i.e., there are multiple peak values ​​or multiple valley values), it indicates that there are at least two types of areas with significant brightness differences (such as reflective areas and shadow areas) within the speed measurement line area, which is judged as uneven illumination.

[0119] Based on the above technical solution, by extracting the velocity line region from a single frame of a water surface video, converting the region into a grayscale image and generating a grayscale histogram that can characterize its grayscale value distribution, and then judging the illumination status based on the number of peaks and valleys in the grayscale histogram, this process can accurately identify the illumination situation of the velocity line region in the water surface video, effectively distinguish between uniform and uneven illumination, and provide an accurate basis for subsequent targeted repair of abnormal illumination areas and elimination of illumination interference. This reduces the adverse effects of illumination factors on subsequent hydrological flow calculations and ensures the accuracy of hydrological flow data calibration.

[0120] In one possible implementation, combining Figure 3 ,like Figure 4 As shown, the method for image repair of abnormal lighting areas in the water surface video based on the judgment result in S2 above, to obtain the repaired water surface video, can be specifically implemented through the following S24 to S27, which are explained in detail below:

[0121] S24. Divide the grayscale into multiple grayscale intervals based on the valley values ​​of the grayscale histogram.

[0122] Among them, grayscale ranges are used to distinguish different lighting areas.

[0123] In some implementations, all valley values ​​are first preprocessed, including sorting them in ascending order of their corresponding grayscale values ​​to obtain an ordered set of valley values ​​(denoted as ). , ,..., , where n is the total number of valley values. The purpose of sorting is to ensure that the subsequently divided grayscale intervals are continuous in the grayscale value dimension, avoid interval overlap or gaps, and ensure that each grayscale value can be assigned to a unique interval.

[0124] Divide the grayscale range into n+1 continuous intervals using the valley value as the boundary. The first interval is [0, ), corresponding to the area with the lowest gray value within the speed measurement line area (mostly dark areas covered by shadows); the middle interval is [ , ),[ , ), [ , ..., [ , Each interval corresponds to a medium grayscale area (mostly a transitional lighting area, with brightness between dark and bright areas); the last interval is [

[255] corresponds to the area with the highest gray value within the speed measurement line area (mostly areas illuminated by sunlight reflection).

[0125] S25. Pixels with gray values ​​belonging to the same range and spatially continuous in a single frame of the water surface video are merged into a window to obtain multiple windows.

[0126] In some implementations, the grayscale values ​​on the speed measurement line are traversed, and the grayscale interval to which they belong is marked according to their grayscale values. Then, a criterion for determining spatial continuity is defined. Based on this criterion, a set of pixels within the speed measurement line area that satisfy the condition of being in the same interval and spatially continuous is selected, while pixels in the same interval but not spatially continuous (such as pixels in the same interval but separated by pixels in other intervals) are excluded. This ensures that pixels within the window to be merged in the subsequent process have spatial correlation and avoids cross-region mixing.

[0127] The criteria for determining spatial continuity are as follows: if two pixels are horizontally adjacent (i.e., left and right pixels with a difference of 1 in horizontal coordinates and the same vertical coordinates) or vertically adjacent (i.e., top and bottom pixels with a difference of 1 in vertical coordinates and the same horizontal coordinates) within the velocity line area of ​​a single frame image, then they are determined to be spatially continuous.

[0128] S26. Compare the deviation of the mean gray level of each window from the mean gray level of a single frame image.

[0129] In some implementations, the degree of deviation of window e The calculation formula is:

[0130]

[0131] In the formula, This indicates the degree of deviation of window e. Let be the average gray value of window e. This represents the average grayscale value of a single frame of the image.

[0132] In existing technologies, evaluation metrics such as relative deviation, relative error, and relative change are all based on the absolute value of the difference between two variables. This application uses the absolute value of the difference between the average grayscale value of pixels within a window and the average grayscale value of pixels in the entire image to reflect the degree of deviation of the average grayscale value within the window when the average grayscale value of pixels in the entire image is used as a benchmark. This application considers the different pixel distributions within the window, therefore, by taking the absolute value of the difference, it quantifies the magnitude of the grayscale difference between the window and the overall image, ensuring that the degree of difference can be uniformly measured regardless of whether the window is too bright or too dark.

[0133] To eliminate the effects of deviations (too high / too low), only the magnitude of the grayscale difference between the window and the whole is quantified, ensuring that the degree of difference can be uniformly measured regardless of whether the window is too bright or too dark.

[0134] The grayscale deviation of window e relative to the overall water surface image is used to characterize the proportion of grayscale deviation of the window e. This can eliminate the influence of the overall grayscale level of the water surface (for example, if the overall grayscale value is high, even if the absolute difference is large, the relative proportion may not be large), and make the criteria for judging the degree of deviation (such as specifying...) When the percentage is greater than 20%, window e is an abnormal window and needs image restoration. This maintains fairness under different lighting scenarios and achieves accurate logic for judging abnormalities proportionally.

[0135] S27. When the deviation exceeds the preset threshold, the corresponding window is marked as an abnormal window. For the abnormal window, a preset image repair algorithm is selected for repair based on the degree and direction of deviation.

[0136] In some implementation methods, the preset threshold can be dynamically adjusted according to the actual river lighting environment. For example, if there is frequent light interference in the area, the threshold can be reduced to 15% to expand the repair range; if the lighting is stable, it can be increased to 25% to reduce ineffective repairs.

[0137] In some implementations, the method of selecting a preset image restoration algorithm for restoration may include:

[0138] If the deviation direction indicates that the average grayscale value of the abnormal window is greater than the average grayscale value of the single-frame image, it indicates that the window has abnormal reflection (such as bright spots formed by direct sunlight on the water surface). In this case, an adaptive histogram equalization algorithm is used for repair based on the degree of deviation. This involves stretching the local dynamic range of the grayscale histogram within the window to reduce the grayscale values ​​of overly bright areas while preserving the details of the water surface texture, so that the average grayscale value of the repaired window approaches the average grayscale value of the single-frame image. It should be noted that if the deviation is large (e.g., exceeding 40%), the local adjustment intensity of the histogram equalization can be increased to ensure complete suppression of bright spots; if the deviation is small (e.g., 20%-40%), moderate adjustments should be made to avoid overprocessing.

[0139] If the deviation direction indicates that the average grayscale value of the abnormal window is less than the average grayscale value of a single frame image, it indicates that the window has abnormal shadows (such as dark areas formed by buildings or trees). In this case, an adaptive contrast enhancement algorithm is used to repair it based on the degree of deviation. This involves locally enhancing the contrast of pixels in the dark area to increase the brightness of the dark area to a normal level, while avoiding noise caused by over-enhancing normal brightness areas. It should be noted that if the deviation is large (e.g., more than 40%), the contrast enhancement coefficient can be increased to quickly brighten the dark area; if the deviation is small (e.g., 20%-40%), moderate enhancement is used to preserve details in the dark area.

[0140] In some implementations, the method of selecting a preset image restoration algorithm for restoration can be further optimized, including: for adaptive histogram equalization of reflective scenes, the kernel function size of equalization can be adjusted in combination with the spatial position of the window (e.g., reflective windows near the center of the river need stronger restoration to avoid affecting the mainstream velocity analysis); for adaptive contrast enhancement of shadow scenes, edge detection technology (such as the Canny operator) can be introduced to first locate the shadow edge, and then the dark area within the edge can be enhanced in a targeted manner to avoid mistakenly enhancing normal texture areas.

[0141] Based on the above technical solution, multiple gray-level intervals can be distinguished according to the valley values ​​of the gray-level histogram, allowing for the precise definition of regions with different lighting characteristics within a single frame of a water surface video image. Furthermore, pixels with spatially continuous gray-level values ​​belonging to the same interval are merged into multiple windows, focusing on specific local lighting areas and avoiding interference from mixed analysis across lighting regions. Next, by comparing the deviation of the gray-level mean of each window from the gray-level mean of the single frame image, windows with abnormal lighting (i.e., windows with deviations exceeding a preset threshold) can be accurately identified. Finally, for abnormal windows, a preset image restoration algorithm is selected based on the degree and direction of deviation for repair. This can specifically eliminate different types of uneven lighting problems such as reflections and shadows, effectively improving the quality of the water surface image, reducing the adverse effects of lighting interference on subsequent hydrological flow calculations, and laying the foundation for improving the accuracy of hydrological flow data calibration.

[0142] In one possible implementation, combining Figure 2 ,like Figure 5 As shown, the method in S3 above can be specifically implemented through the following steps S31 to S35, which are explained in detail below:

[0143] S31. Extract and arrange the velocity measurement line area images of each frame in chronological order from the repaired water surface video to construct a spatiotemporal image.

[0144] First, the extraction range of the velocity measurement line region is determined, ensuring that the extracted region position and size are completely consistent in each frame to avoid spatiotemporal feature misalignment due to region offset. Next, following the frame-time order of the restored water surface video, an image cropping algorithm (such as OpenCV's ROI cropping function) is called frame by frame to accurately extract the velocity measurement line region image from each single-frame restored water surface image (retaining only the core water flow motion region and excluding redundant water surface information other than velocity measurement lines). Finally, all extracted velocity measurement line region images are arranged vertically: the width direction of a single-frame velocity measurement line region image is used as the spatial axis (horizontal axis) of the spatiotemporal image, and the length of this axis corresponds to the actual spatial length of the velocity measurement line; the arrangement direction of the frame time order is used as the time axis (vertical axis) of the spatiotemporal image, and the height of this axis corresponds to the total number of frames in the restored water surface video. After arrangement, a spatiotemporal image is formed, which can intuitively present the movement trajectory of water flow texture at different time points and spatial locations (e.g., the texture of areas with fast flow is more significantly offset on the time axis), providing multi-dimensional texture feature support for subsequent corner detection.

[0145] S32. Detect corners in spatiotemporal images using a corner detection algorithm.

[0146] Corners in spatiotemporal images are key locations where water flow textures intersect and turn. The gray values ​​at these locations change drastically and can reflect local changes in water flow velocity (areas with dense corners are usually areas of drastic flow velocity changes, while areas with sparse corners are usually areas of stable flow velocity).

[0147] In some implementations, the corner detection algorithm can be the Harris corner detection algorithm, which is sensitive to grayscale changes, has strong noise resistance, and is suitable for the dynamic features of water surface textures.

[0148] S33. Use a preset clustering algorithm to cluster the detected corner points to obtain multiple clusters.

[0149] In some implementations, considering the "uneven density" of the corner distribution of water flow textures (such as dense corners in the main flow area and sparse corners in the backflow area), the density-based spatial clustering of applications with noise (DBSCAN) algorithm is preferred. This algorithm does not require pre-setting the number of clusters, can automatically identify clusters of different densities, and remove isolated noise points.

[0150] S34. For each cluster, a preset fitting algorithm is used to generate multiple windows.

[0151] In some implementations, considering that the shapes of clusters are mostly irregular polygons (affected by the distribution of water flow textures), the minimum bounding rectangle fitting algorithm is preferred. This algorithm can generate the minimum rectangle that can completely wrap all corners of the cluster, ensuring that the window can cover all corners within the cluster, while avoiding texture mixing caused by an excessively large window.

[0152] In some implementations, to further improve the adaptability of the window to the water flow texture, the window size can be adjusted according to the distribution of corner points in each cluster. This distribution includes corner point density or the number of corner points. Specifically, this includes: reducing the size of windows with high corner point density and drastic texture changes to avoid including too many regions with different texture features within the window; and increasing the size of windows with low corner point density and gentle texture changes to ensure that the window covers more adjacent similar textures and avoids insufficient sample size due to an excessively small window. Alternatively, reducing the size of windows with a large number of corner points and rich texture information refines the window granularity and improves the accuracy of local texture analysis; and increasing the size of windows with a small number of corner points and scarce texture information by merging surrounding similar texture regions to ensure that the window contains sufficient texture information to support subsequent calculations.

[0153] S35. Determine the window weight of each window based on the number of corner points, texture clarity, and signal-to-noise ratio in multiple windows.

[0154] In some implementations, methods for determining the window weight of each window may include:

[0155] In this application, the corner count weight is calculated based on the number of corners within a single window and the total number of corners across multiple windows. Therefore, based on the number of corners in the current window e... Total number of corner points across multiple windows Determine the weight of the number of corner points in the current window e. , denoted as:

[0156]

[0157] Corner Count Weight It can reflect the richness of the water flow texture within window e. The larger the weight value, the more water flow texture intersections there are within window e, and the stronger the ability to represent the flow velocity characteristics. The value range is (0, 1).

[0158] Quantifying the weights of different objects by feature points or saliency is one of the common techniques in the field of data processing. A common approach is through normalization, such as weight normalization. This application quantifies the weights based on the existing weight normalization method. By considering that the number of corner points in each window is different, the ability to represent the flow velocity feature is different. The weight of the number of corner points is obtained by quantifying the weight of the number of corner points.

[0159] Based on the image texture of the current window e, analyze the sharpness of the gradient changes in the spatial and temporal directions of the image of the current window e, and determine the texture sharpness weight. , denoted as:

[0160]

[0161] In the formula, Let represent the squared integral of the gradient of the image of window e along the time direction (vertical axis). Let represent the squared integral of the gradient of the image of window e along the spatial direction (horizontal axis). This represents the gradient cross term integral of the image of window e in both the spatial and temporal directions.

[0162] For the numerator, to ensure dimensional consistency, both components under the square root are expressed as squares in the numerator. The first term... This represents the combined changes in texture in both the temporal and spatial directions; the second item This represents the change in texture along the intersection direction; therefore, the numerator is an expression that integrates the characteristics of texture change in different spatiotemporal directions. The numerator term integrates the squared gradients in the time direction, the spatial direction, and the gradient intersection term in the spatiotemporal intersection direction, fully capturing the magnitude and directional characteristics of texture change in the time and space dimensions, ensuring that the evaluation of texture sharpness covers gradient information in all dimensions.

[0163] The purpose of the denominator is to account for the differences in absolute gradient changes within different windows. The texture features within a window cannot be distinguished solely by the numerator's expression. Therefore, the denominator, through normalization, ensures that the textures of different windows are clear and their weights are comparable. Dividing by the denominator... Used for normalization, with a value range of (0, 1], it eliminates the influence of the overall gradient size on the weights (for example, even if the absolute gradient changes of two windows are different, this normalization can make the weights reflect relative sharpness), making the texture sharpness weights of different windows comparable.

[0164] In existing technologies, signal-to-noise ratio (SNR) is commonly used to reflect the strength of interference noise encountered during data acquisition. The SNR is calculated as the ratio of the intensity of the received useful signal to the intensity of the received interference signal (noise and interference). Therefore, the SNR weights are determined based on the pixel values ​​of signal and noise within the current window e. , denoted as:

[0165]

[0166] In the formula, Z represents the spatiotemporal image pixel length value, and Q represents the spatiotemporal image pixel width value.

[0167] Point The pixel value of the signal.

[0168] Point The pixel values ​​used to estimate noise can be obtained by using a high-pass filter to obtain the high-frequency components as the estimated noise.

[0169] Based on the existing principle of signal-to-noise ratio, this application quantifies the degree of interference by comparing the pixel value of each point in the spatiotemporal image with the estimated noise component, and normalizes the comparison value to obtain the signal-to-noise ratio weight. This ensures that the value of the weight has the same impact on subsequent calculations of corner point quantity weight and texture clarity weight, and fully considers the interference that spatiotemporal images are subject to in actual hydrological flow measurement.

[0170] Valid signal within the numerator calculation window e The sum of squares reflects the intensity of the effective water flow texture signal; the larger the value, the richer the effective information available for texture angle calculation within the window.

[0171] Noise signal within denominator calculation window e The sum of squares reflects the intensity of noise interference; the larger the value, the more severe the noise pollution to the window.

[0172] At this point, the fractional term can quantify the signal-to-noise ratio (the relative strength of the effective signal and the noise), with a value range of (0, +∞). The larger the ratio, the higher the window signal-to-noise ratio, and the more reliable it is in subsequent texture angle calculations; the smaller the ratio, the more severe the noise interference to the window, and the lower the reliability.

[0173] Finally passed The normalization function is normalized to the (0, 1) interval to obtain the signal-to-noise ratio weights. .

[0174] Finally, the weight is determined based on the number of corner points. Clear texture weight and signal-to-noise ratio weight Determine the window weight of the current window e. , denoted as: .

[0175] Based on the above technical solution, by constructing a spatiotemporal image, the motion characteristics of water flow in both time and space can be effectively integrated. Corner detection algorithms are used to detect corners in the spatiotemporal image, accurately locating intersections of water flow textures (these corners reflect changes in water flow velocity). A pre-defined clustering algorithm is used to cluster the detected corners into multiple clusters. Then, a pre-defined fitting algorithm generates multiple windows for each cluster, achieving dynamic window partitioning based on water flow texture density (avoiding the coarseness of traditional fixed windows), making the windows more adaptable to the water flow characteristics of different regions. Finally, the window weight of each window is determined based on the number of corners (reflecting texture information richness), texture clarity (reflecting texture direction reliability), and signal-to-noise ratio (reflecting image quality) in the multiple windows. This scientifically assesses the importance of each window to subsequent calculations, highlighting the contribution of high-value windows and suppressing the interference of low-quality windows. Overall, this provides a reliable analytical unit and weighting basis for the subsequent accurate calculation of weighted texture angles and hydrological flow data, helping to improve the accuracy of hydrological flow calibration.

[0176] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0177] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0178] In this embodiment of the invention, the online calibration device for hydrological flow data can be divided into functional units according to the above method example. For example, each function can be divided into its own functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.

[0179] This invention also provides a schematic diagram of the hardware structure of an online calibration device for hydrological flow data, see [link / reference]. Figure 6 The online calibration device 800 for hydrological flow data includes a processor 801, and optionally, a memory 802 connected to the processor 801.

[0180] In the first possible implementation, see Figure 6 The online calibration device 800 for hydrological flow data also includes a transceiver 803. The processor 801, memory 802, and transceiver 803 are connected via a bus. The transceiver 803 is used to communicate with other devices or communication networks. Optionally, the transceiver 803 may include a transmitter and a receiver. The device in the transceiver 803 that implements the receiving function can be considered as a receiver, which is used to perform the receiving steps in the embodiments of the present invention. The device in the transceiver 803 that implements the transmitting function can be considered as a transmitter, which is used to perform the transmitting steps in the embodiments of the present invention.

[0181] Based on the first possible implementation method Figure 6 The schematic diagram shown can be used to illustrate the structure of the online calibration device for hydrological flow data involved in the above embodiments.

[0182] in, Figure 6 The diagram can also illustrate the system chip in the online calibration device for hydrological flow data. In this case, the actions performed by the online calibration device for hydrological flow data can be implemented by this system chip; the specific actions performed are described above and will not be repeated here.

[0183] In implementation, each step of the method provided in this embodiment can be completed by integrated logic circuits in the processor or by instructions in software form. The steps of the method disclosed in this embodiment can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules in the processor.

[0184] The processor in this invention may include, but is not limited to, at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or an artificial intelligence processor, etc., which are various computing devices that run software. Each computing device may include one or more cores for executing software instructions to perform calculations or processing. The processor may be a standalone semiconductor chip or integrated with other circuits into a single semiconductor chip. For example, it may be integrated with other circuits (such as encoding / decoding circuits, hardware acceleration circuits, or various bus and interface circuits) to form a System-on-a-Chip (SoC), or it may be integrated as a built-in processor within an ASIC. The ASIC with the integrated processor may be packaged separately or together with other circuits. In addition to the cores for executing software instructions to perform calculations or processing, the processor may further include necessary hardware accelerators, such as field-programmable gate arrays (FPGAs), programmable logic devices (PLDs), or logic circuits that implement dedicated logic operations.

[0185] The memory in the embodiments of the present invention may include at least one of the following types: read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions; random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions; or electrically erasable programmable read-only memory (EEPROM). In some scenarios, the memory may also be a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0186] This invention also provides a computer-readable storage medium including instructions that, when run on a computer, cause the computer to perform any of the methods described above.

[0187] This invention also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the methods described above.

[0188] This invention also provides a chip, which includes a processor and an interface circuit. The interface circuit is coupled to the processor. The processor is used to run computer programs or instructions to implement the above-described method. The interface circuit is used to communicate with other modules outside the chip.

[0189] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software programs, implementation can be, in whole or in part, in the form of a computer program product. This computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device containing one or more servers, data centers, etc., that can be integrated with the medium. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state disks (SSDs)).

[0190] Although the invention has been described herein in conjunction with various embodiments, those skilled in the art, by reviewing the accompanying drawings and the disclosure, will understand and implement other variations of the disclosed embodiments in carrying out the claimed invention. In this invention, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude a plurality. A single processor or other unit can implement several of the functions listed in this invention.

[0191] Although the invention has been described in conjunction with specific features and embodiments, it is obvious that various modifications and combinations can be made therein without departing from the spirit and scope of the invention. Accordingly, this specification and drawings are merely illustrative of the invention and are to be considered as covering any and all modifications, variations, combinations, or equivalents within the scope of the invention. Clearly, those skilled in the art can make various alterations and modifications to the invention without departing from its spirit and scope. Thus, if such modifications and modifications of the invention fall within the scope of the invention and its equivalents, the invention is also intended to include such modifications and modifications.

Claims

1. An online calibration method for hydrological flow data, characterized in that, include: Collect video of the river surface during the water flow process, and set a velocity measurement line area along the direction of water flow in the video; The illumination status is determined based on the grayscale distribution of the speed measurement line area, and the image of the abnormal illumination area in the water surface video is repaired based on the determination result to obtain the repaired water surface video. From the repaired water surface video, the velocity measurement line area images of each frame are extracted in chronological order and arranged to construct a spatiotemporal image; the width of the spatiotemporal image represents the spatial length of the velocity measurement line, and the height represents the number of frames in the time direction; corner points in the spatiotemporal image are detected by a corner detection algorithm; the detected corner points are clustered using a preset clustering algorithm to obtain multiple clusters; multiple windows are generated for each cluster using a preset fitting algorithm; The window weight of each window is determined based on the number of corner points, texture clarity, and signal-to-noise ratio in multiple windows. Determining the window weight includes: determining the corner count weight of the current window based on the number of corners in the current window and the total number of corners in multiple windows; analyzing the image texture of the current window to determine the texture sharpness weight by analyzing the gradient changes in the image sharpness in the spatial and temporal directions; determining the signal-to-noise ratio weight based on the pixel values ​​of signal and noise within the current window; and determining the window weight of the current window based on the corner count weight, the texture sharpness weight, and the signal-to-noise ratio weight. The texture angle of each window is weighted according to the window weight of each window to obtain the weighted texture angle, and the hydrological flow data is calculated based on the weighted texture angle; the texture angle is the angle formed by the direction of the image texture in the spatiotemporal image and the time coordinate axis.

2. The online calibration method according to claim 1, characterized in that, The step of determining the illumination status based on the grayscale distribution of the speed measuring line area includes: Extract the velocity measurement line region from a single frame image of the water surface video; The speed measurement line area is converted into a grayscale image, and a grayscale histogram of the grayscale image is generated; the grayscale histogram is used to characterize the grayscale value distribution of the speed measurement line area. The illumination status is determined based on the number of peaks and valleys in the grayscale histogram; if there are multiple peaks or valleys, it is determined that there is uneven illumination; otherwise, it is determined that the illumination distribution is uniform.

3. The online calibration method according to claim 2, characterized in that, The step of performing image restoration on the abnormal lighting areas in the water surface video based on the judgment result to obtain the restored water surface video includes: The grayscale histogram is divided into multiple grayscale intervals based on its valley values; these grayscale intervals are used to distinguish different lighting areas. Pixels whose grayscale values ​​belong to the same range and are spatially continuous in a single frame of the water surface video are merged into a window to obtain multiple windows; Compare the deviation of the mean grayscale value of each window from the mean grayscale value of the single frame image; When the deviation exceeds a preset threshold, the corresponding window is marked as an abnormal window. For the abnormal window, a preset image repair algorithm is selected for repair based on the degree and direction of deviation.

4. The online calibration method according to claim 3, characterized in that, The step of repairing the abnormal window by selecting a preset image restoration algorithm based on the degree and direction of deviation includes: If the deviation direction is such that the average gray value of the abnormal window is greater than the average gray value of the single frame image, an adaptive histogram equalization algorithm is used to repair it according to the degree of deviation. If the deviation direction is such that the average gray value of the abnormal window is less than the average gray value of the single frame image, an adaptive contrast enhancement algorithm is used to repair it according to the degree of deviation.

5. The online calibration method according to claim 1, characterized in that, Also includes: The window size is adjusted based on the distribution of corner points in each cluster; the distribution includes corner point density or number of corner points.

6. The online calibration method according to claim 1, characterized in that, The calculation of the hydrological flow data based on the weighted texture angle includes: The pixel displacement of the velocity measurement line in the time series is determined based on the weighted texture angle; The actual movement distance is calculated based on the pixel displacement and the actual distance represented by each pixel; The flow rate is calculated based on the actual movement distance and video frame rate.

7. The online calibration method according to claim 1, characterized in that, The video footage of the river surface during the water flow process includes: Collect video of river flow, and perform noise reduction processing on the video of river flow to obtain a noise-reduced video; Each frame of the denoised video is converted into a grayscale image, and the grayscale image is segmented to extract the mask of the water surface region. Each frame of the image is processed according to the mask of the water surface area, and non-water surface areas are removed to generate a water surface video that only contains the water surface area.

8. An online calibration system for hydrological flow data, characterized in that, include: Video acquisition module, image restoration module, window weight construction module, and data calibration module; The video acquisition module is used to acquire water surface video during the river flow process, and to set a velocity measurement line area along the water flow direction in the water surface video; The image restoration module is used to determine the illumination status based on the grayscale distribution of the speed measurement line area, and to perform image restoration on the abnormal illumination areas in the water surface video based on the determination result, so as to obtain the restored water surface video. The window weight construction module is used to extract and arrange the velocity measurement line area images of each frame in chronological order from the repaired water surface video to construct a spatiotemporal image; the width of the spatiotemporal image represents the spatial length of the velocity measurement line, and the height represents the number of frames in the time direction; corner points in the spatiotemporal image are detected by a corner detection algorithm; the detected corner points are clustered by a preset clustering algorithm to obtain multiple clusters; and multiple windows are generated for each cluster using a preset fitting algorithm. The window weight of each window is determined based on the number of corner points, texture clarity, and signal-to-noise ratio in multiple windows. Determining the window weight includes: determining the corner count weight of the current window based on the number of corners in the current window and the total number of corners in multiple windows; analyzing the image texture of the current window to determine the texture sharpness weight by analyzing the gradient changes in the image sharpness in the spatial and temporal directions; determining the signal-to-noise ratio weight based on the pixel values ​​of signal and noise within the current window; and determining the window weight of the current window based on the corner count weight, the texture sharpness weight, and the signal-to-noise ratio weight. The data calibration module is used to weight the texture angle of each window according to the window weight of each window to obtain a weighted texture angle, and to calculate the hydrological flow data according to the weighted texture angle; the texture angle is the angle formed by the direction of the image texture in the spatiotemporal image and the time coordinate axis.

Citation Information

Patent Citations

  • Space-time image flow measurement method, device and system and storage medium

    CN117036434A

  • Intelligent water gauge identification system based on big data technology

    CN119273580A

  • Space-time image velocity measurement method and system based on multi-direction Gabor filtering

    CN121121435A