Image-based local edge target segmentation method, device and medium

CN116824593BActive Publication Date: 2026-09-18CHONGQING WESTERN HANDWRITING BIG DATA RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310831057.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-07
Publication Date
2026-09-18
Estimated Expiration
2043-07-07

AI Technical Summary

Technical Problem

[0021]本发明所要解决的问题是,基于小物体目标分割时存在边缘模糊和过渡区域较大,边缘标注和预测存在的准确性差、一致性差等难点,且现有技术计算量非常大、计算错误率高等问题

Benefits of technology

[0036] The present application proposes to修正 the initial result based on local gradient maxima on annotation or algorithm prediction results, which has the following advantages: improving the efficiency and accuracy of pixel-level annotation for target segmentation. In existing annotation methods, to obtain better annotation results, annotators need to complete a large amount of single-pixel annotation work, especially spending a lot of time on edge regions. After adopting the technical solution of the present invention, only the foreground core region pixels need to be marked by the image processing module, and there is no need to annotate edge pixels anymore; the present invention automatically expands edge pixels. For obvious foreground that is neglected in annotation, as long as there are neighborhood pixels marked, supplementation can be completed; for part of the background that is mistakenly annotated, automatic deletion can also be completed. Improving the consistency of target edge annotation or prediction for target segmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116824593B_ABST
    Figure CN116824593B_ABST
Patent Text Reader

Abstract

The application discloses a target segmentation method based on local edges of images, acquires an original image and an initial segmentation image, converts multiple channel images in the original image into a single channel image, expands the initial segmentation image to obtain a candidate segmentation region; gradient calculation is performed on the single channel image in the candidate segmentation region; new pixels are obtained based on gradient neighborhood pixel iterative marking, as gradient local maximum value pixels; corresponding neighborhood reserved pixels and neighborhood deleted pixels are calculated based on the gradient direction of the maximum value pixels, a gradient maximum value pixel set, a reserved pixel set and a deleted pixel set are obtained, the deleted pixel set is removed from the candidate segmentation region, and after morphological post-processing, an optimized segmentation target is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of artificial intelligence and image processing target segmentation technology, specifically a target segmentation method based on local image edges. Background Technology

[0002] Object segmentation is a key technique in computer vision, aiming to distinguish objects from the background in an image. The development of object segmentation technology can be summarized in the following stages:

[0003] 1. Traditional image processing methods: These methods mainly rely on features of the image such as color, texture and shape, such as threshold segmentation, region growing, edge detection, etc.

[0004] 2. Machine Learning Methods: These methods use feature extractors and classifiers for object segmentation. Common machine learning methods include Support Vector Machines (SVM), Decision Trees, and Random Forests.

[0005] 3. Deep Learning Methods: With the development of deep learning, Convolutional Neural Networks (CNNs) have performed exceptionally well in object segmentation tasks. Typical deep learning methods include:

[0006] Fully Convolutional Network (FCN): Replaces the fully connected layers of a convolutional neural network with convolutional layers to achieve pixel-by-pixel classification.

[0007] U-Net: A symmetric convolutional neural network with skip connections, suitable for tasks such as medical image segmentation. Mask R-CNN: Based on Faster R-CNN, it adds a branch for generating pixel-level masks of the target.

[0008] DeepLab employs techniques such as dilated convolution, spatial pyramid pooling (ASPP), and conditional random fields (CRF) to improve segmentation accuracy.

[0009] Object segmentation technology has wide applications in fields such as autonomous driving, medical image analysis, video surveillance, human-computer interaction, and handwriting recognition. The accuracy of object segmentation algorithms depends not only on the segmentation algorithm itself but also significantly on the training data. The requirements for pixel annotation mainly include the following:

[0010] 1. Accuracy: Pixel annotation requires accurately separating the target object from the background to ensure that each pixel is correctly classified.

[0011] 2. Continuity: Pixel annotations for the same target object should remain continuous to avoid broken or isolated pixels.

[0012] 3. Clear edges: The edges of the target object should be as clear as possible to improve the quality of the segmentation results.

[0013] 4. Consistency: For objects of the same type, pixel annotation shall be consistent and follow the same rules and standards.

