Edge detection method, system, device and medium based on improved loss function

By using an improved buffer-weighted boundary loss function and a deep learning network, the inaccuracy and discontinuity of edge recognition in existing edge detection methods under low contrast and complex backgrounds are solved, achieving higher accuracy and continuity in edge detection.

CN120852459BActive Publication Date: 2025-12-30HUANTIAN SMART TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202511333802.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2025-12-30
Estimated Expiration
2045-09-18

AI Technical Summary

Technical Problem

Existing edge detection methods struggle to accurately identify edges in low-contrast remote sensing images and complex backgrounds, and suffer from edge breaks and discontinuities, especially in cloud-covered scenes and densely built-up areas where misjudgments and missed detections are common.

Method used

An improved buffer-weighted boundary loss function (BWBL) is adopted, which assigns differentiated weights to skeleton boundaries, buffer regions and background, and dynamically adjusts the ratio of positive and negative samples. Combined with deep learning networks (such as Vision Transformer and BiMLANeck structures), the model's focus on edge pixels is optimized, reducing the need for manually set thresholds and improving the accuracy and continuity of edge detection.

Benefits of technology

It improves the accuracy and continuity of edge detection, especially in low-contrast and complex remote sensing images, reduces edge breakage rate, enhances the model's generalization ability, and reduces sensitivity to noise and dependence on manually set thresholds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120852459B_ABST
    Figure CN120852459B_ABST
Patent Text Reader

Abstract

The application discloses an edge detection method and system based on an improved loss function, equipment and a medium, and relates to the technical field of image processing. The method comprises the following steps: acquiring a sample image, and constructing a sample set through the sample image after preprocessing; determining the sample set after morphological operation as a training sample; inputting each image in the training sample into a constructed edge detection model for processing, and calculating the function value of the constructed buffer weighted boundary loss function after processing of each image; adjusting the model parameters of the edge detection model through the function value calculated after each processing, and determining the edge detection model reaching a training end condition as a target model; inputting a to-be-processed image after morphological operation into the target model for processing, and obtaining the edge detection result of the to-be-processed image. The model pays more attention to edge pixels, the accuracy of boundary recognition is optimized, and the continuity of the boundary is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically, to edge detection methods, systems, devices, and media based on improved loss functions. Background Technology

[0002] Edge detection is a core task in image analysis, aiming to accurately detect edge information in images. Traditional edge detection methods have certain limitations and cannot meet the needs of large-scale, high-resolution image analysis. With the rapid development of deep learning technology, deep learning-based edge detection methods have become a popular research direction. Existing deep learning-based edge detection methods mainly rely on traditional loss functions, such as cross-entropy loss function or mean squared error loss function. The following are some existing edge detection schemes:

[0003] 1. Edge detection methods based on traditional operators and skeleton analysis: These methods are based on traditional edge detection operators and combine skeleton feature extraction to achieve refined target edges. For example, the core process disclosed in patent document CN102004922B includes: edge detection, which uses an edge detection algorithm based on embedding confidence to extract the edges of ground features, vectorizes the edge results using ArcScan, and obtains high-precision vector edges through topological inspection and broken patch filtering; skeleton extraction and optimization, which extracts the skeleton baseline from the vector edges based on constrained Delaunay triangulation, uses a binary tree structure and Gestalt principle to screen the main skeleton, and retains key branches; and target recognition, which achieves target recognition by analyzing the geometric features and network measures of the skeleton and combining it with a BP neural network.

[0004] 2. Post-processing optimization methods based on dual thresholds and broken-line connections: This type of method focuses on post-processing optimization after edge detection, improving edge integrity through threshold filtering and broken-line connections. For example, the core process disclosed in patent document CN114255253B includes: edge binarization, generating strong and weak edge binary images using edge extraction operators (such as Canny and Sobel), fusing the two to obtain the target edge binary image, and initially filtering noise; connected component analysis and broken-line connections, scanning the target edge image line by line, marking "clusters" composed of continuous edge pixels, determining connected components based on column coordinate overlap, and filtering target connected components with more than a threshold number of pixels; connecting broken edges using morphological operations (opening and closing operations) to optimize boundary closure; and dynamic threshold adjustment, adaptively determining the filtering threshold based on the number of pixels in the connected components to reduce manual intervention.

