Ship water gauge scale line fitting algorithm

By using image acquisition and weighted least squares nonlinear fitting technology, the problem of large errors in traditional manual measurement of ship draft gauges has been solved, and high-precision draft gauge scale fitting has been achieved in complex environments, making it suitable for shipping and port management.

CN121505592APending Publication Date: 2026-02-10GUOKE (SHANDONG) EQUIPMENT TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511903974.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2025-10-27
Filing Date
2025-12-17
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Traditional manual measurement of ship draft is easily affected by the environment, resulting in large errors and low efficiency. Existing image processing methods cannot accurately fit the nonlinear draft scale, leading to inaccurate measurements.

Method used

Image acquisition equipment is used to extract the measurement points of the water level gauge line. The scale line is located by grayscale conversion, contrast enhancement and Canny edge detection. The coordinates are obtained by combining Hough transform. Weighted least square nonlinear fitting is performed, the polynomial order and weight coefficients are dynamically adjusted, and residual analysis is used to optimize the model parameters.

Benefits of technology

It achieves high-precision and robust draft gauge line fitting in complex environments, providing reliable draft depth data support, and is suitable for shipping safety and port management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121505592A_ABST
    Figure CN121505592A_ABST
Patent Text Reader

Abstract

The invention discloses a ship water gauge scale line fitting algorithm, and relates to the technical field of ship water gauge scale calculation, and the method comprises the steps: obtaining a ship water gauge region image through an image collection device to extract a measurement point coordinate, and building a mapping relation between a pixel position and a physical draft; a weighted least square method is adopted to perform nonlinear curve fitting, a weight coefficient is calculated based on a local neighborhood standard deviation, a polynomial order p is dynamically adjusted according to an adjusted decision coefficient, and the decision coefficient is iteratively optimized to improve the balance between amplitude and model complexity. And the system repeatedly corrects model parameters through a dynamic verification mechanism of the residual sum of squares and a preset threshold value, and finally an accurate water gauge scale fitting curve is generated. The method effectively solves the problems that traditional manual observation is prone to environmental interference and large in measurement error, high robustness is kept in a complex water area environment, and reliable data support can be provided for the fields of ship load evaluation, channel safety management and the like.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to Chinese Patent Application No. 202511541884.6, filed on October 27, 2025, entitled "An Algorithm for Fitting Ship Draft Lines", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of ship draft scale calculation technology, and in particular to a ship draft scale line fitting algorithm. Background Technology

[0003] In shipping and port operations, accurately measuring a ship's draft is crucial for calculating deadweight tonnage, ensuring navigational safety, and optimizing cargo stowage. Traditionally, ship draft measurement relies primarily on manual visual reading of the draft scale. This method requires operators to be close to the draft area and visually observe the draft depth corresponding to the scale lines. Manual measurement is susceptible to environmental conditions such as insufficient light, water surface fluctuations, inclement weather, or damaged scales, leading to significant reading errors.

[0004] Furthermore, manual measurement is inefficient, cannot achieve real-time monitoring, and is prone to subjective judgment bias, making it difficult to meet the automation requirements of modern ports. With the development of digital imaging technology, some methods have begun to use cameras to capture images of ship draft gauges and automatically extract draft values ​​through image processing algorithms. Existing technologies mostly use fixed mathematical models, such as linear regression or low-order polynomial fitting, assuming that draft gauge changes follow a simple linear relationship. However, actual draft gauge readings may exhibit non-linear characteristics, especially under ship tilting or wave action, and fixed models cannot accurately capture the true curve shape. For example, the gauge points near the water surface may fluctuate significantly due to waves, and existing methods do not incorporate weight adjustment mechanisms, causing the fitted curve to be sensitive to outliers and prone to bias. Summary of the Invention

[0005] This application provides a ship draft gauge line fitting algorithm, including the following steps: Step S1: Acquire a digital image of the ship's draft area using an image acquisition device and extract multiple measurement points of the draft scale line. Each measurement point includes pixel position coordinates and the corresponding draft value. Step S2: Perform outlier detection and noise filtering preprocessing on the measurement points; Step S3: Dynamically calculate the weight coefficients of each measurement point, and based on the weight coefficients, use the weighted least squares method to perform nonlinear curve fitting on the preprocessed measurement points to generate an initial fitting curve; Step S4: Calculate the sum of squared residuals of the initial fitted curve and compare it with a preset threshold. If the sum of squared residuals exceeds the preset threshold, adjust the fitting model parameters and refit. Step S5: Generate the final water gauge scale fitting curve.