[0014] 5. Annotation speed: In order to improve work efficiency, the pixel annotation process shall be as fast as possible while ensuring annotation quality. Pixel-level annotation tasks usually require a large amount of manual labor, and the annotation quality directly affects the performance of the model.

[0015] The study found that there are great challenges in the segmentation and annotation of signature handwriting, especially when there are blurred edges or large transition areas for small objects. Due to the small size of small objects and relatively complex edge details, in the process of segmentation and annotation, basically only the central pixels of the target can be quickly annotated, and it is difficult to annotate the edges accurately, consistently and quickly. This situation has a great impact on subsequent model training and algorithm evaluation, resulting in reduced accuracy of recognition results.

[0016] As shown in Figure 1 , which is a schematic diagram of enlarged strokes of the Chinese character "王" (Wang) and local stroke details. By enlarging the details of the last stroke, it can be seen that the edge details are very blurred, and it is difficult to define a unified standard executable for manual annotation.

[0017] Inaccurate edge annotation will prevent the model from fully learning the features of object edges during model training, thereby affecting the segmentation effect. Secondly, poor annotation consistency may lead to overfitting or underfitting problems during model training, further reducing the generalization ability of the model. Finally, it is not conducive to subsequent algorithm evaluation, because evaluation indicators such as IoU and accuracy may be affected by annotation quality, making it impossible to accurately reflect algorithm performance.

[0018] Publication No.: CN116152274A, titled an image segmentation method, apparatus, device and storage medium, discloses an image segmentation method. Based on the initial segmented image obtained after coarse segmentation, according to the corresponding gradient change of the gradient vector at each pixel in the original image, the original image is finely segmented by means of path optimization, thereby improving the accuracy of image segmentation. However, for blurred boundaries, the above-mentioned point features do not perform well in screening boundary points. In the segmentation path optimization algorithm, there are many kinds of pairing between feature points, which leads to a very large amount of calculation. Meanwhile, as the distance between feature points increases, it is prone to false matching of edge feature points that do not belong to the same edge, resulting in edge calculation errors. This method does not provide a specific method on how to obtain better segmentation effects based on edges.

[0019] Chinese invention patent application CN114037710A, entitled "Image Segmentation Method," discloses an image segmentation method. In this method, each element in the target segmentation image indicates the target segmentation confidence of the corresponding pixel in a video image frame belonging to a foreground object. Based on the pixel gradients of candidate regions in the video image frame and the pixel gradient of the video image frame itself, the method determines the target image region in the video image frame that contains motion blur. According to a set threshold, the target segmentation confidence of each pixel in the target image region is corrected. Based on the corrected target segmentation image, the video image frame is segmented. Motion blur regions are detected based on gradient changes, and their segmentation results are corrected, thus improving the accuracy of image segmentation. This method mainly addresses motion blur in consecutive video frames and requires the use of information between video frames.

[0020] The above methods are designed to find continuous and closed single-pixel edges in blurred regions, but their effectiveness is easily affected by noise in the blurred regions. Summary of the Invention

[0021] The problem this invention aims to solve is that segmentation of small objects suffers from challenges such as blurred edges, large transition regions, and poor accuracy and consistency in edge labeling and prediction. Furthermore, existing technologies suffer from high computational demands and error rates. This application corrects the segmentation prediction results based on local edge maxima, improving the consistency of edge labeling and prediction in the segmentation of small image targets such as signatures, and enhancing the accuracy of edge pixel labeling.

[0022] This application does not aim to find continuous and closed single-pixel edges in the fuzzy region. Instead, it divides the fuzzy region into sets of pixels by deleting or retaining pixels based on gradient magnitude and direction. Therefore, it has a smaller computational load, stronger robustness, and achieves high accuracy and consistency in edge labeling and prediction.

[0023] The technical solution to the above-mentioned technical problems is, based on one aspect of this application, a target segmentation method based on local image edges is proposed. This method involves acquiring an original image and an initial segmentation image, converting the multi-channel image in the original image into a single-channel image, expanding the region of the initial segmentation image to obtain a candidate segmentation region, calculating the magnitude and direction of the single-channel image gradient within the candidate segmentation region, iteratively labeling pixels within the candidate segmentation region based on the gradient magnitude, and removing pixel sets labeled as different types from the candidate segmentation region to obtain the optimized segmentation target.

