Image vectorization method and system based on deep learning and edge detection

By constructing a dual-branch structure model based on SimAM and CBAM attention mechanisms, combining Canny edge priors and non-maximum suppression, the edge detection model is optimized, and the edge detection accuracy problem of traditional image vectorization algorithms in the image processing of home appliance modules is solved, and efficient and accurate vectorization processing is achieved.

CN120580309APending Publication Date: 2025-09-02OCEAN UNIV OF CHINA
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510648099.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

When traditional image vectoring algorithms process pictures of home appliance modules, it is difficult to accurately identify complex backgrounds and fine edges. In addition, deep learning has high computational complexity in image vectoring pre-processing, and noise sensitivity leads to false detection and missed detection of edge detection results, affecting the quality of vectoring processing.

Method used

The dual-branch structure model was constructed using SimAM and CBAM attention mechanisms, combined with Canny edge prior and non-maximum suppression, and transformed edge information into vector graphics through multiple sets of Canny threshold detection and Potrace algorithms, optimized the edge detection model and generated DXF files.

Benefits of technology

It improves the accuracy and completeness of edge detection, generates high-precision and low-noise vector graphics, and meets the rapid iteration needs of secondary development of home appliance modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580309A_ABST
    Figure CN120580309A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of images, in particular to an image vectorization method and system based on deep learning and edge detection, and the method comprises the steps: obtaining image data of a household appliance module, and carrying out the preprocessing of the obtained image data; taking the preprocessed image data as input to construct an edge detection model, performing optimization processing on an edge probability graph output by the edge detection model, performing edge detection on the preprocessed image data in sequence to generate multiple groups of edge graphs, and performing average processing on the multiple groups of edge graphs to obtain a comprehensive edge image; the optimized marginal probability graph and the comprehensive marginal image serve as input, marginal information is converted into a vector graph, a DXF file is obtained, the optimized marginal probability graph and the comprehensive marginal image serve as input, vectorization conversion is conducted through the Potrace algorithm, optimization processing on the marginal detection result in the early stage is combined, and the edge detection efficiency is improved. Vector graphs with higher precision and less noise can be generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image technology, and in particular to an image vectorization method and system based on deep learning and edge detection. Background Art

[0002] As an important branch of the manufacturing industry, the home appliance industry is in the midst of a wave of rapid change and innovation. With the increasingly fierce global market competition, the secondary development of home appliance modules has become a key link in improving product competitiveness. Converting home appliance module images into DXF design files is a core prerequisite task in the secondary development process.

[0003] Traditional image vectorization algorithms have significant drawbacks. Limited by their principles, they struggle to accurately identify and extract target edges when processing images of home appliance modules with complex backgrounds and fine edges. Despite significant advances in image processing, deep learning has not been widely applied in the pre-processing stages of image vectorization. Existing deep learning-based image processing techniques are generally cumbersome, involving numerous complex computational and data processing steps. This significantly increases computational complexity, resulting in low processing efficiency and hindering the full potential of deep learning in image feature extraction. For time- and resource-constrained secondary development of home appliance modules, this inefficient approach struggles to meet the demands of rapid iteration and efficient production. Furthermore, traditional edge detection algorithms are extremely sensitive to noise. The acquisition and transmission of home appliance module images inevitably introduces noise, such as electronic noise during capture and data interference during transmission. This subtle noise can lead to numerous false positives and missed detections in edge detection results, significantly compromising the accuracy of the acquired edge information and severely impacting the quality of subsequent vectorization. Therefore, a method and system for image vectorization based on deep learning and edge detection is needed. Summary of the Invention

[0004] In order to solve the problem that the quality of image vectorization processing is affected by the low accuracy of edge detection in traditional image vectorization algorithms, the present invention provides an image vectorization method and system based on deep learning and edge detection.

[0005] In a first aspect, the present invention provides an image vectorization method based on deep learning and edge detection, which adopts the following technical solutions:

[0006] An image vectorization method based on deep learning and edge detection, comprising:

[0007] Acquire image data of the home appliance module and preprocess the acquired image data;

[0008] The preprocessed image data is used as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism;

[0009] Model optimization based on edge detection model, including joint optimization of model using weighted binary cross entropy loss and re_Dice loss;

[0010] Optimizing the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map;

[0011] Multiple sets of different Canny threshold pairs are preset, edge detection is performed on the preprocessed image data in sequence to generate multiple sets of edge maps, and the multiple sets of edge maps are averaged to obtain a comprehensive edge image;