[0006] Further, in step S3, the formula for calculating the weighting coefficient is: Weighting coefficient ,in, Let be the standard deviation of the i-th measurement point. This is the smoothing constant.

[0007] Furthermore, in step S3, the nonlinear curve fitting employs a polynomial fitting model; the order p of the polynomial fitting is dynamically selected based on the goodness of fit, which is determined by the adjusted coefficient of determination. To conduct an evaluation, The calculation formula is: ; Where n is the number of measurement points, and p is the order of the polynomial. The coefficient of determination.

[0009] Furthermore, the dynamic selection process of the polynomial order p includes: fitting from the initial order, calculating the polynomial order p at the current order. Then, the order is increased and the fit is repeated. If the order increases... If the increase is less than the preset threshold, or the order reaches the maximum limit, the increment will stop, and the fitting curve at the current order will be selected.

[0010] Furthermore, step S1 also includes: converting the water gauge image to grayscale and enhancing its contrast, applying the Canny edge detection algorithm to locate the edges of the scale lines, extracting the coordinates of the measurement points through Hough transform, and converting the draft value based on the pre-calibrated depth-pixel relationship.

[0011] Further, in step S3, the formula for calculating the coefficient of determination is: ; in, Let i be the actual draft value at the i-th measurement point. The draft value calculated for fitting the curve. This is the average of the actual draft values ​​at all measurement points.

[0012] Furthermore, it also includes: the standard deviation. The calculation is based on the dispersion of the draft of all measurement points in the local neighborhood centered on the i-th measurement point.

[0013] The embodiments of this application have the following beneficial effects: Image acquisition equipment is used to obtain images of the ship's draft area. Combined with techniques such as grayscale conversion, contrast enhancement, Canny edge detection, and Hough transform, the scale lines are located and the coordinates of measurement points are extracted. A mapping relationship is established between pixel positions and physical draft. To improve data reliability, a weighting coefficient calculated based on the standard deviation of local neighborhoods is used. A smoothing constant ε is introduced into the formula to perform a weighted least squares nonlinear fitting on the measurement points. The polynomial order p is dynamically adjusted according to the adjusted coefficient of determination (R_adj²). The balance between the increase in the coefficient of determination and the model complexity is balanced through iterative optimization, ensuring that the fitted curve can fully fit the data features while avoiding overfitting. The system uses a dynamic verification mechanism of the residual sum of squares and a preset threshold to repeatedly correct the model parameters until the accuracy requirements are met, ultimately generating an accurate draft scale fitting curve. This method effectively solves the problems of traditional manual observation being susceptible to environmental interference and large measurement errors. It maintains high robustness even in complex water environments and can provide reliable data support for ship load assessment, waterway safety management, and other fields. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1 An exemplary schematic diagram of a ship draft gauge line fitting algorithm provided in an embodiment of this application is shown. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0017] To further illustrate the technical solutions provided in the embodiments of this application, a detailed description is provided below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiments of this application provide method operation steps as shown in the following embodiments or drawings, the method may include more or fewer operation steps based on conventional or non-inventive methods. In steps where there is no logically necessary causal relationship, the execution order of these steps is not limited to the execution order provided in the embodiments of this application.

[0018] refer to Figure 1 As shown, this application provides a ship draft gauge line fitting algorithm, including the following steps: Step S1: Acquire a digital image of the ship's draft area using an image acquisition device and extract multiple measurement points from the draft scale lines. Each measurement point includes pixel position coordinates and the corresponding draft depth value.

[0019] Step S1 also includes: converting the water gauge image to grayscale and enhancing its contrast, applying the Canny edge detection algorithm to locate the edges of the scale lines, extracting the coordinates of the measurement points through Hough transform, and converting the draft value based on the pre-calibrated depth-pixel relationship.

[0020] Step S1 achieves accurate extraction of measurement points through multi-stage processing of the water gauge area image. First, the original image is converted to grayscale to eliminate color information interference and reduce the complexity of subsequent calculations. Then, contrast enhancement technology is used to amplify the grayscale difference between the scale lines and the background in the image, making the edge features of the scale lines more prominent.