[0005] 3. Edge detection methods based on deep learning: These methods utilize the feature learning capabilities of deep learning and combine them with supervision and attention mechanisms to improve edge detection accuracy. For example, the core process disclosed in patent document CN116205938B includes: multi-level edge feature extraction, with each level outputting two types of feature maps, and feature fusion optimized through bidirectional supervision of "low-level → high-level" and "high-level → low-level"; the loss function adopts joint cross-entropy loss, and improves multi-scale edge accuracy through self-supervised weights; patent document CN119399230A uses Swin Transformer as the backbone, extracts global features through window attention (W-MSA) and moving window attention (SW-MSA); scale enhancement (multi-dilation rate dilated convolution) and attention weighting (spatial + channel attention) are applied to the features to enhance edge robustness; patent document CN120235900A extracts skeleton information from shallow features, generates sparse attention masks, and guides cross-scale feature fusion to focus on the skeleton region; the loss function combines cross-entropy and Dice loss to balance edge localization and continuity.

[0006] Traditional operators and skeleton analysis rely on manually designed edge operators and skeleton selection rules, which are weak in capturing fine edges in low-contrast remote sensing images (such as scenes covered by clouds and fog) and are prone to skeleton breakage. They do not design loss functions for boundary pixels, and the edge accuracy is limited by the performance of the operators. The strong / weak edge thresholds and connected component selection thresholds based on post-processing optimization methods need to be set manually. In complex backgrounds (such as remote sensing images of densely built-up areas), they are prone to misjudging noise as edges or missing weak edges. The effect of broken line connection is greatly affected by morphological parameters. Existing loss functions of deep learning methods (such as cross-entropy, BCE+Dice) assign equal weights to boundary regions, buffer regions and background, resulting in insufficient attention to edge pixels by the model. Edge blurring is prone to occur at the junction of adjacent ground features (such as the intersection of farmland and roads). They do not consider the imbalance of positive and negative sample ratios (boundary pixels are much less than background pixels), and the model tends to ignore a small number of boundary pixels, resulting in discontinuous extraction results.

[0007] Therefore, this application is hereby submitted. Summary of the Invention

[0008] The purpose of this invention is to provide an edge detection method, system, device, and medium based on an improved loss function, which optimizes the accuracy of boundary recognition and improves the continuity of boundaries.

[0009] The above-mentioned technical objective of the present invention is achieved through the following technical solution:

[0010] Firstly, this application provides an edge detection method based on an improved loss function, including the following specific steps:

[0011] Acquire sample images and construct a sample set using the preprocessed sample images;

[0012] Morphological operations are performed on each image in the sample set to obtain the buffered boundary after dilation of the skeleton boundary of each image, and the sample set after morphological operations is determined as the training sample.

[0013] Each image from the training samples is input into the constructed edge detection model for processing, and the function value of the constructed buffer-weighted boundary loss function after processing each image is calculated.

[0014] The model parameters of the edge detection model are adjusted by calculating the function value after each processing until the training termination condition is met. The edge detection model that has reached the training termination condition is determined as the target model.

[0015] The image to be processed is subjected to morphological operations, and then the morphologically operated image is input into the target model for processing to obtain the edge detection result of the image to be processed.

[0016] Based on the above technical solution, the present invention can be further improved as follows.

[0017] Furthermore, the above methods also include:

[0018] pass The accuracy of the boundary detection results of the target model is evaluated using the similarity between the average path length and the target model until the accuracy evaluation results meet the preset conditions; otherwise, the target model is retrained.

[0019] Furthermore, the aforementioned buffer-weighted boundary loss function is specifically as follows:

[0020] ;

[0021] In the formula, This represents the total number of samples in the training samples. The sample weights are calculated based on the ratio of positive to negative sample pixels in each sample. Represented as true boundary labels, This indicates the convenient probability of the prediction.

[0022] Furthermore, the sample weights in the aforementioned buffer-weighted boundary loss function are determined in the following way:

[0023] ;

[0024] In the formula, This represents the boundary pixels of each sample in the training samples, and is the number of positive samples; This represents the background pixels of each sample in the training samples, and is the number of negative samples. The sample weights are calculated based on the ratio of positive to negative sample pixels in each sample. This represents the value of each pixel in the sample, with 0 for background, 1 for boundary, and 2 for buffer.

[0025] Furthermore, the above Determined in the following ways;

[0026] ,in:

[0027] , ;

