Ship waterline detection method based on image processing

By segmenting the ship's waterline detection image, gradient calculation, non-maximum suppression and double-threshold processing, the problems of threshold fixation and noise interference in the prior art are solved, and high-precision waterline detection is achieved.

CN119477952APending Publication Date: 2025-02-18DALIAN MARITIME UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411695445.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art requires manual determination of fixed thresholds when detecting ship waterlines, which cannot be adaptively adjusted, and may cause weak edges to not be detected under image noise interference, resulting in inaccurate detection.

Method used

Using an image-based processing method, pre-processing is performed by acquiring the ship waterline detection image, segmenting the image into a local image, calculating the gradient amplitude and direction, performing non-maximum suppression and double-threshold setting, excluding non-edge areas, and forming a complete The boundary profile of the , and finally the local image is stitched to obtain the optimized waterline image.

Benefits of technology

Adaptive adjustment of threshold values ​​according to image pixel changes is achieved, noise interference is reduced, edge detection accuracy and waterline detection accuracy are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119477952A_ABST
    Figure CN119477952A_ABST
Patent Text Reader

Abstract

The invention discloses a ship waterline detection method based on image processing, and the method comprises the steps: S1, obtaining a ship waterline detection image, and carrying out the preprocessing of the image; s2, carrying out image segmentation operation on the preprocessed image, and obtaining a gradient magnitude and a gradient direction of a pixel point based on a plurality of segmented local images; s3, performing non-maximum suppression operation on the plurality of segmented local images to obtain a refined image; s4, eliminating a non-edge region in the refined image through double thresholds; s5, performing link operation on the image without the non-edge region to form a complete boundary contour; and S6, re-splicing the plurality of local images processed in the step S5 to obtain an image after waterline optimization. According to the method, the image is segmented, the double thresholds are set according to the gradient magnitude, and the double thresholds can be adaptively adjusted according to the pixel change of the image, so that the problem of mistakenly eliminating the weak edge of the waterline is avoided, and the accurate detection of the waterline is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of ship waterline detection, and in particular to a ship waterline detection method based on image processing. Background Art

[0002] Ship draft is one of the important indicators of the main performance parameters of ships. It is of great significance to improve navigation safety, optimize ship design, reduce ship operating costs, maintain ship stability, etc. The traditional draft detection method mainly relies on manual visual detection. This method is greatly affected by the subjective factors of the detection personnel and has low accuracy. A lot of research has been done on ship waterline detection. The existing technologies include optimizing Canny edge detection for salt and pepper noise; edge detection algorithm using statistical filtering denoising and grayscale-based iterative method to calculate thresholds; infrared image feature extraction method based on Otsu method (OTSU) and Canny operator; circle positioning improvement method based on edge detection and Hough transform, using the basic principle of Hough transform and its application in straight line detection; ship waterline and ship freeboard automatic detection method based on image processing, using adaptive edge detection method based on Canny operator, etc. Although the above algorithm optimizes the edge detection of the Canny operator for various situations, it still requires manual determination of a fixed threshold value, and cannot be adaptively adjusted as the pixels of the image change. In the case of image noise interference, weak edges may not be detected, resulting in inaccurate waterline detection. At the same time, the adaptive Canny operator edge calculates the threshold value based on the entire image, and the processing effect of some details is not good. Summary of the invention

[0003] The present invention provides a ship waterline detection method and device based on image processing, so as to overcome the technical problems that in the prior art, a fixed threshold needs to be manually determined when detecting the ship waterline, and the threshold cannot be adaptively adjusted with the pixel changes of the image. In the case of image noise interference, weak edges may not be detected, resulting in inaccurate waterline detection.

[0004] In order to achieve the above object, the technical solution of the present invention is:

[0005] A ship waterline detection method based on image processing, the specific steps include:

[0006] S1: Acquire a ship waterline detection image, and preprocess the ship waterline detection image;

[0007] S2: performing image segmentation on the preprocessed image, and obtaining the gradient amplitude and gradient direction of the pixel points based on several segmented local images;