[0012] The optimized edge probability map and the integrated edge image are used as input, and the edge information is converted into vector graphics using the Potrace algorithm to obtain a DXF file.

[0013] Furthermore, the dual-branch structure model is constructed using the SimAM attention mechanism and the CBAM attention mechanism, including S1, using the VGG16 network as the backbone network, and using the multi-layer convolution and pooling structure of the backbone network to extract features from the input preprocessed image data;

[0014] S2. Constructing a dual-branch structure to enhance edge features of the extracted features, wherein the dual-branch structure includes a branch φ and a branch σ;

[0015] S3. Integrate the SimAM attention mechanism in branch φ, which adaptively focuses on the areas with important edge features in the image and processes the features extracted by the backbone network. The calculation formula is:

[0016]

[0017] Among them, a k represents the branch extracted from the backbone network, j represents the number of branches extracted from each backbone, C represents the branch sequence number extracted from the backbone ID block, and up represents the upsampling operation;

[0018] S4. Integrate the CBAM attention mechanism in branch σ to enhance the ability to extract specific edge features by adjusting the attention of the channel and spatial dimensions. The calculation formula is:

[0019]

[0020] Among them, cbam(a k ) indicates a kThe feature branch applies the CBAM attention mechanism, sigmoid is represented as the activation function, and conv is represented as the convolution operation.

[0021] Furthermore, the method of constructing an edge detection model using the preprocessed image data as input also includes constructing an interactive attention fusion module for fusing the outputs of branch φ and branch σ, processing the output features of branch φ and branch σ respectively through two attention modules, each attention module including a convolution combination of multiple convolution kernels, and interactively splicing the output features of each attention module. Finally, the spliced ​​features are assigned attention weights with the original output features of branch φ and branch σ, and the feature map is fused by element-by-element addition to obtain an edge probability map.

[0022] Furthermore, the model optimization based on the edge detection model also includes introducing Canny edge prior as auxiliary supervision. First, the feature image output by the edge detection model is Gaussian blurred, and the edge features of the blurred image are extracted using the Canny algorithm. The edge features extracted by the Canny algorithm are dot-producted with the edge features predicted by the edge detection model to generate compensation labels, and the loss value is calculated based on the compensation labels.

[0023] Furthermore, the edge probability map output by the edge detection model is optimized, including normalizing the edge probability map output by the edge detection model, smoothing the normalized edge probability map using a triangular filter, calculating the second-order derivatives and cross derivatives of the smoothed edge probability map in the x and y directions, and calculating the edge direction of each pixel based on the derivatives. The edge direction calculation formula is:

[0024]

[0025] Among them, mod represents the modulo operation, arctan is the inverse tangent function, 1e-5 represents the minimum value added to avoid the denominator being zero, O xy Expressed as cross derivative, O xx and O yy Expressed as a second-order derivative.

[0026] Furthermore, the edge probability map is optimized using a non-maximum suppression method, including performing non-maximum suppression in the edge direction of each pixel point, obtaining the edge strength values ​​of adjacent points in the direction through bilinear interpolation, calculating the interpolated edge strength of each pixel point (x, y) at a distance d in the edge direction O(x, y), calculating the edge strength of the pixel based on the interpolated edge strength, and finally performing intensity attenuation on the pixels in the boundary area of ​​the image.

[0027] Furthermore, the edge detection is performed on the preprocessed image data in sequence to generate multiple sets of edge maps, including setting at least two sets of different high and low threshold pairs, performing Canny edge detection on the preprocessed image data using each set of threshold pairs in sequence to generate multiple sets of edge maps, performing double threshold processing and edge connection using the threshold pairs to obtain binary edge maps, averaging the generated multiple sets of edge maps to obtain a comprehensive edge image, and performing a kernel filtering operation on the comprehensive edge image again to obtain a final edge detection result.

[0028] In the second aspect, an image vectorization system based on deep learning and edge detection includes:

[0029] The data acquisition module is configured to: acquire image data of the home appliance module and pre-process the acquired image data;

[0030] The model module is configured to: take the preprocessed image data as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism;

[0031] The training module is configured to: perform model optimization based on the edge detection model, including jointly optimizing the model using weighted binary cross entropy loss and re_Dice loss;

[0032] The optimization module is configured to: optimize the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map;