[0021] The Canny edge detection algorithm is used to extract edges at multiple scales in the enhanced image. Gaussian filtering is used to eliminate high-frequency noise while preserving the weak signal features of the scale line edges. Combined with a dual-threshold detection and hysteresis connection strategy, the continuous edge contours of the water gauge scale lines are accurately captured. Subsequently, Hough transform is used to detect straight lines in the edge image. A parameter space voting mechanism is used to select straight line segments that conform to the geometric features of the water gauge scale lines. Combined with a pre-calibrated depth-pixel mapping relationship, the detected scale line pixel coordinates are converted into actual physical draft values.

[0022] This step, through the cascading application of multi-level image processing technology, effectively overcomes the image blurring problem caused by wave swaying and light changes during ship navigation, improves the positioning accuracy and robustness of the measurement point coordinates, and provides a high-quality raw data foundation for subsequent nonlinear fitting.

[0023] Step S2: Perform outlier detection and noise filtering preprocessing on the measurement points. Step S2, by performing outlier detection and noise filtering preprocessing on the measurement points, provides a high-quality data foundation for subsequent nonlinear curve fitting.

[0024] Outlier detection aims to identify and eliminate measurement points that significantly deviate from the true scale values ​​due to factors such as image noise, sensor errors, or surface contamination of the water gauge. Statistical methods (such as threshold judgment based on standard deviation or interquartile range) are used to filter out reasonable data ranges that conform to physical laws, avoiding misleading influences from individual outliers on the fitting results. Noise filtering smooths out high-frequency noise or low-frequency disturbances remaining from image processing, suppressing random fluctuations while preserving key features of the scale lines.

[0025] For example, a moving average filter or Savitzky-Golay filter is used to perform a weighted average correction on the local measurement point set, making the discrete measurement point distribution more consistent with the continuous characteristics of the actual water gauge scale. This preprocessing step, through data cleaning and optimization, significantly improves the convergence speed and solution accuracy of the subsequent weighted least squares fitting, while also enhancing the algorithm's adaptability to complex imaging conditions.

[0026] Step S3: Dynamically calculate the weight coefficients of each measurement point, and based on the weight coefficients, use the weighted least squares method to perform nonlinear curve fitting on the preprocessed measurement points to generate an initial fitting curve.

[0027] Further, in step S3, the formula for calculating the weighting coefficient is: Weighting coefficient ,in, Let be the standard deviation of the i-th measurement point. The smoothing constant. Standard deviation. The calculation is based on the dispersion of the draft of all measurement points in the local neighborhood centered on the i-th measurement point.

[0028] The weighting coefficient calculation formula used in step S3 optimizes the reliability of the nonlinear curve fitting process through a differentiated weighting mechanism. Specifically, The standard deviation of the i-th measurement point reflects the dispersion of the data distribution at that point. The larger the standard deviation, the more significantly the measurement point is affected by noise or local interference. Therefore, a lower weight is assigned to suppress its excessive influence on the fitting results.

[0029] Smoothing constant Introduced as a regularization term to avoid when To address the numerical instability caused by a sharp increase in weight values ​​approaching zero, the smoothness of weight allocation can be adjusted, with the value balancing data fidelity and noise resistance. This weight allocation strategy quantifies the confidence level of each measurement point, prioritizing the adoption of highly reliable data features during the fitting process. This effectively suppresses the interference of abnormal fluctuations on the curve shape, thereby improving the accuracy of the initial fitted curve in representing the physical characteristics of the water level gauge line, and laying a data foundation for subsequent residual analysis and model parameter optimization.

[0030] Furthermore, in step S3, the nonlinear curve fitting employs a polynomial fitting model. The order p of the polynomial fitting is dynamically selected based on the goodness of fit, which is determined by the adjusted coefficient of determination. To conduct an evaluation, The calculation formula is: .

[0031] Where n is the number of measurement points, and p is the order of the polynomial. The coefficient of determination.

[0032] In step S3, the formula for calculating the coefficient of determination is: .

[0033] in, Let i be the actual draft value at the i-th measurement point. The draft value calculated for fitting the curve. This is the average of the actual draft values ​​at all measurement points.

[0034] In step S3, a polynomial fitting model is used to perform nonlinear curve fitting on the preprocessed measurement points. The core of this method is to approximate the physical shape of the water gauge mark lines using a polynomial function. Due to its good continuity and smoothness, the polynomial fitting model can effectively describe the complex bending characteristics of the water gauge mark lines caused by ship deformation, shooting angle, or optical distortion.