[0008] S3: performing a non-maximum suppression operation on the segmented local images based on the gradient amplitude and the gradient direction to refine the edge region of the image to obtain a refined image;

[0009] S4: setting a double threshold based on the gradient amplitude, and excluding the non-edge area in the refined image by the double threshold, so as to obtain an image excluding the non-edge area;

[0010] S5: performing a linking operation on the image excluding the non-edge area to form a complete boundary contour;

[0011] S6: rejoining the several local images processed by S5 according to the original pixel coordinates to obtain an image after waterline optimization, and obtaining a waterline detection result based on the image.

[0012] Furthermore, in S2, the image segmentation operation is performed on the preprocessed image, and the process of obtaining the gradient amplitude and gradient direction based on the segmented local images is as follows:

[0013] Divide the preprocessed image into N×N local images;

[0014] Let A be the window pixel matrix, expressed as:

[0015]

[0016] Among them, (x, y) represents the center pixel;

[0017] A is convolved horizontally through the horizontal template, and the convolution result is:

[0018]

[0019] Where Gx represents the amplitude of the horizontal gradient of A;

[0020] A is convolved vertically through the longitudinal template, and the convolution result is:

[0021]

[0022] Where Gy represents the amplitude of the vertical gradient of A;

[0023] The gradient amplitude G is calculated based on the above convolution result, expressed as:

[0024]

[0025] Calculate the gradient direction θ, expressed as:

[0026]

[0027] Further, in S3, the process of performing non-maximum suppression operation on the segmented local images based on the gradient amplitude and gradient direction is:

[0028] S31: Discretize the gradient direction θ into four cases, expressed as:

[0029] θ(i,j)∈(45,90]∪(-135,-90]

[0030] θ(i,j)∈(90,135]∪(-90,-45]

[0031] θ(i,j)∈[0,45]∪[-180,-135]

[0032] θ(i,j)∈(135,180]∪(-45,0)

[0033] The interpolation method is used to fit the gradient amplitude in the gradient direction, including:

[0034] When θ(i,j)∈(45,90]∪(-135,-90], the calculation formulas for the two interpolation values ​​Δ1 and Δ2 are:

[0035]

[0036] Where (i+1, j-1) and (i, j-1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j);

[0037] (i-1, j+1) and (i, j+1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); and The proportionality coefficient when |dy(i,j)|>|dx(i,j)|;

[0038] When θ(i,j)∈(90,135]∪(-90,-45]), the calculation formulas for the two interpolation values ​​Δ3 and Δ4 are:

[0039]

[0040] Where (i-1, j-1) and (i, j-1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j);

[0041] (i+1,j+1) and (i,j+1) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); and The proportionality coefficient when |dy(i,j)|>|dx(i,j)|;

[0042] When θ(i,j)∈[0,45]∪[-180,-135], the calculation formulas for the two interpolation values ​​Δ5 and Δ6 are:

[0043]

[0044] Where (i+1,j-1) and (i+1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j);

[0045] (i-1,j+1) and (i-1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j). and The proportionality coefficient when |dy(i,j)|<|dx(i,j)|;

[0046] When θ(i,j)∈(135,180]∪(-45,0), the calculation formulas for the two interpolation values ​​Δ7 and Δ8 are:

[0047]

[0048] Where (i-1, j-1) and (i-1, j) are the gradient amplitudes of the neighboring pixels of pixel point (i, j);

[0049] (i+1,j+1) and (i+1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); and The proportionality coefficient when |dy(i,j)|<|dx(i,j)|;

[0050] S32: Based on the range to which the calculated gradient direction θ belongs, the corresponding interpolation calculation formula is clarified and then the corresponding interpolation value is determined, that is, the two gradient amplitudes in the neighborhood of the gradient direction of the pixel point (i, j), and the gradient amplitude at the pixel point (i, j) is compared with the two determined gradient amplitudes to determine whether the gradient amplitude of the pixel point is a local maximum. If so, the original value is retained, otherwise, it is suppressed, that is, assigned a value of 0.