[0024] Further preferably, the step of converting a multi-channel image into a single-channel image includes: statistically analyzing the foreground and background sets of the original image within the initial segmentation image range in the R, G, and B channels of the color image and the converted grayscale channels; calculating the equal error rate of binary classification of foreground or background grayscale values; selecting the channel with the smallest equal error rate as the optimal channel; and converting the multi-channel image in the original image into a single-channel image through the optimal channel.

[0025] Further preferably, expanding the initial segmented image region includes: if the initial segmented image has undersegmentation, using a 3*3 morphological operator for images that need to expand the edge region; and using multiple 3*3 or 5*5 morphological operators for images that need to expand the range, thereby expanding the initial segmented image region.

[0026] Further preferably, the calculation of the magnitude and direction of the single-channel image gradient includes convolving the image using a convolution kernel and calculating the horizontal and vertical gradient values ​​G for each pixel of the image. x and G y Call the formula:

[0027] |G|=|G x |+|G y |

[0028]

[0029] Calculate the gradient magnitude |G| and orientation angle θ of a single-channel image.

[0030] Further optimization involves iteratively labeling pixels within the candidate segmentation region, including calculating the magnitude and direction of the gradient of the target image, and arranging the unlabeled pixel set in order based on the gradient magnitude; filtering out all pixels in the unlabeled pixel set whose gradient magnitude is less than a set gradient threshold and labeling them as gradient minima; obtaining the unlabeled pixel with the new maximum gradient each time as the gradient maxima, and determining the positions of retained and deleted pixels based on the gradient direction of the gradient maxima pixel; and labeling the accessed new pixel, retained pixel, and deleted pixel in the unlabeled pixel set as gradient maxima pixels, retained pixels, and deleted pixels, respectively, until all pixels are labeled.

[0031] Further optimization involves determining whether a pixel gradient direction is a deletion or addition direction by the direction angle of the gradient maxima pixel and the range of the foreground and background pixels. Each gradient direction is divided clockwise from the negative half-axis of the y-axis, and the neighborhood gradient angle is divided into equal or unequal parts. The neighborhood is determined sequentially to obtain the deletion and addition pixels within the neighborhood. The gradient angle range is determined based on the gradient distribution of the segmentation target to avoid multiple maxima pixels corresponding to the same deletion or addition pixels.

[0032] Further preferably, for Chinese character segmentation, an 8-neighborhood uneven gradient direction is adopted, wherein the gradient range of 1, 3, 5, and 7 neighborhood pixels corresponding to horizontal strokes and vertical strokes is 60°, and the gradient range of other neighborhood pixels is 30°; if the gradient distribution of the Chinese character to be segmented only has horizontal strokes or vertical strokes, a 4-neighborhood uniform gradient direction is adopted.

[0033] Further preferably, if the average value of foreground pixels in a single channel is less than the average value of background pixels, it is determined that the direction of gradient increase is from foreground to background, the neighborhood pixels corresponding to the gradient increase direction are deleted, while the direction of gradient decrease is from background to foreground, and the neighborhood pixels corresponding to the gradient increase direction are retained.

[0034] According to another aspect of the present application, an electronic device is provided, comprising: a processor; and a memory storing a program, wherein the program comprises instructions that, when executed by the processor, cause the processor to execute the target segmentation method based on local edges of an image as described above.

[0035] According to another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute any one of the above target segmentation methods based on local edges of an image.

[0036] The present application proposes to修正 the initial result based on local gradient maxima on annotation or algorithm prediction results, which has the following advantages: improving the efficiency and accuracy of pixel-level annotation for target segmentation. In existing annotation methods, to obtain better annotation results, annotators need to complete a large amount of single-pixel annotation work, especially spending a lot of time on edge regions. After adopting the technical solution of the present invention, only the foreground core region pixels need to be marked by the image processing module, and there is no need to annotate edge pixels anymore; the present invention automatically expands edge pixels. For obvious foreground that is neglected in annotation, as long as there are neighborhood pixels marked, supplementation can be completed; for part of the background that is mistakenly annotated, automatic deletion can also be completed. Improving the consistency of target edge annotation or prediction for target segmentation.