[0033] The detection module is configured to: preset multiple sets of different Canny threshold pairs, perform edge detection on the preprocessed image data in sequence to generate multiple sets of edge maps, and average the multiple sets of edge maps to obtain a comprehensive edge image;

[0034] The output module is configured to: take the optimized edge probability map and the integrated edge image as input, and use the Potrace algorithm to convert the edge information into vector graphics to obtain a DXF file.

[0035] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device, such as a method for image vectorization based on deep learning and edge detection.

[0036] In a fourth aspect, the present invention provides a terminal device comprising a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; and the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded and executed by the processor to implement the image vectorization method based on deep learning and edge detection.

[0037] In summary, the present invention has the following beneficial technical effects:

[0038] 1. The present invention constructs a dual-branch structure model based on the SimAM and CBAM attention mechanisms. SimAM can adaptively focus on important edge feature areas in the image, and CBAM enhances the ability to extract specific edge features from the channel and spatial dimensions. The two work together to enable the model to more accurately capture the edge information of the home appliance module image. Finally, the Canny edge prior is introduced as auxiliary supervision, and the edge features extracted by the Canny algorithm are combined with the model prediction features to generate compensation labels, which further enhances the model's ability to recognize complex geometric edge structures and effectively improves the accuracy and completeness of edge detection.

[0039] 2. The present invention uses non-maximum suppression (NMS) to optimize the edge probability map output by the edge detection model. Through a series of operations such as normalization, smoothing, calculating edge direction, suppressing non-maxima, and boundary attenuation, it effectively eliminates redundant edge responses, refines edges, makes edge positioning more accurate, and provides high-quality input for subsequent vectorization.

[0040] 3. The present invention performs edge detection by presetting multiple sets of different Canny thresholds and averaging the results, which can comprehensively capture edge information of different intensities, avoid the problem of edge omission caused by a single threshold, and further remove noise and scattered pixels in combination with the kernel filtering operation, thereby improving the quality of the edge image.

[0041] 4. The present invention takes the optimized edge probability map and the integrated edge image as input, uses the Potrace algorithm to perform vectorization conversion, and combines the early optimization processing of the edge detection results to generate vector graphics with higher precision and less noise, and outputs a DXF file that meets the design specifications. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 1 is a schematic diagram of an edge detection model of an image vectorization method based on deep learning and edge detection in an embodiment of the present invention.

[0043] Figure 2 This is a SEDI model structure diagram of an image vectorization method based on deep learning and edge detection in Example 1 of the present invention.

[0044] Figure 3 This is a schematic diagram of a dual-branch structure of an image vectorization method based on deep learning and edge detection in Example 1 of the present invention.

[0045] Figure 4 This is a rendering of a vectorization process based on deep learning of an image vectorization method based on deep learning and edge detection in Example 1 of the present invention.

[0046] Figure 5 This is a Canny method vectorization effect diagram of an image vectorization method based on deep learning and edge detection in Example 1 of the present invention. DETAILED DESCRIPTION

[0047] The present invention will be further described in detail below with reference to the accompanying drawings.

[0048] Example 1

[0049] Reference Figure 1 , an image vectorization method based on deep learning and edge detection in this embodiment includes:

[0050] Acquire image data of the home appliance module and preprocess the acquired image data;

[0051] The preprocessed image data is used as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism;

[0052] Model optimization based on edge detection model, including joint optimization of model using weighted binary cross entropy loss and re_Dice loss;

[0053] Optimizing the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map;

[0054] Multiple sets of different Canny threshold pairs are preset, edge detection is performed on the preprocessed image data in sequence to generate multiple sets of edge maps, and the multiple sets of edge maps are averaged to obtain a comprehensive edge image;

[0055] The optimized edge probability map and the integrated edge image are used as input, and the edge information is converted into vector graphics using the Potrace algorithm to obtain a DXF file.

[0056] Specifically, an image vectorization method based on deep learning and edge detection includes the following steps:

[0057] S1. Acquire image data of the home appliance module and preprocess the acquired image data;

[0058] A large number of home appliance module images are collected. These images cover home appliances of different brands and models, as well as complex background environments and lighting conditions. In order to provide accurate annotation data for model training, professional annotation tools are used for annotation to ensure the accuracy and consistency of the annotation. Each image is annotated to clearly demarcate the module edge and background area. The annotation process strictly follows unified standards and specifications to ensure the accuracy and consistency of the annotation results, laying a solid data foundation for subsequent model training. In the data collection step, complex backgrounds include messy production environments, background boards of different colors and materials, and various lighting conditions including direct strong light, low light environments, and lighting under shadows.