[0051] Furthermore, in S4, the process of setting a double threshold based on the gradient amplitude and excluding the non-edge area in the refined image by the double threshold is:

[0052] Traverse all the pixels in each image and select the maximum value G among the gradient amplitudes of all pixels max , based on the maximum value G max Set the double threshold, expressed as:

[0053]

[0054] Among them, T low Indicates the low threshold; Thigh Indicates high threshold;

[0055] The gradient amplitude G of the pixel point is compared with the double threshold value, and different pixel processing is performed according to the comparison result, including:

[0056] 1) If the gradient amplitude G of a pixel point is greater than the high threshold, the point is determined as a strong edge point;

[0057] 2) If the gradient amplitude G of a pixel point is less than the low threshold, the point is removed, thereby excluding the non-edge area in the refined image;

[0058] 3) If the gradient amplitude G of a pixel point is between the low threshold and the high threshold, the point is determined as a weak edge point.

[0059] Furthermore, in S5, the image excluding the non-edge area is linked to form a complete boundary contour in the following process:

[0060] A linking operation is performed between weak edge points and adjacent strong edge points to form a complete boundary contour by linking incomplete boundary line segments.

[0061] Furthermore, in S1, the process of preprocessing the ship waterline detection image is as follows:

[0062] The ship waterline detection image is grayed out, and the processing formula is:

[0063] grey=0.299R+0.58G'+0.114B

[0064] Wherein, grey represents the gray value of x, grey∈[0,255]; R represents the value of the R channel in the RGB color space, G' represents the value of the G' channel in the RGB color space, and B represents the value of the B channel in the RGB color space;

[0065] The grayscale image is subjected to Gaussian filtering for noise reduction, and the processing formula is:

[0066]

[0067]

[0068] Where f(x,y) represents a pixel in the image; G(x,y) represents a two-dimensional Gaussian function; σ represents the coefficient of the Gaussian filter; represents the convolution operation; S(x,y) represents the image after convolution.

[0069] Beneficial effects: The present invention performs image segmentation processing, calculates the gradient amplitude of the pixel points of the local image after segmentation, and then sets a dual threshold value according to the gradient amplitude. The dual threshold value can be adaptively adjusted according to the change of image pixels, excluding the non-edge area in the refined image while avoiding the problem of mistakenly removing the weak edge of the waterline, thereby ensuring accurate detection of the waterline. The present invention has a better processing effect in the detail processing part, and improves the accuracy of edge detection by reducing the possibility of the required weak edge being mistakenly removed. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0071] Figure 1 This is a flow chart of a ship waterline detection method based on image processing in the present invention;

[0072] Figure 2 The ship waterline detection image obtained in the embodiment of the present invention;

[0073] Figure 3 The image is an image obtained by graying the ship waterline detection image in an embodiment of the present invention;

[0074] Figure 4 The image is an image obtained by performing Gaussian filtering and noise reduction processing on the grayscale processed image in the embodiment of the present invention;

[0075] Figure 5 The image is an image obtained by performing an image segmentation operation on the preprocessed image in the embodiment of the present invention;

[0076] Figure 6 A gradient amplitude result diagram obtained based on several segmented local images in an embodiment of the present invention;

[0077] Figure 7 is a gradient map of non-maximum suppression in an embodiment of the present invention;

[0078] Figure 8 The image is an image obtained by performing a non-maximum suppression operation on the segmented local images in an embodiment of the present invention;

[0079] Fig. 9 The image excluding the non-edge area is obtained by excluding the non-edge area in the thinned image in the embodiment of the present invention;

[0080] Fig.10An image with a processed waterline in an embodiment of the present invention;

[0081] Fig.11 The image of the waterline obtained by using the Canny edge detection method without segmenting the image in the embodiment of the present invention;

[0082] Fig.12 This is an image of the waterline obtained by using the Sobel edge detection method in an embodiment of the present invention. DETAILED DESCRIPTION

[0083] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0084] This embodiment provides a ship waterline detection method based on image processing, such as Figure 1 As shown, the specific steps include:

[0085] S1: Get Figure 2 The ship waterline detection image shown in FIG. 1 is used for preprocessing the ship waterline detection image;

[0086] In a specific embodiment, in S1, the process of preprocessing the ship waterline detection image is:

[0087] The ship waterline detection image is grayed out, and the processed image is as follows: Figure 3 As shown, the processing formula is:

[0088] grey=0.299R+0.58G'+0.114B

[0089] Wherein, grey represents the gray value of x, grey∈[0,255]; R represents the value of the R channel in the RGB color space, G' represents the value of the G' channel in the RGB color space, and B represents the value of the B channel in the RGB color space; 0.299, 0.587, and 0.114 are the weighting coefficients of the three channels, and their ratios reflect the sensitivity of the human eye to different colors;

[0090] The grayscale image is subjected to Gaussian filtering for noise reduction. The processed image is as follows: Figure 4 As shown, the processing formula is:

[0091]

[0092]

[0093] Where f(x,y) represents a pixel in the image; G(x,y) represents a two-dimensional Gaussian function; σ represents the coefficient of the Gaussian filter; represents the convolution operation; S(x,y) represents the image after convolution.

[0094] S2: performing image segmentation on the preprocessed image, and obtaining the gradient amplitude and gradient direction of the pixel points based on several segmented local images;

[0095] In a specific embodiment, in S2, the process of performing an image segmentation operation on the preprocessed image and obtaining a gradient amplitude and a gradient direction based on a plurality of segmented local images is as follows:

[0096] The preprocessed image is divided into N×N local images; specifically, in this embodiment, as Figure 5 As shown, the preprocessed image is divided into 3×3 local images;

[0097] Let A be a 3×3 window pixel matrix in the image, expressed as:

[0098]

[0099] Among them, (x, y) represents the center pixel;

[0100] In this embodiment, the Sobel operator is used for gradient calculation. The Sobel operator includes two groups of 3*3 matrices, namely, a horizontal template and a vertical template, which are used to perform convolution on the image in the horizontal and vertical directions respectively, including:

[0101] A is convolved horizontally through the horizontal template, and the convolution result is:

[0102]

[0103] Where Gx represents the amplitude of the horizontal gradient of A;

[0104] A is convolved vertically through the longitudinal template, and the convolution result is:

[0105]

[0106] Where Gy represents the amplitude of the vertical gradient of A;

[0107] like Figure 6 As shown, the gradient amplitude G is calculated based on the above convolution result, which is expressed as:

[0108]

[0109] Calculate the gradient direction θ, expressed as:

[0110]

[0111] S3: performing a non-maximum suppression operation on the segmented local images based on the gradient amplitude and the gradient direction to refine the edge region of the image to obtain a refined image;

[0112] In a specific embodiment, in S3, the process of performing a non-maximum suppression operation on the segmented local images based on the gradient amplitude and the gradient direction is:

[0113] S31: Discretize the gradient direction θ into four cases, expressed as:

[0114] θ(i,j)∈(45,90]∪(-135,-90]

[0115] θ(i,j)∈(90,135]∪(-90,-45]

[0116] θ(i,j)∈[0,45]∪[-180,-135]

[0117] θ(i,j)∈(135,180]∪(-45,0)

[0118] like Figure 7 As shown in Figure 1, the interpolation method is used to fit the gradient magnitude in the gradient direction, which retains all information and can more accurately measure the gradient magnitude in the gradient direction, including:

[0119] When θ(i,j)∈(45,90]∪(-135,-90], the calculation formulas for the two interpolation values ​​Δ1 and Δ2 are:

[0120]

[0121] Where (i+1,j-1) and (i,j-1) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); (i-1,j+1) and (i,j+1) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); and

[0122] The proportionality coefficient when |dy(i,j)|>|dx(i,j)|;

[0123] When θ(i,j)∈(90,135]∪(-90,-45]), the calculation formulas for the two interpolation values ​​Δ3 and Δ4 are:

[0124]

[0125] Where (i-1, j-1) and (i, j-1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); (i+1, j+1) and (i, j+1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); and