[0037] In existing annotation methods and prediction methods, inconsistency is prone to occur in foreground edge regions; even the annotation results of the same annotator in different annotations differ greatly in edge regions, which is extremely unfavorable for algorithm training and model evaluation. After修正 by the present solution, based on local gradient maxima, the consistency of annotation or region results is improved. Description of Drawings

[0038] Figure 1 A schematic diagram of the strokes of the Chinese character "王" and the enlarged details of local strokes;

[0039] Figure 2A flowchart of a refined edge optimization method for target segmentation in an exemplary embodiment of this application;

[0040] Figure 3 A schematic diagram of the target edge gradient change in an exemplary embodiment of this application;

[0041] Figure 4 This application provides an exemplary schematic diagram of the pixel set marking process in this exemplary embodiment;

[0042] Figure 5 A schematic diagram illustrating the determination and marking of deleted and retained pixels based on gradient maxima pixels in an exemplary embodiment of this application;

[0043] Figure 6 A schematic diagram of the signature results obtained by segmentation using existing segmentation methods and the method described in this invention in an exemplary embodiment of this application;

[0044] Figure 7 A schematic diagram of an electronic device according to an embodiment of this application.

[0045] Among them, 100 is electronic equipment, 101 is processor, 102 is bus, and 103 is memory. Detailed Implementation

[0046] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While some embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this application. It should be understood that the drawings and embodiments of this application are for illustrative purposes only and are not intended to limit the scope of protection of this application.

[0047] It should be understood that the steps described in the method embodiments of this application may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this application is not limited in this respect.

[0048] The term "comprising" and its variations as used herein are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc., mentioned in this application are used only to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies.

[0049] It should be noted that the terms "a" and "a plurality of" used in this application are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0050] The names of the messages or information exchanged between multiple devices in the embodiments of this application are for illustrative purposes only and are not intended to limit the scope of these messages or information.

[0051] like Figure 2 The diagram illustrates a refined edge optimization method for small image target segmentation according to an exemplary embodiment of this application. First, an original image and an initial segmentation image are input. The initial segmentation image typically represents the most obvious and easily labeled foreground pixel region. Second, the original image and the initial segmentation image are preprocessed. Specifically, for the original image, if it is a multi-channel image, it is processed into a single-channel image. For the initial segmentation image, a dilation morphological operation is performed to expand the initial segmentation region, obtaining candidate segmentation regions. Third, a gradient is applied to the single-channel image within the candidate segmentation regions. The calculation includes calculating the magnitude and direction of the gradient. Then, based on the gradient, neighboring pixels are iteratively labeled. New pixels are obtained in descending order of gradient magnitude as seeds for local maxima. Based on the gradient direction of the pixel, the corresponding neighboring pixels to be retained and deleted are calculated. The neighboring pixels to be retained and deleted continue to undergo neighboring deletion or retention iteration. Pixels that have been visited are no longer visited again. After the iteration is completed, a set of pixels with gradient maxima, a set of retained pixels, and a set of deleted pixels are obtained. Finally, the segmentation candidate region is removed by removing the deleted pixel set, and then morphological post-processing is performed to obtain the final optimized segmentation result.

[0052] Input the original image and the initial segmentation result. The initial segmentation result can be the most obvious and easily labeled foreground pixel region, such as the core foreground region quickly labeled through image editing, eliminating the need for further labeling of edge pixels, or the foreground region predicted by the algorithm model, or even the skeleton region of the foreground. These results will be used as input to subsequent segmentation algorithms to generate more accurate image segmentation results.

[0053] In one embodiment of the exemplary embodiments of this application, the initial segmentation image preprocessing method specifically involves: if the initial segmentation image is under-segmented, i.e., the actual foreground is wider than the initial segmentation image, dilation operations can be performed using morphological operators of different sizes to obtain a larger range of candidate segmentation regions. Dilation is a morphological operation that can be used in image processing to increase the region size of a binary image. Different sizes of dilation operators can be selected to achieve different foreground enhancement effects. Typically, for images that need to expand edge regions, a 3x3 morphological operator can be used. For larger dilation ranges, multiple 3x3 or 5x5 morphological operators can be used to achieve a larger foreground enhancement. In morphological operators, element values ​​are usually set to all 1s to maximize the effect of the dilation operation. Through dilation operations, the initial segmentation region can be expanded, thereby obtaining a wider range of candidate segmentation regions. These candidate regions can be further used for subsequent image segmentation and processing tasks.