[0035] To avoid overfitting or underfitting, a strategy of dynamically selecting the polynomial order is adopted, and the goodness of fit of the model is quantified by the adjusted coefficient of determination R_adj². This index balances model complexity and fitting accuracy by introducing a degree-of-freedom penalty term, where R² is the traditional coefficient of determination, n is the number of measurement points, and p is the polynomial order.

[0036] The dynamic selection process begins with a preset initial order, successively increases the order, and refits the data. When the order increases, it causes... The iteration terminates when the increase falls below a preset threshold or the order reaches its maximum limit, and the final selection is made... The optimal order is used to construct the fitting curve. This method quantitatively evaluates the model's generalization ability, avoiding the shortcomings of low-order models in capturing detailed features and preventing high-order models from amplifying noise sensitivity due to excessive parameters. This improves the accuracy of the initial fitting curve in representing the physical laws of the water level gauge line, providing a reliable foundation for subsequent residual analysis and model optimization.

[0037] Furthermore, the dynamic selection process of the polynomial order p includes: fitting from the initial order, calculating the polynomial order p at the current order. Then, the order is increased and the fit is repeated. If the order increases... If the increase is less than the preset threshold, or the order reaches the maximum limit, the increment will stop, and the fitting curve at the current order will be selected.

[0038] In step S3, the dynamic selection of the polynomial order is achieved through an iterative fitting and model evaluation mechanism, aiming to balance fitting accuracy and model complexity. The specific process begins with a preset initial order, first using a polynomial of that order to perform nonlinear fitting on the preprocessed measurement points, and then calculating the adjusted coefficients of determination for the current model. To evaluate the goodness of fit, the system automatically increments the polynomial order and re-performs the fitting operation on the same set of measurement points. The results are then compared before and after the order increment. The extent of the improvement determines whether the model complexity is necessary.

[0039] When successive orders increase When the increment is lower than the preset threshold, it indicates that the higher-order polynomials are beginning to overfit the noise rather than capture the true scale features, and the order increment process is terminated at this time; if the order has reached the preset maximum allowable value, the iteration is also forcibly terminated.

[0040] Final selection The polynomial order that reaches the peak or meets the convergence condition is used as the optimal model parameter to generate the initial fitting curve. This adaptive order selection mechanism avoids the loss of key scale features due to insufficient fitting ability in low-order models, and prevents the amplification of measurement noise due to excessive freedom in high-order models. It ensures that the fitting results can accurately represent the physical shape of the water gauge scale line, and also have good anti-interference ability and generalization performance.

[0041] Step S4: Calculate the sum of squared residuals of the initial fitted curve and compare it with a preset threshold. If the sum of squared residuals exceeds the preset threshold, adjust the fitting model parameters and refit.

[0042] Step S4 achieves adaptive verification of the fitting model's accuracy by quantitatively evaluating the overall deviation between the initial fitted curve and the actual measurement data. Specifically, the system calculates the sum of squared residuals between the initial fitted curve and the actual draft values ​​at each measurement point, and compares it with a preset threshold.

[0043] This threshold is pre-calibrated based on the physical characteristics of the water gauge scale and the measurement noise level, reflecting the acceptable range of fitting error. When the sum of squared residuals exceeds the threshold, it indicates that the initial fitted curve failed to fully represent the true shape of the water gauge scale, possibly due to improper model parameter selection, local noise interference, or residual outliers. At this point, the system triggers a parameter optimization mechanism, adjusting key parameters such as the polynomial order, weight coefficient allocation rules, or convergence conditions of the optimization algorithm, and re-executes the nonlinear curve fitting process until the sum of squared residuals meets the accuracy requirements.

[0044] Step S5: Generate the final draft gauge line fitting curve. After optimizing the model parameters and verifying the residuals, Step S5 outputs the final draft gauge line fitting curve. This curve is a continuous mathematical representation generated based on the dynamically adjusted optimal model parameters, accurately describing the curvature and depth variation trend of the draft gauge line through a polynomial function. To ensure engineering practicality, the final fitting curve must simultaneously meet three constraints: First, the curve shape must conform to the symmetry and continuity characteristics of the draft gauge's physical structure; second, the residuals between the predicted values ​​and the actual draft depth values ​​at each measurement point must be uniformly distributed and the root mean square error must be less than a preset limit; third, the slope of the tangent at the endpoints of the draft gauge line must be consistent with the mechanical structural characteristics specified in the draft gauge installation specifications.