[0126] The proportionality coefficient when |dy(i,j)|>|dx(i,j)|;

[0127] When θ(i,j)∈[0,45]∪[-180,-135], the calculation formulas for the two interpolation values ​​Δ5 and Δ6 are:

[0128]

[0129] Where (i+1,j-1) and (i+1,j) are the gradient amplitudes of the neighboring pixels to the right of the pixel (i,j); (i-1,j+1) and (i-1,j) are the gradient amplitudes of the neighboring pixels to the pixel (i,j). and The proportionality coefficient when |dy(i,j)|<|dx(i,j)|;

[0130] When θ(i,j)∈(135,180]∪(-45,0), the calculation formulas for the two interpolation values ​​Δ7 and Δ8 are:

[0131]

[0132] Where (i-1, j-1) and (i-1, j) are the gradient amplitudes of the neighboring pixels of pixel point (i, j);

[0133] (i+1,j+1) and (i+1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); and The proportionality coefficient when |dy(i,j)|<|dx(i,j)|;

[0134] Specifically, since the calculated gradient direction θ is not necessarily a fixed angle such as 45 degrees or 90 degrees, the present embodiment chooses to use interpolation method to consider the gradient amplitudes of the four surrounding neighborhood pixels and assign a proportional coefficient based on their distances to infer the gradient amplitude of the target position.

[0135] S32: Based on the range to which the calculated gradient direction θ belongs, the corresponding interpolation calculation formula is determined, and then the corresponding interpolation value is determined, that is, the two gradient amplitudes in the neighborhood of the gradient direction of the pixel point (i, j), and the gradient amplitude at the pixel point (i, j) is compared with the two determined gradient amplitudes to determine whether the gradient amplitude of the pixel point is a local maximum. If so, the original value is retained, otherwise, it is suppressed, that is, the value is assigned to 0. The processed image is as follows: Figure 8 shown.

[0136] Specifically, the purpose of non-maximum suppression (NMS) is to perform a "slimming" operation on the gradient amplitude in the gradient direction, that is, only retaining the local maximum points in the global gradient amplitude and setting other non-local maximum points to zero. This method can enhance the clarity of the image edge and reduce the interference in the gradient direction, thereby achieving accurate positioning of the edge and refining the image edge.

[0137] S4: setting a double threshold based on the gradient amplitude, and excluding the non-edge area in the refined image by the double threshold, to obtain an image excluding the non-edge area. The processed image is as follows: Fig. 9 As shown;

[0138] S5: performing a linking operation on the image excluding the non-edge area to form a complete boundary contour;

[0139] S6: Rejoin the several local images processed by S5 according to the original pixel coordinates to obtain an image with optimized waterline, such as Fig.10 As shown, the waterline detection result is obtained based on the image.

[0140] Specifically, in this embodiment, because the image is cut, the maximum value of the gradient amplitude of the cut local image is selected as the threshold reference, thereby avoiding the problem that the weak edge of the waterline is mistakenly eliminated due to the maximum value of the gradient amplitude of the water gauge character in the overall image, and ensuring the accurate detection of the waterline. In a specific embodiment, in S4, the process of setting a double threshold based on the gradient amplitude and excluding the non-edge area in the refined image through the double threshold is:

[0141] Traverse all the pixels in each image and select the maximum value G among the gradient amplitudes of all pixels max , based on the maximum value G max Set the double threshold, expressed as:

[0142]

[0143] Among them, T low Indicates the low threshold; T high Indicates high threshold;

[0144] The gradient amplitude G of the pixel point is compared with the double threshold value, and different pixel processing is performed according to the comparison result, including:

[0145] 1) If the gradient amplitude G of a pixel point is greater than the high threshold, the point is determined as a strong edge point;

[0146] 2) If the gradient amplitude G of a pixel point is less than the low threshold, the point is removed, thereby excluding the non-edge area in the refined image;

[0147] 3) If the gradient amplitude G of a pixel point is between the low threshold and the high threshold, the point is determined as a weak edge point and processed by edge connection.

