Industrial part image edge detection method based on improved EdgeNAT network
By improving the EdgeNAT network and introducing a multi-scale edge enhancement module and a saliency guidance mechanism, the problems of insufficient local feature perception and inadequate multi-scale fusion in industrial part inspection are solved, improving the accuracy and robustness of edge detection and making it suitable for complex backgrounds and real-time detection.
Patent Information
- Application Number
- CN202511622407.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-01-30
Smart Images

Figure CN121437474A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and intelligent inspection technology, and in particular to an image edge detection method for industrial parts based on an improved EdgeNAT network. Background Technology
[0002] Image edge detection, as a fundamental task in computer vision, aims to accurately extract object boundaries and significant visual edge information from input images, providing crucial information for subsequent image segmentation, object recognition, measurement, and matching.
[0003] Traditional edge detection algorithms (such as Canny and Sobel) primarily rely on pixel-level gradients and local texture changes. While computationally simple, they are poorly robust to lighting variations, complex background textures, and blurred boundaries. With the development of deep learning, edge detectors based on convolutional neural networks (CNNs) (such as HED and RCF) can improve edge detection performance by expanding the receptive field to learn global semantic information. However, the local convolutional nature of CNN structures limits their performance in handling long-range dependencies, making it difficult to balance detail and global consistency.
[0004] In recent years, the Transformer architecture has been widely used in image classification, detection, and segmentation due to its powerful global modeling capabilities. However, the original VisionTransformer (ViT) lacks a hierarchical structure, and its direct application to edge detection leads to the loss of feature details. To address this issue, existing research, such as EDTER, has introduced a two-stage Transformer framework to combine global and local features. However, this design is computationally intensive and has a slow inference speed, making it difficult to apply to real-time detection scenarios.
[0005] Therefore, there is an urgent need for an efficient detection method that can enhance local detail perception, reduce computational complexity, and achieve multi-scale edge consistency while maintaining the advantages of global features of the Transformer. We propose an image edge detection method for industrial parts based on an improved EdgeNAT network to address these issues. Summary of the Invention
[0006] (a) Technical problems to be solved
[0007] This invention addresses the following technical problems of existing image edge detection methods in industrial part inspection scenarios: Insufficient local feature perception capability: Traditional convolutional neural network (CNN) structures have limited ability to extract long-distance dependent features, making it difficult to simultaneously consider global semantic information and detailed edge features, resulting in blurred boundaries and missing details in complex backgrounds; Insufficient multi-scale edge feature fusion: Existing edge detection networks based on the Transformer structure lack effective multi-scale feature enhancement and fusion mechanisms, resulting in information fragmentation between features at different levels and affecting edge localization accuracy; Lack of saliency guidance mechanism: Most methods do not introduce an edge saliency guidance mechanism, failing to fully utilize low-level high-resolution features to guide the edge response of high-level semantic features, leading to insufficient detection capability for small targets and weak boundaries. To address the shortcomings of existing technologies, this invention provides an industrial part image edge detection method based on an improved EdgeNAT network. By introducing a multi-scale edge enhancement (MEE) module and a saliency guidance mechanism, it effectively improves edge detection accuracy and computational efficiency while ensuring the global modeling capability of the Transformer; thus solving the problems mentioned in the background technology.
[0008] (II) Technical Solution
[0009] To achieve the above objectives, the present invention specifically adopts the following technical solution:
[0010] An image edge detection method for industrial parts based on an improved EdgeNAT network, comprising the following steps:
[0011] S1: Construct an industrial parts image dataset: A dataset is built based on BSDS500 industrial parts sample images and a self-built dataset. After data augmentation, the images are used to generate standardized labeled samples for training.
[0012] S2: Constructing an improved EdgeNAT-MEE network model: Based on EdgeNAT, the network structure is built and includes three main functional modules: DiNAT coding module, MEE multi-scale edge enhancement module, and SCAF-MLA decoding module;
[0013] A MEE multi-scale edge enhancement module is introduced between the DiNAT encoding module and the SCAF-MLA decoding module. The MEE multi-scale edge enhancement module adopts a multi-scale convolutional structure and a dynamic dilation rate mechanism to enhance the feature maps at different levels, forming the EdgeNAT-MEE model.
[0014] S3: Performance evaluation of the trained model: The EdgeNAT-MEE model is optimized using a composite loss function, and then trained using an enhanced image dataset. The model performance is evaluated using ODS, OIS, AP and GFLOPs metrics, and the optimal weights are selected.
[0015] S4: Testing and Validation: The trained EdgeNAT-MEE model is validated using a partitioned test set. The output stage of the EdgeNAT-MEE model includes a saliency generation module (ESG-S). Based on the fused features output by the SCAF-MLA decoding module, a saliency probability map is generated through convolution, channel compression, and activation functions. Subsequently, the edge probability map is processed by thresholding and non-maximum suppression (NMS) edge refinement units to obtain the final object edge contour map. This is used to evaluate the accuracy and robustness of the EdgeNAT-MEE model in industrial part dimension measurement tasks.
[0016] Furthermore, the image data enhancement processing in S1 includes, but is not limited to, geometric transformations such as random rotation, scaling, flipping, and translation; and illumination enhancement with brightness, contrast, and color perturbations. These enhancement methods improve the robustness of edge detection in complex backgrounds, blurred edges, and multi-scale scenes without destroying the original edge topology.
[0017] Furthermore, the network structure improvements of the EdgeNAT-MEE model in S2 include:
[0018] (1) A MEE module is introduced between the DiNAT encoding module and the SCAF-MLA decoding module. Combining multi-scale convolutional feature extraction and neighborhood attention mechanism, while maintaining the contextual capabilities provided by the DiNAT encoding module, the response of the edge at different scales is enhanced, low-level detail information is preserved, and edge saliency guidance is injected into high-level semantic features to improve the edge localization accuracy and the detection capability of blurry or small targets. Spatial weighting and context enhancement are performed in the fusion stage, so that the edge response is adaptively optimized in both spatial and scale dimensions.
[0019] (2) Subsequently, edge saliency-guided ESG-G is introduced after input to the MEE multi-scale edge enhancement module. The role of ESG-G is to generate saliency edge maps using low-level high-resolution features. It is then downsampled and used to guide high-level feature enhancement, thereby preserving the low-level details in the high-level response;
[0020] Generate low-level saliency maps: from input start:
[0021]
[0022] in The function maps the convolution output to the range of 0-1 to obtain the edge probability or saliency weight of each pixel, thus forming an edge saliency map; express Convolution; For activation functions; Represents the learnable parameters of the convolutional layer; The spatial dimensions of the feature map are height × width:
[0023] For target layer i: and The resolution may differ, Downsampling / Upsampling Matching Dimensions;
[0024]
[0025] Where: Resize represents the "size adjustment" spatial resampling operation, used to resize the global saliency map. Adjusted to match the i-th feature map Consistent in size; This represents the height and width of the feature map at layer i;
[0026] Guidance mechanism: multiplicative enhancement or additive enhancement—commonly multiplicative form: stronger modulation effect:
[0027]
[0028] in This means "multiplying by corresponding positions", that is, multiplying the values at corresponding positions in the matrix; This is the scaling factor; if weighted by channel, it can be expanded to:
[0029]
[0030] Projecting S onto the channel dimension compensates for channel differences; if If the value is close to 1 at a certain position, the features of each channel at that position are enhanced; if it is close to 0, the original feature intensity is maintained at that position.
[0031] in: Indicates channel dimension mapping or projection operation;
[0032] (3) For a certain layer of input The MEE module contains M parallel scale branches, each branch employing a convolutional kernel. With expansion rate The m-th branch performs the following transformation:
[0033] Channel compression:
[0034] ,
[0035] Where M is the number of multi-scale branches, usually M=3, and the branch index is... r represents the channel compression ratio. For example, r=4 indicates that the intermediate bottleneck channel is compressed to a certain value. .
[0036] Furthermore, in the MEE multi-scale edge enhancement module, multiple convolutional branches with different receptive fields are used to extract edge features at different scales. Small convolutional kernels + small dilation rate → capture fine edge details; large convolutional kernels + large dilation rate → capture coarse structural contours, resulting in multiple sets of features at different "scales". However, these features are distributed on different channels and the scale information is inconsistent. Therefore, a normalized residual fusion unit (NRF) is constructed in the MEE multi-scale edge enhancement module.
[0037] The output of the M branches of layer i is Scale fusion generally includes the steps of stitching, dimensionality reduction, and residual fusion.
[0038] Step 1: Channel splicing:
[0039]
[0040] Step 2: Dimensionality Reduction and Fusion convolution:
[0041]
[0042] Step 3: Residual connection and normalization:
[0043]
[0044] Concat refers to fusing contextual information from different scales into the same feature space; This represents the output feature map of the m-th convolutional branch; C represents the number of channels (feature depth) in each layer. This represents the feature representation after dimensionality reduction and fusion. Convolution acts as a "weighted integration" and "channel compression" mechanism, essentially learning the importance of each scale. This represents the tensor resulting from concatenating all branch channels; express The weight parameters of the convolution are used for channel dimensionality reduction and fusion; This represents the final enhanced feature output after fusion and normalization; LayerNorm indicates that the layer normalization operation makes the feature distribution smoother, avoiding training instability caused by amplitude differences at different scales. This represents the scaling factor for residual fusion.
[0045] Furthermore, in S3, a composite loss function containing multiple loss terms is used to optimize the EdgeNAT-MEE model. This loss function consists of the main edge detection loss, edge consistency loss, saliency fidelity loss, and multi-scale supervision loss, and its mathematical expression is as follows:
[0046]
[0047] Among them: main edge detection loss Defined as the weighted binary cross-entropy between the output edge probability map and the ground truth labeled edge map: ; This represents the final edge prediction map output by the main decoding module; This represents the middle edge prediction map output by the i-th scale branch;
[0048] in: Marginal probabilities output by the model; Real edge label; , : Weights of edge and non-edge pixels; M: Total number of pixels;
[0049] Edge consistency loss Defined as a consistency constraint among multi-scale predictions, its formula is:
[0050]
[0051] in: Marginal probability plot of the main branch output; : Convolution mapping; L1 norm: used to measure differences between scales;
[0052] Significant fidelity loss Defined as the Euclidean distance between the saliency-guided feature and the true margin:
[0053]
[0054] in: : A saliency feature map generated by the saliency guiding unit (ESG); L2 norm squared, used to measure the difference between predicted significance and the true margin; each coefficient , , , The loss weights are used to balance the contributions of each factor to model optimization. Through experimental analysis and debugging, this invention selects the following coefficients for the optimal condition: , , , .
[0055] Furthermore, S3 includes training the image dataset of industrial parts after image enhancement to optimize the parameters of the EdgeNAT-MEE model;
[0056] During training, the model performance is evaluated by setting multiple metrics, including ODS, OIS, AP, and GFLOPs. Based on the combined results of these metrics, the optimal weight parameters are automatically selected to achieve a balance between edge detection accuracy and computational efficiency. The specific formula is as follows:
[0057]
[0058] in, ; The F-measure for the i-th image at threshold t; N: total number of images in the test set;
[0059]
[0060]
[0061] Where L is the number of network layers; , This is the input / output channel for layer l; The kernel size; , The feature map size; .
[0062] Furthermore, the output stage of the S4 model includes a saliency generation module ESG-S, which generates a saliency probability map based on the fused features output by the SCAF-MLA decoding module through convolution, channel compression, and activation functions, thereby performing probabilistic modeling and saliency supervision of edge regions. The saliency generation module ESG-S comprises sequentially connected local convolutional units, channel compression units, and activation mapping units. The algorithm flow includes:
[0063]
[0064]
[0065]
[0066] In the formula, for Convolution operators are used to extract local textures and edge responses; for Convolution operators are used for channel compression and feature mapping; The Sigmoid activation function is used to normalize the output to... Intervals are used to form a significance probability plot;
[0067] The significance probability graph Supervised optimization is performed between the ground truth edge labels (GT) and the target ground truth (Ground Truth) using a saliency-fidelity loss function, which is defined as follows:
[0068]
[0069] in, This indicates that the actual label size will be adjusted to match... Consistent operation; through the By minimizing the edge size, the network can adaptively learn the saliency distribution characteristics of industrial parts edges, thereby improving the positioning accuracy and robustness of edge detection results.
[0070] Furthermore, S4 includes validating the trained EdgeNAT-MEE model using a partitioned test set by extracting continuous and refined object edge contours from the edge probability map output by the model through thresholding and non-maximum suppression algorithm, and using this as the basis for evaluating the accuracy and robustness of the model in industrial part size measurement tasks.
[0071] Non-maximum suppression algorithm (NMS) for marginal probability maps First calculate the gradient , Thus, the amplitude is obtained. With direction For each pixel The amplitudes on both sides are sampled using bilinear interpolation along the gradient direction. If satisfied and and If the pixel is not an edge, it is retained; otherwise, it is suppressed. When using the dual-threshold hysteresis strategy, connectivity detection is further performed on pixels between the high and low thresholds to determine whether to retain them.
[0072] (III) Beneficial Effects
[0073] Compared with existing technologies, this invention provides a method for edge detection of industrial parts images based on an improved EdgeNAT network, which has the following advantages:
[0074] This invention introduces a multi-scale edge enhancement module (MEE) into the EdgeNAT network. Combined with a neighborhood attention mechanism, it employs a multi-branch convolutional structure with different receptive fields (3×3, dilation rate d=1 / 2 / 4) to simultaneously capture both fine edges and coarse contour information. An edge saliency guidance unit (ESG-G) is embedded within the MEE multi-scale edge enhancement module. This unit guides the edge responses of different levels of features by utilizing salient edge maps generated from shallow features of the DiNAT coding module, injecting salient edge information into the feature maps of the corresponding levels, thus achieving multi-scale fusion of low-level information and high-level semantics. By introducing the MEE multi-scale edge enhancement module into features of different levels, edge saliency injection and multi-scale feature enhancement are achieved, innovatively strengthening edge responses at each scale and further enhancing the innovation and edge preservation capabilities of the overall network structure design.
[0075] This invention employs a Normalized Residual Fusion Unit (NRF) to perform channel stitching, dimensionality reduction, and weighted fusion of multi-scale features, maintaining the consistency of edge responses at different scales. The residual structure of the NRF preserves the original feature information, while LayerNorm normalization avoids amplitude differences between scales. The method of this invention can take into account both the global structure and local details of the image, ensuring that the edge detection results remain consistent across multiple scales, and improving the global integrity and local precision of the edge response.
[0076] This invention utilizes a low-level high-resolution feature generation module (ESG-S) to generate salient edge maps, and then downsamples them to guide high-level feature enhancement. This salient guidance mechanism can highlight edge region features and effectively enhance the detection capability for weak and complex edges. Combined with the multi-layer aggregation of the Spatial-Channel Attention Fusion Decoding Module (SCAF-MLA), this invention can reconstruct high-resolution edge maps layer by layer, significantly improving the fineness and localization accuracy of edge maps, and significantly improving the shortcomings of traditional Transformer structures in local edge fidelity.
[0077] This invention significantly improves detection robustness in complex backgrounds and multi-target scenarios while maintaining high-speed inference through comprehensive data augmentation strategies (random rotation, scaling, flipping, lighting perturbation, etc.) and efficient network design. Furthermore, through evaluation and optimization of indicators such as ODS, OIS, AP, and GFLOPs, the model maintains high-precision edge extraction capabilities while possessing high inference speed, meeting the real-time application needs of online inspection and dimensional measurement of industrial parts, and has strong practical value. Attached Figure Description
[0078] Figure 1 This is an overall flowchart of an industrial part image edge detection method based on an improved EdgeNAT network according to the present invention.
[0079] Figure 2 This is a schematic diagram of the network structure of the EdgeNAT-MEE improved model of the present invention;
[0080] Figure 3 This is a schematic diagram of the structure of the MEE multi-scale edge enhancement module of the present invention;
[0081] Figure 4 This is a schematic diagram of the normalized residual fusion unit (NRF) structure of the present invention;
[0082] Figure 5 This is a schematic diagram of the saliency generation module ESG-S of the present invention;
[0083] Figure 6 This is a bar chart comparing the accuracy of the present invention with the original EdgeNAT model across multiple performance metrics. Detailed Implementation
[0084] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0085] Example
[0086] like Figure 1 and Figure 2 As shown in the figure, an embodiment of the present invention proposes an image edge detection method for industrial parts based on an improved EdgeNAT network, which mainly includes the following steps:
[0087] Step 1: Construct an industrial parts image dataset:
[0088] A dataset was established based on BSDS500 industrial parts sample images and a self-built dataset. After data augmentation, the images were used to generate standardized labeled samples for training. The original images were mainly derived from publicly available data resources on the Internet.
[0089] To enhance the model's generalization ability and robustness in complex scenes, various enhancement methods were introduced during the construction of the image dataset. These enhancement methods include, but are not limited to, geometric transformations such as random rotation, scaling, flipping, and translation; and illumination enhancement with brightness, contrast, and color perturbations. These enhancement strategies significantly improved the model's edge detection robustness in complex backgrounds, blurred edges, and multi-scale scenes without disrupting the original edge topology.
[0090] After image augmentation, the LabelMe tool was used to annotate bounding boxes and class labels on all images, resulting in a training dataset of 5000 training samples, consisting of 1000 original images and 4000 augmented images, providing ample data support for subsequent model training.
[0091] Step 2: Construct the improved EdgeNAT-MEE network model:
[0092] Based on the original EdgeNAT network, the following structural improvements are mainly introduced, including:
[0093] By introducing a MEE multi-scale edge enhancement module between the DiNAT encoding module and the SCAF-MLA decoding module, edge saliency injection and multi-scale fusion of features at each layer are achieved.
[0094] In the output stage, a saliency generation module (ESG-S) is set up. This module generates an edge saliency probability map based on the features of the shallow DiNAT coding module, and processes the edge probability map through thresholding and non-maximum suppression (NMS) to obtain the final object edge contour.
[0095] (1) Introduce MEE multi-scale edge enhancement module
[0096] like Figure 3 As shown, the MEE multi-scale edge enhancement module consists of M parallel scale branches, each of which uses a convolutional structure with different convolutional kernels and dilation rates for processing.
[0097] First, edge saliency-guided ESG-G is introduced after the input to the MEE multi-scale edge enhancement module. The role of ESG-G is to generate saliency edge maps using low-level high-resolution features. It is then downsampled and used to guide high-level feature enhancement, thereby preserving the low-level details in the high-level response;
[0098] Generating low-level saliency maps: from start:
[0099]
[0100] in The function maps the convolution output to the range of 0-1 to obtain the edge probability or saliency weight of each pixel, thus forming an edge saliency map; express Convolution; For activation functions; Represents the learnable parameters of the convolutional layer; Indicates the spatial dimensions (height × width) of the feature map.
[0101] For target layer i: and The resolution may differ, Downsampling / Upsampling Matching Dimensions;
[0102]
[0103] Where: Resize represents the "sizing (spatial resampling)" operation, used to resize the global saliency map. Adjusted to match the i-th feature map Consistent in size; This represents the height and width of the feature map at layer i.
[0104] Guidance mechanism: multiplicative enhancement or additive enhancement—commonly multiplicative form: stronger modulation effect:
[0105]
[0106] in This means "multiplying by corresponding positions", that is, multiplying the values at corresponding positions in the matrix; This is the scaling factor; if weighted by channel, it can be expanded to:
[0107]
[0108] Projecting S onto the channel dimension compensates for channel differences; if If the value is close to 1 at a certain position, the features of each channel at that position are enhanced; if it is close to 0, the original feature intensity is maintained at that position.
[0109] in: This indicates a channel dimension mapping or projection operation.
[0110] (3) For a certain layer of input The MEE module contains M parallel scale branches, each branch employing a convolutional kernel. With expansion rate The m-th branch performs the following transformation:
[0111] Channel compression:
[0112] ,
[0113] Where M is the number of multi-scale branches, usually M=3, and the branch index is... r represents the channel compression ratio. For example, r=4 indicates that the intermediate bottleneck channel is compressed to a certain value. .
[0114] Subsequently, multiple convolutional branches with different receptive fields are used to extract edge features at different scales. For example, a small convolutional kernel with a small dilation rate captures fine edge details; a large convolutional kernel with a large dilation rate captures coarse structural contours, resulting in multiple sets of features at different "scales." However, these features are distributed across different channels, and the scale information is inconsistent. Figure 4 A normalized residual fusion unit (NRF) was constructed in the MEE multi-scale edge enhancement module.
[0115] The output of the M branches of layer i is Scale fusion generally includes the steps of stitching, dimensionality reduction, and residual fusion.
[0116] Step 1: Channel splicing:
[0117]
[0118] Step 2: Dimensionality Reduction and Fusion convolution:
[0119]
[0120] Step 3: Residual connection and normalization:
[0121]
[0122] Concat refers to fusing contextual information from different scales into the same feature space; This represents the output feature map of the m-th convolutional branch; C represents the number of channels (feature depth) in each layer. This represents the feature representation after dimensionality reduction and fusion. Convolution acts as a "weighted integration" and "channel compression" mechanism, essentially learning the importance of each scale. This represents the tensor resulting from concatenating all branch channels; express The weight parameters of the convolution are used for channel dimensionality reduction and fusion; This represents the final enhanced feature output after fusion and normalization; LayerNorm indicates that the layer normalization operation makes the feature distribution smoother and avoids training instability caused by amplitude differences at different scales. This represents the scaling factor for residual fusion.
[0123] Step 3: Testing and Performance Evaluation
[0124] First, the EdgeNAT-MEE model is optimized using a composite loss function containing multiple loss terms. The loss function consists of the main edge detection loss, edge consistency loss, saliency fidelity loss, and multi-scale supervision loss, and its mathematical expression is as follows:
[0125]
[0126] Among them: main edge detection loss Defined as the weighted binary cross-entropy between the output edge probability map and the ground truth labeled edge map: ; This represents the final edge prediction map output by the main decoding module; This represents the intermediate edge prediction map output by the i-th scale branch.
[0127] in: Marginal probabilities output by the model; Real edge label; , : Weights of edge and non-edge pixels; M: Total number of pixels;
[0128] Edge consistency loss Defined as a consistency constraint among multi-scale predictions, its formula is:
[0129]
[0130] in: Marginal probability plot of the main branch output; : Convolution mapping; L1 norm: used to measure differences between scales;
[0131] Significant fidelity loss Defined as the Euclidean distance between the saliency-guided feature and the true margin:
[0132]
[0133] in: : A saliency feature map generated by the saliency guiding unit (ESG); L2 norm squared, used to measure the difference between predicted significance and the true margin; each coefficient , , , The loss weights are used to balance the contributions of each factor to model optimization. Through experimental analysis and debugging, this invention selects the following coefficients for the optimal condition: , , , .
[0134] The EdgeNAT-MEE model was then trained. After training, the trained weights were applied to a pre-defined test set to validate the overall performance of the EdgeNAT-MEE model. Evaluation metrics included ODS (Optimal Dataset Scale), OIS (Optimal Image Scale), AP (Average Precision), and GFLOPs (Giga Floating-point Operations), among others, to assess model performance. Based on the combined results of these metrics, the optimal weight parameters were automatically selected to achieve a balance between edge detection accuracy and computational efficiency. The specific formula is as follows:
[0135] in, ; is the F-measure for the i-th image at threshold t; N: the total number of images in the test set.
[0136]
[0137]
[0138] Where L is the number of network layers; , This is the input / output channel for layer l; The kernel size; , The feature map size;
[0139] like Figure 6 As shown in the test results, EdgeNAT-MEE achieves a significant performance improvement compared to the original EdgeNAT model while maintaining a low inference latency.
[0140] from Figure 6 It can be seen that the EdgeNAT-MEE model of this invention significantly outperforms traditional models in all three accuracy metrics: ODS, OIS, and AP, with an average improvement of approximately 4.5%-7%, while the computational complexity increases slightly, demonstrating the effectiveness of the multi-scale feature enhancement and saliency guidance mechanism. It reduces GFLOPs by approximately 3%, and the reduction is even more pronounced when using a lightweight version with a higher channel ratio, while still maintaining high detection performance, indicating that this invention has good scalability and engineering applicability.
[0141] S4: Testing and Validation: The trained EdgeNAT-MEE model is validated using a partitioned test set. The output stage of the EdgeNAT-MEE model includes a saliency generation module (ESG-S). Based on the fused features output by the SCAF-MLA decoding module, a saliency probability map is generated through convolution, channel compression, and activation functions. Subsequently, the edge probability map is processed by thresholding and non-maximum suppression (NMS) edge refinement units to obtain the final object edge contour map. This is used to evaluate the accuracy and robustness of the EdgeNAT-MEE model in industrial part dimension measurement tasks.
[0142] (1) Saliency generation module ESG-S, such as Figure 5 It is used to generate a saliency probability map based on the fused features output by the SCAF-MLA decoding module through convolution, channel compression, and activation functions, thereby performing probabilistic modeling and saliency supervision of edge regions; the saliency generation module ESG-S includes sequentially connected local convolutional units, channel compression units, and activation mapping units, and the algorithm flow includes:
[0143]
[0144]
[0145]
[0146] In the formula, for Convolution operators are used to extract local textures and edge responses; for Convolution operators are used for channel compression and feature mapping; The Sigmoid activation function is used to normalize the output to... Intervals are used to form a significance probability plot;
[0147] The significance probability graph Supervised optimization is performed between the ground truth edge labels (GT) and the target ground truth (Ground Truth) using a saliency-fidelity loss function, which is defined as follows:
[0148]
[0149] in, This indicates that the actual label size will be adjusted to match... Consistent operation; through the By minimizing the edge size, the network can adaptively learn the saliency distribution characteristics of industrial parts edges, thereby improving the positioning accuracy and robustness of edge detection results.
[0150] (2) Non-maximum suppression algorithm (NMS):
[0151] To further improve the accuracy and continuity of edge detection results, after the edge probability map generated by the EdgeNAT-MEE model, the Non-Maximum Suppression (NMS) algorithm is introduced to refine the edge response. The NMS algorithm refines the edge probability map. First calculate the gradient , Thus, the amplitude is obtained. With direction For each pixel The amplitudes on both sides are sampled using bilinear interpolation along the gradient direction. If satisfied and and If the pixel is not an edge, it is retained; otherwise, it is suppressed. When using the dual-threshold hysteresis strategy, connectivity detection is further performed on pixels between the high and low thresholds to determine whether to retain them.
[0152] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An image edge detection method for industrial parts based on improved EdgeNAT network, characterized in that, The steps are as follows: S1: Constructing an industrial part image dataset: Based on the BSDS500 industrial part sample images and the self-built dataset, the standardized labeled samples for training are generated after data enhancement processing; S2: Constructing an improved EdgeNAT-MEE network model: Based on the EdgeNAT network structure, the overall model includes three main functional modules: DiNAT encoding module, MEE multi-scale edge enhancement module, and SCAF-MLA decoding module; The MEE multi-scale edge enhancement module is introduced between the DiNAT encoding module and the SCAF-MLA decoding module, which uses a multi-scale convolution structure and a dynamic expansion rate mechanism to enhance feature maps at different levels, forming an EdgeNAT-MEE model; S3: Training model performance evaluation: The EdgeNAT-MEE model is optimized using a composite loss function, then trained using the enhanced image dataset, and the model performance is evaluated by ODS, OIS, AP, and GFLOPs indicators, and the optimal weight is selected; S4: Test verification: The EdgeNAT-MEE model is verified using the test set, and the output stage of the EdgeNAT-MEE model is equipped with an ESG-S significant generation module, which generates a significant probability map based on the fusion features output by the SCAF-MLA decoding module, then processes the edge probability map through thresholding and non-maximum suppression NMS edge refinement unit to obtain the final object edge contour map; used to evaluate the accuracy and robustness of the EdgeNAT-MEE model in industrial part size measurement tasks.
2. The method for image edge detection of industrial parts based on improved EdgeNAT network according to claim 1, characterized in that: The enhancement method of the image data enhancement processing in S1 includes but is not limited to random rotation, scaling, flipping and translation geometric transformation; Lighting enhancement of brightness, contrast and color disturbance, the enhancement method does not destroy the original edge topology structure, and improves the edge detection robustness of the model in complex background, fuzzy edge and multi-scale scene.
3. The method of claim 1, wherein the method is based on an improved EdgeNAT network for image edge detection of industrial parts. The network structure improvement of the EdgeNAT-MEE model in S2 includes: (1) Introducing MEE module between DiNAT encoding module and SCAF-MLA decoding module, combining multi-scale convolution feature extraction and neighborhood attention mechanism, while maintaining the context ability given by DiNAT encoding module, strengthening the response of edges at different scales, preserving low-level detail information and injecting edge saliency guidance into high-level semantic features, improving edge positioning accuracy and detection ability of fuzzy or small targets, and performing spatial weighting and context enhancement in the fusion stage, so that the edge response is adaptively optimized in space and scale dimensions; (2) Then introduce edge saliency guidance ESG-G after inputting MEE multi-scale edge enhancement module, the role of ESG-G: use low layer high resolution features to generate saliency edge map And use it to guide high layer feature enhancement after downsampling, so as to retain low layer details in high layer response; Generating a low-level saliency map: From the input beginning: wherein The function maps the convolution output to a 0-1 range, resulting in an edge probability or saliency weight for each pixel, thus forming an edge saliency map; denotes convolution; is an activation function; denotes the learnable parameters of the convolution layer; denotes the spatial dimensions height x width of the feature map; For target layer i: with resolution can be different, will down / up sampling match size; wherein: Resize denotes a "size adjustment" spatial resampling operation for adjusting the global saliency map to the i-th feature map to the i-th feature map denotes the height and width of the i-th layer feature map Guiding mechanism: multiplicative enhancement or additive enhancement - commonly used multiplicative form: stronger modulation effect: wherein denotes "multiplication of corresponding positions", i.e. multiplication of the values in the corresponding positions of the matrices; is a scaling factor; if weighting per channel is applied, it can be extended as S is projected to the channel dimension and added to compensate for channel difference; if If the value is close to 1, the feature of each channel at this position is enhanced; if the value is close to 0, the original feature intensity is maintained. wherein: represents a channel dimension mapping or projection operation; (3) For a certain layer input The MEE module includes M parallel scale branches, and each branch uses a convolution kernel and a dilation rate The mth branch performs the following transformation: Channel compression: , Wherein, M is the number of multi-scale branches, usually M = 3, branch index r is the channel compression ratio, for example r = 4, indicating that the intermediate bottleneck channel is .
4. The method of claim 3, wherein the method is based on an improved EdgeNAT network for image edge detection of industrial parts. In the MEE multi-scale edge enhancement module, a plurality of convolution branches with different receptive fields are used to extract edge features of different scales, small convolution kernel + small dilation rate → capture small edge details; large convolution kernel + large dilation rate → capture coarse structure outline, obtain a plurality of features with different "scales"; but these features are distributed in different channels, and the scale information is inconsistent, so a normalized residual fusion unit NRF is constructed in the MEE multi-scale edge enhancement module; The M branch outputs of layer i are ; scale fusion generally includes the steps of stitching, dimension reduction and residual fusion: Step 1: channel splicing: Step 2: Dimensionality reduction and fusion Convolution: Step 3: residual connection and normalization: where Concat means to fuse the context information of different scales into the same feature space; represents the output feature map of the mth convolution branch; C represents the channel number feature depth of each layer; represents the feature representation after dimension reduction and fusion; Convolution plays a role of "weighted integration" and "channel compression", which is equivalent to learning the importance of each scale; represents the tensor after splicing all branch channels; represents the weight parameter of convolution, used for channel dimension reduction and fusion; represents the final enhanced feature output after fusion and normalization; LayerNorm represents the layer normalization operation to make the feature distribution smoother, avoiding training instability caused by the difference in amplitude of different scales, represents the scaling factor of residual fusion.
5. The method for image edge detection of industrial parts based on improved EdgeNAT network according to claim 3, characterized in that: In S3, the EdgeNAT-MEE model is optimized by using a composite loss function including multiple loss terms, and the loss function is composed of a main edge detection loss, an edge consistency loss, a saliency fidelity loss and a multi-scale supervision loss, and the mathematical expression is as follows: wherein: main edge detection loss is defined as the weighted binary cross-entropy between the output edge probability map and the ground-truth edge map: ; denotes the final edge prediction map output by the main decoding module; denotes the intermediate edge prediction map output by the i-th scale branch. wherein: : edge probability output by the model; : true edge label; , : weight of edge, non-edge pixel; M: total number of pixels; Edge consistency loss defined as a consistency constraint between multi-scale predictions, whose formula is: wherein: : edge probability map output by the main branch; : convolution mapping; : L1 norm, used to measure the difference between scales; salience fidelity loss defined as the euclidean distance between the salient guided features and the true edges: Wherein: : saliency feature map generated by saliency guidance unit (ESG); : L2 norm square, used to measure the difference between predicted saliency and real edge; each coefficient , , , is a loss weight, used to balance the contribution of each item to model optimization, and through experimental analysis and debugging, each coefficient is selected as follows in the optimal case of the present application: , , , .
6. The method for image edge detection of industrial parts based on improved EdgeNAT network according to claim 1, wherein: S3 includes training the industrial part image data set after image enhancement processing to optimize the parameters of the EdgeNAT-MEE model; In the training process, the performance of the model is evaluated by setting multiple indicators such as ODS, OIS, AP and GFLOPs, and the optimal weight parameter is automatically selected according to the comprehensive results of the above indicators to balance and optimize the edge detection accuracy and computational efficiency, and the specific formula is as follows: wherein, ; F-measure at threshold t for the i-th image; N: total number of test set images; Wherein, L is the network layer number; 、 is the input / output channel of the lth layer; is the convolution kernel size; 、 is the feature map size; .
7. The method for image edge detection of industrial parts based on improved EdgeNAT network according to claim 1, characterized in that: The output stage of the S4 model is provided with a saliency generation module ESG-S, which is used to generate a saliency probability map by convolution, channel compression and activation function on the basis of the fusion features output by the SCAF-MLA decoding module, so as to probabilistically model the edge region and perform saliency supervision; The saliency generation module ESG-S includes sequentially connected local convolution units, channel compression units and activation mapping units, and the algorithm process includes: wherein, is a convolution operator for extracting local texture and edge responses; is a convolution operator for channel compression and feature mapping; is a Sigmoid activation function for normalizing the output to the interval to form a saliency probability map; The saliency probability map is supervised by the ground truth GT through saliency fidelity loss function, whose loss function is defined as: wherein, represents the operation of adjusting the real label size to be consistent with ; through the minimization of , the network can adaptively learn the saliency distribution characteristics of the edge of the industrial part, thereby improving the positioning accuracy and robustness of the edge detection result.
8. The method for image edge detection of industrial parts based on improved EdgeNAT network according to claim 1, wherein: S4 includes verifying the trained EdgeNAT-MEE model by using the divided test set, extracting continuous and refined object edge contours by thresholding and non-maximum suppression algorithm NMS on the edge probability map output by the model, and taking the edge contours as the basis for evaluating the accuracy and robustness of the model in the industrial part size measurement task; Non-maximum suppression algorithm NMS on edge probability map First compute gradient , , thus get magnitude and direction ; for each pixel sample the magnitude on both sides by bilinear interpolation in the gradient direction , if and and , then keep the pixel as edge, otherwise suppress; when using double thresholding strategy, further perform connectivity detection on pixels between high and low thresholds to decide whether to keep or not.