[0054] The preprocessing method for the original image is as follows: if the original image is a multi-channel image, it is converted into a single-channel image after processing through the optimal channel, which facilitates the calculation of the image gradient under that channel;

[0055] If it is a single-channel image, this operation is not required. This exemplary embodiment selects the channel with the lowest foreground / background pixel classification error rate as the optimal channel. Specifically, if the input is a standard RGB 3-channel image, extract the R, G, B channels and the grayscale channel respectively. The grayscale channel value can be obtained by linearly weighting the R, G, and B channels. The optimal grayscale channel value can be obtained by using the following formula:

[0056] gray=0.299*R+0.587*G+0.114*B

[0057] Define the gray channel.

[0058] For the R, G, B, and gray channels mentioned above, the foreground and background sets of the original image within the initial segmentation image range are statistically analyzed for each channel. The equal error rate of binary classification of foreground and background gray values ​​is calculated, and the channel with the smallest equal error rate among the four channels can be selected as the optimal channel.

[0059] This single-channel selection method allows for a greater distinction between the foreground and background, resulting in more pronounced edges and facilitating the subsequent calculation of discriminative edge gradients. However, if the classification error rate is too high, the foreground and background may not be well distinguished, and the foreground edge gradient may be easily affected by the background. Therefore, selecting the channel with the lowest error rate is crucial.

[0060] Gradient calculation is performed on a single-channel image within the candidate segmentation region, calculating both the magnitude and direction of the gradient. The image gradient is a measure of grayscale change, representing the rate of change for each pixel in the image. We observed a regular gradient variation at the target edge regions of the image, such as... Figure 3 The diagram illustrates the gradient changes of the target edge in an exemplary embodiment of this application, showing the gradients of the background region, the edge region from the background to the foreground, the foreground region, the edge region from the foreground to the background, and the background region. By magnifying and observing the target edge locally, a statistical table of target edge gradient changes is obtained as shown in Table 1.

[0061] Table 1: Statistics on Gradient Changes at the Target Edge

[0062]

[0063]

[0064] The statistical table shows that the gradients of the background and foreground are small and chaotic, while the gradient directions from the background to the foreground edge and from the foreground to the background edge are relatively stable and their changes are relatively regular. The gradient directions are relatively stable, and the gradient magnitudes gradually increase and then decrease. Therefore, the characteristics of large gradient magnitudes and stable directions at the foreground and background edges can be used as a basis for foreground edge optimization. There are many methods for calculating gradient magnitude and direction. Conventional calculation methods in this field can be used to calculate the gradient and direction. However, due to the complexity of edge areas when signing electronic signatures using different devices and pens, the numerous strokes and intersections in Chinese characters, and the different writing habits and styles of signatories, including non-standard writing and the use of different fonts, etc., the calculations may be affected by these factors.

[0065] The exemplary embodiments of this application employ the Sobel operator for image gradient calculation.

[0066] First, the image is convolved using a 3x3 convolution kernel, and the horizontal and vertical gradient values ​​G for each pixel are calculated. x and G y Call the formula:

[0067] |G|=|G x |+|G y |

[0068]

[0069] The gradient magnitude |G| and gradient direction θ can be calculated more quickly by adding them together.

[0070] To prevent the denominator from being 0, you can add 0.1 to both the numerator and denominator of the formula when calculating the gradient direction.

[0071] G|=|Gx |+|G y |

[0072]

[0073] For electronic signatures with complex handwriting styles and fonts, the Sobel operator is the optimal choice for calculating the gradient. Other operators, such as the Laplacian operator and the Scharr operator, can also be used to calculate the gradient.

[0074] To filter out some imaging noise that could affect the gradient distribution at the edges, a 3x3 or 5x5 median smoothing operation is performed on the single-channel image before gradient calculation. The gradient direction is rotated clockwise from the negative y-axis, with θ taking values ​​in the open interval of 0 to 2π.