[0059] S2. Using the preprocessed image data as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism;

[0060] like Figure 1 As shown in the figure, step 1: determine whether the image of the home appliance module to be processed has a complex impurity background. If so, use the BackgroundRemover library to remove the background. Complete the library installation by executing the pip installBackgroundRemover command, input the image to be processed into the corresponding processing function of the library, and output the image after removing the background. If the image background is simple and has no interference, you can skip this step directly.

[0061] Step 2: In the first stage, the VGG16 structure is used as the backbone network, which contains five convolutional blocks (ID blocks); the input image (if step 1 is executed, the image after background removal is processed; if not, the original image is processed) is processed using the pre-trained VGG16 backbone network to extract rich semantic content and texture details in the image, and obtain multiple feature branches a extracted from different positions of the backbone network. k , where k represents the branch number, C is the branch number extracted from the trunk ID block, and j is the number of branches extracted from each trunk.

[0062] like Figure 3 As mentioned above, in the second stage, a dual-branch structure is designed, which are respectively denoted as branch φ and branch σ. The SimAM attention mechanism is integrated in branch φ. Through this mechanism, the features extracted by the backbone network are processed by adaptively focusing on the area with important edge features in the image. The calculation formula is:

[0063]

[0064] Among them, a kRepresents the branch extracted from the backbone network, j represents the number of branches extracted from each backbone, C represents the branch sequence number extracted from the backbone ID block, up represents the upsampling operation, and the feature branch a extracted from the backbone network is k Processing is performed to adaptively focus on important edge feature areas in the image. The CBAM attention mechanism is integrated in branch σ to enhance the ability to extract specific edge features through attention adjustment in channel and spatial dimensions. The calculation formula is:

[0065]

[0066] Among them, cbam(a k ) indicates a k The feature branch uses the CBAM attention mechanism, sigmoid is expressed as the activation function, and conv is expressed as the convolution operation, which enhances the ability to extract specific edge features from the channel and spatial dimensions. Through the above dual-branch structure processing, the edge feature S is obtained. i and S ii The CBAM attention mechanism performs weighted processing on features in the channel dimension and spatial dimension respectively. In the channel dimension, channel feature statistics are obtained through global average pooling and global maximum pooling, and channel attention weights are generated through a multi-layer perceptron. In the spatial dimension, spatial attention weights are generated through convolution operations after channel compression.

[0067] like Figure 2 As shown in the third stage, the interactive attention fusion module SEDI is constructed to combine the edge features S output by branch φ and branch σ i and S ii Two ATT modules containing a combination of 3x3 convolution and 1x1 convolution are input for processing respectively; the results processed by the ATT modules are interactively concat-operated to make the features complement each other; by calculating:

[0068] k l =sigmoid(conv([att1(S i ),att3(S ii )])),

[0069] k g =sigmoid(conv([att2(S i ),att4(S ii )])),

[0070] Attention weight distribution is performed, where sigmoid is represented as the activation function, att(S) is represented as the transformation function, and the structure is: att(S) = BatchNormal(conv(Relu(conv(S)))), BatchNormal represents batch normalization, kl and k g Represents the weighted result after multiple ATT attentions.

[0071] The interactive concat features are fused element by element with the original branch. The calculation formula is:

[0072] lst(S i ,S ii )=(S i +S ii )*k l +(S i +S ii )(1-k g ),

[0073] S′ i =lst(S i ,S ii ),

[0074] Among them, 1-k g Expressed as k g After negating the weights, the SEDI module performs a fine-grained deep fusion of these features through convolution operations, improving traditional simple feature fusion methods using the attention mechanism. The attention mechanism allows the model to dynamically select and emphasize important features, rather than simply linearly combining all features. This allows for more efficient use of information, effectively complementing the detailed information extracted by the two side branches. Specifically, the input features are first processed through two attention modules (ATT) to process the outputs of the two branches. Each ATT module contains a combination of 3x3 convolution and 1x1 convolution. This combination can effectively extract features and reduce the number of parameters while maintaining the expressive power of the model. The results are then interactively concat, which allows these features to complement each other and improve the expressive power of the features. The attention weights are then assigned to the original branch. After the attention mechanism of each branch, the feature maps are fused through element-by-element addition. This fusion method can integrate information from different branches and improve the module's understanding of image content.

