Contour extraction method, computer device and medium for semantic segmentation map
By disassembling the semantic segmentation diagram into multiple pixel blocks and inserting zero pixel points, a segmentation mask diagram is generated, which solves the problem of slow speed of existing contour extraction methods and inability to collinear contour lines, and efficient contour extraction is achieved.
Patent Information
- Application Number
- CN202510193032.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-02-21
AI Technical Summary
The existing contour extraction methods have the defects of slow speed and the extracted contour lines are incoherent.
By disassembling the semantic segmentation map into multiple pixel blocks and inserting zero pixel points into the pixel blocks, a segmentation mask map is obtained, and then contour extraction is performed based on the segmentation mask map.
Collinear representation of the contour lines of adjacent objects is realized, which avoids redundant calculations and improves the contour extraction speed.
Smart Images

Figure CN119693403B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to a contour extraction method, computer equipment and medium for semantic segmentation graphs. Background Art
[0002] Contour extraction is an important process in computer vision and image processing. It can detect and depict the boundaries of objects from digital images. By analyzing the contours, many advanced applications can be realized, such as object recognition, feature extraction, shape analysis, etc.
[0003] In the prior art, contour extraction is usually implemented using functions in the OpenCV library. The main idea is to find contour edges based on a threshold or edge detection algorithm, determine foreground pixels by scanning the pixel values of the image line by line based on pixel connectivity, and draw contours based on contour edges and foreground pixels. In the contour extraction process, since each color block needs to perform a contour extraction operation, this results in two calculations of the common contour part for adjacent color blocks, resulting in redundant calculations, and for two adjacent color blocks, the contours of the two color blocks cannot overlap, resulting in the contours being unable to be colinear.
[0004] Therefore, the existing contour extraction methods have the defects of slow contour extraction speed and the extracted contour lines cannot be collinear. Summary of the invention
[0005] In order to overcome the above-mentioned defects, the contour extraction method, computer device and medium for semantic segmentation map provided by the present invention can solve the technical problems in the prior art that the contour extraction speed is slow and the extracted contour lines cannot be represented colinearly.
[0006] In a first aspect, the present invention provides a contour extraction method for a semantic segmentation map, comprising:
[0007] Obtain a semantic segmentation map, and decompose the semantic segmentation map into multiple pixel blocks;
[0008] Segmenting each pixel block in the semantic segmentation map by inserting zero pixels into the pixel blocks to obtain a segmentation mask map corresponding to the semantic segmentation map;
[0009] Perform contour extraction on the semantic segmentation map based on the segmentation mask map.
[0010] In some embodiments, decomposing the semantic segmentation map into a plurality of pixel blocks comprises:
[0011] Divide the semantic segmentation map into a plurality of n×n pixel blocks according to the resolution, wherein any two adjacent pixel blocks have x overlapping pixels, and x=n×nn, where n is an integer greater than or equal to 2;
[0012] For each pixel block, a mark value is set for each pixel in the pixel block according to the position and color arrangement and combination of the pixel points in the pixel block.
[0013] Furthermore, setting a mark value for each pixel in the pixel block according to the arrangement and combination of the positions and colors of the pixel points in the pixel block includes:
[0014] Determining the arrangement and combination mode corresponding to the pixel blocks according to whether the colors of the pixels at each position are the same, wherein the colors of the pixels are the colors corresponding to the semantic categories of the pixels;
[0015] The mark value of each pixel point in the pixel block is set according to the arrangement and combination mode, wherein the mark values of the pixel points with the same color in the pixel block are the same.
[0016] In some embodiments, segmenting each pixel block in the semantic segmentation map by inserting zero pixels into the pixel block comprises:
[0017] For all pixel blocks in the semantic segmentation map, pixel blocks corresponding to the same arrangement and combination are segmented in parallel using the same method of inserting zero pixels.
[0018] Furthermore, the parallel segmentation processing of pixel blocks corresponding to the same arrangement and combination mode by inserting the same zero pixel point mode includes:
[0019] The following segmentation processing is performed for each pixel block corresponding to each arrangement and combination:
[0020] Convert the pixel block into a new color block by inserting zero pixels between all adjacent pixels in the pixel block, and define the pixel points in the new color block that are different from the zero pixels as original pixels;
[0021] All original pixel points in the new color block are traversed, the original pixel points are respectively compared with the adjacent pixel points in the preset direction for consistency, and the zero pixel points between the original pixel points and the adjacent pixel points in the preset direction are updated according to the comparison result.
[0022] Further, traversing the original pixel points in the new color block, comparing the original pixel points with adjacent pixel points in a preset direction for consistency, and updating the zero pixel points between the original pixel points and the adjacent pixel points in the preset direction according to the comparison result includes:
[0023] Step a1: Select an original pixel from the new color block as the current pixel;
[0024] Step a2: determining whether the mark value of the current pixel is consistent with the mark value of the adjacent pixel in a preset direction; if they are consistent, changing the zero pixel between the current pixel in the new color block and the adjacent pixel in the preset direction to the current pixel; otherwise, keeping the zero pixel between the current pixel in the new color block and the adjacent pixel in the preset direction unchanged;
[0025] Step a3: Determine whether there are any original pixels in the new color block that have not been selected as the current pixel. If yes, continue to execute step a1; otherwise, complete the traversal operation.
[0026] In some embodiments, extracting contours from the semantic segmentation map based on the segmentation mask map comprises:
[0027] A contour line is determined based on zero pixel points in the segmentation mask image, and object contours corresponding to different semantic categories in the semantic segmentation image are obtained according to the contour line.
[0028] Further, the determining of the contour line based on the zero pixel points in the segmentation mask image includes:
[0029] Determine a corner point based on a four-connected relationship of zero pixel points in the segmentation mask image, and determine a non-corner point based on the corner point; wherein the corner point refers to a zero pixel point that includes at least three zero pixel points in a four-connected neighborhood;
[0030] Determine points belonging to the same line segment based on the four-connected relationship of the non-corner points and connect them into collinear line segments;
[0031] The contour line is obtained based on the corner points and the collinear line segments.
[0032] In a second aspect, the present invention provides a computer device comprising a processor and a memory, wherein the memory is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor to execute the contour extraction method for semantic segmentation maps described in any one of the technical solutions of the above-mentioned contour extraction method for semantic segmentation maps.
[0033] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute the contour extraction method for a semantic segmentation map described in any one of the technical solutions of the above-mentioned contour extraction method for a semantic segmentation map.
[0034] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects: the solution of the present application decomposes the semantic segmentation map into multiple pixel blocks, segments each pixel block in the semantic segmentation map by inserting zero pixels in the pixel blocks to obtain a segmentation mask map corresponding to the semantic segmentation map, and performs contour extraction based on the segmentation mask map, thereby achieving the collinear representation of the extracted contour lines of adjacent objects, avoiding redundant calculations when extracting the common contour parts of adjacent objects; the solution of the present application assigns a value to each pixel point when decomposing the semantic segmentation map into multiple pixel blocks, that is, converts the image data into a numerical vector, and realizes fast segmentation of pixel blocks through vectorization, thereby improving the contour extraction speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:
[0036] Figure 1 It is a schematic flow chart of the main steps of a contour extraction method for a semantic segmentation map according to an embodiment of the present application;
[0037] Figure 2 It is a schematic flow chart of main steps of decomposing a semantic segmentation map into multiple pixel blocks according to an embodiment of the present application;
[0038] Figure 3 is a schematic diagram of 13 permutation and combination methods corresponding to a 2×2 pixel block shown in an embodiment of the present application;
[0039] Figure 4 This is a schematic diagram of the main steps of segmenting a pixel block provided by an embodiment of the present application;
[0040] Figure 5 This is a vectorized implementation method flow for segmenting pixel blocks in a semantic segmentation map provided by an embodiment of the present application;
[0041] Figure 6 The two specific 2×2 pixel blocks shown in the embodiment of the present application are as follows Figure 5 Schematic diagram of the result obtained after processing the process shown;
[0042] Figure 7 It is a schematic diagram of the main steps of determining a contour line based on zero pixel points in a segmentation mask image provided by an embodiment of the present application;
[0043] Figure 8It is a main structural diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0044] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0045] In the description of the present invention, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memories, and may also include software parts, such as program codes, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program codes, such as a magnetic disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, and the like. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B", and may include only A, only B, or A and B. The singular terms "one" and "the" may also include plural forms.
[0046] The following is an explanation of the technical terms involved in this application.
[0047] 2×2 pixel block: is a basic unit for representing an image. The pixel block is a square area composed of 4 pixels. In image processing, the use of 2×2 pixel blocks can simplify calculations and improve processing efficiency.
[0048] Four-connectivity: refers to a pixel being connected to its adjacent pixels in the four directions of up, down, left, and right. In a two-dimensional image, the four-connected neighborhood of a pixel includes the pixels in the four directions of up, down, left, and right. Four-connectivity means that the central pixel is connected to the pixels in its four-connected neighborhood in the horizontal and vertical directions.
[0049] Corner point: A term commonly used to describe geometric figures, referring to the point where two line segments or two boundaries intersect.
[0050] Semantic segmentation: Semantic segmentation is a computer vision technology, the core of which is to assign a category label to each pixel in the image, forming a pixel-level classification prediction task. This classification is not limited to identifying objects in the image, but also involves the precise location and shape of the object. Specifically, semantic segmentation assigns a category label to each pixel in the image and generates a pixel-level mask. This mask represents the area in the image that belongs to a specific category. The semantic segmentation map obtained after semantic segmentation of the image is the mask map.
[0051] In downstream application scenarios of image segmentation, such as automatic annotation or detection and recognition tasks, it is often necessary to convert the semantic segmentation map into a polygonal expression, that is, to extract the contour of the semantic segmentation map. However, the current common practice is to use the implementation in OpenCV (Open Source Computer Vision Library, an open source computer vision and machine learning software library) to convert it. One disadvantage is that the speed is very slow, and the other is that the multiple polygons obtained by conversion cannot be collinear. To this end, this application proposes a contour extraction method for semantic segmentation maps, which not only optimizes the contour extraction speed, but also can obtain the contour lines of collinear representation.
[0052] See attached Figure 1 , Figure 1 This is a flowchart of the main implementation steps of a contour extraction method for a semantic segmentation map provided by an embodiment of the present application. As shown in the figure, the method mainly includes the following steps S11 to S13:
[0053] Step S11: obtaining a semantic segmentation map, and decomposing the semantic segmentation map into a plurality of pixel blocks;
[0054] Step S12: Segmenting each pixel block in the semantic segmentation map by inserting zero pixels into the pixel blocks to obtain a segmentation mask map corresponding to the semantic segmentation map;
[0055] Step S13: extracting contours of the semantic segmentation map based on the segmentation mask map.
[0056] Based on the above step S11, the implementation steps of decomposing the semantic segmentation map into multiple pixel blocks in this embodiment are as follows: Figure 2 As shown, it mainly includes the following steps S111 and S112:
[0057] Step S111: dividing the semantic segmentation map into a plurality of pixel blocks of size n×n according to the resolution;
[0058] Specifically in this embodiment, among the multiple pixel blocks obtained by the division in this step, there are x overlapping pixel points between any two adjacent pixel blocks, and x=n×nn, where n is an integer greater than or equal to 2. For example, when n is equal to 2, the 4 pixel points in the 2×2 pixel block may be specifically pixel points at the four positions of the upper left, lower left, upper right, and lower right. Assuming that the pixel block a is adjacent to the right of the pixel block b and the pixel block a is adjacent to the bottom of the pixel block c, the 2 pixel points at the upper right and lower right positions of the pixel block a overlap with the 2 pixel points at the upper left and lower left positions of the pixel block b, and the 2 pixel points at the lower left and lower right positions of the pixel block a overlap with the 2 pixel points at the upper left and upper right positions of the pixel block c.
[0059] Step S112: for each pixel block, a mark value is set for each pixel in the pixel block according to the position and color arrangement and combination of the pixel points in the pixel block.
[0060] Specifically, for each pixel block, the arrangement and combination mode corresponding to the pixel block can be determined based on whether the colors of the pixels at each position are the same, wherein the color of the pixel is the color corresponding to the semantic category of the pixel; and the mark value of each pixel in the pixel block is set according to the arrangement and combination mode, wherein the mark values of the pixels with the same color in the pixel block are set to be the same.
[0061] Exemplarily, a specific implementation of the above-mentioned step S111 and step S112 may be to divide the acquired semantic segmentation map into a plurality of pixel blocks of 2×2 in size according to the resolution size, and determine the arrangement and combination mode corresponding to the 2×2 pixel block according to whether the color of the pixel points at each position is the same. Specifically, 13 arrangement and combination modes can be determined for the 2×2 pixel block. For example, the colors of the pixel points at the 4 positions in the 2×2 pixel block are all different, which corresponds to the arrangement and combination mode 1. Accordingly, the mark values of the 4 pixels in the 2×2 pixel block corresponding to the arrangement and combination mode 1 can be set to 1, 2, 3, and 4 respectively. It should be understood that the mark values of the pixels are set to 1, 2, 3, and 4 only to exemplarily indicate that the colors of the 4 positions are different. In actual applications, the mark values of each pixel in the pixel block can be customized to other values based on the same principle.
[0062] like Figure 3As shown, it is a schematic diagram of 13 permutations and combinations corresponding to a 2×2 pixel block determined based on the principle of whether the colors of the pixels at each position in the pixel block are the same according to an embodiment of the present application. As shown in the figure, the positions of the four pixels in the 2×2 pixel block can be identified as the upper left, lower left, upper right, and lower right, respectively. It should be understood that the mark values 1, 2, 3, and 4 set for each pixel in the pixel block in the figure are only exemplary for indicating that the colors of the four pixels are different. For example, the mark values of the four pixels are all 1, which is only used to indicate that the colors of the pixels at the four positions in the pixel block are the same; for another example, the mark values of the pixels at the upper left, lower left, upper right, and lower right in the pixel block are 1, 1, 2, and 2, respectively, which is only used to indicate that the colors of the pixels at the upper left and lower left positions in the pixel block are the same, the colors of the pixels at the upper right and lower right positions are the same, and the colors of the pixels at the upper left and lower left positions are different from the colors of the pixels at the upper right and lower right positions; for another example, the mark values of the pixels at the upper left, lower left, upper right, and lower right in the pixel block are 1, 1, 2, and 2, respectively, which is only used to indicate that the colors of the pixels at the upper left and lower left positions in the pixel block are the same, the colors of the pixels at the upper right and lower right positions are the same, and the colors of the pixels at the upper left and lower left positions are different from the colors of the pixels at the upper right and lower right positions; The label values are 1, 1, 2, and 3, respectively, which are only used to indicate that the colors of the pixels at the upper left and lower left positions in the pixel block are the same, the colors of the pixels at the upper right and lower right positions are different, and the colors of the pixels at the upper left and lower left positions are also different from the colors of the pixels at the upper right and lower right positions. It can be understood that the situation where the label values of the pixels at the upper left, lower left, upper right, and lower right in the pixel block are 1, 1, 2, and 3, respectively, is the same as the situation where the label values of the pixels at the upper left, lower left, upper right, and lower right in the pixel block are 1, 1, 3, and 2, respectively, and the situation where the label values of the pixels at the upper left, lower left, upper right, and lower right in the pixel block are 2, 1, 1, and 2, respectively, is the same as the situation where the label values of the pixels at the upper left, lower left, upper right, and lower right in the pixel block are 1, 2, 2, and 1, respectively.
[0063] Furthermore, based on the above-mentioned steps S111 and S112, the specific implementation of the step S12 in the embodiment of the present application may include: for all pixel blocks in the semantic segmentation map, the pixel blocks corresponding to the same arrangement and combination are subjected to parallel segmentation processing by inserting zero pixels in the same manner.
[0064] For example, taking the decomposition of the semantic segmentation map into 2×2 pixel blocks as an example, all 2×2 pixel blocks contained in the semantic segmentation map may correspond to the following: Figure 3 Any of the 13 permutations and combinations shown in the figure can, in a specific implementation, each permutation and combination can be concretized as a specific process of segmentation processing by inserting zero pixels. Then, when processing all pixel blocks in the semantic segmentation map, all pixel blocks corresponding to the same permutation and combination can be processed in parallel according to the same process, thereby accelerating the conversion speed of pixel blocks in the semantic segmentation map, thereby achieving the purpose of optimizing the contour extraction speed with the help of vectorization.
[0065] In a specific implementation manner provided by this embodiment, the parallel segmentation processing of pixel blocks corresponding to the same arrangement and combination manner using the same zero pixel insertion manner may specifically include:
[0066] The following segmentation processing is performed for each pixel block corresponding to each arrangement and combination mode, as follows: Figure 4 As shown, it mainly includes the following steps S121 and S122:
[0067] Step S121: converting the pixel block into a new color block by inserting zero pixels between all adjacent pixels in the pixel block, and defining the pixels in the new color block that are different from the zero pixels as original pixels;
[0068] In this embodiment, taking the pixel block as a 2×2 pixel block as an example, the new color block is specifically a 3×3 pixel block formed by inserting a zero pixel point between every two adjacent pixels of the 2×2 pixel block.
[0069] Step S122: traverse all original pixel points in the new color block, compare the original pixel points with adjacent pixel points in a preset direction for consistency, and update the zero pixel points between the original pixel points and the adjacent pixel points in the preset direction according to the comparison result.
[0070] In this embodiment, the adjacent pixel points in the preset direction include: the original pixel points at the upper (or lower) position adjacent to the current pixel point, and the original pixel points at the right (or left) position adjacent to the current pixel point. It can be understood that in image processing, the traversal order of pixel points is usually from top to bottom and from left to right. This is because this traversal method can ensure that each pixel is only visited once, and the access order is continuous, which is conducive to improving processing efficiency. In the specific implementation of traversing pixel points, it can be prioritized to compare the consistency with the original pixel points at the upper (or lower) position, or it can be prioritized to compare the consistency with the original pixel points at the right (or left) position. In this embodiment, for each pixel block, the premise for comparing the original pixel point with the adjacent pixel points in a preset direction for consistency is that there are adjacent pixel points in the preset direction relative to the original pixel point. If there are no adjacent pixel points in the preset direction, there is no need to compare the original pixel point for consistency. In the embodiment of the present application, there are overlapping pixels between the adjacent pixel blocks obtained by splitting the semantic segmentation map. Therefore, when traversing and comparing the original pixel points in each pixel block for consistency, it can be ensured that all pixel points in the semantic segmentation map are compared for consistency with the adjacent pixel points in the preset direction.
[0071] In this embodiment, a specific implementation of step S122 may include the following steps a1 to a3:
[0072] Step a1: Select an original pixel from the new color block as the current pixel;
[0073] Step a2: determine whether the mark value of the current pixel is consistent with the mark value of the adjacent pixel in the preset direction, if they are consistent, change the zero pixel between the current pixel and the adjacent pixel in the preset direction to the current pixel, otherwise the zero pixel between the current pixel and the adjacent pixel in the preset direction remains unchanged;
[0074] Specifically in this embodiment, assuming that the mark value of the current pixel is x, during the consistency comparison process, if the zero pixel between the current pixel and its adjacent pixel in a preset direction is changed to a pixel with a mark value of x, then the newly changed pixel with a mark value of x will be recorded as the original pixel in the new color block.
[0075] Step a3: Determine whether there are any original pixels in the new color block that have not been selected as the current pixel. If yes, continue to execute step a1; otherwise, complete the traversal operation.
[0076] Based on the above steps S121 and S122, Figure 5 As shown, the embodiment of the present application provides a vectorized implementation method flow for segmenting pixel blocks in a semantic segmentation map, such as Figure 5 As shown, the vectorization implementation of taking the semantic segmentation map (picture for short) as the input picture and taking the pixel blocks in the picture as the processing object for segmentation processing mainly includes the following steps 201 to 210:
[0077] Step 201: for each pixel block in the image, insert a 0 pixel point between each pixel point in the pixel block, and the pixel points in the pixel block other than the 0 pixel point are called original pixel points;
[0078] Step 202: traverse each original pixel point in the pixel block, and record the original pixel point currently traversed as x;
[0079] Step 203: Determine whether x is consistent with the original pixel point above it, if it is consistent, execute step 204, if it is not consistent, execute step 205;
[0080] Specifically, this step can be specifically to determine whether the mark value of x is consistent with the mark value of the original pixel point above it. For example, if the mark value of x and the mark value of the original pixel point above it are both 4, then step 204 is executed after the determination in this step.
[0081] Step 204: Change the 0 pixel point between x and the original pixel point above it to x, and execute step 206;
[0082] Step 205: the 0 pixel point between x and the original pixel point above it remains unchanged;
[0083] Step 206: traverse each original pixel point in the pixel block again, and record the original pixel point currently traversed as x;
[0084] Step 207: Determine whether x is consistent with the original pixel point at the right position, if it is consistent, execute step 208, if not, execute step 209;
[0085] Specifically, this step can be specifically to determine whether the mark value of x is consistent with the original pixel point at its right position. For example, if the mark value of x is 1 and the mark value of the original pixel point at its right position is 2, then step 209 is executed after the determination in this step.
[0086] Step 208: Change the 0 pixel point between x and the original pixel point to its right to x, and execute step 210;
[0087] Step 209: the 0 pixel point between x and the original pixel point to its right remains unchanged;
[0088] Step 210: until the traversal operation of the original pixels is completed for all pixel blocks in the image, a picture segmented by masking with 0 pixels is obtained.
[0089] In practical applications, after the semantic segmentation map is decomposed into multiple pixel blocks, multiple parallel processing threads can be created according to the multiple permutations and combinations corresponding to the pixel blocks. In each processing thread, the pixel blocks are taken as processing objects, thereby realizing the processing of all pixel blocks in the semantic segmentation map according to the permutations and combinations corresponding to the pixel blocks. Figure 5 The method flow shown is vectorized and a segmentation mask image is obtained by masking the semantic segmentation image with zero pixels.
[0090] like Figure 6 As shown, two specific 2×2 pixel blocks are shown in the embodiment of the present application according to the exemplary embodiment. Figure 5Schematic diagram of the result obtained after the specific implementation process is processed. As shown in the figure, one specific 2×2 pixel block is specifically: a 2×2 pixel block with the mark values of the upper left, lower left, upper right and lower right positions being 1, 1, 2, and 3 respectively, and the corresponding arrangement and combination mode is that the pixel points at the upper left and lower left positions have the same color, the pixel points at the upper right and lower right positions have different colors, and the pixel points at the upper left and lower left are different from the upper right and lower right pixels; another specific 2×2 pixel block is specifically: a 2×2 pixel block with the mark values of the upper left, lower left, upper right and lower right positions being 1, and the corresponding arrangement and combination mode is that the pixel points at the upper left, lower left, upper right and lower right positions have the same color.
[0091] Based on the above step S13, the contour extraction of the semantic segmentation map based on the segmentation mask map includes: determining contour lines based on zero pixel points in the segmentation mask map, and obtaining object contours corresponding to different semantic categories in the semantic segmentation map according to the contour lines. It should be understood that in the embodiment of the present application, the contour lines determined based on the zero pixel points in the segmentation mask map are contour lines that realize co-linear representation.
[0092] Furthermore, when the contour line is determined based on the zero pixel point, the polygonal collinear line segments of the object contours corresponding to different semantic categories can also be obtained, thereby obtaining the contour line represented by a plurality of collinear line segments.
[0093] like Figure 7 FIG. 1 is a schematic flow chart of the main steps of a specific implementation method of determining the contour line based on the zero pixel points in the segmentation mask image in this embodiment, which mainly includes the following steps S131 to S133:
[0094] Step S131: determining corner points based on the four-connected relationship of zero-pixel points in the segmentation mask image, and determining non-corner points based on the corner points;
[0095] Specifically in this embodiment, the corner point refers to a zero pixel point including at least three zero pixels in a four-connected neighborhood. It should be understood that the non-corner point refers to the zero pixel point remaining after removing the corner point in the segmentation mask image.
[0096] Step S132: determining points belonging to the same line segment based on the four-connected relationship of the non-corner points and connecting them into collinear line segments;
[0097] Specifically, in this embodiment, connected non-corner points, i.e., zero pixel points belonging to the same line segment, can be found according to the four-connected relationship, and the collinear line segment can be obtained by connecting the zero pixel points belonging to the same line segment. In combination with practical applications, it can be known that by searching for connected pixel points according to the four-connected relationship and connecting them, multiple collinear line segments can usually be obtained.
[0098] Step S133: Obtain the contour line based on the corner points and the collinear line segments.
[0099] Specifically in this embodiment, the corner points and the plurality of collinear line segments can usually be connected to form the contour line. In combination with practical applications, it can be known that a polygonal contour can usually be drawn based on the contour line.
[0100] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium, etc. that can carry the computer program code.
[0101] Furthermore, the present invention also provides a computer device. Figure 7 , Figure 7 It is a schematic diagram of the main structure of a computer device according to an embodiment of the present application. In a computer device embodiment according to the present application, the computer device includes a processor 301 and a memory 302. The memory 302 can be configured to store a program for executing the contour extraction method for a semantic segmentation map of the above-mentioned method embodiment. The processor 301 can be configured to execute the program in the memory, which includes but is not limited to executing the contour extraction method for a semantic segmentation map of the above-mentioned method embodiment. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer device can be a control device device formed by various electronic devices.
[0102] In some possible implementations of the present application, the computer device may include multiple processors 301 and multiple memories 302. The program for executing the contour extraction method for semantic segmentation maps of the above method embodiment may be divided into multiple subprograms, and each subprogram may be loaded and run by the processor 301 to execute different steps of the contour extraction method for semantic segmentation maps of the above method embodiment. Specifically, each subprogram may be stored in different memories 302, respectively, and each processor 301 may be configured to execute the program in one or more memories 302 to jointly implement the contour extraction method for semantic segmentation maps of the above method embodiment, that is, each processor 301 executes different steps of the contour extraction method for semantic segmentation maps of the above method embodiment, respectively, to jointly implement the contour extraction method for semantic segmentation maps of the above method embodiment.
[0103] Furthermore, the present invention also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present invention, the computer-readable storage medium can be configured to store a program for executing the contour extraction method for a semantic segmentation map of the above-mentioned method embodiment, and the program can be loaded and run by a processor to implement the above-mentioned contour extraction method for a semantic segmentation map. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer-readable storage medium can be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present invention is a non-temporary computer-readable storage medium.
[0104] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A contour extraction method for a semantic segmentation map, characterized in that: include: Obtain a semantic segmentation map, and decompose the semantic segmentation map into multiple pixel blocks; Segmenting each pixel block in the semantic segmentation map by inserting zero pixels into the pixel blocks to obtain a segmentation mask map corresponding to the semantic segmentation map; Performing contour extraction on the semantic segmentation map based on the segmentation mask map; Wherein, the zero pixel points in the segmentation mask image are used to determine the contour line.
2. The method according to claim 1, characterized in that Decomposing the semantic segmentation map into a plurality of pixel blocks comprises: Divide the semantic segmentation map into a plurality of n×n pixel blocks according to the resolution, wherein any two adjacent pixel blocks have x overlapping pixels, and x=n×nn, where n is an integer greater than or equal to 2; For each pixel block, a mark value is set for each pixel in the pixel block according to the position and color arrangement and combination of the pixel points in the pixel block.
3. The method according to claim 2, characterized in that The step of setting a mark value for each pixel in the pixel block according to the arrangement and combination of the positions and colors of the pixel points in the pixel block comprises: Determining the arrangement and combination mode corresponding to the pixel blocks according to whether the colors of the pixels at each position are the same, wherein the colors of the pixels are the colors corresponding to the semantic categories of the pixels; The mark value of each pixel in the pixel block is set according to the arrangement and combination mode, wherein the mark values of the pixels with the same color in the pixel block are the same.
4. The method according to claim 2, characterized in that: The segmenting of each pixel block in the semantic segmentation map by inserting zero pixels into the pixel block comprises: For all pixel blocks in the semantic segmentation map, pixel blocks corresponding to the same arrangement and combination are segmented in parallel using the same method of inserting zero pixels.
5. The method according to claim 4, characterized in that The parallel segmentation processing of pixel blocks corresponding to the same arrangement and combination mode by inserting the same zero pixel point includes: The following segmentation processing is performed for each pixel block corresponding to each arrangement and combination: Convert the pixel block into a new color block by inserting zero pixels between all adjacent pixels in the pixel block, and define the pixel points in the new color block that are different from the zero pixels as original pixels; All original pixel points in the new color block are traversed, the original pixel points are respectively compared with the adjacent pixel points in the preset direction for consistency, and the zero pixel points between the original pixel points and the adjacent pixel points in the preset direction are updated according to the comparison result.
6. The method according to claim 5, characterized in that The traversing of the original pixel points in the new color block, comparing the original pixel points with the adjacent pixel points in a preset direction for consistency, and updating the zero pixel points between the original pixel points and the adjacent pixel points in the preset direction according to the comparison result includes: Step a1: Select an original pixel from the new color block as the current pixel; Step a2: determining whether the mark value of the current pixel is consistent with the mark value of the adjacent pixel in a preset direction; if they are consistent, changing the zero pixel between the current pixel in the new color block and the adjacent pixel in the preset direction to the current pixel; otherwise, keeping the zero pixel between the current pixel in the new color block and the adjacent pixel in the preset direction unchanged; Step a3: Determine whether there are any original pixels in the new color block that have not been selected as the current pixel. If yes, continue to execute step a1; otherwise, complete the traversal operation.
7. The method according to claim 1, characterized in that The extracting contours of the semantic segmentation map based on the segmentation mask map comprises: A contour line is determined based on zero pixel points in the segmentation mask image, and object contours corresponding to different semantic categories in the semantic segmentation image are obtained according to the contour line.
8. The method according to claim 7, characterized in that The determining of the contour line based on the zero pixel points in the segmentation mask image comprises: Determine a corner point based on a four-connected relationship of zero pixel points in the segmentation mask image, and determine a non-corner point based on the corner point; wherein the corner point refers to a zero pixel point that includes at least three zero pixel points in a four-connected neighborhood; Determine points belonging to the same line segment based on the four-connected relationship of the non-corner points and connect them into collinear line segments; The contour line is obtained based on the corner points and the collinear line segments.
9. A computer device comprising a processor and a memory, wherein the memory is suitable for storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by the processor to execute the contour extraction method for a semantic segmentation map according to any one of claims 1 to 8.
10. A computer-readable storage medium storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by a processor to execute the contour extraction method for a semantic segmentation map according to any one of claims 1 to 8.
Citation Information
Patent Citations
Object contour extraction method based on mask-RCNN
CN108898610A
Method and device for extracting land parcels in image, electronic equipment and storage medium
CN112884764A