[0075] Based on the gradient magnitude, pixels are accessed in order (from largest to smallest or smallest to largest), and the set of pixels with maximum gradient values ​​is automatically marked, the set of pixels with maximum values ​​is retained, and the set of pixels to be deleted is automatically marked.

[0076] like Figure 4 The diagram illustrates the pixel set labeling process in this exemplary embodiment. Various gradient sets are labeled, including: the gradient maxima pixel set, the retained pixel set, and the deleted pixel set.

[0077] The annotation method in this exemplary embodiment can be implemented using the following method:

[0078] ① Calculate the magnitude and direction of the gradient of the target image through gradient calculation, and arrange them in descending order based on the gradient magnitude (the magnitude is determined by the magnitude) to form a set of unlabeled pixels.

[0079] ② In the unlabeled pixel set, label and filter out all pixels with gradient magnitudes less than a set gradient threshold. These pixels typically represent non-edge regions, such as foreground areas and solid-color background areas. Set the gradient threshold according to the filtering range and accuracy requirements; for example, the gradient threshold can be set to 5-20 by default. Setting this threshold can greatly reduce the computational load. For annotation tools with interactive interfaces, this threshold can be manually adjusted to filter out more background areas. The following operations perform iterative pixel labeling.

[0080] ③ Obtain the unlabeled pixel with the largest gradient from the unlabeled pixel set each time, and use it as the gradient maxima. Determine the position of the pixel to be retained and the position of the pixel to be deleted based on the gradient direction of the pixel.

[0081] ④ In the unmarked pixel set, mark the accessed new pixel, the retained pixel, and the deleted pixel as the gradient maximum pixel, the retained pixel, and the deleted pixel, respectively.

[0082] ⑤ Repeat steps 3 and 4 to perform pixel iterative marking. When no new pixel meets the unmarked requirement, stop the iteration and complete the marking of all pixels.

[0083] Finally, all pixels are labeled, including pixels with gradient maxima, pixels to be retained, pixels to be deleted, and a set of gradient minima that do not meet the gradient threshold requirements.

[0084] The method for determining the positions of retained and deleted pixels based on gradient direction can be as follows: By analyzing the direction of the pixel with the maximum gradient, and using the gradient direction angle θ and the size range of the foreground and background pixels, determine whether the specific gradient direction is a deletion or addition direction. This allows you to obtain the deleted and added pixels within the 8-neighborhood of that pixel. The deletion and addition directions are opposite to each other.

[0085] Based on the gradient direction angle of the pixel with the maximum gradient, and taking the negative half of the y-axis as the starting point for each gradient direction, rotate clockwise, considering the gradient distribution of the target, and divide the neighborhood into equal or unequal parts, and determine the neighborhood in sequence.

[0086] For cases where the gradient direction distribution at the target edge is relatively random, an 8-neighborhood can be used to evenly distribute the gradient direction across 360°, with each direction at 45°. The gradient direction is defined starting from the negative half of the y-axis and rotating clockwise, with the neighborhood numbers numbered 1-8. The value of the first neighbor is [335°~360°) & (0°~25°), and the gradient angle for each subsequent neighbor increases by 45°. The gradient angle range allocation method needs to be based on the gradient distribution of the segmented target to avoid multiple pixels with maximum values ​​corresponding to the same deleted or added pixel; this helps to obtain more continuous segmentation edges.

[0087] For example, when segmenting Chinese characters, where strokes are primarily horizontal and vertical, the 8-neighborhood pixels can be unevenly distributed. For instance, the gradient range corresponding to the 1st, 3rd, 5th, and 7th neighboring pixels for horizontal and vertical strokes can be increased to 60°, while the range for other neighboring pixels is 30°. This results in more continuous segmentation edges for horizontal and vertical strokes, reducing the impact of unstable pixel noise. If the gradient distribution of the segmentation target is primarily horizontal or vertical, then a 4-neighborhood gradient distribution scheme can be used.

[0088] Based on the gradient direction of the pixel with the maximum gradient value, and the pixel range of the foreground and background, determine the corresponding neighboring pixels to be deleted and retained, and mark the neighbors of the deleted and retained pixels. If the average value of the foreground pixels in a single channel is less than the average value of the background pixels, then the direction of increasing gradient is determined to be from foreground to background, and the neighboring pixels in the direction of increasing gradient are deleted; conversely, the direction of decreasing gradient is determined to be from background to foreground, and the neighboring pixels in the direction of increasing gradient are retained.

