Water body segmentation method and system, computer equipment and storage medium
By employing multi-resolution grayscale image layering processing and the magic wand algorithm, combined with seed pixels and grayscale tolerance parameters, the problem of balancing high accuracy and high efficiency in water body segmentation of remote sensing images is solved, providing efficient and accurate water body segmentation results suitable for geographic information systems.
Patent Information
- Application Number
- CN202511821873.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-05
- Publication Date
- 2026-02-03
AI Technical Summary
Existing technologies struggle to balance high accuracy and efficiency in water body segmentation of remote sensing images. Traditional methods are poorly adaptable to complex scenarios, deep learning models suffer from generalization bottlenecks, and manual segmentation is time-consuming and inconsistent, failing to meet the timeliness requirements of large-scale surveys and disaster emergency responses.
The algorithm employs multi-resolution grayscale image layering processing combined with the magic wand algorithm. It uses seed pixels and grayscale tolerance parameters, queues and binary mask tables for region growing, combines a weighted local averaging algorithm to smooth the boundaries, and adds a geographic coordinate reference system to output closed polygon vector data.
It achieves a dynamic balance between high efficiency and high accuracy, adapts to complex water body scenarios, and the segmentation results can be directly used in geographic information systems to meet the timeliness requirements of water resource management and disaster assessment.
Smart Images