[0028] In the formula, For accuracy, For recall rate, TP Indicates pixels that are correctly identified as boundaries; FP and FN These represent pixels that were incorrectly identified as boundaries and non-boundaries, respectively.

[0029] Furthermore, the aforementioned average path length similarity is determined in the following way:

[0030] ;

[0031] In the formula, The average path length similarity. It is the number of shortest paths. Represents nodes in the label and nodes The shortest path length between them. Indicating nodes in the boundary prediction results and The shortest path length between them. and It is the distance from the node within the threshold range in the prediction result. and nodes The most recent node.

[0032] Secondly, this application provides an edge detection system based on an improved loss function, applicable to any of the edge detection methods based on an improved loss function in the first aspect, including:

[0033] The sample acquisition module is used to acquire sample images and construct a sample set using the preprocessed sample images;

[0034] The training sample construction module is used to perform morphological operations on each image in the sample set to obtain the buffered boundary after dilation of the skeleton boundary of each image, and to determine the sample set after morphological operations as the training samples.

[0035] The model training module is used to input each image in the training samples into the constructed edge detection model for processing, and to calculate the function value of the constructed buffer-weighted boundary loss function after processing each image;

[0036] The model determination module is used to adjust the model parameters of the edge detection model by calculating the function value after each processing until the training termination condition is met, and the edge detection model that has reached the training termination condition is determined as the target model.

[0037] The edge detection module is used to perform morphological operations on the image to be processed, and then input the morphologically operated image to the target model for processing to obtain the edge detection result of the image to be processed.

[0038] Furthermore, the aforementioned system also includes:

[0039] The model evaluation module is used to evaluate the model through... The accuracy of the boundary detection results of the target model is evaluated using the similarity between the average path length and the target model until the accuracy evaluation results meet the preset conditions; otherwise, the target model is retrained.

[0040] Thirdly, this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method of any one of the first aspects.

[0041] Fourthly, this application provides a non-transitory computer-readable storage medium that stores computer instructions that cause a computer to perform any of the methods in the first aspect.

[0042] Compared with the prior art, the present invention has at least the following beneficial effects:

[0043] By designing a buffer-weighted boundary loss function (BWBL), differential weights are assigned to skeleton boundaries, buffer regions, and background to enhance the model's attention to edge pixels. The weights are dynamically adjusted based on the ratio of positive to negative samples to solve the class imbalance problem and enhance edge continuity in low-contrast scenes. Buffer boundaries are automatically generated through morphological operations without the need for manual threshold setting, improving the model's generalization ability in complex remote sensing images.

[0044] Compared to traditional operators and skeleton analysis methods, this application combines a deep learning model with an improved loss function, avoiding the sensitivity of traditional operators to noise and the limitations of manual skeleton selection. Specifically, the BWBL loss assigns higher weights to fragmented edges (such as field ridges and forest edges), improving edge extraction accuracy in low-resolution remote sensing images. This scheme eliminates the need for manually setting thresholds, directly optimizing the model's edge learning ability through the loss function, reducing subsequent processing steps. Furthermore, in scenes with blurred boundaries, the edge breakage rate is reduced. Compared to existing deep learning methods, such as bidirectional supervised loss (which treats all regions equally), the BWBL loss enhances attention to edge pixels by weighting the skeleton and buffer boundaries. The joint loss BCE+Dice loss (which does not distinguish boundary levels) addresses the class imbalance problem by dynamically adjusting the weights of positive and negative samples. Attached Figure Description

[0045] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and form part of this application, do not constitute a limitation thereof. In the drawings:

[0046] Figure 1 This is a flowchart of the detection method in an embodiment of the present invention;

[0047] Figure 2 This is a schematic diagram of the skeleton boundary and buffer boundary in an embodiment of the present invention;

[0048] Figure 3 This is a schematic diagram of the connection of the detection system in an embodiment of the present invention;

[0049] Figure 4 This is a schematic diagram of the connection of an electronic device in an embodiment of the present invention. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0051] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0052] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0053] In the description of the embodiments of the present invention, "multiple" means at least two.

[0054] Example 1: To address the problems of current loss functions introducing a large amount of non-boundary redundancy, leading to low detection accuracy, broken edges, and difficulty in accurately describing the complexity of edge information, and the fact that existing loss functions assign equal weights to boundary pixels and background pixels, causing the model to ignore fine edges and resulting in discontinuous extraction results, this example provides an edge detection method based on an improved loss function, such as... Figure 1 As shown, the specific steps include the following:

[0055] S1, acquire sample images, and construct a sample set using the preprocessed sample images.

[0056] In the process of image acquisition and processing, remote sensing images of a certain region in RGB three bands can be acquired. The images usually contain features such as buildings, farmland, woodland, and ponds. The boundary vectors of the features in the images are drawn on the images, and the boundaries are converted into raster data with a single pixel width aligned with the image range and resolution. Then, a cropping operation is performed to crop the images and corresponding boundary labels to a size of 512×512.

[0057] S2, morphological operations are performed on each image in the sample set to obtain the buffered boundary after dilation of the skeleton boundary of each image, and the sample set after morphological operations is determined as the training sample.

[0058] The training samples can be proportionally divided into training, validation, and test sets. The edge detection model described below is then trained, validated, and tested using these sets, respectively. This process is relatively mature and will not be elaborated upon here. Specifically, to calculate the buffer-weighted boundary loss function, the boundary needs to be processed. Morphological operations are used to dilate the skeleton boundary to obtain the buffer boundary. A schematic diagram of the skeleton boundary and the buffer boundary is shown below. Figure 2 As shown, in Figure 2 In the diagram, (a) represents the skeleton boundary before processing, and (b) represents the buffer boundary after processing.

[0059] S3 inputs each image from the training samples into the constructed edge detection model for processing, and calculates the function value of the constructed buffer-weighted boundary loss function after processing each image.

[0060] The edge detection model can adopt an encoder-decoder network model. The backbone network can use the Vision Transformer (ViT) model, which can effectively extract image features through a self-attention mechanism. The network processes an input image of size 512×512, divides the image into 16×16 blocks, and processes them using 1024-dimensional embedding vectors.

[0061] Furthermore, the feature maps output by the backbone network contain intermediate features from different layers, which possess rich spatial and semantic information. The intermediate networks utilize a BiMLANeck structure to connect the backbone network and the decoder head. This network fuses feature maps at multiple scales, further enhancing the diversity and robustness of feature representation. The decoder head network receives multi-scale feature maps from the intermediate networks and performs target classification and bounding box regression through a series of convolutional operations. The output of the decoder head is used to further refine the target detection results. Auxiliary head networks enhance the model's ability to detect targets at different scales; each auxiliary head processes feature maps from different scales obtained from the intermediate networks.

[0062] Specifically, the Buffer-Weighted Boundary Loss (BWBL) function is used in both the decoding head and the auxiliary head. This loss function prevents background pixels from being misclassified as boundaries by eliminating gradient contributions from the buffer boundaries, and also improves the accuracy of skeleton boundary detection by applying higher weights to skeleton pixels.

[0063] Optionally, the above buffer-weighted boundary loss function is as follows:

[0064] ;

[0065] In the formula, This represents the total number of samples in the training samples. The sample weights are calculated based on the ratio of positive to negative sample pixels in each sample. Represented as true boundary labels, This indicates the convenient probability of the prediction.

[0066] The sample weights in the buffer-weighted boundary loss function described above are determined in the following way:

[0067] ;

[0068] In the formula, This represents the boundary pixels of each sample in the training samples, and is the number of positive samples; This represents the background pixels of each sample in the training samples, and is the number of negative samples. The sample weights are calculated based on the ratio of positive to negative sample pixels in each sample. This represents the value of each pixel in the sample, with 0 for background, 1 for boundary, and 2 for buffer.

[0069] S4. The model parameters of the edge detection model are adjusted by calculating the function value after each processing until the training termination condition is met. The edge detection model that has reached the training termination condition is determined as the target model.

[0070] During model training, a 512×512 RGB three-band remote sensing image and corresponding buffer boundary labels are input. The buffer weighted boundary loss function is used to evaluate and optimize the model during training, and the model parameters are continuously adjusted until a specified number of training iterations or a cutoff condition is reached. The cutoff condition can be that the function value does not exceed a set threshold.

[0071] S5 performs morphological operations on the image to be processed, and then inputs the morphologically operated image to the target model for processing to obtain the edge detection result of the image to be processed.

[0072] The novel edge detection loss function provided in this embodiment enhances the accuracy and continuity of edge recognition by adding a boundary buffer and assigning different weights to boundary pixels, buffer pixels, and skeleton pixels proportionally, thereby avoiding the identification of non-boundary pixels as boundaries. Based on the edge detection model of the above loss function, combined with a deep learning network (ViT backbone network, BiMLANeck structure), high-precision extraction of image edges is achieved.