[0089] like Figure 5 The diagram illustrates how, in an exemplary embodiment of this application, pixels are determined and marked as deleted and retained based on pixels with maximum gradient values. The following specific examples further illustrate this.

[0090] A gradient direction strategy is set to distribute the gradient evenly among 8 neighboring pixels. The gradient direction of the pixel with the maximum gradient value is 5°+90°, and the corresponding deleted pixel is neighbor 3. When processing with a single channel, the size of the pixel range of the foreground and background is determined. In this example, the background pixel value is greater than the foreground pixel value, so neighbor 3 is the deleted pixel and neighbor 7 is the retained pixel.

[0091] According to the above formula for calculating the gradient direction The gradient direction is calculated.

[0092] If neighboring pixel 3 has not been marked, then neighboring pixel 3 is marked as a deleted pixel, and the iteration of deleting pixels continues, centered on neighboring pixel 3, until a new deleted pixel position is marked. Similarly, if neighboring pixel 7 has not been marked, then neighboring pixel 7 is marked as a retained pixel, and the iteration of retaining pixels continues, centered on neighboring pixel 7, until a new retaining pixel position is marked.

[0093] In addition, to obtain an image with a more prominent foreground, the set of pixels with maximum gradient values ​​can also be merged into the range of deleted pixels, resulting in a finer and more prominent foreground.

[0094] Removing the set of deleted pixels from the candidate segmentation regions yields new segmentation regions. However, due to local gradient irregularities, these new segmentation regions may exhibit irregularities such as burrs or holes. Morphological processing, including erosion followed by dilation, can be used to obtain a smoothed and optimized final segmentation result. Common morphological operators include 3x3 operators, where element values ​​are typically set to all 1s. Erosion removes burrs, while dilation makes edges more continuous and smooth. New outliers can be identified by combining the pixel values ​​of the nearest labeled retained pixels and the values ​​of the labeled deleted pixels.

[0095] like Figure 6 The diagram shows the signature results obtained by segmentation using existing segmentation methods and the method described in this invention in an exemplary embodiment of this application.

[0096] Figure a shows the original image's grayscale effect, where the background contains many messy images and strokes, making it difficult to distinguish the foreground from the background. Figure b is a schematic diagram of the segmentation result predicted by existing algorithms. Figure c is a schematic diagram of the effect after single-channel processing using the method of this invention. After single-channel processing, the foreground image is significantly enhanced, which has a beneficial effect on subsequent gradient extraction. Figure d is the segmentation result optimized by the method of this invention. As can be seen from the figures, the method of this invention obtains a more optimized signature segmentation result. Due to the merging of a large number of edge pixels, the segmented and extracted signature is thicker overall, more closely resembling the stroke thickness of the original signature image. Furthermore, there are five significant differences, manifested at four stroke connection points. The conventional method results in stroke connections that are adhered together, while the method of this invention separates these adhered strokes. For areas where the conventional method segmented strokes were slightly incomplete, the method of this invention also restores them to normal. Overall, the method of this invention achieves higher fidelity and more realistic signature segmentation compared to the original signature.

[0097] like Figure 7 As shown, the electronic device 100 includes a processor 101 and a memory 103. The processor 101 and the memory 103 are connected, for example, via a bus 102.

[0098] The structure of the electronic device 100 does not constitute a limitation on the embodiments of this application.

[0099] Processor 101 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, transistor logic device, hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 101 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0100] Bus 102 may include a pathway for transmitting information between the aforementioned components. Bus 102 may be a PCI bus or an EISA bus, etc. Bus 102 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0101] The memory 103 may be a ROM or other type of static storage device capable of storing static information and instructions, RAM or other type of dynamic storage device capable of storing information and instructions, or it may be an EEPROM, CD-ROM or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0102] The applicant of this invention has provided a detailed description of the embodiments of the invention in conjunction with the accompanying drawings. However, those skilled in the art should understand that the above embodiments are merely preferred embodiments of the invention. The detailed description is only to help better understand the spirit of the invention and is not intended to limit the scope of protection of the invention. Those skilled in the art can make various modifications or additions to the specific embodiments described or use similar methods to replace them, but without departing from the spirit of the invention or exceeding the scope defined by the appended claims.

