A method for identifying ship types based on adaptive chain code
The method of identifying ship types through adaptive chain codes solves the problem of high computational cost of deep learning methods in actual deployment, and achieves efficient and accurate ship type identification, which is suitable for surface traffic monitoring and ship management.
Patent Information
- Application Number
- CN202211592930.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2042-12-13
AI Technical Summary
Existing deep learning-based ship classification and identification methods have a large number of parameters and computational costs in actual deployment, making it difficult to ensure computational efficiency and low latency, and the training process is complex.
The method of using adaptive chain code to identify ship types is adopted. The adaptive chain code is calculated by extracting the outer contour of the ship, and the similarity is calculated with the chain code in the preset ship type library to identify the ship type.
It improves the accuracy and stability of ship type identification, reduces the computing load, and is suitable for fields such as surface traffic monitoring and ship operation management.
Smart Images

Figure CN116168230B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision, and in particular relates to a method for identifying ship types based on adaptive chain codes. Background Art
[0002] With the rapid growth of surface shipping, the number of ship inbound and outbound operations, ocean-going shipping, inland waterway shipping, and inland lake fishing vessel management is increasing. The burden of controlling surface vessel traffic, controlling vessels during fishing moratoriums, and monitoring illegal vessel use is increasing. Building a "smart ocean" and "intelligent transportation" has become an important solution. Intelligent analysis of waterway and surface vessel images is a key component of this.
[0003] A key component of intelligent analysis of surface vessel images is identifying vessel types. The remarkable achievements of deep learning in academia, particularly in image recognition, image segmentation, and object detection, have led to the rapid industrialization of computer vision-based applications. Therefore, existing research on vessel type identification generally utilizes deep learning methods.
[0004] However, in real-world scenarios, the training model of the deep learning-based ship classification and recognition method has a large number of parameters, computational costs, and a large amount of storage costs. It is difficult to ensure computational efficiency, low latency, and low storage during the actual deployment of the model. Summary of the Invention
[0005] The purpose of the present invention is to provide a method for identifying ship types based on adaptive chain codes, which can effectively improve the recognition rate. Compared with machine learning methods for identifying ship types, it does not require a training process and has a smaller computational load.
[0006] The present invention is achieved through the following technical solutions:
[0007] A method for identifying ship types based on an adaptive chain code comprises the following steps:
[0008] S1. Obtain a picture of the ship to be identified;
[0009] S2, extracting the outer contour of the ship to be identified in the ship image;
[0010] S3, calculating the first adaptive chain code of the outer contour line of the ship to be identified;
[0011] S4. Calculate the similarity between the first adaptive chain code and each second adaptive chain code in a preset ship type library, and use the second adaptive chain code with the highest similarity as the target chain code. The ship type library at least includes the second adaptive chain codes corresponding to the outer contours of different ships and the ship types corresponding to the second adaptive chain codes.
[0012] S5. Obtain the corresponding ship type in the ship type library according to the target chain code, and use the obtained ship type as the ship type of the ship to be identified;
[0013] The step of calculating the first adaptive chain code of the outer contour line of the ship to be identified includes:
[0014] S31, calculating the minimum circumscribed rectangle of the ship image, and establishing an XOY rectangular coordinate system with the center of the circumscribed rectangle of the outer contour of the ship to be identified as the origin;
[0015] S32, taking the intersection of the positive direction of the Y axis and the outer contour of the ship to be identified as the starting reference point;
[0016] S33, taking the reference point as the starting point, obtaining the nth pixel point as the first boundary point and the 2nth pixel point as the second boundary point along the counterclockwise direction on the outer contour line of the ship to be identified;
[0017] S34, calculating the angle between the line connecting the reference point and the first boundary point and the positive direction of the x-axis, which is recorded as a first angle, and calculating the angle between the line connecting the reference point and the second boundary point and the positive direction of the x-axis, which is recorded as a second angle;
[0018] S35. Determine whether the absolute value of the difference between the second angle and the first angle is less than a preset threshold;
[0019] If not, encode the first and second boundary points using a 16-directional chain code to obtain chain codes corresponding to the first and second boundary points. The 16-directional chain code has a value range of 0 to F expressed as a hexadecimal number, and the encoding step interval is 22.5 degrees.
[0020] S37. If yes, encode the obtained second boundary point using an 8-direction chain code to obtain a chain code for the second boundary point. The value range of the 8-direction chain code is consecutive letters from G to N, and the encoding step interval is 45 degrees.
[0021] S38, recording the obtained second boundary point as a new reference point, and repeating steps S33 to S37 until the outer contour line of the ship to be identified is coded;
[0022] S39: Concatenate the obtained chain codes of all boundary points to form a coding sequence to obtain a first adaptive chain code of the outer contour line of the ship to be identified.
[0023] Furthermore, the step of obtaining a ship image of the ship to be identified includes:
[0024] A surveillance image containing a ship to be identified is obtained, a regional image of the area where the ship to be identified is located is intercepted from the surveillance image, and background removal processing is performed on the intercepted regional image to obtain a ship image of the ship to be identified.
[0025] Furthermore, the step of extracting the outer contour of the ship to be identified in the ship image includes:
[0026] Perform size normalization on the ship image to obtain a normalized image;
[0027] Perform grayscale transformation on the normalized image to obtain a grayscale image;
[0028] The grayscale image is processed by the edge detection operator to obtain the outer contour of the ship to be identified.
[0029] Furthermore, after the step of processing the grayscale image by an edge detection operator to obtain the outer contour line of the ship to be identified, the method further includes:
[0030] Determine whether the outer contour line of the ship to be identified is a closed curve. If not, repair the outer contour line of the ship to be identified into a closed curve.
[0031] Furthermore, the edge detection operator is a Canny operator.
[0032] Furthermore, the steps of respectively calculating the similarity between the first adaptive chain code and each second adaptive chain code in the preset ship type library include:
[0033] Selecting one second adaptive chain code from multiple second adaptive chain codes in the ship type library as a calculation chain code;
[0034] The Mahalanobis distance between the first adaptive chain code and the calculation chain code is calculated, and the similarity between the first adaptive chain code and the calculation chain code is calculated based on the calculated Mahalanobis distance and formula (1); formula (1) is:
[0035]
[0036] Where Lh is the similarity between the first adaptive chain code and the calculation chain code, and MD is the Mahalanobis distance between the first adaptive chain code and the calculation chain code.
[0037] Compared with the prior art, the beneficial effects of the present invention are as follows: since the surrounding environment of the ship to be identified is the water surface or the distant background, and the color of the ship is relatively uniform and the scale of the ship is large, it is not easily disturbed by light on the water surface; especially the outline of the ship in motion is rigid and cannot be changed, so the outline feature is highly stable, the type of ship is closely related to the outline of the ship, and the outline of the ship can be used as an effective feature of the ship for ship type identification. Therefore, the present invention extracts the outline features of the ship to be identified and represents them in a refined manner through the adaptive chain code of the outline of the ship to be identified. It can more accurately identify subtle features such as the mast and tower of the ship, so as to effectively describe and retain the key outline detail information of the ship to be identified and reduce the encoding storage amount. Finally, the ship type is judged according to the adaptive chain code, which has strong stability, effectively improves the recognition rate, and reduces the computing load. The present invention has a wide range of applications and can be used in fields such as surface traffic monitoring and ship operation management. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This is a flowchart of the steps of the method for identifying ship types based on adaptive chain codes according to the present invention;
[0039] Figure 2 This is a module diagram of the system for identifying ship types based on adaptive chain codes according to the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions 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 only part of the embodiments of the present invention, not all of the embodiments.
[0041] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0042] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are used only to distinguish the description and should not be understood as indicating or implying relative importance.
[0043] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0044] See also Figure 1 , Figure 1 The following is a flow chart of the steps of the method for identifying the type of ship based on the adaptive chain code of the present invention. A method for identifying the type of ship based on the adaptive chain code comprises the following steps:
[0045] S1. Obtain a ship image of a ship to be identified;
[0046] S2, extracting the outer contour of the ship to be identified in the ship image;
[0047] S3, calculating the first adaptive chain code of the outer contour line of the ship to be identified;
[0048] S4. Calculate the similarity between the first adaptive chain code and each second adaptive chain code in a preset ship type library, and use the second adaptive chain code with the highest similarity as the target chain code. The ship type library at least includes the second adaptive chain codes corresponding to the outer contours of different ships and the ship types corresponding to the second adaptive chain codes.
[0049] S5. Obtain the corresponding ship type in the ship type library according to the target chain code, and use the obtained ship type as the ship type of the ship to be identified;
[0050] The step of calculating the first adaptive chain code of the outer contour line of the ship to be identified includes:
[0051] S31 establishes an XOY rectangular coordinate system with the center of the circumscribed rectangle of the outer contour of the ship to be identified as the origin;
[0052] S32, taking the intersection of the positive direction of the Y axis and the outline of the ship to be identified as a reference point;
[0053] S33, taking the reference point as the starting point, obtaining the nth pixel point as the first boundary point and the 2nth pixel point as the second boundary point along the counterclockwise direction on the outer contour line of the ship to be identified;
[0054] S34, calculating the angle between the line connecting the reference point and the first boundary point and the positive direction of the x-axis, which is recorded as a first angle, and calculating the angle between the line connecting the reference point and the second boundary point and the positive direction of the x-axis, which is recorded as a second angle;
[0055] S35. Determine whether the absolute value of the difference between the second angle and the first angle is less than a preset threshold;
[0056] If not, encode the first and second boundary points using a 16-directional chain code to obtain chain codes corresponding to the first and second boundary points. The 16-directional chain code has a value range of 0 to F expressed as a hexadecimal number, and the encoding step interval is 22.5 degrees.
[0057] S37. If yes, encode the obtained second boundary point using an 8-direction chain code to obtain a chain code for the second boundary point. The value range of the 8-direction chain code is consecutive letters from G to N, and the encoding step interval is 45 degrees.
[0058] S38, recording the obtained second boundary point as a new reference point, and repeating steps S33 to S37 until the outer contour line of the ship to be identified is coded;
[0059] S39: Concatenate the obtained chain codes of all boundary points to form a coding sequence to obtain a first adaptive chain code of the outer contour line of the ship to be identified.
[0060] In the above step S1, the acquired ship image contains the ship to be identified, and the size of the ship image is the size of the minimum circumscribed rectangle of the outer contour of the ship to be identified.
[0061] Furthermore, in step S1, the step of obtaining a ship image of the ship to be identified includes:
[0062] S11. Acquire a surveillance image containing a ship to be identified, intercept a region image of the area where the ship to be identified is located from the surveillance image, and perform background removal processing on the intercepted region image to obtain a ship image of the ship to be identified.
[0063] In the above step S11, since ships sailing on inland rivers, lakes and seas or ships entering and leaving ports all operate according to specific waterways, the monitoring images of the ships taken by the monitoring on the waterways are all taken based on a certain angle of the ship, that is, the ship perspective on the ship images taken by the monitoring is basically the same, and the monitoring image captures an image of a water area. The ship to be identified only occupies a part of the area in the monitoring image. Therefore, for ease of processing, the minimum circumscribed rectangular area of the outer contour of the ship to be identified is captured in the monitoring image to obtain a regional image, and the regional image is subjected to background removal processing based on the difference between the ship texture and the background, the background of the ship is removed, and the ship foreground is obtained, thereby obtaining a ship image of the ship to be identified.
[0064] Furthermore, in step S2, the step of extracting the outer contour line of the ship to be identified in the ship image includes:
[0065] S21, performing size normalization processing on the ship image to obtain a normalized image;
[0066] S22, performing grayscale transformation on the normalized image to obtain a grayscale image;
[0067] S23. Process the grayscale image using an edge detection operator to obtain the outer contour of the ship to be identified.
[0068] In steps S21 through S23, to ensure standardization of the results of the subsequent adaptive chain code calculations, the ship images are normalized and scaled to the same size before extracting the outer contours of the vessels to be identified, ensuring that the resolution of each vessel is the same. The normalized images are then grayscale-converted to black and white. The Canny operator can be used as an edge detection operator. The Canny operator calculates the gradient of the grayscale image, removes noise, and extracts the outer contours of the vessels to be identified.
[0069] Furthermore, after the step of processing the grayscale image by an edge detection operator to obtain the outer contour line of the ship to be identified, the method further includes:
[0070] S24. Determine whether the outer contour line of the ship to be identified is a closed curve. If not, repair the outer contour line of the ship to be identified into a closed curve.
[0071] In the above step S24, since part of the extracted outer contour line of the ship to be identified may be broken due to interference or other reasons when the outer contour line of the ship to be identified is extracted by the edge detection operator, after obtaining the outer contour line of the ship to be identified, it is determined whether the outer contour line of the ship to be identified is a closed curve. If it is a closed curve, the obtained outer contour line of the ship to be identified is directly output; if it is not a closed curve, the outer contour line of the ship to be identified is repaired by expansion or corrosion to achieve the purpose of repairing the outer contour line of the ship to be identified into a closed curve.
[0072] In steps S31 through S310, to avoid confusion, the 16-directional chain code ranges from 0 to F in hexadecimal, with a coding step interval of 22.5 degrees. The 8-directional chain code ranges from G to N, with a coding step interval of 45 degrees. The minimum circumscribed rectangle of the vessel's outer contour is calculated, and an XOY rectangular coordinate system is established with the center of the rectangle as the origin. The reference point can be selected arbitrarily on the vessel's outer contour; the subsequent calculation of the vessel's adaptive chain code requires only the first reference point to be selected at the same location. Furthermore, to facilitate the programmatic execution of reference point selection, the intersection of the positive Y-axis and the vessel's outer contour is selected as the reference point. After selecting a reference point, the outer contour of the ship to be identified is calculated counterclockwise. The nth and 2nth pixel points following the reference point are used as the first and second boundary points, respectively, according to the direction of each pixel relative to the reference point. The lines connecting the reference point, the first and second boundary points, respectively, form the first and second angles with the positive x-axis. The first and second angles are each quantized using a chain code direction of eight equally divided angles, from G to N, forming an eight-direction chain code. These are concatenated in order to form a chain code. n is preferably, but not limited to, 4 and may also take other values.
[0073] If the absolute value of the difference between the first angle and the second angle between the reference point and the 2nth point is greater than or equal to a preset threshold (which can be determined empirically). In this embodiment, the preset threshold is set to 45 degrees. This indicates that the change in the first angle between the line connecting the first boundary point and the reference point and the positive x-axis relative to the second angle between the line connecting the second boundary point and the reference point and the positive x-axis is greater than or equal to 45 degrees. This means that the outer contour of the vessel to be identified at the first boundary point has a sudden change, indicating the presence of contour detail information at the first boundary point. Therefore, the step interval is automatically reduced to 22.5 degrees. At this point, the chain code is represented using 0-F quantization based on the angle with the positive x-axis, forming a 16-directional chain code. The first and second boundary points are then encoded using the 16-directional chain code to obtain the chain codes corresponding to the first and second boundary points. If the absolute value of the difference between the first angle and the second angle is less than a preset threshold, it means that the change in the first angle between the line connecting the first boundary point and the reference point and the positive direction of the x-axis relative to the second angle between the line connecting the second boundary point and the reference point and the positive direction of the x-axis is less than 45 degrees, that is, the outer contour line of the ship to be identified at the first boundary point is relatively smooth with respect to the second boundary point, indicating that there is no contour detail information at the first boundary point. Therefore, the 8-direction chain code is used to encode the second boundary point to obtain the chain code corresponding to the second boundary point, and the first boundary is not encoded. Then the second boundary point is recorded as the new reference point, and the above process is repeated until the selected boundary point exceeds the first reference point, that is, the encoding of all boundary points on the outer contour line of the ship to be identified is completed. At this time, the repetitive process ends. Whether the selected boundary point exceeds the first reference point can be judged based on the number of points on the outer contour line and the coordinates, such as traversing the outer contour line to obtain the number of pixels on the outer contour line. When obtaining the boundary point, record the pixel number of the obtained boundary point and record it as the number of boundary points. Judge whether the number of boundary points exceeds the number of pixels on the outer contour line. If so, it is judged that the selected boundary point exceeds the first reference point. This is the existing technology and will not be repeated here. Finally, the chain codes of all the obtained boundary points are concatenated to form a coding sequence to obtain the first adaptive chain code of the outer contour line of the ship to be identified.
[0074] In step S4, when a ship is sailing on a waterway, its surroundings are the water surface or a distant background. The ship's color is relatively uniform, and its size is large, making it less susceptible to light interference on the water surface. In particular, the ship's outline is rigid and unchangeable while in motion, so its outline features are highly stable. The large dimensions of the hull, tower, and mast make it easy to extract these features. The ship's type is closely associated with its outline, and its outline can serve as an effective feature for ship type identification. Therefore, a second adaptive chain code for the ship's outer contour can be pre-calculated for all types of ships on the market according to steps S1 to S3. The second adaptive chain code can then be associated with the corresponding ship type and stored in a database, forming a ship type library. By calculating the similarity between the first adaptive chain code and each second adaptive chain code in the preset ship type library, and then comparing the calculated similarities, the second adaptive chain code closest to the first adaptive chain code is found in the ship database, and the second adaptive chain code closest to the first adaptive chain code is replaced by the target chain code. It can be considered that the outer contour line of the ship corresponding to the target chain code is basically the same as the outer contour line of the ship to be identified corresponding to the first adaptive chain code.
[0075] Furthermore, in step S4, the steps of respectively calculating the similarity between the first adaptive chain code and each second adaptive chain code in the preset ship type library include:
[0076] S41. Select one second adaptive chain code from multiple second adaptive chain codes in the ship type library as a calculation chain code;
[0077] S42. Calculate the Mahalanobis distance between the first adaptive chain code and the calculation chain code, and calculate the similarity between the first adaptive chain code and the calculation chain code based on the calculated Mahalanobis distance and formula (1); formula (1) is:
[0078]
[0079] Where Lh is the similarity between the first adaptive chain code and the calculation chain code, and MD is the Mahalanobis distance between the first adaptive chain code and the calculation chain code.
[0080] In the above steps S41 to S42 , when the Mahalanobis distance between the first adaptive chain code and the calculation chain code is 0, the similarity between the first adaptive chain code and the calculation chain code is 100%.
[0081] In the above step S5, since the outer contour line of the ship corresponding to the target chain code is basically the same as the outer contour line of the ship to be identified corresponding to the first adaptive chain code, and the outer contour lines of different ship types have great differences, that is, it can be considered that the ship corresponding to the target chain code and the ship to be identified corresponding to the first adaptive chain code are also basically the same. Therefore, after obtaining the ship type of the target ship in the ship type library, the ship type of the target ship is output as the ship type of the ship to be identified, thereby completing the identification of the ship type of the ship to be identified.
[0082] See also Figure 2 , Figure 2 The present invention also provides a system for identifying ship types based on adaptive chain codes, including:
[0083] Acquisition module 1, used to acquire a ship image of a ship to be identified;
[0084] Extraction module 2, used to extract the outer contour of the ship to be identified in the ship image;
[0085] A first calculation module 3, used for calculating a first adaptive chain code of an outer contour line of a ship to be identified;
[0086] The second calculation module 4 is configured to respectively calculate the similarity between the first adaptive chain code and each second adaptive chain code in a preset ship type library, and use the second adaptive chain code with the highest similarity as the target chain code. The ship type library at least includes the second adaptive chain codes corresponding to the outer contours of different ships and the ship types corresponding to the second adaptive chain codes.
[0087] Obtaining module 5, for obtaining the corresponding ship type in the ship type library according to the target chain code, and using the obtained ship type as the ship type of the ship to be identified;
[0088] The first calculation module includes:
[0089] Establishing a submodule for establishing an XOY rectangular coordinate system with the center of the circumscribed rectangle of the outer contour of the ship to be identified as the origin;
[0090] The first selection submodule is used to take the intersection of the positive direction of the Y axis and the contour line of the ship to be identified as a reference point;
[0091] an acquisition submodule, configured to take the reference point as a starting point, acquire the nth pixel point as a first boundary point, and acquire the 2nth pixel point as a second boundary point along the counterclockwise direction on the outer contour line of the ship to be identified;
[0092] a calculation submodule, configured to calculate an angle between a line connecting the reference point and the first boundary point and the positive direction of the x-axis, recorded as a first angle, and to calculate an angle between a line connecting the reference point and the second boundary point and the positive direction of the x-axis, recorded as a second angle;
[0093] a judging submodule, configured to judge whether the absolute value of the difference between the second angle and the first angle is less than a preset threshold;
[0094] A first encoding submodule is configured to, if not, encode the first and second boundary points using a 16-directional chain code to obtain chain codes corresponding to the first and second boundary points, where the 16-directional chain code has a value range of 0 to F in hexadecimal notation, and the encoding step interval is 22.5 degrees;
[0095] A second encoding submodule is configured to, if yes, encode the obtained second boundary point using an 8-directional chain code to obtain a chain code for the second boundary point, where the value range of the 8-directional chain code is consecutive letters from G to N, and the encoding step interval is 45 degrees;
[0096] a repeating submodule, configured to record the acquired second boundary point as a new reference point, and repeat the acquiring submodule to the second encoding submodule until the encoding of the outer contour line of the ship to be identified is completed;
[0097] The concatenation submodule is used to concatenate the chain codes of all the boundary points obtained to form a coding sequence to obtain a first adaptive chain code of the outer contour line of the ship to be identified.
[0098] The ship image acquired by the acquisition module 1 contains the ship to be identified, and the size of the ship image is the size of the minimum circumscribed rectangle of the outer contour of the ship to be identified.
[0099] Furthermore, the acquisition module 1 includes:
[0100] The interception submodule is used to obtain a surveillance image containing a ship to be identified, intercept a regional image of the area where the ship to be identified is located from the surveillance image, and remove the background of the intercepted regional image to obtain a ship image of the ship to be identified.
[0101] Since ships sailing on inland rivers, lakes and seas or ships entering and leaving ports all operate according to specific waterways, the surveillance images of ships taken by the monitoring on the waterways are all taken based on a certain angle of the ship, that is, the ship perspective on the ship images taken by the monitoring is basically the same, and the monitoring image captures an image of a water area. The ship to be identified only occupies a part of the area in the monitoring image. Therefore, for ease of processing, the interception submodule intercepts the minimum circumscribed rectangular area of the outer contour of the ship to be identified in the monitoring image, thereby obtaining a regional image, and according to the difference between the ship texture and the background, the regional image is subjected to background removal processing, the background of the ship is removed, and the ship foreground is obtained, thereby obtaining a ship image of the ship to be identified.
[0102] Furthermore, the extraction module 2 includes:
[0103] The normalization submodule is used to perform size normalization processing on the ship image to obtain a normalized image;
[0104] Grayscale submodule, used to perform grayscale transformation on the normalized image to obtain a grayscale image;
[0105] The edge submodule is used to process the grayscale image through the edge detection operator to obtain the outer contour line of the ship to be identified.
[0106] To ensure standardization of the results of subsequent adaptive chain code calculations, the normalization submodule normalizes the ship images before extracting the outer contours of the vessels to be identified, scaling them to the same size to ensure the same resolution for each vessel. The grayscale submodule then performs grayscale transformation on the normalized images, converting them into black and white grayscale images. The Canny operator can be used as an edge detection operator. The edge submodule calculates the gradient of the grayscale image using the Canny operator, removes noise, and extracts the outer contours of the vessels to be identified.
[0107] Furthermore, the extraction module 2 further includes:
[0108] The repair submodule is used to determine whether the outer contour line of the ship to be identified is a closed curve. If it is not a closed curve, the outer contour line of the ship to be identified is repaired into a closed curve.
[0109] Since some segments of the outer contour line of the ship to be identified may be broken due to interference and other reasons when the outer contour line of the ship to be identified is extracted by the edge detection operator, after obtaining the outer contour line of the ship to be identified, the repair submodule determines whether the outer contour line of the ship to be identified is a closed curve. If it is a closed curve, the outer contour line of the ship to be identified is directly output; if it is not a closed curve, the outer contour line of the ship to be identified is repaired by expansion or corrosion to achieve the purpose of repairing the outer contour line of the ship to be identified into a closed curve.
[0110] In the above-mentioned establishment submodule to the concatenation submodule, to avoid confusion, the value range of the 16-direction chain code is expressed in hexadecimal numbers from 0 to F, and the encoding step interval is 22.5 degrees; the value range of the 8-direction chain code is consecutive letters from G to N, and the encoding step interval is 45 degrees. Calculate the minimum circumscribed rectangle of the outer contour line of the ship to be identified, and establish an XOY rectangular coordinate system with the center of the rectangle as the origin; when establishing a plane rectangular coordinate system, the XOY rectangular coordinate system can be established with the center of the ship image as the origin. The reference point can be selected arbitrarily on the outer contour line of the ship to be identified. It is only necessary to select the first reference point at the same position when subsequently calculating the adaptive chain code of the ship. Furthermore, in order to facilitate the use of the program to execute the work of selecting the reference point, the intersection of the positive direction of the Y axis and the outer contour line of the ship to be identified is selected as the reference point. After selecting a reference point, the outer contour of the ship to be identified is calculated counterclockwise. The nth and 2nth pixel points following the reference point are used as the first and second boundary points, respectively, according to the direction of each pixel relative to the reference point. The lines connecting the reference point, the first and second boundary points, respectively, form the first and second angles with the positive x-axis. The first and second angles are each quantized using a chain code direction of eight equally divided angles, from G to N, forming an eight-direction chain code. These are concatenated in order to form a chain code. n is preferably, but not limited to, 4 and may also take other values.
[0111] If the absolute value of the difference between the first angle and the second angle between the reference point and the 2nth point is greater than or equal to a preset threshold (which can be determined empirically). In this embodiment, the preset threshold is set to 45 degrees. This indicates that the change in the first angle between the line connecting the first boundary point and the reference point and the positive x-axis relative to the second angle between the line connecting the second boundary point and the reference point and the positive x-axis is greater than or equal to 45 degrees. This means that the outer contour of the vessel to be identified at the first boundary point has a sudden change, indicating the presence of contour detail information at the first boundary point. Therefore, the step interval is automatically reduced to 22.5 degrees. At this point, the chain code is represented using 0-F quantization based on the angle with the positive x-axis, forming a 16-directional chain code. The first and second boundary points are then encoded using the 16-directional chain code to obtain the chain codes corresponding to the first and second boundary points. If the absolute value of the difference between the first angle and the second angle is less than the preset threshold, it means that the change of the first angle between the line connecting the first boundary point and the reference point and the positive direction of the x-axis relative to the second angle between the line connecting the second boundary point and the reference point and the positive direction of the x-axis is less than 45 degrees, which means that the outer contour line of the ship to be identified at the first boundary point is relatively smooth compared to the second boundary point, indicating that there is no contour detail information at the first boundary point. Therefore, the second boundary point is encoded using an 8-direction chain code to obtain the chain code corresponding to the second boundary point, and the first boundary is not encoded. The second boundary point is then recorded as a new reference point, and the above process is repeated until the selected boundary point exceeds the first reference point, that is, the encoding of all boundary points on the outer contour line of the ship to be identified is completed. Whether the selected boundary point exceeds the first reference point can be determined by traversing the points on the outer contour line and judging by coordinates, etc. This is a prior art and will not be repeated here. At this point, the repetitive process ends. Whether the selected boundary point exceeds the first reference point can be determined based on the number of points on the outer contour line and the coordinates. For example, the outer contour line is traversed to obtain the number of pixels on the outer contour line. When a boundary point is obtained, the pixel number of the obtained boundary point is recorded as the number of boundary points. Whether the number of boundary points exceeds the number of pixels on the outer contour line is determined. If so, the selected boundary point is determined to exceed the first reference point. This is a prior art technique and will not be further described here. Finally, the chain codes of all the obtained boundary points are concatenated in the order in which they were obtained to form a coding sequence to obtain the first adaptive chain code for the outer contour line of the ship to be identified.
[0112] When a ship is navigating a waterway, its surroundings are the water surface or a distant background. The ship's color is relatively uniform, and its size is large, making it less susceptible to light interference on the water surface. In particular, the ship's silhouette is rigid and unchangeable while in motion, so its silhouette features are highly stable. The large dimensions of the hull, tower, and mast make it easy to extract these features. The ship's type is closely associated with its silhouette, and its silhouette can serve as an effective feature for ship type identification. Therefore, a second adaptive chain code for the ship's outer contour can be calculated in advance for all types of ships on the market, using the acquisition module 1 through the first calculation module 3. The second adaptive chain code is then associated with the corresponding ship type and stored in a database to form a ship type library. The second calculation module 4 calculates the similarity between the first adaptive chain code and each second adaptive chain code in the preset ship type library, and then compares the calculated similarities to find the second adaptive chain code closest to the first adaptive chain code in the ship database. The second adaptive chain code closest to the first adaptive chain code is then replaced with the target chain code. The outer contour of the ship corresponding to the target chain code is considered to be substantially identical to the outer contour of the ship to be identified, corresponding to the first adaptive chain code.
[0113] Furthermore, the second calculation module 4 includes:
[0114] A second selection submodule is used to sequentially select a second adaptive chain code from a plurality of second adaptive chain codes in the ship type library as a calculation chain code;
[0115] The similarity module is used to calculate the Mahalanobis distance between the first adaptive chain code and the calculation chain code, and calculate the similarity between the first adaptive chain code and the calculation chain code based on the calculated Mahalanobis distance and formula (1); formula (1) is:
[0116]
[0117] Where Lh is the similarity between the first adaptive chain code and the calculation chain code, and MD is the Mahalanobis distance between the first adaptive chain code and the calculation chain code.
[0118] In the above-mentioned second selection submodule to similarity module, when the Mahalanobis distance between the first adaptive chain code and the calculation chain code is 0, the similarity between the first adaptive chain code and the calculation chain code is 100%.
[0119] Since the outer contour line of the ship corresponding to the target chain code is basically the same as the outer contour line of the ship to be identified corresponding to the first adaptive chain code, and the outer contour lines of different ship types have great differences, it can be considered that the ship corresponding to the target chain code and the ship to be identified corresponding to the first adaptive chain code are also basically the same. Therefore, after module 5 obtains the ship type of the target ship in the ship type library, it outputs the ship type of the target ship as the ship type of the ship to be identified, thereby completing the identification of the ship type of the ship to be identified.
[0120] Compared with the prior art, the beneficial effects of the present invention are as follows: since the surrounding environment of the ship to be identified is the water surface or the distant background, and the color of the ship is relatively uniform and the scale of the ship is large, it is not easily disturbed by light on the water surface; especially the outline of the ship in motion is rigid and cannot be changed, so the outline feature is highly stable, the type of ship is closely related to the outline of the ship, and the outline of the ship can be used as an effective feature of the ship for ship type identification. Therefore, the present invention extracts the outline features of the ship to be identified and represents them in a refined manner through the adaptive chain code of the outline of the ship to be identified. It can more accurately identify subtle features such as the mast and tower of the ship, so as to effectively describe and retain the key outline detail information of the ship to be identified and reduce the encoding storage amount. Finally, the ship type is judged according to the adaptive chain code, which has strong stability, effectively improves the recognition rate, and reduces the computing load. The present invention has a wide range of applications and can be used in fields such as surface traffic monitoring and ship operation management.
[0121] The present invention is not limited to the above-mentioned embodiments. If various changes or modifications of the present invention do not depart from the spirit and scope of the present invention, and if these changes and modifications fall within the scope of the claims of the present invention and equivalent technologies, the present invention is also intended to include these changes and modifications.
Claims
1. A method for identifying ship types based on adaptive chain codes, characterized in that: The following steps are involved: S1. Obtain a ship image of a ship to be identified; S2. Extracting the outer contour of the ship to be identified in the ship image; S3, calculating the first adaptive chain code of the outer contour line of the ship to be identified; S4. Calculate the similarity between the first adaptive chain code and each second adaptive chain code in a preset ship type library, and use the second adaptive chain code with the highest similarity as the target chain code. The ship type library at least includes the second adaptive chain codes corresponding to the outer contours of different ships and the ship types corresponding to the second adaptive chain codes. S5. Obtain a corresponding ship type in a ship type library according to the target chain code, and use the obtained ship type as the ship type of the ship to be identified; The step of calculating the first adaptive chain code of the outer contour line of the ship to be identified includes: S31, establishing an XOY rectangular coordinate system with the center of the circumscribed rectangle of the outer contour of the ship to be identified as the origin; S32, taking the intersection of the positive direction of the Y axis and the outer contour of the ship to be identified as a reference point; S33, taking the reference point as the starting point, obtaining the nth pixel point as the first boundary point and the 2nth pixel point as the second boundary point along the counterclockwise direction on the outer contour line of the ship to be identified; S34, calculating the angle between the line connecting the reference point and the first boundary point and the positive direction of the x-axis, which is recorded as a first angle, and calculating the angle between the line connecting the reference point and the second boundary point and the positive direction of the x-axis, which is recorded as a second angle; S35. Determine whether the absolute value of the difference between the second angle and the first angle is less than a preset threshold; If not, encode the first and second boundary points using a 16-directional chain code to obtain chain codes corresponding to the first and second boundary points. The 16-directional chain code has a value range of 0 to F expressed as a hexadecimal number, and the encoding step interval is 22.5 degrees. S37. If yes, encode the obtained second boundary point using an 8-direction chain code to obtain a chain code for the second boundary point. The value range of the 8-direction chain code is consecutive letters from G to N, and the encoding step interval is 45 degrees. S38, recording the obtained second boundary point as a new reference point, and repeating steps S33 to S37 until the outer contour line of the ship to be identified is coded; S39: Concatenate the obtained chain codes of all boundary points to form a coding sequence to obtain a first adaptive chain code of the outer contour line of the ship to be identified.
2. The method for identifying ship types based on adaptive chain codes according to claim 1, characterized in that: The step of obtaining a ship image of a ship to be identified comprises: A surveillance image containing a ship to be identified is acquired, a regional image of the area where the ship to be identified is located is intercepted from the surveillance image, and background removal processing is performed on the intercepted regional image to obtain a ship image of the ship to be identified.
3. The method for identifying ship types based on adaptive chain codes according to claim 1, characterized in that: The step of extracting the outer contour line of the ship to be identified in the ship picture includes: performing size normalization processing on the ship image to obtain a normalized image; Performing grayscale transformation on the normalized image to obtain a grayscale image; The grayscale image is processed by an edge detection operator to obtain the outer contour line of the ship to be identified.
4. The method for identifying ship types based on adaptive chain codes according to claim 3 is characterized in that: After the step of processing the grayscale image by an edge detection operator to obtain the outer contour line of the ship to be identified, the method further includes: Determine whether the outer contour line of the ship to be identified is a closed curve. If not, repair the outer contour line of the ship to be identified into a closed curve.
5. The method for identifying ship types based on adaptive chain codes according to claim 3, characterized in that: The edge detection operator is the Canny operator.
6. The method for identifying ship types based on adaptive chain codes according to claim 1, characterized in that: The step of respectively calculating the similarity between the first adaptive chain code and each second adaptive chain code in the preset ship type library includes: Selecting one second adaptive chain code from the plurality of second adaptive chain codes in the ship type library in turn as a calculation chain code; The Mahalanobis distance between the first adaptive chain code and the calculation chain code is calculated, and the similarity between the first adaptive chain code and the calculation chain code is calculated based on the calculated Mahalanobis distance and formula (1); the formula (1) is: Where Lh is the similarity between the first adaptive chain code and the calculation chain code, and MD is the Mahalanobis distance between the first adaptive chain code and the calculation chain code.
Citation Information
Patent Citations
Vehicle brand recognition method
CN111046875A
Device and method of classifying an image
WO2007052957A1