[0073] Optionally, the above method may also include:

[0074] pass The accuracy of the boundary detection results of the target model is evaluated using the similarity between the average path length and the target model until the accuracy evaluation results meet the preset conditions; otherwise, the target model is retrained.

[0075] In order to evaluate the effectiveness of the model, the following methods were used: The accuracy of the extracted boundaries is evaluated using average pathlength similarity (APLS). It is the harmonic mean of precision and recall, which comprehensively considers the model's precision and recall capabilities. Determined in the following ways;

[0076] ,in:

[0077] , ;

[0078] In the formula, For accuracy, For recall rate, TP Indicates pixels that are correctly identified as boundaries; FP and FN These represent pixels that were incorrectly identified as boundaries and non-boundaries, respectively.

[0079] Furthermore, APLS measures network similarity by comparing the shortest path lengths between node pairs in two networks, making it suitable for evaluating network connectivity and overall structure, rather than just differences in individual pixels. In APLS, the path length error for each pair of nodes is normalized and constrained to the range [0,1] to reduce the impact of extreme errors on the final score; the aforementioned average path length similarity is determined as follows:

[0080] ;

[0081] In the formula, The average path length similarity. It is the number of shortest paths. Represents nodes in the label and nodes The shortest path length between them. Indicating nodes in the boundary prediction results and The shortest path length between them. and It is the distance from the node within the threshold range in the prediction result. and nodes The nearest node; the formula first calculates the relative path length error of each pair of nodes in the actual network and the predicted network, truncates it to the maximum value of 1, then averages all path errors, subtracts the average value from 1 to obtain the final APLS score.

[0082] Specifically, the model outputs a boundary prediction result as a probability result. An adaptive threshold method is used to calculate the binary boundary result from the probability result. Then, morphological operations are used to perform skeletonization and dilation operations to obtain a boundary result with a three-pixel width, which facilitates accuracy calculation.

[0083] Example 2: This application provides an edge detection system based on an improved loss function, applied to the edge detection method based on an improved loss function in Example 1, such as... Figure 3 As shown, it includes:

[0084] The sample acquisition module is used to acquire sample images and construct a sample set using the preprocessed sample images;

[0085] The training sample construction module is used to perform morphological operations on each image in the sample set to obtain the buffered boundary after dilation of the skeleton boundary of each image, and to determine the sample set after morphological operations as the training samples.

[0086] The model training module is used to input each image in the training samples into the constructed edge detection model for processing, and to calculate the function value of the constructed buffer-weighted boundary loss function after processing each image;

[0087] The model determination module is used to adjust the model parameters of the edge detection model by calculating the function value after each processing until the training termination condition is met, and the edge detection model that has reached the training termination condition is determined as the target model.

[0088] The edge detection module is used to perform morphological operations on the image to be processed, and then input the morphologically operated image to the target model for processing to obtain the edge detection result of the image to be processed.

[0089] Optionally, the above system may also include:

[0090] The model evaluation module is used to evaluate the model through... The accuracy of the boundary detection results of the target model is evaluated using the similarity between the average path length and the target model until the accuracy evaluation results meet the preset conditions; otherwise, the target model is retrained.

[0091] Example 3: This application provides an electronic device, such as... Figure 4 As shown, it includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method of Embodiment 1.

[0092] Example 4: This application provides a non-transitory computer-readable storage medium that stores computer instructions that cause a computer to execute the method of Example 1.

[0093] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0094] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0095] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0096] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0097] Those skilled in the art will understand that all or part of the steps in the above facts and methods can be implemented by a program instructing related hardware. The program or the program described therein can be stored in a computer-readable storage medium. When the program is executed, it includes the following steps: at this time, the corresponding method steps are introduced. The storage medium can be ROM / RAM, magnetic disk, optical disk, etc.