Figure CN121458741A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of remote sensing image processing, and particularly relates to a water body segmentation method and system, a computer device and a storage medium. BACKGROUND
[0002] Water body segmentation is a core link of remote sensing technology serving water resource management, environmental monitoring and disaster assessment, and its precision is directly related to the effectiveness of decision-making. A centimeter-level deviation of flood inundation boundary may lead to the misplacement of rescue supplies, and misjudgment of water body range may cause more than 20% estimation error of subsequent water quality parameters (such as chlorophyll concentration).
[0003] However, the current technical system always has difficulty in breaking through the binary opposition of "precision" and "efficiency". On the one hand, the inherent limitations of traditional automatic segmentation methods are prominent: the threshold method has poor adaptability to complex scenes such as water turbidity, waterfront vegetation and building shadows, and its water area accounting deviation in known cases can be more than 15%; the shallow machine learning method relies on artificial feature design and has insufficient generalization ability; although the deep learning model has improved precision, it has "black box" dependence and generalization bottleneck, and is easy to destroy the geographical continuity of linear water bodies when processing large images. On the other hand, completely manual segmentation is trapped in the "efficiency dilemma", which takes hours for a single scene image, and the consistency of results from different operators is generally less than 70%, which cannot meet the timeliness requirements of large-scale survey or disaster emergency response.
[0004] Especially severe is that with the advent of the era of ultra-high resolution remote sensing, the richness of data details has intensified the technical challenges: limited spectral information, water surface specular reflection noise, and great multiscale differences from kilometer-level lakes to meter-level ditches, making it difficult for traditional methods to balance between "capturing details" and "maintaining overall accuracy". This bottleneck has become a key obstacle to fine management of water resources and accurate governance of ecological environment.
[0005] In summary, the existing technology cannot simultaneously achieve high precision and high efficiency in solving the water body segmentation of remote sensing images, and there is a problem that the segmentation results cannot be directly used by professional geographic information systems. SUMMARY
[0006] In order to solve the above background problems, the application provides a water body segmentation method, system, computer device and storage medium.
[0007] In order to achieve the above purpose, the application provides a water body segmentation method, comprising: Collecting a remote sensing image of a target water area.
[0008] Processing the remote sensing image into a plurality of gray scale images of different resolutions; selecting at least one seed pixel point for each gray scale image, and setting a gray scale tolerance parameter according to the seed pixel point.
[0009] initializing a queue for the seed pixel point, designing a binary mask table and an access mark map with the same size as the remote sensing image, adding the seed pixel point to the queue, extracting the seed pixel point from the head of the current queue in a loop, calculating the gray difference between the seed pixel point and four neighborhood pixels in the gray image, judging whether the four neighborhood pixels have been accessed by querying the access mark map, if the neighborhood pixels have not been accessed and the gray difference is less than a gray tolerance parameter, marking the current neighborhood pixels that meet the condition as target pixels and accessed in the binary mask table and the access mark map respectively, and adding the current neighborhood pixels that meet the condition to the tail of the queue, until the queue is empty, and obtaining an initial binary mask table.
[0010] extracting a water body boundary point sequence of the initial binary mask table, outputting a boundary vector contour point set, smoothing the boundary vector contour point set using a weighted local average algorithm, outputting a vector contour polygon, attaching geographic coordinate reference system information to the vector contour polygon, and outputting a closed polygon vector data; and segmenting a target region water body using the closed polygon vector data.
[0011] Preferably, the remote sensing image is processed into a plurality of gray images with different resolutions, specifically, the remote sensing image is processed into water area image layers with original resolution layer, one-half resolution layer and one-eighth resolution layer; the original resolution layer is used for accurate segmentation, the one-half resolution layer is used for zoom-in operation, and the one-eighth resolution layer is used for global display and zoom-out operation; and a weighted average method is used to convert the RGB images of the water area image layers into gray images.
[0012] Preferably, before extracting a water body boundary point sequence of the initial binary mask table and outputting a boundary vector contour point set, the method further comprises: performing hole filling processing on the initial binary mask table, identifying and filling internal holes with an area less than a first preset threshold; removing noise from the binary mask table after hole filling, deleting connected regions with an area less than a second preset threshold, the area being a total number of pixel points contained in the selected region; performing boundary smoothing processing on the binary mask table after noise removal, performing morphological opening operation and closing operation using a circular structural element, optimizing the region boundary, and obtaining an optimized binary mask table; performing connected component analysis on the optimized binary mask table, marking independent connected regions, and filtering out a target water body region according to a preset area threshold, and obtaining a filtered binary mask table.
[0013] Preferably, the using weighted local average algorithm to smooth the boundary vector profile point set outputs a vector profile polygon, specifically: constructing a local window for each profile point in the boundary vector profile point set, using Gaussian weight to perform weighted average calculation on all profile points in the local window to generate a smooth vector profile polygon; wherein the center point weight of the local window is the highest weight.
[0014] Preferably, before the attaching geographic coordinate reference system information to the vector profile polygon and outputting the closed polygon vector data, the method further comprises: converting the vector profile polygon into a standard geographic information vector format, attaching preset geographic coordinate reference system information on the standard geographic information vector format, and outputting the closed polygon vector data, i.e. the water body boundary of the target area.
[0015] Preferably, the method further comprises: analyzing the color distribution characteristics of the region based on the region within a preset range around the seed pixel point; the color distribution characteristics include color range, mean value, standard deviation and median; and automatically generating a gray tolerance suggestion value based on the color distribution characteristics for the user to refer to when setting the gray tolerance parameter.
[0016] Preferably, the converting the vector profile polygon into a standard geographic information vector format specifically comprises: selecting a corresponding standard geographic information vector format according to the morphological type of the target water body, if the target water body is a planar water body, converting the vector profile polygon into a polygon vector format conforming to the OGC SimpleFeature specification; if the target water body is a linear water body, extracting the boundary line of the vector profile polygon and converting it into a line feature vector format conforming to the OGC Simple Feature specification; and the converted standard geographic information vector format is compatible with the import and analysis functions of ArcGIS and QGIS geographic information system software.
[0017] The application also provides a water body segmentation system, comprising: a data acquisition module configured to acquire a remote sensing image of a target water area.
[0018] a calculation module configured to process the remote sensing image into a plurality of gray scale images with different resolutions, select at least one seed pixel point for each gray scale image, and set a gray tolerance parameter according to the seed pixel point; Initialize a queue for the seed pixel point, design a binary mask table and an access mark map consistent with the size of the remote sensing image; add the seed pixel point to the queue; loop to extract the seed pixel point from the head of the current queue, calculate the gray difference between the seed pixel point and the four-neighborhood pixels in the gray image; judge whether the four-neighborhood pixels have been accessed by querying the access mark map, if the neighborhood pixels have not been accessed and the gray difference is less than the gray tolerance parameter, mark the current neighborhood pixels that meet the condition as target pixels and accessed in the binary mask table and the access mark map respectively, and add the current neighborhood pixels that meet the condition to the tail of the queue; until the queue is empty, obtain the initial binary mask table.
[0019] The water body segmentation module is used to extract a water body boundary point sequence of the initial binary mask table, output a boundary vector contour point set, use a weighted local average algorithm to smooth the boundary vector contour point set, output a vector contour polygon, add geographic coordinate reference system information to the vector contour polygon, and output a closed polygon vector data; and the target region water body is segmented by using the closed polygon vector data.
[0020] The application further provides a computer device, which comprises a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to realize the steps of any one of the water body segmentation method.
[0021] The application further provides a computer readable storage medium, which stores a computer program, and the computer program can execute the steps of any one of the water body segmentation method when loaded by a processor.
[0022] The water body segmentation method provided by the application has the following beneficial effects: The dynamic balance of efficiency and precision is realized by multi-resolution gray image layering processing, low-resolution layers support fast global browsing and operation response, high-resolution layers guarantee the accurate segmentation of water body boundaries, avoiding the short board of slow response or low precision under a single resolution; the semi-automatic interactive mode of seed pixel and gray tolerance is the core, which not only gets rid of the inefficiency and tediousness of full manual segmentation, but also compensates for the accuracy deviation of full automatic segmentation in complex water body scenes through manual point selection, and balances the operation convenience and flexible intervention; the cooperative mechanism of queue scheduling, access mark graph and binary mask table can effectively avoid pixel repeated access and redundant calculation, greatly improve the operation efficiency of region growing, and adapt to the processing needs of large-size remote sensing images; the weighted local average algorithm is used to optimize the contour smoothness, additional geographic coordinate reference system is added, and closed polygon vector data is output, which not only solves the sawtooth distortion problem of the segmentation boundary, but also ensures that the result can be directly connected to mainstream geographic information systems such as ArcGIS and QGIS, seamlessly connects practical application scenes such as water resource management, environmental monitoring and disaster assessment, and completely solves the industry pain points that traditional methods are difficult to balance efficiency, precision and result practicability. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present application and the design of the embodiments of the present application, the drawings required by the present embodiments will be briefly introduced below. The drawings in the following description are only part of the embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0024] Figure 1 A flow chart of a water body segmentation method according to an embodiment of the present application; Figure 2 An interactive main interface diagram according to an embodiment of the present application; Figure 3 A lake segmentation result display page diagram according to an embodiment of the present application; Figure 4 A magic wand algorithm water body segmentation result diagram according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make those skilled in the art better understand the technical solutions of the present application and can be implemented, the present application will be described in detail below in conjunction with the drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present application, and cannot be used to limit the protection scope of the present application.
[0026] The embodiment of the present application takes the magic wand algorithm as the core, combines multiple resolution pyramid technology, morphological image processing, contour detection and smoothing and other technologies, and constructs a complete water body segmentation solution. The embodiment of the present application not only realizes high-precision water body segmentation, but also provides a friendly user interface and powerful post-processing function, which can meet the needs of different application scenarios. The semi-automatic segmentation method based on the magic wand algorithm combines the efficiency of automation and the precision of manual intervention, and becomes an important technical solution for water body segmentation.
[0027] Based on this, the present application provides a water body segmentation method, specifically as shown in the following Figure 1 The present application provides a water body segmentation method, specifically as shown in the following S1, collecting a remote sensing image of a target water area.
[0028] Collecting the water area remote sensing image of the target detection area for segmentation detection.
[0029] S2, processing the remote sensing image into a plurality of gray scale images of different resolutions; selecting at least one seed pixel point for each gray scale image, setting a gray scale tolerance parameter according to the seed pixel point; initializing a queue for the seed pixel point, designing a binary mask table and an access mark map consistent with the size of the remote sensing image; adding the seed pixel point to the queue; cyclically extracting the seed pixel point from the head of the current queue, calculating the gray scale difference between the seed pixel point and the four neighborhood pixels in the gray scale image; judging whether the four neighborhood pixels have been accessed by querying the access mark map, if the neighborhood pixels have not been accessed and the gray scale difference is less than the gray scale tolerance parameter, then marking the current neighborhood pixels that meet the conditions as target pixels and accessed in the binary mask table and the access mark map respectively, and adding the current neighborhood pixels that meet the conditions to the tail of the queue; until the queue is empty, an initial binary mask table is obtained.
[0030] The magic wand algorithm is a region growing algorithm based on seed points, and its core idea is to automatically expand the region boundary based on color similarity through user-specified seed points. The algorithm uses a breadth-first search strategy, starting from the seed point and expanding in four directions (up, down, left and right) step by step until there are no new similar pixels that can be added.
[0031] The theoretical basis of the algorithm is based on color similarity judgment, which determines whether it belongs to the same region by calculating the color distance between pixels. Common distance calculation methods include Euclidean distance, Manhattan distance and weighted distance. The weighted distance takes into account the sensitivity of the human eye to different color components, usually giving higher weight to the green component, which is more consistent with the characteristics of human eye perception, which makes the algorithm have better effect when processing natural images.
[0032] Region growing is the core mechanism of the magic wand algorithm, which uses a queue data structure to manage the pixels to be processed. The algorithm first adds the seed point to the queue, then loops through each pixel in the queue, checks the color similarity of its four adjacent pixels. If the color of the adjacent pixel is within the tolerance range of the seed point color, it is marked as the same region and added to the queue for further expansion.
[0033] The advantage of this mechanism is that it can handle regions of any complex shape, without being limited by the shape of the region. At the same time, the breadth-first search strategy ensures uniform expansion from the seed point, avoiding the problem of incomplete regions that may be caused by depth-first search.
[0034] Color similarity judgment is a key link in the algorithm, which directly affects the segmentation accuracy. The absolute value method of gray value difference is used to calculate the color distance in the embodiment of the invention, which is simple and efficient and suitable for most application scenarios. The algorithm also provides an extension interface, which can implement more complex color distance calculation methods as needed.
[0035] In order to adapt to different lighting conditions and image quality, the algorithm provides a color analysis function, which can analyze the color distribution characteristics of the region around the seed point, including color range, average value, standard deviation and median. Based on these statistical information, the algorithm can automatically suggest appropriate tolerance settings to help users get better segmentation results.
[0036] Multi-resolution pyramid technology is an important technical support for the embodiment of the invention, which improves processing efficiency and user experience by constructing different resolution levels of image hierarchy. The embodiment of the invention constructs a three-layer pyramid: the original resolution layer is used for accurate segmentation, the half resolution layer is used for zoom-in operation, and the eighth resolution layer is used for global display and zoom-out operation.
[0037] The core advantage of this layered strategy is to ensure segmentation accuracy and improve display and interaction efficiency. When the user is browsing globally, using low-resolution images can quickly respond; when the user needs to operate accurately, automatically switching to high-resolution images ensures accuracy. The algorithm automatically selects the appropriate resolution level according to the current display zoom ratio, achieving seamless user experience.
[0038] S3, extract the water body boundary point sequence of the initial binary mask table, output the boundary vector contour point set; use the weighted local average algorithm to smooth the boundary vector contour point set, then output the vector contour polygon; add geographic coordinate reference system information to the vector contour polygon, output the closed polygon vector data; use the closed polygon vector data to segment the target region water body.
[0039] Multi-resolution processing requires accurate coordinate conversion mechanism. The embodiment of the present application realizes the complete conversion chain from canvas coordinates to current display coordinates, and then to original coordinates. This conversion ensures that the user's operation at different resolution levels is correctly positioned to the corresponding position in the original image.
[0040] The coordinate conversion also supports conversion from pixel coordinates to geographic coordinates using an affine transformation matrix for coordinate mapping. This conversion enables the segmentation result to be integrated with a geographic information system, providing a basis for subsequent spatial analysis. The embodiment of the present application includes a coordinate verification mechanism to ensure that all coordinate conversions are within the valid range, and provides corresponding error prompts when the user's operation exceeds the image boundary.
[0041] User interface technology is an important bridge connecting users and algorithms. The user interface Figure 2 and Figure 3 as shown. The embodiment of the present application provides a variety of interactive tools, including a drag tool for panning the view, a zoom-in and zoom-out tool for zooming the view, a point selection tool for selecting a seed point, and a global tool for displaying the entire image. Each tool has a corresponding mouse cursor and operation feedback, providing an intuitive user experience.
[0042] Real-time feedback mechanism is an important feature of the user interface, which displays detailed information of the current selected point, including coordinate position, RGB color value and gray value. The user interface also displays the recommended tolerance setting to help users quickly obtain appropriate segmentation parameters. This design greatly reduces the learning cost of users and improves the operation efficiency.
[0043] Color space processing is a key technology to ensure segmentation accuracy. The embodiment of the present application uses a weighted average method to convert the RGB image to a grayscale image, and the weight coefficient is based on the sensitivity of the human eye to different color components. The weight of the red component is 0.299, the weight of the green component is 0.587, and the weight of the blue component is 0.114. This conversion method can better maintain the visual features of the image, providing a reliable basis for subsequent color similarity judgment.
[0044] In order to adapt to different application scenarios, the embodiment of the present application reserves a variety of color space conversion interfaces, including LAB color space (more robust to changes in illumination), HSV color space (separates brightness and chroma information), YUV color space (suitable for video image processing), etc. These different color spaces can handle segmentation tasks under different lighting conditions and image quality.
[0045] Morphological image processing technology is an important means to improve the quality of segmentation results. The embodiment of the present application integrates a hole filling technique for processing internal cavities in the segmentation result. The algorithm uses a structure element to scan the entire area, identifies and fills holes with an area less than a threshold value, ensuring the integrity of the segmented area.
[0046] The noise removal technique cleans up the segmentation result by removing areas that are too small. The algorithm calculates the area of each connected region and removes regions that are smaller than a minimum area threshold, effectively removing small regions that are caused by noise or missegmentation. The boundary smoothing technique uses morphological opening and closing operations to optimize the region boundaries, using a circular structuring element for these operations. This effectively smooths the boundaries without changing the basic shape of the regions.
[0047] The contour detection and smoothing technique is a key technology for obtaining accurate boundaries. The present embodiment uses edge detection techniques to extract accurate contour information from the binary mask, and can identify multiple independent contours and calculate the area and geometric features of each contour. For contours that are too small, the algorithm automatically filters them to improve processing efficiency.
[0048] The contour smoothing algorithm uses a weighted local average method to smooth the contours. The algorithm calculates a local window for each contour point and uses a Gaussian weight to perform a weighted average of the points within the window. The center point has a higher weight, ensuring that the smoothed contour still retains the original main features. The contour area calculation uses the polygon area formula to determine the area by calculating the cross product of the coordinates of the contour points, providing a reliable basis for subsequent region screening.
[0049] The connected component analysis technique is used to process the segmentation regions generated by multiple seed points. The present embodiment first merges all the regions generated by the seed points, and then uses connected component labeling techniques to identify independent connected regions. This method can effectively handle overlapping or adjacent regions that may be generated by multiple seed points.
[0050] The region screening mechanism filters meaningful regions based on an area threshold. The algorithm calculates the area of each connected region and only retains regions with an area greater than a minimum threshold, effectively removing noise regions and retaining truly meaningful water body regions. The algorithm sorts the regions by area from largest to smallest, and the user can choose to retain all meaningful regions or only the largest few regions. This flexibility allows the algorithm to adapt to different application requirements.
[0051] Performance optimization is an important technique to ensure the practicality of the algorithm. The present embodiment uses a multi-resolution pyramid technique to optimize memory usage, loading data at only the required resolution, significantly reducing memory usage and allowing the algorithm to handle large remote sensing images.
[0052] Computational efficiency optimization uses a queue data structure to optimize the region growing process, using a breadth-first search strategy to ensure expansion efficiency. The access marking mechanism avoids repeated calculations, improving overall processing speed. Real-time response optimization ensures a smooth interface through asynchronous processing and progress feedback mechanisms, displaying processing progress when processing large images and avoiding user confusion during waiting.
[0053] Debugging and diagnostic techniques are important to improve the reliability of the algorithm. The embodiment of the present application provides detailed color analysis function, which can analyze the color distribution characteristics of the region around the seed point, and the analysis result includes color range, statistical characteristics and recommended parameters, which helps users understand the image characteristics and optimize the segmentation parameters.
[0054] The segmentation process monitoring function displays the processing result of each seed point, including region size, boundary information and whether the seed point is in the segmentation region. These information helps users diagnose segmentation problems and adjust parameters. The parameter test function can test the influence of different tolerance values on the segmentation result, and the test result shows the region size and seed point inclusion under each tolerance setting, helping users to select the optimal parameters.
[0055] Data export technology is an important link between segmentation results and subsequent applications. The embodiment of the present application supports exporting segmentation results to vector data format, including polygon and line features. Polygon format is suitable for surface water, and line feature format is suitable for linear water. The algorithm uses contour detection technology to extract boundary information, and then converts it to standard geometric objects.
[0056] The exported data format is compatible with mainstream geographic information system software, including ArcGIS, QGIS, etc. The embodiment of the present application supports multiple coordinate reference systems to ensure that data can be displayed and analyzed correctly. If the target water body is a surface water body, the vector contour polygon is converted to a polygon vector format that conforms to the OGC Simple Feature specification; if the target water body is a linear water body, the boundary line of the vector contour polygon is extracted and converted to a line feature vector format that conforms to the OGC Simple Feature specification. The data quality control mechanism verifies the validity of the exported geometric objects, and for invalid geometric objects, the algorithm will try to regenerate with different parameters or provide detailed error information to help users diagnose problems.
[0057] Algorithm integration and expansion is an important design to ensure the sustainable development of the embodiment of the present application. The embodiment of the present application adopts modular design, and each functional module is relatively independent, which is convenient for maintenance and expansion. Each module has clear interface definition, supporting independent testing and optimization.
[0058] The embodiment of the present application reserves multiple expansion interfaces, which supports adding new color distance calculation methods, preprocessing techniques and post-processing algorithms. This design makes the algorithm adapt to different application requirements. The compatibility design considers the compatibility with existing image processing libraries, using standard image formats and data structures to ensure that the algorithm can be seamlessly integrated with other image processing tools.
[0059] The water body segmentation based on the magic wand algorithm has good precision in different application scenarios. In remote sensing images, the water body segmentation can usually achieve a pixel accuracy rate of 85%-95%, and the IoU is between 75%-90%. The water body color is relatively uniform, and the boundary is clear, which is an ideal application scenario for the magic wand algorithm.
[0060] For vegetation areas with large color changes, the precision is relatively low, with a pixel accuracy rate of 80%-90% and an IoU of 70%-85%. For building areas with complex edges, the precision is further reduced, with a pixel accuracy rate of 75%-85% and an IoU of 65%-80%. These precision performances are consistent with the technical characteristics of the magic wand algorithm, which performs well in color-uniform areas and needs to be combined with other technologies in complex texture areas.
[0061] In combination with the lake survey in the Mongolian highland lake area in the current year, the technical application of the algorithm was carried out in six provinces and regions of Inner Mongolia, Shanxi, etc. during the 2024 high water period. A total of 702 lakes (area greater than 0.1 square kilometers) were interpreted during the 2024 high water period, of which 611 were applied using the algorithm, with an application rate of 87.04%. The segmentation results are shown in Figure 4 .
[0062] The main advantage of the embodiment of the present application is the combination of automation efficiency and manual intervention precision. As the core, the magic wand algorithm provides a simple and intuitive operation method, and the user only needs to click to select the seed point to obtain the segmentation result. The multi-resolution pyramid technology ensures the efficiency when processing large images, and the morphological processing technology improves the quality of the segmentation result.
[0063] The user interface is user-friendly, and the real-time feedback mechanism helps users quickly master the operation method. The parameter suggestion function automatically sets the appropriate tolerance based on the image features, reducing the user's learning cost. The debugging and diagnosis function provides detailed segmentation process information to help users optimize parameter settings.
[0064] The embodiment of the present application has good application scenario adaptability. In remote sensing image analysis, it can quickly and accurately extract the water body boundary to provide basic data for water resource management, flood monitoring, etc. In medical image processing, it can be used for organ segmentation, lesion area identification, etc. to provide accurate anatomical structure information for disease diagnosis and surgical planning.
[0065] The water body segmentation technical scheme based on the magic wand algorithm is a comprehensive technical solution that integrates multiple advanced image processing technologies. As the core technology, the magic wand algorithm provides a simple and intuitive operation method and high-precision segmentation effect. The integration of multi-resolution pyramid technology, morphological processing, contour detection, etc. enables the embodiment of the present application to handle various complex application scenarios.
[0066] The embodiment of the present application has good practicability and expansibility, and can meet the water body segmentation needs in different fields. The friendly user interface and powerful post-processing function make the embodiment of the present application suitable for professional users and ordinary users. The modular design and expansion interface provide a basis for the continuous development and application expansion of technology.
[0067] The successful application of the embodiment of the present application proves the important value of the magic wand algorithm in modern image processing, and provides an important reference for the development of semi-automatic image segmentation technology. Through continuous technological innovation and application expansion, the segmentation technology based on the magic wand algorithm will play an important role in more fields and provide strong technical support for the development of related industries.
[0068] Based on the same inventive concept, the present application also provides a water body segmentation system, comprising: A data acquisition module is configured to acquire a remote sensing image of a target water area.
[0069] A computing module is configured to process the remote sensing image into a plurality of gray scale images with different resolutions, select at least one seed pixel point for each of the gray scale images, set a gray scale tolerance parameter according to the seed pixel point, initialize a queue for the seed pixel point, design a binary mask table and an access mark map with the same size as the remote sensing image, add the seed pixel point to the queue, and repeatedly extract the seed pixel point from the head of the current queue, calculate the gray scale difference between the seed pixel point and the four-neighborhood pixels in the gray scale image, and determine whether the four-neighborhood pixels have been accessed by querying the access mark map. If the neighborhood pixels have not been accessed and the gray scale difference is less than the gray scale tolerance parameter, the current neighborhood pixels that meet the condition are marked as target pixels and accessed in the binary mask table and the access mark map, respectively, and the current neighborhood pixels that meet the condition are added to the tail of the queue. The process is repeated until the queue is empty, and an initial binary mask table is obtained.
[0070] A water body segmentation module is configured to extract a water body boundary point sequence of the initial binary mask table, output a boundary vector contour point set, smooth process the boundary vector contour point set using a weighted local average algorithm, output a vector contour polygon, add geographic coordinate reference system information to the vector contour polygon, output a closed polygon vector data, and segment a target area water body using the closed polygon vector data.
[0071] The present application also provides a computer device. At the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and can also include other hardware required for business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs to implement the water body segmentation method provided above.
[0072] The application further provides a computer readable storage medium, which stores a computer program, and the computer program is used for executing the water body segmentation method provided above.
[0073] The specific limitations of the water body segmentation method computing system can refer to the limitations of the water body segmentation method described above, which will not be repeated here. Each module in the water body segmentation system described above can be realized by software, hardware and their combinations in whole or in part. Each module described above can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0074] The technical features of the above embodiments can be combined in any way. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application. In addition, the above embodiments only express several embodiments of the present application, the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of the patent of the present application should be subject to the appended claims.
Claims
1. A water body segmentation method, characterized in that, The method comprises the following steps: Collecting remote sensing images of a target water area; Processing the remote sensing images into multiple gray scale images with different resolutions; selecting at least one seed pixel point for each gray scale image, and setting a gray scale tolerance parameter according to the seed pixel point; Initializing a queue for the seed pixel point, designing a binary mask table and an access mark map with the same size as the remote sensing image, adding the seed pixel point to the queue, and repeatedly extracting the seed pixel point from the head of the current queue to calculate the gray scale difference between the seed pixel point and the four neighboring pixels in the gray scale image; Judging whether the four neighboring pixels have been accessed by querying the access mark map, if the neighboring pixels have not been accessed and the gray scale difference is less than the gray scale tolerance parameter, marking the current neighboring pixels that meet the conditions as target pixels and accessed in the binary mask table and the access mark map respectively, and adding the current neighboring pixels that meet the conditions to the tail of the queue; until the queue is empty, an initial binary mask table is obtained; Extracting a water body boundary point sequence of the initial binary mask table, outputting a boundary vector contour point set, smoothing the boundary vector contour point set by using a weighted local average algorithm, outputting a vector contour polygon, adding geographic coordinate reference system information to the vector contour polygon, and outputting a closed polygon vector data; and segmenting the target area water body by using the closed polygon vector data.
2. The water body segmentation method of claim 1, wherein, The remote sensing images are processed into multiple gray scale images with different resolutions, specifically, the remote sensing images are processed into water area image layers with original resolution layer, one-half resolution layer and one-eighth resolution layer; the original resolution layer is used for accurate segmentation, the one-half resolution layer is used for magnification operation, and the one-eighth resolution layer is used for global display and reduction operation; and the RGB images of each water area image layer are converted into gray scale images by using a weighted average method.
3. The method of claim 1, wherein, Before the step of extracting a water body boundary point sequence of the initial binary mask table and outputting a boundary vector contour point set, the method further comprises the following steps: performing hole filling processing on the initial binary mask table, identifying and filling internal cavities with an area less than a first preset threshold; removing noise from the binary mask table after hole filling, deleting connected regions with an area less than a second preset threshold, the area being the total number of pixel points contained in the selected region; performing boundary smoothing processing on the binary mask table after noise removal, performing morphological opening operation and closing operation by using a circular structural element, optimizing the region boundary, and obtaining an optimized binary mask table; performing connected component analysis on the optimized binary mask table, marking independent connected regions, and selecting a target water body region according to a preset area threshold to obtain a screened binary mask table.
4. The water body segmentation method of claim 3, wherein, The step of smoothing the boundary vector contour point set by using a weighted local average algorithm and outputting a vector contour polygon specifically comprises the following steps: constructing a local window for each contour point in the boundary vector contour point set, performing weighted average calculation on all contour points in the local window by using a Gaussian weight, and generating a smooth vector contour polygon; wherein the center point of the local window has the highest weight.
5. The method of claim 1, wherein, The method further comprises: converting the vector contour polygon into a standard geographic information vector format, adding preset geographic coordinate reference system information to the standard geographic information vector format, and outputting closed polygon vector data, i.e., the water body boundary of the target region.
6. The method of claim 1, wherein, The method further comprises: analyzing color distribution characteristics of a region based on a region within a preset range around the seed pixel point; the color distribution characteristics include a color range, an average value, a standard deviation, and a median value; and a gray scale tolerance suggestion value is automatically generated based on the color distribution characteristics, for reference by a user to set the gray scale tolerance parameter.
7. The method of claim 5, wherein, The method further comprises: selecting a corresponding standard geographic information vector format according to the morphological type of the target water body, if the target water body is a planar water body, converting the vector contour polygon into a polygon vector format in compliance with the OGC Simple Feature specification; if the target water body is a linear water body, extracting a boundary line of the vector contour polygon and converting the boundary line into a line feature vector format in compliance with the OGC Simple Feature specification; and the converted standard geographic information vector format is compatible with the import and analysis functions of ArcGIS and QGIS geographic information system software.
8. A water body segmentation system, characterized by, The method comprises: a data acquisition module configured to acquire a remote sensing image of a target water area; a calculation module configured to process the remote sensing image into a plurality of gray scale images with different resolutions, select at least one seed pixel point for each of the gray scale images, set a gray scale tolerance parameter based on the seed pixel point, initialize a queue for the seed pixel point, design a binary mask table and an access mark map with a size consistent with that of the remote sensing image, add the seed pixel point to the queue, and repeatedly extract a seed pixel point from a head of the queue, and calculate a gray scale difference between the seed pixel point and four neighboring pixels in the gray scale image; determine whether the four neighboring pixels have been accessed by querying the access mark map, if the neighboring pixels have not been accessed and the gray scale difference is less than the gray scale tolerance parameter, mark the currently eligible neighboring pixels as target pixels and as having been accessed in the binary mask table and the access mark map, and add the currently eligible neighboring pixels to a tail of the queue, until the queue is empty, and obtain an initial binary mask table; a water body segmentation module configured to extract a water body boundary point sequence of the initial binary mask table, output a boundary vector contour point set, smooth the boundary vector contour point set using a weighted local average algorithm, output a vector contour polygon, add geographic coordinate reference system information to the vector contour polygon, and output closed polygon vector data, and segment a target region water body based on the closed polygon vector data.
9. A computer device comprising a memory, a processor, and a computer program stored on the memory, wherein the computer program comprises instructions that, when executed by the processor, cause the processor to perform the method of any one of claims 1-8. The processor executes the computer program to implement the steps of the method of any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program, when loaded by the processor, can implement the steps of the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Completed drawing multi-element extraction and vectorization method, device and equipment and storage medium
CN120656201A
Teachable object contour mapping for biology image region partition
US20120106809A1