[0075] S3. Model optimization based on the edge detection model, including joint optimization of the model using weighted binary cross entropy loss and re_Dice loss;

[0076] Input the image to be processed X∈R W×H×3 And the constructed edge detection model is used to process the image X through the edge detection model, and the predicted edge Y' is output: Y'=ψ(X), where ψ represents the edge detection model. Gaussian blur processing is performed on the image X to obtain X blur =blur(X), where blur represents blurring, using the Canny algorithm to blur Xblur Perform edge detection, normalize the results, and calculate edge features The output result is divided by 255 to normalize it to the range of 0 to 1, and the edge feature S c Perform dot product processing with the predicted edge Y' to generate the compensation label Y" = (S c *Y').

[0077] In order to train the edge prediction model, this embodiment uses weighted binary cross entropy (WCE) loss for optimization and the re_Dice loss mentioned in LPCB, E i is the ground truth edge probability of the ith pixel, and for the ith pixel in the jth edge map, the value is The uncertainty-aware WCE loss is calculated as:

[0078]

[0079] in, η is the threshold for determining uncertain edge pixels in the ground truth, and such ambiguous samples will be ignored in the subsequent optimization process, E + and E - represents the number of edge and non-edge pixels in the ground truth edge map, and λ is the balance E + and E - The final WCE loss of each edge mapping is:

[0080] Where N represents the total number of samples.

[0081] The relevant calculation formula for re_Dice loss is as follows:

[0082]

[0083] where p i ,E i Represent the value of the i-th pixel on the predicted image P and the ground truth G respectively. The loss is to compare the similarity of the two sets P and G and minimize their distance on the training data.

[0084] The total loss of this embodiment is given by L D and L WCE Composition, all prediction graphs are P1, P2, P3, P4, P5, P fuse , the loss can be expressed as L total ,as follows:

[0085]

[0086] Among them, α iRepresents the coefficients of the corresponding layers, and their optimal combination is determined through experiments. Here α i and α fuse Both are set to 0.2, λ1 and λ2 are set to 1.1 and 100 respectively, and Y” will be the compensation label obtained by the supervised compensation algorithm of this embodiment.

[0087] Finally, the labeled images are used as training samples. By continuously adjusting the model parameters, the model gradually learns the characteristic distribution of the background and module edges in the image. During training, the model's performance on the test set is closely monitored. When the model achieves excellent edge detection results on the test set, such as high precision and recall, the model training is considered complete. Given the time-consuming and complex nature of data labeling, it is also possible to use an open source pre-trained model as a basis and fine-tune it to accelerate the model development process.

[0088] I′=Edge(Rm(I)),

[0089] Wherein, I is the input image, Rm and Edge represent the background removal and edge detection models adopted in this embodiment respectively.

[0090] S4, optimizing the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map;

[0091] Step 1: Normalize the edge detection result image I' output by the deep learning model so that its pixel values ​​are mapped to the ([0,1]) interval. The calculation formula is:

[0092]