[0148] Specifically, in this embodiment, the purpose of the dual threshold detection processing is to exclude non-edge areas and obtain an image excluding non-edge areas. At the same time, the pixels are judged by two thresholds, a high threshold and a low threshold, and the pixels are divided into two types, namely strong edge points and weak edge points.

[0149] In a specific embodiment, in S5, the process of performing a linking operation on the image excluding the non-edge area to form a complete boundary contour is as follows:

[0150] A linking operation is performed between weak edge points and adjacent strong edge points to form a complete boundary contour by linking incomplete boundary line segments.

[0151] Specifically, the edge linking process is mainly divided into two stages: tracking and end-to-end connection:

[0152] (1) Tracking

[0153] Tracking means starting from a certain strong edge point, searching in the direction of the adjacent weak edge point, and marking it as a strong edge point or an edge point that has been tracked; if the edge point currently searched is a weak edge point, continue searching in its adjacent area until all the weak edge points adjacent to the current strong edge point are found. This process can be seen as a path starting from a strong edge point, and the incomplete edges are connected by continuously expanding the path.

[0154] (2) End to end

[0155] After the tracking phase, many weak edge points will be obtained, which can be regarded as independent edge segments. In the process of connecting the end to the end, these independent edge segments need to be connected to each other to form a complete edge contour. The specific operation is to first find all the strong edge points, that is, the starting and ending points of the edge segments, and then regard the weak edge points as nodes. Through traversal and connectivity analysis, connections are established between adjacent weak edge points, so that these edge segments are connected into a whole.

[0156] Specifically, from Fig.11 and 12 It can be seen that Fig.12 The Sobel edge detection used is sensitive to noise. The left part of the picture shows a lot of noise interference, which affects the detection of the ship's waterline. Fig.11 Compared with the scheme without image segmentation, when performing non-maximum suppression, due to the presence of water gauge characters in the image, the gradient amplitude is large, which easily causes small edges to be mistakenly excluded. The right part of the image shows that part of the waterline is mistakenly excluded. Fig.10 Compared to Fig.11 and Fig.12 The obtained waterline edge is clearer and the waterline is easier to detect. Therefore, in practice, the technical solution described in the present invention is more suitable for waterline detection.

