Port large model training data image segmentation method and system
By employing multimodal image fusion and hierarchical optimization techniques, combined with a port edge sample library, the accuracy problem of image segmentation under complex backgrounds and severe weather conditions in port images was solved, achieving a significant improvement in the efficiency and robustness of port image edge detection.
Patent Information
- Application Number
- CN202511710141.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2045-11-20
AI Technical Summary
In the complex background and adverse weather conditions of port images, traditional image segmentation methods struggle to accurately segment target elements in port scenes. In particular, under varying lighting conditions and weather influences, insufficient edge precision leads to a significant increase in the deviation between the segmentation results and the actual targets.
Multimodal image fusion and hierarchical optimization techniques are employed, combined with a port edge sample library, to enhance image edge features. This includes dynamic illumination compensation for visible light images, denoising of infrared images, edge detection of multimodal images, and hierarchical edge detection optimization. The port edge sample library is then used for edge feature restoration.
It improves the accuracy and robustness of image edge detection in port scenes, and can effectively segment target elements in port images under complex lighting and severe weather conditions.
Smart Images

Figure CN121147935B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to a method and system for segmenting images of large port model training data. Background Technology
[0002] In port operations and intelligent monitoring scenarios, the unique characteristics of port images pose significant challenges to image segmentation technology. First, port images often contain densely stacked containers of various colors, towering gantry cranes and quay cranes, shuttling transport vehicles, various moored ships, and elements such as dock buildings, lighthouses, and signal towers. These elements intertwine and occlude each other, forming a highly complex background environment, making it extremely easy to confuse the feature boundaries of target elements with other background elements. Second, the scale differences of these elements are even more pronounced: from equipment parts as small as centimeters, to transport vehicles and small fishing boats several meters long, to container ships and large cruise ships tens or even hundreds of meters long. Targets of different scales coexist in the same image, with the size difference between the smallest and largest elements reaching hundreds of times. This places extremely high demands on the scale adaptability of segmentation algorithms.
[0003] Meanwhile, the limitations of traditional image segmentation methods (such as thresholding, edge detection, region growing, SVM, and random forest) in the complex environment of ports become more apparent, especially under complex lighting and adverse weather conditions, where insufficient edge accuracy is a common problem. From a lighting perspective, ports, as open-air scenes, experience constantly changing lighting conditions. Under strong midday sunlight, strong shadows are easily generated (such as container shadows covering adjacent targets, or quay crane shadows projected onto the sea or dock surface), resulting in the compression of the grayscale feature difference between the shadowed area and the target itself. In the low-light environment of dawn and dusk, the overall image contrast decreases, and the grayscale gradient of the target edge is not obvious. In backlit scenes, the side of the target facing the light source may be overexposed, while the other side may fall into darkness. From the perspective of weather factors, rainy days can cause raindrops to obscure images and water surface reflections (such as water reflecting skylights on a dock or light spots created by raindrops on the sea surface). These disturbances can disrupt the continuity of target edges. In foggy scenes, fog can cause image details to become blurred, and the gray values of the target and the background tend to be similar, severely weakening edge features. In snowy or dusty weather, the overall brightness of the image is abnormal or there are a lot of noise points, which further increases the difficulty of edge detection in traditional segmentation methods, resulting in a significant increase in the deviation between the segmentation results and the actual target. Summary of the Invention
[0004] To address the aforementioned problems in existing technologies, this invention proposes a method and system for segmenting port large-scale model training data images, optimizing image segmentation boundaries or edges to improve the accuracy of port image segmentation.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: a method for segmenting port large-scale model training data images, specifically including the following steps: Step S1: acquiring visible light images and infrared images of the scene obtained from the port large-scale model training data; Step S2: performing dynamic illumination compensation on the visible light images to obtain compensated visible light images; Step S3: obtaining multimodal images based on the compensated visible light images and the infrared images, and denoising the multimodal images to obtain denoised images; Step S4: enhancing the denoised images based on a port edge sample library to obtain enhanced images; Step S5: performing layered edge detection on the enhanced images to obtain layered edge detection results; Step S6: optimizing the layered edge detection results, using the optimized layered edge detection results as the edges of the port large-scale model training data images, and segmenting the port large-scale model training data images based on the image edges.
[0006] Further, step S2 specifically includes the following sub-steps: Step S21: Use the rgb2ycbcr function to convert the visible light image into the YCbCr color space to obtain the conversion result, and then extract the first dimension data of the conversion result, denoted as matrix Y; obtain the number of rows and columns of matrix Y, and pre-allocate memory for the compensated visible light image; Step S22: Establish a double loop based on a preset step size, with the number of rows of matrix Y as the outer loop and the number of columns of matrix Y as the inner loop to traverse matrix Y; Step S23: Define an image block matrix smaller than the boundary of the visible light image, and calculate the average brightness of the current image block matrix; Step S24: Calculate the adaptive correction value GM based on the average brightness.
[0007] ;
[0008] Where GM represents the adaptive correction value, K1 represents the first constraint coefficient, K2 represents the second constraint coefficient, N1 represents the image matching value, and MEAN represents the average brightness; Step S25: Using the imajust function, the current image block matrix is mapped to a new matrix based on the adaptive correction value GM, denoted as the compensated current image block matrix; the compensated current image block matrix is assigned to the first dimension of the conversion result, and the ycbcr2rgb function is used to convert the conversion result to the RGB color space, thereby obtaining the compensated visible light image.
[0009] Further, step S3 specifically includes: Step S31: Converting the compensated visible light image and the infrared image into compensated visible light grayscale images and infrared grayscale images respectively; performing three-level wavelet decomposition on the compensated visible light grayscale images and the infrared grayscale images using the swt2 function to obtain visible light image decomposition matrix and infrared image decomposition matrix; Step S32: Using each level of the three-level wavelet decomposition as a loop, defining a first weight and a second weight, multiplying the visible light image decomposition matrix by the first weight to obtain a first result, multiplying the infrared image decomposition matrix by the second weight to obtain a second result, adding the first result and the second result and assigning it to the visible light image decomposition matrix; obtaining the updated visible light image decomposition matrix after the loop ends; Step S33: Obtaining the size and wavelet decomposition level of the updated visible light image decomposition matrix, and creating a storage matrix according to the size and wavelet decomposition level of the updated visible light image decomposition matrix; Step S34: Using each level of the three-level wavelet decomposition as a loop, using the dct2 function to perform three-level wavelet decomposition on the updated visible light image decomposition matrix. Step S35: Calculate the local spatial frequencies of the visible light image decomposition matrix and the infrared image decomposition matrix. Step S36: Compare the local spatial frequencies of the visible light image decomposition matrix and the infrared image decomposition matrix. If the local spatial frequency of the visible light image decomposition matrix is greater than that of the infrared image decomposition matrix, select the first DCT variable as the final DCT variable. If the local spatial frequency of the visible light image decomposition matrix is less than or equal to that of the infrared image decomposition matrix, select the second DCT variable as the final DCT variable. Step S37: Perform an inverse DCT transformation on the final DCT variable using the idct2 function to obtain DCT coefficients and end the loop in step S34. Perform an inverse wavelet transform on the DCT coefficients using the iswt2 function to obtain a multimodal image. Finally, perform median filtering on the multimodal image to obtain a denoised image.
[0010] Further, step S4 specifically includes: Step S41: Define three structural radii at different scales and set corresponding weight coefficients; create a zero matrix of the same size as the denoised image to store the edge detection results; Step S42: Perform the following sequentially for each scale: First, based on the structural radii described in step S41, use the strel function to create circular structural elements, then dilate and erode the denoised image; subtract the erosion result from the dilation result and calculate the morphological gradient, then accumulate the morphological gradient at the current scale into the edge detection result according to the weight coefficients set in step S41 to obtain the edge detection result; Step S43: Normalize the edge detection result in step S42 using the mat2gray function to obtain a normalized matrix; Step S44: Use the bwlabel function to label the normalized matrix obtained in step S43 with connected regions, and use the regionprops function to calculate the area of each connected region based on the connected region labels. And perimeter attribute; create a horizontal line-type structural element with a length of 10, and perform a closing operation on the normalized matrix using the horizontal line-type structural element and the normalized matrix as input parameters of the imclose function, and then perform a logical AND operation with the normalized matrix to identify the missing edge parts in the normalized matrix; Step S45: use the bwmorph function to refine the normalized matrix, and use the refinement result as the initial enhanced image; traverse all repair templates in the port edge sample library, and for each repair template, use the normxcorr2 function to calculate the correlation coefficient between the repair template and the missing edge parts; find the position of the maximum value in the correlation coefficient and determine the matching position; Step S46: obtain the height h and width w of the image corresponding to the repair template, and calculate the rectangular area centered at the matching position that does not exceed the height h and width w; use a logical OR operation to fuse the repair template into the initial enhanced image; after traversal, obtain the enhanced image.
[0011] Further, step S5 specifically includes: Step S51: Using a high-sensitivity Canny detector to perform small-scale feature detection on the enhanced image, then using the bwmorph function to perform morphological thinning of the small-scale feature detection results, and finally using the bwareaopen function to filter the morphologically thinned results to obtain small-scale edge features; Step S52: Using the imgaussfilt function to perform Gaussian smoothing on the enhanced image, then using a low-sensitivity Canny detector to perform large-scale feature detection on the enhanced image, using the strel function to create a circular structuring element with a radius of 3, using the input parameters of the imclose function to perform a closing operation on the large-scale feature detection results based on the circular structuring element, and finally using the bwareaopen function to filter the closing operation results to obtain large-scale edge features; and using the small-scale edge features and the large-scale edge features as the layered edge detection results.
[0012] Further, step S6 specifically includes: Step S61: Performing a bitwise OR operation on the small-scale and large-scale edge features in the layered edge detection result, and using the bwmorph and bwareaopen functions to refine and filter the result of the bitwise OR operation to obtain the initial optimized edge features; Step S62: Using the bwmorph function to identify the position of all endpoints in the initial optimized edge features, and using the bwdist function to calculate the distance from each pixel in the initial optimized edge features to the nearest edge point; Step S63: Obtaining the row and column coordinates of all endpoint positions; establishing an outer loop i from the value 1 to the total number of endpoints and an inner loop j from the value i+1 to the total number of endpoints; calculating the Euclidean distance between the current point pairs based on i and j, and determining whether the Euclidean distance is less than a preset threshold. When the Euclidean distance is less than the preset threshold, using the bresenham function to generate continuous pixel coordinates between the current point pairs to complete the line segment connection between the current point pairs of the initial optimized edge features; and using the result after completing the line segment connection as the optimized layered edge detection result.
[0013] This invention also provides a port large-scale model training data image segmentation system for performing the aforementioned port large-scale model training data image segmentation method. The port large-scale model training data image segmentation system includes an image data acquisition module, an image edge detection module, and an image segmentation module. The image data acquisition module is connected to the image edge detection module, and the image edge detection module is connected to the image segmentation module. The image data acquisition module acquires visible light and infrared images of the scene obtained from the port large-scale model training data. The image edge detection module determines the edges of the port large-scale model training data images. The image segmentation module performs segmentation of the port large-scale model training data images based on the edges determined by the image edge detection module.
[0014] The beneficial technical effects of this invention compared with the prior art are as follows: by using multimodal image data fusion and hierarchical optimization technology, and combining it with a port edge sample library to enhance image edge features, the accuracy and robustness of image edge detection in port scenes are improved. Attached Figure Description
[0015] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0016] Figure 1 This is a simplified flowchart of a port large-scale model training data image segmentation method according to the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] The concepts involved in this application will first be described with reference to the accompanying drawings. It should be noted that the following descriptions of various concepts are only for the purpose of making the content of this application easier to understand and do not constitute a limitation on the scope of protection of this application; furthermore, the embodiments and features in the embodiments of this application can be combined with each other unless otherwise specified. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0019] Refer to the instruction manual. Figure 1This invention proposes a method for segmenting port large-scale model training data images, specifically including the following steps: Step S1: Acquire visible light and infrared images of the scene obtained from the port large-scale model training data; Step S2: Perform dynamic illumination compensation on the visible light image to obtain a compensated visible light image; Step S3: Obtain a multimodal image based on the compensated visible light image and the infrared image, and denoise the multimodal image to obtain a denoised image; Step S4: Enhance the denoised image based on a port edge sample library to obtain an enhanced image; Step S5: Perform layered edge detection on the enhanced image to obtain layered edge detection results; Step S6: Optimize the layered edge detection results, use the optimized layered edge detection results as the edges of the port large-scale model training data image, and segment the port large-scale model training data image based on the image edges. It is understood that the aforementioned port edge sample library should include various typical port edge templates, such as ship hull outline templates, container outline templates, wharf boundary templates, gantry crane outline templates, and quay crane outline templates.
[0020] The following is a detailed description of each step. Step S2 specifically includes: Step S21: Using the rgb2ycbcr function to convert the visible light image to the YCbCr color space to obtain the conversion result, then extracting the first dimension of the conversion result, denoted as matrix Y; obtaining the number of rows and columns of matrix Y, and pre-allocating memory for the compensated visible light image; Step S22: Establishing a double loop based on a preset step size (preferably 32 in this invention), with the number of rows of matrix Y as the outer loop and the number of columns of matrix Y as the inner loop, to traverse matrix Y; Step S23: Defining an image block matrix smaller than the boundary of the visible light image, and calculating the average brightness of the current image block matrix; Step S24: Calculating the adaptive correction value GM based on the average brightness.
[0021] ;
[0022] Where GM represents the adaptive correction value, K1 represents the first constraint coefficient (K1 is preferably 0.5), K2 represents the second constraint coefficient (K2 is preferably 2.5), N1 represents the image matching value (N1 is preferably 128), and MEAN represents the average brightness; Step S25: Using the imajust function, the current image block matrix is mapped to a new matrix based on the adaptive correction value GM, denoted as the compensated current image block matrix; the compensated current image block matrix is assigned to the first dimension of the conversion result, and the ycbcr2rgb function is used to convert the conversion result to the RGB color space, thereby obtaining the compensated visible light image. In the above step S2, the brightness component is separated by the YCbCr color space, which can avoid color distortion; the adaptive correction value is used to dynamically adjust the parameters according to the local brightness, which can achieve accurate illumination compensation of the visible light image, and at the same time, the block processing strategy of image blocks effectively handles uneven illumination and improves the illumination compensation efficiency.
[0023] Step S3 specifically includes: Step S31: Converting the compensated visible light image and the infrared image into compensated visible light grayscale images and infrared grayscale images, respectively; performing a three-level wavelet decomposition on the compensated visible light grayscale images and the infrared grayscale images using the swt2 function to obtain the visible light image decomposition matrix and the infrared image decomposition matrix; Step S32: Using each level of the three-level wavelet decomposition as a loop, defining a first weight and a second weight (the sum of the first weight and the second weight is 1), multiplying the visible light image decomposition matrix by the first weight to obtain... Upon obtaining the first result, multiply the infrared image decomposition matrix by the second weight to obtain the second result. Add the first and second results and assign them to the visible light image decomposition matrix. After the loop ends, obtain the updated visible light image decomposition matrix. Step S33: Obtain the size and wavelet decomposition level of the updated visible light image decomposition matrix, and create a storage matrix based on the size and wavelet decomposition level of the updated visible light image decomposition matrix. Step S34: Using each level of the three-level wavelet decomposition as a loop, use the dct2 function to process the updated visible light image decomposition matrix. Step S35: Calculate the local spatial frequencies of the visible light image decomposition matrix and the infrared image decomposition matrix. Step S36: Compare the local spatial frequencies of the visible light image decomposition matrix and the infrared image decomposition matrix. If the local spatial frequency of the visible light image decomposition matrix is greater than that of the infrared image decomposition matrix, select the first DCT variable as the final DCT variable. If the local spatial frequency of the visible light image decomposition matrix is less than or equal to that of the infrared image decomposition matrix, select the second DCT variable as the final DCT variable. Step S37: Perform an inverse DCT transformation on the final DCT variable using the idct2 function to obtain DCT coefficients and end the loop in step S34. Perform an inverse wavelet transform on the DCT coefficients using the iswt2 function to obtain a multimodal image. Finally, perform median filtering with 3×3 kernels on the multimodal image to obtain a denoised image. In step S3 above, a hybrid fusion strategy combining discrete stationary wavelet transform and DCT is adopted. While preserving the translation invariance of the image, it can concentrate the image energy on a few low-frequency coefficients. Therefore, it can capture multi-scale structural features at the same time, effectively preserve the image's detailed information, structural features and key frequency domain information, and help distinguish between real edges and noise. This reduces the impact of complex lighting and weather conditions on image edge detection to a certain extent. Meanwhile, local spatial frequency calculation enhances the spatial consistency of the fusion results.
[0024] Step S4 specifically includes: Step S41: Define three structural radii at different scales (preferably [35 7] in this invention) and set corresponding weight coefficients; create a zero matrix of the same size as the denoised image to store the edge detection results; Step S42: Perform the following steps for each scale in sequence: First, based on the structural radius described in Step S41, use the strel function to create a circular structural element (radius of 3), and then dilate and erode the denoised image; calculate the morphological gradient after subtracting the erosion result from the dilation result, and then accumulate the morphological gradient at the current scale into the edge detection result according to the weight coefficients set in Step S41 to obtain the edge detection result; Step S43: Normalize the edge detection result in Step S42 using the mat2gray function to obtain a normalized matrix; Step S44: Use the bwlabel function to label the normalized matrix obtained in Step S43 with connected regions, and use the regionprops function to calculate the area and perimeter attributes of each connected region based on the connected region label; create a zero matrix of length 10 The horizontal linear structural element is used as input parameters for the `imclose` function, and a closing operation is performed on the normalized matrix using the horizontal linear structural element and the normalized matrix. The result of the closing operation is then logically ANDed with the normalized matrix to identify missing edge parts in the normalized matrix. Step S45: The normalized matrix is thinned using the `bwmorph` function, and the thinning result is used as the initial enhanced image. All repair templates in the port edge sample library are traversed. For each repair template, the correlation coefficient between the repair template and the missing edge part is calculated using the `normxcorr2` function. The maximum value position is found in the correlation coefficient, and the matching position is determined. Step S46: The height `h` and width `w` of the image corresponding to the repair template are obtained, and a rectangular region centered at the matching position and not exceeding the height `h` and width `w` is calculated. The repair template is fused into the initial enhanced image using a logical OR operation. After the traversal is completed, the enhanced image is obtained.
[0025] Step S5 specifically includes: Step S51: Using a high-sensitivity Canny detector to perform small-scale feature detection on the enhanced image, then using the bwmorph function to perform morphological thinning of the small-scale feature detection results, and finally using the bwareaopen function to filter the morphologically thinned results to obtain small-scale edge features; Step S52: Using the imgaussfilt function to perform Gaussian smoothing on the enhanced image, then using a low-sensitivity Canny detector to perform large-scale feature detection on the enhanced image, using the strel function to create a circular structuring element with a radius of 3, using the input parameters of the imclose function to perform a closing operation on the large-scale feature detection results based on the circular structuring element, and finally using the bwareaopen function to filter the closing operation results to obtain large-scale edge features; and using the small-scale edge features and the large-scale edge features as the layered edge detection results. The above steps S4 and S5 are combined to first integrate the templates of the port edge sample library with image edge enhancement, which can adapt to the edge detection and repair of different image targets in port scenes; secondly, three disk structure elements of different scales are used to perform morphological gradient calculation, and the detection effect of thick and thin edges is balanced by weighted fusion, which can simultaneously capture the large-scale contours and small-scale details of port equipment, thereby improving the accuracy and robustness of image edge detection in port scenes.
[0026] Step S6 specifically includes: Step S61: Performing a bitwise OR operation on the small-scale and large-scale edge features in the layered edge detection result, and using the bwmorph and bwareaopen functions to refine and filter the result of the bitwise OR operation to obtain the initial optimized edge features; Step S62: Using the bwmorph function to identify the position of all endpoints in the initial optimized edge features, and using the bwdist function to calculate the distance from each pixel in the initial optimized edge features to the nearest edge point; Step S63: Obtaining the row and column coordinates of all endpoint positions; establishing an outer loop i from the value 1 to the total number of endpoints and an inner loop j from the value i+1 to the total number of endpoints; calculating the Euclidean distance between the current point pairs based on i and j, and determining whether the Euclidean distance is less than a preset threshold (preferably 15 in this invention); when the Euclidean distance is less than the preset threshold, using the Bresenham function to generate continuous pixel coordinates between the current point pairs, completing the line segment connection between the current point pairs of the initial optimized edge features; and using the result after completing the line segment connection as the optimized layered edge detection result. In step S6 above, isolated noise points are removed using the bwareaopen function, which improves the edge signal-to-noise ratio and thus further enhances the clarity of the image edge detection results.
[0027] This invention also provides a port large-scale model training data image segmentation system for executing the aforementioned port large-scale model training data image segmentation method. The port large-scale model training data image segmentation system includes an image data acquisition module, an image edge detection module, and an image segmentation module. The image data acquisition module is connected to the image edge detection module, and the image edge detection module is connected to the image segmentation module. The image data acquisition module acquires visible light and infrared images of the scene obtained from the port large-scale model training data. The image edge detection module determines the edges of the port large-scale model training data images. The image segmentation module performs image segmentation of the port large-scale model training data images based on the edges determined by the image edge detection module. It is understood that the aforementioned port large-scale model training data image segmentation system can be integrated into a CPU or FPGA to improve the system's integration level.
[0028] The embodiments and / or implementation methods described above are merely preferred embodiments and / or implementation methods for implementing the technology of the present invention, and are not intended to limit the implementation methods of the technology of the present invention in any way. Any person skilled in the art can make some modifications or alterations to other equivalent embodiments without departing from the scope of the technical means disclosed in the content of the present invention, but they should still be regarded as the technology or embodiments that are substantially the same as the present invention.
[0029] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. The above descriptions are only preferred embodiments of this application. It should be noted that due to the limitations of written expression, while there are objectively infinite specific structures, those skilled in the art can make several improvements, modifications, or changes without departing from the principles of this application, and can also combine the above technical features in an appropriate manner. These improvements, modifications, changes, or combinations, or the direct application of the inventive concept and technical solution to other situations without modification, should all be considered within the scope of protection of this application.
Claims
1. A method for image segmentation in training data of a large port model, characterized in that, Specifically, the following steps are included: Step S1: Obtain visible light and infrared images of the scene from the training data of the large port model; Step S2: Perform dynamic illumination compensation on the visible light image to obtain a compensated visible light image; Step S3: Obtain a multimodal image based on the compensated visible light image and the infrared image, and denoise the multimodal image to obtain a denoised image; Step S4: Enhance the denoised image based on the port edge sample library to obtain the enhanced image; Step S5: Perform layered edge detection on the enhanced image to obtain the layered edge detection results; Step S6: Optimize the layered edge detection results, use the optimized layered edge detection results as the edges of the port large model training data image, and segment the port large model training data image based on the image edges; Step S3 specifically includes: Step S31: Convert the compensated visible light image and the infrared image into compensated visible light grayscale image and infrared grayscale image, respectively; The swt2 function is used to perform three-level wavelet decomposition on the compensated visible light grayscale image and the infrared grayscale image to obtain the visible light image decomposition matrix and the infrared image decomposition matrix. Step S32: Using each layer of the three-layer wavelet decomposition as a loop, define a first weight and a second weight, multiply the visible light image decomposition matrix by the first weight to obtain a first result, multiply the infrared image decomposition matrix by the second weight to obtain a second result, add the first result and the second result and assign them to the visible light image decomposition matrix; after the loop ends, obtain the updated visible light image decomposition matrix. Step S33: Obtain the size and wavelet decomposition level of the updated visible light image decomposition matrix, and create a storage matrix based on the size and wavelet decomposition level of the updated visible light image decomposition matrix; Step S34: Using each layer of the three-layer wavelet decomposition as a loop, use the dct2 function to perform a two-dimensional discrete cosine transform on the updated visible light image decomposition matrix to obtain the first DCT variable, and use the dct2 function to perform a two-dimensional discrete cosine transform on the infrared image decomposition matrix to obtain the second DCT variable. Step S35: Calculate the local spatial frequency of the visible light image decomposition matrix and the local spatial frequency of the infrared image decomposition matrix. Step S36: Compare the local spatial frequencies of the visible light image decomposition matrix and the infrared image decomposition matrix. When the local spatial frequency of the visible light image decomposition matrix is greater than that of the infrared image decomposition matrix, select the first DCT variable as the final DCT variable. When the local spatial frequency of the visible light image decomposition matrix is less than or equal to that of the infrared image decomposition matrix, select the second DCT variable as the final DCT variable. Step S37: Use the idct2 function to perform inverse DCT transform on the final DCT variable to obtain DCT coefficients, and end the loop of step S34; use the iswt2 function to perform inverse wavelet transform on the DCT coefficients to obtain a multimodal image; finally, perform median filtering on the multimodal image to obtain a denoised image.
2. The method for image segmentation of port large-scale model training data according to claim 1, characterized in that, Step S2 specifically includes: Step S21: Use the rgb2ycbcr function to convert the visible light image into the YCbCr color space to obtain the conversion result, then extract the first dimension data of the conversion result, denoted as matrix Y; obtain the number of rows and columns of matrix Y, and pre-allocate memory for the compensated visible light image; Step S22: Establish a double loop based on a preset step size, with the number of rows of matrix Y as the outer loop and the number of columns of matrix Y as the inner loop, to traverse the matrix Y; Step S23: Define an image patch matrix smaller than the visible light image boundary, and calculate the average brightness of the current image patch matrix; Step S24: Calculate the adaptive correction value GM based on the average brightness: ; Where GM represents the adaptive correction value, K1 represents the first constraint coefficient, K2 represents the second constraint coefficient, N1 represents the image matching value, and MEAN represents the average brightness; Step S25: Using the imajust function, the current image patch matrix is mapped to a new matrix based on the adaptive correction value GM, denoted as the compensated current image patch matrix; the compensated current image patch matrix is assigned to the first dimension of the conversion result, and the ycbcr2rgb function is used to convert the conversion result to the RGB color space, thereby obtaining the compensated visible light image.
3. The method for image segmentation of port large-scale model training data according to claim 1, characterized in that, Step S4 specifically includes: Step S41: Define three structural radii at different scales and set corresponding weight coefficients; create a zero matrix of the same size as the denoised image to store the edge detection results; Step S42: Perform the following steps for each scale: First, based on the structural radius described in step S41, use the strel function to create a circular structural element. Then, dilate and erode the denoised image. Subtract the erosion result from the dilation result and calculate the morphological gradient. Then, add the morphological gradient at the current scale to the edge detection result according to the weight coefficient set in step S41 to obtain the edge detection result. Step S43: Normalize the edge detection results from step S42 using the mat2gray function to obtain a normalized matrix; Step S44: Use the bwlabel function to label the connected components of the normalized matrix obtained in step S43, and use the regionprops function to calculate the area and perimeter attributes of each connected component based on the labeled components; create a horizontal line-type structuring element of length 10, and use the horizontal line-type structuring element and the normalized matrix as input parameters of the imclose function to perform a closing operation on the normalized matrix, and then perform a logical AND operation between the closing operation result and the normalized matrix to identify missing edge parts in the normalized matrix; Step S45: Thin the normalized matrix using the bwmorph function, and use the thinned result as the initial enhanced image; traverse all the repair templates in the port edge sample library, and for each repair template, use the normxcorr2 function to calculate the correlation coefficient between the repair template and the missing edge part; find the position of the maximum value in the correlation coefficient and determine the matching position; Step S46: Obtain the height h and width w of the image corresponding to the repair template, and calculate a rectangular region centered at the matching position that does not exceed the height h and width w; use a logical OR operation to merge the repair template into the initial enhanced image; obtain the enhanced image after traversal.
4. The method for image segmentation of port large-scale model training data according to claim 1, characterized in that, Step S5 specifically includes: Step S51: Use a high-sensitivity Canny detector to perform small-scale feature detection on the enhanced image, then use the bwmorph function to perform morphological thinning of the small-scale feature detection results, and finally use the bwareaopen function to filter the morphologically thinned results to obtain small-scale edge features. Step S52: Apply Gaussian smoothing to the enhanced image using the `imgaussfilt` function, then perform large-scale feature detection on the enhanced image using a low-sensitivity Canny detector. Create a circular structuring element with a radius of 3 using the `strel` function. Perform a closing operation on the large-scale feature detection result using the input parameters of the `imclose` function based on the circular structuring element. Finally, filter the result after the closing operation using the `bwareaopen` function to obtain large-scale edge features. Use the small-scale edge features and the large-scale edge features as the layered edge detection result.
5. The method for image segmentation of port large-scale model training data according to claim 1, characterized in that, Step S6 specifically includes: Step S61: Perform a bitwise OR operation on the small-scale edge features and large-scale edge features in the layered edge detection results, and use the bwmorph function and bwareaopen function to refine and filter the result of the bitwise OR operation to obtain the initial optimized edge features; Step S62: Use the bwmorph function to identify the positions of all endpoints in the initial optimized edge features, and use the bwdist function to calculate the distance from each pixel in the initial optimized edge features to the nearest edge point; Step S63: Obtain the row and column coordinates of all endpoint positions; establish an outer loop i from the value 1 to the total number of endpoints and an inner loop j from the value i+1 to the total number of endpoints; calculate the Euclidean distance between the current point pairs based on i and j, and determine whether the Euclidean distance is less than a preset threshold. When the Euclidean distance is less than the preset threshold, use the Bresenham function to generate continuous pixel coordinates between the current point pairs to complete the line segment connection between the current point pairs for initial optimization of edge features; and use the result after completing the line segment connection as the optimized layered edge detection result.
6. A port large-scale model training data image segmentation system, used to execute the port large-scale model training data image segmentation method according to any one of claims 1-5, characterized in that, The port large-scale model training data image segmentation system includes an image data acquisition module, an image edge detection module, and an image segmentation module. The image data acquisition module is connected to the image edge detection module, and the image edge detection module is connected to the image segmentation module. The image data acquisition module is used to acquire visible light images and infrared images of the scene obtained from the port large-scale model training data. The image edge detection module is used to determine the edges of the port large-scale model training data images. The image segmentation module is used to perform segmentation of the port large-scale model training data images based on the edges of the port large-scale model training data images determined by the image edge detection module.
Citation Information
Patent Citations
Port container cargo loading and unloading state identification method based on computer vision
CN120431504A
Multi-modal image fusion method based on modal self-adaption and modal interaction compensation
CN120912448A