[0098] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An edge detection method based on an improved loss function, characterized in that, The method comprises the following specific steps: obtaining sample images, and constructing a sample set through the preprocessed sample images; performing morphological operation on each image in the sample set to obtain a buffer boundary after the skeleton boundary of each image is dilated, and determining the sample set after the morphological operation as a training sample; inputting each image in the training sample into a constructed edge detection model for processing, and calculating a function value of a constructed buffer weighted boundary loss function after each image is processed; adjusting model parameters of the edge detection model through the function value calculated after each processing until a training end condition is reached, and determining the edge detection model that reaches the training end condition as a target model; performing morphological operation on a to-be-processed image, inputting the to-be-processed image after the morphological operation into the target model for processing, and obtaining an edge detection result of the to-be-processed image; the buffer weighted boundary loss function is specifically: ; In the formula, denotes the total number of samples in the training samples, is a sample weight calculated based on the proportion of the number of positive and negative sample pixels in each sample, denotes a true boundary label, denotes a predicted boundary probability; the sample weight in the buffer weighted boundary loss function is determined in the following manner: ; In the formula, represents the boundary pixels of each sample in the training sample, and is the number of positive samples; represents the background pixels of each sample in the training sample, and is the number of negative samples; is a sample weight calculated based on the proportion of the number of positive and negative sample pixels in each sample, represents the value of each pixel of the sample, 0 is the background, 1 is the boundary, and 2 is the buffer area.

2. The edge detection method based on improved loss function according to claim 1, wherein, The method further comprises: By and the average path length similarity, the boundary detection result of the target model is evaluated in precision, until the precision evaluation result reaches a preset condition, otherwise the target model is retrained.

3. The edge detection method based on improved loss function according to claim 2, characterized in that, The was determined by wherein: , ; wherein Precision, Recall, TP correctly identified as boundary; FP and FN incorrectly identified as boundary and non-boundary, respectively.

4. The edge detection method based on improved loss function according to claim 2, characterized in that, The average path length similarity is determined in the following manner: ; wherein, is the average path length similarity, is the number of shortest paths, denotes the shortest path length between nodes and nodes in the label, denotes the shortest path length between nodes and in the boundary prediction result, and are the nodes in the prediction result that are closest to nodes and nodes within a threshold range.

5. An edge detection system based on an improved loss function, characterized in that, comprises: a sample acquisition module, configured to obtain sample images, and construct a sample set through the preprocessed sample images; a training sample construction module, configured to perform morphological operation on each image in the sample set to obtain a buffer boundary after the skeleton boundary of each image is dilated, and determine the sample set after the morphological operation as a training sample; a model training module, configured to input each image in the training sample into a constructed edge detection model for processing, and calculate a function value of a constructed buffer weighted boundary loss function after each image is processed; a model determination module, configured to adjust model parameters of the edge detection model through the function value calculated after each processing until a training end condition is reached, and determine the edge detection model that reaches the training end condition as a target model; an edge detection module, configured to perform morphological operation on a to-be-processed image, input the to-be-processed image after the morphological operation into the target model for processing, and obtain an edge detection result of the to-be-processed image; the buffer weighted boundary loss function is specifically: ; wherein, denotes the total number of samples in the training samples, is a sample weight computed based on the proportion of positive and negative sample pixels in each sample, denotes a true boundary label, denotes a predicted boundary probability; the sample weight in the buffer weighted boundary loss function is determined in the following manner: ; In the formula, represents the boundary pixels of each sample in the training sample, and is the number of positive samples; represents the background pixels of each sample in the training sample, and is the number of negative samples; is a sample weight calculated based on the proportion of the number of positive and negative sample pixels in each sample, represents the value of each pixel of the sample, 0 is the background, 1 is the boundary, and 2 is the buffer area.

6. The improved loss function based edge detection system of claim 5, wherein, The system further comprises: a model evaluation module, configured to evaluate the boundary detection result of the target model by and the average path length similarity, until the accuracy evaluation result reaches a preset condition, otherwise retrain the target model.

7. An electronic device, comprising: comprise a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the edge detection method based on the improved loss function in any one of claims 1-4 when executing the computer program.

8. A non-transitory computer-readable storage medium, comprising: The non-transitory computer readable storage medium stores computer instructions, and the computer instructions cause the computer to execute the edge detection method based on the improved loss function in any one of claims 1-4.

Citation Information

Patent Citations

  • High-resolution remote sensing image plane extraction method based on skeleton characteristic

    CN102004922B

  • Edge detection method, edge detection device and computer readable storage medium

    CN114255253B

  • Edge Detection Method and Device Based on Bidirectional Feature Supervision

    CN116205938B

  • Transfomer-based edge detection method

    CN119399230A

  • Image edge detection method and device, equipment and storage medium

    CN120235900A