[0093] Where max(I') is the maximum pixel value in image I'. Normalization is used to ensure the numerical stability of subsequent calculations and eliminate the impact of pixel value scale differences between different images on the processing results.

[0094] Step 2: Use a triangular filter to smooth the normalized image E through the function:

[0095] E conv =convTri(E,4),

[0096] Among them, convTri represents a triangular filter function, and the parameter 4 represents the radius of the filter. This operation effectively reduces the noise in the image, prevents noise from interfering with the subsequent edge direction calculation and non-maximum suppression process, and improves the accuracy of the edge detection results.

[0097] Step 3: Calculate the smoothed image E conv The second derivative O in the x and y directionsxx , O xy , O yy , based on the above second derivative, through the formula:

[0098]

[0099] where mod represents the modulo operation, arctan is the arctangent function, 1e-5 represents a very small value added to avoid a zero denominator, O xy represents the cross derivative, O xx and O yy represents the second derivative, to calculate the edge direction O of each pixel.

[0100] Step four: For each pixel point ((x, y)) in the image, on its edge direction (O[x, y]), through the bilinear interpolation function:

[0101] e0 = interp(E, h, w, x + d·cos(O[x, y]), y + d·sin(O[x, y])),

[0102] where d is the offset within the neighborhood, with a range of [-r, r], r is the suppression radius which is 1 here, interp is the bilinear interpolation function, h and w are the height and width of the image respectively; compare the edge intensity E conv [x, y] with the edge intensities e0 of each pixel in the neighborhood. If there exists d ∈ [-1, 1] such that E conv [x, y] < e0, then suppress the edge intensity of the current pixel to 0, otherwise slightly enhance it, and the formula is

[0103]

[0104] In the non-maximum suppression step, the edge intensity enhancement coefficient (1.01) can be adjusted according to the actual edge detection requirements, with an adjustment range of (1.0 -​​​​​​​​​​​​

[0109] Where h and w are the height and width of the image respectively. To round down, for the upper boundary of the image (y <s):

[0110]

[0111] For the lower boundary of the image (y>hs):

[0112]

[0113] For the left edge of the image (x <s):

[0114]

[0115] For the right border of the image (x>ws):

[0116]

[0117] Finally, for the image E1 after NMS suppression and boundary suppression, perform kernel filtering and set the initial product threshold F m1 , overall threshold F g1 , using a 5×5 filter kernel, by the formula:

[0118]

[0119] Among them, ∑ l>1 x i is pixel x i Half of the sum of the surrounding non-self pixel values, ∑ l=1 x i The calculated pixel density is the sum of the pixel values ​​including itself, and the product threshold F is set m1 , overall threshold F g1 Compare, if the pixel density is lower than the threshold requirement, then the pixel is judged as a scattered impurity point and removed, calculate each pixel x i The pixel density around it is calculated and multiplied by the set product threshold F m1 , overall threshold F g1 Compare, if the pixel density is lower than the threshold requirement, the pixel is judged as a scattered impurity point and removed, and the edge map after the first round of filtering is obtained. In each subsequent round of filtering, the product threshold F is dynamically adjusted according to the changes in the impurity distribution, edge clarity, etc. of the current edge image. m and the overall threshold F g , continue the kernel filtering operation until the preset filtering times are reached or the edge image quality meets the requirements, and the optimized edge image E is obtained. final .

[0120] S5, presetting multiple sets of different Canny threshold pairs, performing edge detection on the preprocessed image data in sequence to generate multiple sets of edge maps, and averaging the multiple sets of edge maps to obtain a comprehensive edge image;

[0121] Based on the pre-processed image data, at least two different Canny high and low threshold pairs (T h1 ,T l1 ),(T h2 ,T l2 ),…,(T hn ,T ln ), where the high threshold T hi For identifying strong edges, low threshold T li Used to connect weak edges and satisfy T hi >T li ,The value range of different threshold pairs covers the detection interval from low sensitivity to high sensitivity;

[0122] The input image I is subjected to Canny edge detection through each set of threshold pairs. For the nth set of threshold pairs (T hn ,T ln ),implement Get the corresponding edge detection result Figure I n , where I n It is the edge map detected under the nth set of threshold pairs for the input image I. Through multiple sets of threshold detection, the edge information of different intensity ranges in the image can be fully captured.

[0123] For each group of edge detection results Figure I n , perform multiple kernel filtering processes and set the initial product threshold F m1 , overall threshold F g1 The setting method of the multiple Canny threshold pairs is the adaptive threshold method. The threshold is dynamically calculated based on the mean and standard deviation of the local area of ​​the image, using a filter kernel of (5×5) size, through the formula:

[0124]

[0125] Among them, ∑ l>1 x i is pixel x i Half of the sum of the surrounding non-self pixel values, ∑ l=1 x i The calculated pixel density is the sum of the pixel values ​​including itself, and the product threshold F is set m1 , overall threshold F g1After comparison, if the pixel density is lower than the threshold requirement, the pixel is judged as a scattered impurity point and removed to obtain the edge map after the first round of filtering.

[0126] In each subsequent round of filtering, the product threshold F is dynamically adjusted according to the changes in the impurity distribution and edge clarity of the current edge image. m and the overall threshold F g , continue the kernel filtering operation until the preset filtering times are reached or the edge image quality meets the requirements, and finally obtain the optimized edge image II n =filt(I n ), where filt is an operation function that includes multiple kernel filtering and threshold adjustment processes.

[0127] After multiple kernel filtering optimizations, multiple sets of edge detection results are averaged, and a comprehensive edge image is obtained by calculating the average value of each pixel in different results. This averaging method can integrate the advantages of multiple sets of detection results, reduce edge omissions or false detections caused by single threshold detection, and make the final edge image more accurately reflect the true edge information of the image:

[0128]

[0129] Here, n represents the total number of samples. To further improve the quality of the edge image, the averaged image is subjected to kernel filtering again. This time, more refined parameter settings can be used to further remove residual impurities and discontinuous edges, making the edges smoother and more continuous, providing a high-quality input image for subsequent vectorization conversion:

[0130]

[0131] filt can also be performed multiple times, and after the above processing, the post-processed edge is obtained

[0132] S6. Using the optimized edge probability map and the integrated edge image as input, the edge information is converted into a vector graphic using the Potrace algorithm to obtain a DXF file.

[0133] like Figure 4 、 Figure 5As shown, based on steps S4 and S5, the image of the deep learning edge detection result or the improved Canny edge detection result after NMS processing is used as input according to the application scenario, the smoothness parameter is adjusted according to the image complexity, the path parameter is optimized, and the edge information is converted into vector graphics using the Potrace algorithm to generate a DXF file that meets the design specifications. The original image, the DXF file generated by the traditional vectorization method, and the DXF file generated by this solution are compared to evaluate the edge accuracy and noise suppression effect; the generated DXF file is applied to the secondary development of home appliance modules, and is expanded to the product design and production manufacturing links in the industrial manufacturing field.

[0134] Example 2

[0135] This embodiment differs from Embodiment 1 in that this embodiment provides an image vectorization system based on deep learning and edge detection, including:

[0136] The data acquisition module is configured to: acquire image data of the home appliance module and pre-process the acquired image data;

[0137] The model module is configured to: take the preprocessed image data as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism;

[0138] The training module is configured to: perform model optimization based on the edge detection model, including jointly optimizing the model using weighted binary cross entropy loss and re_Dice loss;

[0139] The optimization module is configured to: optimize the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map;

[0140] The detection module is configured to: preset multiple sets of different Canny threshold pairs, perform edge detection on the preprocessed image data in sequence to generate multiple sets of edge maps, and average the multiple sets of edge maps to obtain a comprehensive edge image;

[0141] The output module is configured to: take the optimized edge probability map and the integrated edge image as input, and use the Potrace algorithm to convert the edge information into vector graphics to obtain a DXF file.

[0142] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device, for example, a method for image vectorization based on deep learning and edge detection.

[0143] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded and executed by the processor to implement the image vectorization method based on deep learning and edge detection.

[0144] The above are all preferred embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. An image vectorization method based on deep learning and edge detection, characterized in that: include: Acquire image data of the home appliance module and preprocess the acquired image data; The preprocessed image data is used as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism; Model optimization based on edge detection model, including joint optimization of model using weighted binary cross entropy loss and re_Dice loss; Optimizing the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map; Multiple sets of different Canny threshold pairs are preset, edge detection is performed on the preprocessed image data in sequence to generate multiple sets of edge maps, and the multiple sets of edge maps are averaged to obtain a comprehensive edge image; The optimized edge probability map and the integrated edge image are used as input, and the edge information is converted into vector graphics using the Potrace algorithm to obtain a DXF file.

2. The image vectorization method based on deep learning and edge detection according to claim 1, characterized in that: The dual-branch structure model is constructed using the SimAM attention mechanism and the CBAM attention mechanism, including S1, using the VGG16 network as the backbone network, and using the multi-layer convolution and pooling structure of the backbone network to extract features from the input preprocessed image data; S2. Constructing a dual-branch structure to enhance edge features of the extracted features, wherein the dual-branch structure includes a branch φ and a branch σ; S3. Integrate the SimAM attention mechanism in branch φ, which adaptively focuses on the areas with important edge features in the image and processes the features extracted by the backbone network. The calculation formula is: Among them, a k represents the branch extracted from the backbone network, j represents the number of branches extracted from each backbone, C represents the branch sequence number extracted from the backbone ID block, and up represents the upsampling operation; S4. Integrate the CBAM attention mechanism in branch σ to enhance the ability to extract specific edge features by adjusting the attention of the channel and spatial dimensions. The calculation formula is: Among them, cbam(a k ) indicates a k The feature branch applies the CBAM attention mechanism, sigmoid is represented as the activation function, and conv is represented as the convolution operation.

3. The image vectorization method based on deep learning and edge detection according to claim 1, characterized in that: The method uses the preprocessed image data as input to construct an edge detection model, and also includes constructing an interactive attention fusion module for fusing the outputs of branch φ and branch σ, processing the output features of branch φ and branch σ respectively through two attention modules, each attention module includes a convolution combination of multiple convolution kernels, and interactively splicing the output features of each attention module. Finally, the spliced ​​features are assigned attention weights with the original output features of branch φ and branch σ, and the feature map is fused by element-by-element addition to obtain an edge probability map.

4. The image vectorization method based on deep learning and edge detection according to claim 1, characterized in that: The model optimization based on the edge detection model also includes introducing Canny edge prior as auxiliary supervision. First, the feature image output by the edge detection model is Gaussian blurred, and the edge features of the blurred image are extracted using the Canny algorithm. The edge features extracted by the Canny algorithm are dot-producted with the edge features predicted by the edge detection model to generate compensation labels, and the loss value is calculated based on the compensation labels.

5. The image vectorization method based on deep learning and edge detection according to claim 1, characterized in that: The edge probability map output by the edge detection model is optimized, including normalizing the edge probability map output by the edge detection model, smoothing the normalized edge probability map using a triangular filter, calculating the second-order derivatives and cross derivatives of the smoothed edge probability map in the x-direction and y-direction, and calculating the edge direction of each pixel based on the derivatives. The edge direction calculation formula is: Among them, mod represents the modulo operation, arctan is the inverse tangent function, 1e-5 represents the minimum value added to avoid the denominator being zero, O xy Expressed as cross derivative, O xx and O yy Expressed as a second-order derivative.

6. The image vectorization method based on deep learning and edge detection according to claim 1, characterized in that: The method uses non-maximum suppression to optimize the edge probability map, including performing non-maximum suppression in the edge direction of each pixel point, obtaining the edge strength values ​​of adjacent points in the direction through bilinear interpolation, calculating the interpolated edge strength of each pixel point (x, y) at a distance d in the edge direction O(x, y), calculating the edge strength of the pixel based on the interpolated edge strength, and finally performing intensity attenuation on the pixels in the boundary area of ​​the image, and performing a kernel filtering operation on the image after intensity attenuation.

7. The image vectorization method based on deep learning and edge detection according to claim 1, characterized in that: The method sequentially performs edge detection on the preprocessed image data to generate multiple sets of edge maps, including setting at least two sets of different high and low threshold pairs, sequentially performing Canny edge detection on the preprocessed image data using each set of threshold pairs to generate multiple sets of edge maps, performing double threshold processing and edge connection using the threshold pairs to obtain binary edge maps, averaging the generated multiple sets of edge maps to obtain a comprehensive edge image, and performing a kernel filtering operation on the comprehensive edge image again to obtain a final edge detection result.

8. An image vectorization system based on deep learning and edge detection, executing the method according to claim 1, characterized in that: include: The data acquisition module is configured to: acquire image data of the home appliance module and pre-process the acquired image data; The model module is configured to: take the preprocessed image data as input to build an edge detection model, including building a dual-branch structure model using the SimAM attention mechanism and the CBAM attention mechanism; The training module is configured to: perform model optimization based on the edge detection model, including jointly optimizing the model using weighted binary cross entropy loss and re_Dice loss; The optimization module is configured to: optimize the edge probability map output by the edge detection model, including optimizing the edge probability map using a non-maximum suppression method to obtain an optimized edge probability map; The detection module is configured to: preset multiple sets of different Canny threshold pairs, perform edge detection on the preprocessed image data in sequence to generate multiple sets of edge maps, and average the multiple sets of edge maps to obtain a comprehensive edge image; The output module is configured to: take the optimized edge probability map and the integrated edge image as input, and use the Potrace algorithm to convert the edge information into vector graphics to obtain a DXF file.

9. A computer-readable storage medium storing a plurality of instructions, characterized in that: The instructions are suitable for being loaded by a processor of a terminal device and executing an image vectorization method based on deep learning and edge detection as described in claim 1.

10. A terminal device comprising a processor and a computer-readable storage medium, wherein the processor is configured to implement various instructions; and the computer-readable storage medium is configured to store a plurality of instructions, wherein: The instructions are suitable for being loaded by a processor and executed by the image vectorization method based on deep learning and edge detection as described in claim 1.

Citation Information

Cited By

  • Method and system for detecting iron in down feather based on spectral analysis

    CN120908159A

  • DXF file generation method and device, electronic equipment and storage medium

    CN121458820A