Claims

1. A method for object segmentation based on local edge of image, characterized in that, The process involves acquiring the original image and the initial segmentation image, converting the multi-channel image in the original image into a single-channel image, expanding the region of the initial segmentation image to obtain candidate segmentation regions, and calculating the magnitude and direction of the gradient of the single-channel image within the candidate segmentation regions. Pixels within candidate segmentation regions are iteratively labeled based on gradient magnitude; Remove the sets of pixels labeled as different types from the candidate segmentation regions to obtain the optimized segmentation target; The iterative labeling of pixels within the candidate segmentation region includes calculating the magnitude and direction of the gradient of the target image and arranging the set of unlabeled pixels in order based on the gradient magnitude. Filter out all pixels with gradient magnitudes less than a set gradient threshold from the unlabeled pixel set and mark them as gradient minima; each time, obtain the unlabeled pixel with the maximum gradient as the gradient maxima, and determine the position of the pixel to be retained and the position of the pixel to be deleted by the gradient direction of the pixel with the maximum gradient. Based on the location in the unmarked pixel set, the newly accessed pixel, the retained pixel, and the deleted pixel are marked as gradient maxima pixels, retained pixels, and deleted pixels, respectively, until all pixels are marked.

2. The method according to claim 1, characterized in that, The process of converting a multi-channel image in the original image into a single-channel image includes: statistically analyzing the foreground and background sets of the original image within the initial segmentation image range in the R, G, and B channels of the color image and the converted grayscale channels; calculating the equal error rate of binary classification of foreground or background grayscale values; selecting the channel with the smallest equal error rate as the optimal channel; and converting the multi-channel image in the original image into a single-channel image through the optimal channel.

3. The method according to claim 1, characterized in that, Expanding the initial segmented image region includes: if the initial segmented image is under-segmented, using a 3*3 morphological operator for images that need to expand the edge region; and using multiple 3*3 or 5*5 morphological operators for images that need to expand the range, thereby expanding the initial segmented image region.

4. The method according to claim 1, characterized in that, The calculation of the magnitude and direction of the single-channel image gradient includes convolving the image using a convolution kernel and calculating the horizontal and vertical gradient values ​​for each pixel of the image. and Call the formula: Calculate the gradient magnitude of a single-channel image and direction angle .

5. The method according to claim 4, characterized in that, The direction of a pixel gradient is determined by the direction angle of the pixel with the maximum gradient value and the range of the foreground and background pixels. The gradient direction is divided into two parts: the negative half-axis of the y-axis and the neighbor gradient angle is divided into equal or unequal parts. The neighboring pixels are determined sequentially to obtain the deleted and added pixels in the neighboring pixels. The gradient angle range is determined based on the gradient distribution of the segmentation target to avoid multiple maximum pixels corresponding to the same deleted or added pixels.

6. The method according to claim 5, characterized in that, For Chinese character segmentation, an 8-neighborhood uneven gradient direction is adopted. The gradient range of the 1, 3, 5, and 7 neighboring pixels corresponding to horizontal and vertical strokes is 60°, and the gradient range of other neighboring pixels is 30°. If the gradient distribution of the Chinese character to be segmented only consists of horizontal or vertical strokes, a 4-neighborhood even gradient direction is adopted.

7. The method according to any one of claims 1-6, characterized in that, If the average value of foreground pixels is less than the average value of background pixels in a single channel, the direction of gradient increase is determined to be from foreground to background, and the neighboring pixels in the direction of gradient increase are deleted. Conversely, the direction of gradient decrease is from background to foreground, and the neighboring pixels in the direction of gradient increase are retained.

8. An electronic device, comprising: processor; And a memory for storing a program, characterized in that the program includes instructions that, when executed by the processor, cause the processor to perform the target segmentation method based on local image edges according to any one of claims 1-7.

9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, in, The computer instructions are used to cause the computer to perform the target segmentation method based on local image edges according to any one of claims 1-7.

Citation Information

Patent Citations

  • Image segmentation method and device, equipment and storage medium

    CN116152274A

  • Image edge detection and edge precision verification method

    CN112967303A