[0045] Through the synergistic effect of the above multi-dimensional constraints, the final fitted curve not only has high-precision numerical representation capabilities, but also effectively addresses the dynamic measurement challenges caused by changes in ship attitude, wave disturbances, or fluctuations in imaging conditions during ship navigation, providing a reliable data foundation for real-time monitoring of ship draft.

[0046] To address the nonlinear characteristics of water level gauge markings due to hull deformation or optical distortion, this solution employs a polynomial fitting model to characterize the physical morphology of the markings. By dynamically adjusting the model complexity, overfitting is effectively suppressed while ensuring fitting accuracy. This allows the model to capture the detailed features of the markings while avoiding excessive parameter amplification of noise sensitivity. Simultaneously, a differentiated weight allocation mechanism is introduced, assigning weights based on the reliability of measurement points to suppress the interference of abnormal fluctuations on the curve morphology and enhance the ability of the initial fitted curve to characterize the physical properties of the water level gauge markings.

[0047] An adaptive verification mechanism for model accuracy is established through residual analysis. When the deviation between the fitted result and the actual measurement data exceeds a set range, the parameter optimization process is automatically triggered, and the fitting process is re-executed by adjusting the model parameters. This ensures that the fitted result not only closely matches the physical laws of the water gauge scale but also effectively suppresses the effects of measurement noise and random disturbances. Through continuous iterative optimization, the system maintains stable measurement performance even under complex working conditions.

[0048] This solution can be widely applied in shipping safety monitoring, port scheduling management, and marine engineering, providing reliable technical support for improving ship cargo carrying efficiency and controlling maintenance costs.

[0049] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0050] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0051] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A ship draft gauge line fitting algorithm, characterized in that, Includes the following steps: Step S1: Acquire a digital image of the ship's draft area using an image acquisition device and extract multiple measurement points of the draft scale line. Each measurement point includes pixel position coordinates and the corresponding draft value. Step S2: Perform outlier detection and noise filtering preprocessing on the measurement points; Step S3: Dynamically calculate the weight coefficients of each measurement point, and based on the weight coefficients, use the weighted least squares method to perform nonlinear curve fitting on the preprocessed measurement points to generate an initial fitting curve; Step S4: Calculate the sum of squared residuals of the initial fitted curve and compare it with a preset threshold. If the sum of squared residuals exceeds the preset threshold, adjust the fitting model parameters and refit. Step S5: Generate the final water gauge scale fitting curve.

2. The method according to claim 1, characterized in that, In step S3, the formula for calculating the weighting coefficient is: Weighting coefficient ,in, Let be the standard deviation of the i-th measurement point. This is the smoothing constant.

3. The method according to claim 2, characterized in that, In step S3, the nonlinear curve fitting employs a polynomial fitting model; the order p of the polynomial fitting is dynamically selected based on the goodness of fit, which is determined by the adjusted coefficient of determination. To conduct an evaluation, The calculation formula is: ; Where n is the number of measurement points, and p is the order of the polynomial. The coefficient of determination.

4. The method according to claim 3, characterized in that, The dynamic selection process of the polynomial order p includes: fitting from the initial order, calculating the polynomial order at the current order... Then, the order is increased and the fit is repeated. If the order increases... If the increase is less than the preset threshold, or the order reaches the maximum limit, the increment will stop, and the fitting curve at the current order will be selected.

5. The method according to claim 1, characterized in that, Also includes: Step S1 also includes: converting the water gauge image to grayscale and enhancing its contrast, applying the Canny edge detection algorithm to locate the edges of the scale lines, extracting the coordinates of the measurement points through Hough transform, and converting the draft depth value based on the pre-calibrated depth-pixel relationship.

6. The method according to claim 3, characterized in that, In step S3, the formula for calculating the coefficient of determination is: ; in, Let i be the actual draft value at the i-th measurement point. The draft value calculated for fitting the curve. This is the average of the actual draft values ​​at all measurement points.

7. The method according to claim 2, characterized in that, Also includes: The standard deviation The calculation is based on the dispersion of the draft of all measurement points in the local neighborhood centered on the i-th measurement point.

Citation Information

Cited By

  • Ship draft intelligent measurement method and system based on marker template matching

    CN122335948A

  • Ship draft intelligent measurement method and system based on marker template matching

    CN122335948B