[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A ship waterline detection method based on image processing, characterized in that: The specific steps include: S1: Acquire a ship waterline detection image, and preprocess the ship waterline detection image; S2: performing image segmentation on the preprocessed image, and obtaining the gradient amplitude and gradient direction of the pixel points based on several segmented local images; S3: performing a non-maximum suppression operation on the segmented local images based on the gradient amplitude and the gradient direction to refine the edge region of the image to obtain a refined image; S4: setting a double threshold based on the gradient amplitude, and excluding the non-edge area in the refined image by the double threshold, so as to obtain an image excluding the non-edge area; S5: performing a linking operation on the image excluding the non-edge area to form a complete boundary contour; S6: rejoining the several local images processed by S5 according to the original pixel coordinates to obtain an image after waterline optimization, and obtaining a waterline detection result based on the image.

2. The ship waterline detection method based on image processing according to claim 1 is characterized in that: In S2, the image segmentation operation is performed on the preprocessed image, and the process of obtaining the gradient amplitude and gradient direction based on several segmented local images is as follows: Divide the preprocessed image into N×N local images; Let A be the window pixel matrix, expressed as: Among them, (x, y) represents the center pixel; A is convolved horizontally through the horizontal template, and the convolution result is: Where Gx represents the amplitude of the horizontal gradient of A; A is convolved vertically through the longitudinal template, and the convolution result is: Where Gy represents the amplitude of the vertical gradient of A; The gradient amplitude G is calculated based on the above convolution result, expressed as: Calculate the gradient direction θ, expressed as:

3. The ship waterline detection method based on image processing according to claim 2 is characterized in that: In S3, the process of performing non-maximum suppression operation on the segmented local images based on the gradient amplitude and gradient direction is as follows: S31: Discretize the gradient direction θ into four cases, expressed as: θ(i,j)∈(45,90]∪(-135,-90] θ(i,j)∈(90,135]∪(-90,-45] θ(i,j)∈[0,45]∪[-180,-135] θ(i,j)∈(135,180]∪(-45,0) The interpolation method is used to fit the gradient amplitude in the gradient direction, including: When θ(i,j)∈(45,90]∪(-135,-90], the calculation formulas for the two interpolation values ​​Δ1 and Δ2 are: Where (i+1, j-1) and (i, j-1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); (i-1, j+1) and (i, j+1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); and The proportionality coefficient when |dy(i,j)|>|dx(i,j)|; When θ(i,j)∈(90,135]∪(-90,-45]), the calculation formulas for the two interpolation values ​​Δ3 and Δ4 are: Where (i-1, j-1) and (i, j-1) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); (i+1,j+1) and (i,j+1) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); and The proportionality coefficient when |dy(i,j)|>|dx(i,j)|; When θ(i,j)∈[0,45]∪[-180,-135], the calculation formulas for the two interpolation values ​​Δ5 and Δ6 are: Where (i+1,j-1) and (i+1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); (i-1,j+1) and (i-1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j). and The proportionality coefficient when |dy(i,j)|<|dx(i,j)|; When θ(i,j)∈(135,180]∪(-45,0), the calculation formulas for the two interpolation values ​​Δ7 and Δ8 are: Where (i-1, j-1) and (i-1, j) are the gradient amplitudes of the neighboring pixels of pixel point (i, j); (i+1,j+1) and (i+1,j) are the gradient amplitudes of the neighboring pixels of pixel point (i,j); and The proportionality coefficient when |dy(i,j)|<|dx(i,j)|; S32: Based on the range to which the calculated gradient direction θ belongs, the corresponding interpolation calculation formula is clarified and then the corresponding interpolation value is determined, that is, the two gradient amplitudes in the neighborhood of the gradient direction of the pixel point (i, j), and the gradient amplitude at the pixel point (i, j) is compared with the two determined gradient amplitudes to determine whether the gradient amplitude of the pixel point is a local maximum. If so, the original value is retained, otherwise, it is suppressed, that is, assigned a value of 0.

4. The ship waterline detection method based on image processing according to claim 3 is characterized in that: In S4, the process of setting a double threshold based on the gradient amplitude and excluding the non-edge area in the refined image by the double threshold is as follows: Traverse all the pixels in each image and select the maximum value G among the gradient amplitudes of all pixels max , based on the maximum value G max Set the double threshold, expressed as: Among them, T low Indicates the low threshold; T high Indicates high threshold; The gradient amplitude G of the pixel point is compared with the double threshold value, and different pixel processing is performed according to the comparison result, including: 1) If the gradient amplitude G of a pixel point is greater than the high threshold, the point is determined as a strong edge point; 2) If the gradient amplitude G of a pixel point is less than the low threshold, the point is removed, thereby excluding the non-edge area in the refined image; 3) If the gradient amplitude G of a pixel point is between the low threshold and the high threshold, the point is determined as a weak edge point.

5. The ship waterline detection method based on image processing according to claim 4 is characterized in that: In S5, the image excluding the non-edge area is linked to form a complete boundary contour as follows: A linking operation is performed between weak edge points and adjacent strong edge points to form a complete boundary contour by linking incomplete boundary line segments.

6. The ship waterline detection method based on image processing according to claim 5 is characterized in that: In S1, the process of preprocessing the ship waterline detection image is as follows: The ship waterline detection image is grayed out, and the processing formula is: grey=0.299R+0.58G'+0.114B Wherein, grey represents the gray value of x, grey∈[0,255]; R represents the value of the R channel in the RGB color space, G' represents the value of the G' channel in the RGB color space, and B represents the value of the B channel in the RGB color space; The grayscale image is subjected to Gaussian filtering for noise reduction, and the processing formula is: Where f(x,y) represents a pixel in the image; G(x,y) represents a two-dimensional Gaussian function; σ represents the coefficient of the Gaussian filter; represents the convolution operation; S(x,y) represents the image after convolution.