Numerical control machine tool cutter wear identification method and system based on image processing

By using a boundary-aware refinement network and a bilinear attention pooling module, high-order fusion features are generated, which solves the problem of insufficient boundary perception in wear areas, improves the accuracy and stability of tool wear recognition, and adapts to complex working conditions.

CN122090171APending Publication Date: 2026-05-26DONGGUAN DIAORUN NUMERICAL CONTROL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
DONGGUAN DIAORUN NUMERICAL CONTROL TECH CO LTD
Filing Date
2026-04-17
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies cannot effectively perceive and refine the boundaries of wear areas, and it is difficult to integrate the internal content of the area with the geometric features of the boundary, resulting in insufficient accuracy and stability of tool wear recognition, especially under complex scenarios with changes in lighting and oil interference.

Method used

A boundary-aware refinement network is used to generate an initial wear region mask and a boundary orientation field. Through semantically guided multi-scale directional boundary feature maps and wear region masks with clear boundaries, combined with local information aggregation and bilinear attention pooling modules, high-order fusion features are generated for tool wear state recognition.

Benefits of technology

It significantly improves the accuracy and stability of tool wear condition recognition, effectively suppresses texture noise interference, extracts clear boundary features, adapts to geometric deformation and lighting changes in wear patterns, and improves the reliability of recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122090171A_ABST
    Figure CN122090171A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and particularly relates to a numerical control machine tool cutter wear identification method and system based on image processing, and the method comprises the following steps: obtaining a cutting edge image of a to-be-identified cutter, and inputting the cutting edge image into a pre-trained boundary perception refining network; the boundary perception refining network extracts a multi-scale feature map through an encoder, and generates a global probabilistic initial wear region mask and an initial boundary direction field in parallel by using an initial prediction module according to the highest-layer semantic features output by the encoder; and according to the probabilistic initial wear region mask and the initial boundary direction field, generating a semantic-guided multi-scale directional boundary feature map and a wear region mask with a clear boundary. The method has good stability for illumination change, oil stain interference and geometric deformation of a wear form in the cutting edge image, and the reliability of tool wear identification is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing technology, specifically relating to a method and system for identifying CNC machine tool wear based on image processing. Background Technology

[0002] Tool wear monitoring methods typically employ manual inspection or monitoring based on indirect signals such as cutting force, vibration, and acoustic emission. The former is highly subjective, inefficient, and requires downtime; the latter is easily affected by cutting conditions, workpiece material, and environmental noise, resulting in poor model generalization ability. Methods that acquire tool images and utilize convolutional neural networks for intelligent analysis offer advantages such as non-contact operation. In deep learning-based image recognition methods, semantic segmentation networks are used to locate and segment tool wear regions in images. In actual working conditions, the boundaries of tool wear regions are often irregular, morphologically varied, and have low contrast with unworn areas. During the layer-by-layer downsampling process, convolutional neural networks are prone to smoothing or losing boundary details, resulting in blurry, adhered, or broken wear region masks at the edges, leading to insufficient segmentation accuracy. When using the segmentation results for wear state classification, most existing methods perform simple global average pooling or max pooling on the features within the predicted wear region, mixing the texture information within the wear region with the geometric morphology information of the boundary, failing to utilize two types of features with different discriminative values. When an image is subjected to noise interference, the stability of its internal texture features decreases; and when the wear pattern is extremely irregular, a single fused feature cannot represent the geometric characteristics of the pattern. Therefore, how to perceive and refine the boundary of the wear region, and on this basis fuse features that can represent the internal content and boundary geometry of the region, thereby improving the model's noise resistance to various interferences, is a technical challenge that urgently needs to be solved in the current field. Summary of the Invention

[0003] This invention provides a method and system for identifying CNC machine tool wear based on image processing, in order to solve the technical problems of existing technologies being unable to perceive and refine the boundary of the wear area and having difficulty in integrating the internal content of the area with the geometric features of the boundary.

[0004] In a first aspect, the present invention provides a method for identifying CNC machine tool wear based on image processing, comprising the following steps: The cutting edge image of the tool to be identified is acquired and input into a pre-trained boundary awareness thinning network. The boundary awareness thinning network extracts multi-scale feature maps through the encoder and uses the initial prediction module to generate a global probabilistic initial wear area mask and an initial boundary orientation field in parallel based on the highest-level semantic features output by the encoder. Based on the probabilistic initial wear region mask and the initial boundary orientation field, a semantically guided multi-scale directional boundary feature map and a wear region mask with clear boundaries are generated. A well-defined wear region mask is used as spatial attention to perform weighted pooling on the multi-scale feature map output by the encoder, generating a contextual semantic feature vector representing the texture and content inside the wear region. Simultaneously, statistical moments are calculated on the semantically guided multi-scale directional boundary feature map along the contour line of the well-defined wear region mask, generating a boundary representation vector representing the boundary geometry and gradient stability. The contextual semantic feature vector and the boundary representation vector are fused through a bilinear attention pooling module to generate a high-order fused feature that is stable against geometric deformation and texture noise. The high-order fused feature is then input into the classifier to output the identification result of the tool wear state.

[0005] Its effect is as follows: Compared with traditional recognition methods based on simple global features or fixed pooling, this invention constructs a boundary-aware refinement network and generates wear area masks and boundary direction fields in parallel. It can integrate regional content and geometric shape information in multi-scale space to address the irregular and variable shape characteristics of wear boundaries in actual working conditions. This significantly improves the accuracy and stability of tool wear state recognition under complex scenarios with changes in lighting and oil pollution.

[0006] Furthermore, based on the probabilistic initial wear region mask and the initial boundary orientation field, a semantically guided multi-scale directional boundary feature map and a wear region mask with clear boundaries are generated. This includes: a boundary-aware thinning network using the initial boundary orientation field as guidance to weight a set of preset structured gradient operators at each feature map scale to achieve anisotropic gradient calculation, thereby generating a semantically guided multi-scale directional boundary feature map; and a boundary-aware thinning network using a local information aggregation module to construct a local one-dimensional sampling path parallel to the local direction for each pixel in the region to be identified, based on the local direction of the pixel in the initial boundary orientation field, and bidirectionally aggregating the context information and boundary features of neighboring pixels along the local one-dimensional sampling path, and updating the posterior probability of the pixel belonging to the wear region by combining the prior probability provided by the probabilistic initial wear region mask, thereby generating a wear region mask with clear boundaries.

[0007] Its effect is that the present invention uses the initial boundary direction field to guide the calculation of anisotropic gradients and combines local one-dimensional sampling paths to aggregate information, which can correct the blurred or broken boundary positions in real time, thereby generating wear masks with clear edges and complete contours, providing high-quality topological constraints for subsequent precise classification.

[0008] Furthermore, a set of pre-defined structured gradient operators are weighted at each feature map scale to achieve anisotropic gradient calculation, including: A set of eight 3×3 gradient operators is predefined, each gradient operator corresponds to a specific direction, and the directions are spaced 45° apart; For any pixel in the feature map, extract the normalized direction vector corresponding to the pixel in the initial boundary direction field; Calculate the cosine similarity between the direction vector and the preset directions of the eight gradient operators, and convert the similarity values ​​into a set of weights with a sum of 1 using the Softmax function; Eight gradient operators are applied to the neighborhood of a pixel, and the resulting eight gradient response values ​​are weighted and summed with their corresponding weights to obtain the anisotropic gradient values ​​of the pixel.

[0009] Its effect is that, by pre-setting multi-directional gradient operators and using Softmax for dynamic weight allocation, compared with traditional isotropic gradient extraction, this invention can more effectively suppress texture noise interference inside the wear area, extract boundary feature maps with clearer directionality and richer semantic information, and make the model more sensitive to capturing subtle wear features.

[0010] Furthermore, the contextual information and boundary features of neighboring pixels are bidirectionally aggregated along the local one-dimensional sampling path, and combined with the prior probability provided by the probabilistic initial wear region mask, the posterior probability of a pixel belonging to the wear region is updated, including: Centered on the target pixel, a local one-dimensional sampling path is constructed along the corresponding direction of the pixel in the initial boundary direction field. Ten points are sampled at equal intervals in two opposite directions to obtain a sequence containing 21 sampling points. For each sampling point in the sequence, the context feature vector of the sampling point in the corresponding scale feature map of the encoder and the boundary feature value in the semantically guided multi-scale directional boundary feature map are obtained by bilinear interpolation, and the two are concatenated. The feature sequences are fed into two gated recurrent unit networks in opposite directions to obtain aggregated information vectors in two directions. The aggregated information vectors from the two directions are concatenated, and the initial probability value of the target pixel in the probabilistic initial wear region mask is obtained. The initial probability value is then concatenated with the concatenated aggregated information vector, and the updated posterior probability value of the target pixel belonging to the wear region is calculated through a prediction head containing two fully connected layers and a Sigmoid activation function.

[0011] Its effect is that by using a bidirectional gated loop unit to integrate neighborhood context information along the boundary normal direction, compared with independent prediction based on pixels, this invention can better utilize the spatial correlation between pixels to update the posterior probability. Even when the wear pattern undergoes severe geometric deformation, it can still maintain the continuity of boundary inference and effectively solve the problem of mask adhesion or holes.

[0012] Furthermore, the clearly defined wear region mask is used as spatial attention to perform weighted pooling on the multi-scale feature map output by the encoder, generating a contextual semantic feature vector representing the texture and content inside the wear region, including: The probability values ​​of the wear region mask with clear boundaries are scaled to the same spatial resolution as the feature maps of the second, third, fourth, and fifth stages output by the encoder through bilinear interpolation, resulting in four spatial attention maps. Each spatial attention map is multiplied element-wise with the feature map at the corresponding scale to enhance the feature response within the wear area; For each weighted feature map, perform average pooling based on spatial attention map area normalization to generate a feature vector with four fixed dimensions. The four feature vectors are concatenated along the channel dimension to obtain the contextual semantic feature vector.

[0013] Its effect is that by using the wear area mask as a spatial attention mechanism for multi-scale feature maps, compared with directly extracting features from the whole image, this invention can accurately focus on the core wear area, enhance the feature response within the target area and suppress background interference through weighted pooling, and extract a more representative contextual semantic feature vector.

[0014] Furthermore, along the contour line of the clearly defined wear region mask, statistical moments are calculated on the semantically guided multi-scale directional boundary feature map to generate a boundary representation vector representing the boundary geometry and gradient stability, including: The mask of the wear area with clear boundaries is binarized, and the coordinate set of all contour pixels is extracted by applying the edge detection operator; Based on the coordinates of the contour pixels, the boundary strength value corresponding to the pixel in the highest resolution semantically guided multi-scale directional boundary feature map is indexed. Based on the set of boundary intensity values ​​of all contour pixels, calculate the first moment, second central moment, third normalized moment, and fourth normalized moment; The calculated first-order moment, second-order central moment, third-order normalized moment, and fourth-order normalized moment are concatenated to form the boundary representation vector.

[0015] Furthermore, a bilinear attention pooling module is used to fuse the context semantic feature vector and the boundary representation vector to generate a high-order fused feature that is stable against geometric deformation and texture noise, including: Dimension is The context semantic feature vector is linearly projected through a fully connected layer to an intermediate vector of dimension 1024; Dimension is The boundary representation vector is linearly projected through another fully connected layer to an intermediate vector of dimension 1024; Multiply the two projected vectors of dimension 1024 element by element to obtain a fused vector of dimension 1024. The fused vectors are then subjected to sign square root processing and L2 norm normalization processing in sequence to obtain higher-order fused features.

[0016] Furthermore, the boundary-aware refinement network extracts multi-scale feature maps through the encoder, including: The encoder uses a ResNet-50 network pre-trained on the ImageNet dataset as the backbone and removes the last global average pooling layer and fully connected layer. From the outputs of the second, third, fourth, and fifth residual modules of the ResNet-50 network, feature maps with decreasing resolution and increasing semantic information are extracted respectively to serve as multi-scale feature maps.

[0017] Furthermore, the higher-order fusion features are input into the classifier, and the output is the identification result of the tool wear state, including: The classifier consists of two sequentially connected fully connected layers; The first fully connected layer maps the high-order fusion features from the input dimension to a 128-dimensional hidden layer and applies the ReLU activation function; The second fully connected layer maps the 128-dimensional hidden layer features to the output dimension corresponding to the number of tool wear state categories, and calculates the probability of each category through the Softmax function. The one with the highest probability is the recognition result.

[0018] Secondly, the present invention provides a CNC machine tool wear identification system based on image processing, including a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned CNC machine tool wear identification method based on image processing is realized.

[0019] The beneficial effects are as follows: This invention guides the anisotropic gradient calculation by generating an initial boundary direction field, which can suppress the interference of texture noise inside the wear region and extract semantically rich and directional boundary features. Utilizing a local information aggregation mechanism, it integrates neighborhood contextual information along the boundary normal direction, corrects the boundary position, and generates a wear region mask with clear edges and complete contours. It separately constructs contextual semantic features focusing on the internal content of the wear region and boundary representations characterizing the geometric stability of the boundary, and performs high-order feature fusion through a bilinear attention pooling module. The generated high-order fused features can take into account both the internal texture and external contour information of the wear region, and have good stability against illumination changes, oil contamination, and geometric deformation of the wear morphology in the cutting edge image, thus improving the reliability of tool wear recognition. Attached Figure Description

[0020] Figure 1 This is a flowchart of a CNC machine tool wear identification method based on image processing. Detailed Implementation

[0021] 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, not all, of the embodiments of the present invention. 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.

[0022] An embodiment of the image processing-based CNC machine tool wear identification method provided by this invention: like Figure 1 As shown, the CNC machine tool wear identification method based on image processing includes the following steps: S1. Obtain the cutting edge image of the tool to be identified and input the cutting edge image into the pre-trained boundary awareness thinning network. The boundary awareness thinning network extracts multi-scale feature maps through the encoder and uses the initial prediction module to generate a global probabilistic initial wear area mask and an initial boundary orientation field in parallel based on the highest-level semantic features output by the encoder.

[0023] Images of the cutting edge of the tool are acquired and preprocessed using OpenCV library functions, including converting to grayscale, resizing to 512×512 pixels, and normalizing. The boundary-aware thinning network uses a ResNet-50 pre-trained on the ImageNet dataset as the encoder, removing fully connected and pooling layers, and using the feature maps output from the 2nd, 3rd, 4th, and 5th residual stages as multi-scale feature maps. The initial prediction module contains two parallel branches, each consisting of two 3×3 convolutional layers, a batch normalization layer, and a ReLU activation function layer. The input is the highest layer of the encoder output, i.e., the feature map from the 5th stage. The branch generating the initial wear region mask is finally connected to a 1×1 convolutional layer and a Sigmoid activation function, outputting a single-channel probability map. The branch generating the initial boundary orientation field is finally connected to a 1×1 convolutional layer with 2 output channels, and the output is L2-norm normalized at the pixel level to obtain a unit-length orientation vector field.

[0024] In an optional embodiment, the boundary-aware thinning network extracts multi-scale feature maps via an encoder, including: The encoder uses a ResNet-50 network pre-trained on the ImageNet dataset as the backbone and removes the last global average pooling layer and fully connected layer. From the outputs of the second, third, fourth, and fifth residual modules of the ResNet-50 network, feature maps with decreasing resolution and increasing semantic information are extracted respectively to serve as multi-scale feature maps.

[0025] We load the weights of a ResNet-50 model pre-trained on the ImageNet image classification task. The network structure retains the original convolutional layers, batch normalization layers, ReLU activation function, and four main residual stages. We remove the global average pooling layer and the 1000-dimensional fully connected layer used for classification at the end of the model. When given a 256×256 pixel image of a cutting edge, we perform a forward propagation and extract the outputs of the last residual block of the second, third, fourth, and fifth residual stages as multi-scale feature maps. The spatial resolution of the feature maps is 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input image, respectively, while the number of channels increases accordingly, thus forming a hierarchical feature pyramid from low-level features containing rich spatial details to high-level features containing abstract semantic information.

[0026] The encoder is a deep convolutional neural network, specifically a ResNet-50 model pre-trained on the ImageNet dataset, with the final global average pooling layer and fully connected classification layer removed. The network consists of convolutional layers, batch normalization layers, ReLU activation functions, and four core residual stages. The input is a cutting edge image of size H×W×3, for example, 256×256×3. The output consists of four feature maps at different scales, representing the outputs of the second, third, fourth, and fifth residual stages, with corresponding sizes of H / 4×W / 4×256, H / 8×W / 8×512, H / 16×W / 16×1024, and H / 32×W / 32×2048, respectively.

[0027] S2, based on the probabilistic initial wear region mask and the initial boundary orientation field, generates a semantically guided multi-scale directional boundary feature map and a wear region mask with clear boundaries. The boundary-aware refinement network uses the initial boundary orientation field as guidance to weight a set of preset structured gradient operators at each feature map scale to achieve anisotropic gradient calculation, thereby generating a semantically guided multi-scale directional boundary feature map. The boundary-aware refinement network uses a local information aggregation module to construct a local one-dimensional sampling path parallel to the local direction for each pixel in the region to be identified, based on the local direction of the pixel in the initial boundary orientation field. It then aggregates the context information and boundary features of neighboring pixels bidirectionally along the local one-dimensional sampling path. Combined with the prior probability provided by the probabilistic initial wear region mask, it updates the posterior probability that the pixel belongs to the wear region, thereby generating a wear region mask with clear boundaries.

[0028] The structured gradient operators are a set of 3×3 Sobel operators rotating in eight directions, with adjacent directions spaced at 45° intervals. For weighted anisotropic gradients, the normalized direction vector corresponding to the pixel in the initial boundary direction field is extracted. The cosine similarity between this direction vector and the preset directions of the eight Sobel operators is calculated, and the similarity values ​​are converted into a set of weights summing to 1 using the Softmax function. The gradient response values ​​of the eight operators are weighted and summed with their corresponding weights to obtain the anisotropic gradient map, i.e., the semantically guided multi-scale directional boundary feature map. For the local information aggregation module, for each pixel, the direction vector in the initial boundary direction field is obtained, the perpendicular vector of this vector is calculated, and 10 points are sampled along this direction vector and its opposite direction to obtain a one-dimensional path of length 21. A bilinear interpolation method is used to sample features along this path on the encoder feature map and the directional boundary feature map. The sampled feature sequence is input into a bidirectional gated recurrent unit network (BiGRU) for information aggregation. The hidden states of the BiGRU in both directions are concatenated, and the initial probability value of the pixel in the probabilistic initial wear region mask is obtained. The initial probability value is then concatenated with the concatenated hidden states again, and subsequently passed through a prediction head containing two fully connected layers and a sigmoid activation function to calculate the updated posterior probability value, thereby generating a wear region mask with clear boundaries.

[0029] In an optional embodiment, a set of preset structured gradient operators are weighted at various feature map scales to achieve anisotropic gradient calculation, including: A set of eight 3×3 gradient operators is predefined, each gradient operator corresponds to a specific direction, and the directions are spaced 45° apart; For any pixel in the feature map, extract the normalized direction vector corresponding to the pixel in the initial boundary direction field; Calculate the cosine similarity between the direction vector and the preset directions of the eight gradient operators, and convert the similarity values ​​into a set of weights with a sum of 1 using the Softmax function; Eight gradient operators are applied to the neighborhood of a pixel, and the resulting eight gradient response values ​​are weighted and summed with their corresponding weights to obtain the anisotropic gradient values ​​of the pixel.

[0030] The eight preset gradient operators are 3×3 Sobel operators along the directions of 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°. For any pixel p(x,y) in the feature map F, the direction vector is extracted from the initial boundary direction field of the two channels. Then perform L2 normalization. Calculate the normalized vector and the eight preset direction unit vectors. The dot product yields eight cosine similarity values. Through the Softmax function A set of weights was calculated. At the same time, eight Sobel operators are used. Convolution with the 3×3 neighborhood of pixel p(x,y) yields eight gradient responses. The anisotropic gradient value G(p) of this pixel is obtained by weighted summation. The calculations show that the directionality of the gradient calculation is aligned with the boundary direction of the initial prediction.

[0031] In an optional embodiment, the context information and boundary features of neighboring pixels are bidirectionally aggregated along a local one-dimensional sampling path, and the posterior probability of a pixel belonging to a wear region is updated by combining the prior probability provided by the probabilistic initial wear region mask, including: Centered on the target pixel, a local one-dimensional sampling path is constructed along the corresponding direction of the pixel in the initial boundary direction field. Ten points are sampled at equal intervals in two opposite directions to obtain a sequence containing 21 sampling points. For each sampling point in the sequence, the context feature vector of the sampling point in the corresponding scale feature map of the encoder and the boundary feature value in the semantically guided multi-scale directional boundary feature map are obtained by bilinear interpolation, and the two are concatenated. The feature sequences are fed into two gated recurrent unit networks in opposite directions to obtain aggregated information vectors in two directions. The aggregated information vectors from the two directions are concatenated, and the initial probability value of the target pixel in the probabilistic initial wear region mask is obtained. The initial probability value is then concatenated with the concatenated aggregated information vector, and the updated posterior probability value of the target pixel belonging to the wear region is calculated through a prediction head containing two fully connected layers and a Sigmoid activation function.

[0032] For the target pixel whose probability needs to be updated Based on the direction vector of the pixel in the initial boundary direction field Determine a unit direction vector perpendicular to it. Directly along the direction vector v and its opposite direction -v, with a step size of 1 pixel, sample 10 points respectively, including the center point. Together they form a sampling point sequence of length 21. For any sampling point in the sequence Using bilinear interpolation, context feature vectors are extracted from the feature map output by the third stage of the encoder, and boundary feature values ​​are extracted from the semantic guidance boundary feature map at the corresponding resolution. These are then concatenated into a 513-dimensional feature vector. . Feature sequence and The data are fed into two gated recurrent unit networks with 64 hidden units each, resulting in two 64-dimensional aggregated information vectors. and Obtain the target pixel. The initial probability value corresponds to the initial wear region mask in the probabilistic initial wear region. The two aggregated information vectors are concatenated with the initial probability value to form a 129-dimensional vector, which is then passed sequentially through a 129×64 fully connected layer, a ReLU activation function, a 64×1 fully connected layer, and a Sigmoid activation function. The output is a posterior probability value between 0 and 1, which serves as the posterior probability value. The probability of belonging to a wear zone.

[0033] The gated recurrent unit (GRU) network and prediction head constitute a local information aggregation network, consisting of two parallel GRU networks and a prediction head. Each GRU network contains a GRU layer with 64 hidden units. The prediction head is composed of a 129×64 fully connected layer, a ReLU activation function, a 64×1 fully connected layer, and a Sigmoid activation function, sequentially connected. The input consists of two feature sequences of length 11. and Each feature vector in the sequence Both are 513-dimensional, and there is a one-dimensional initial probability scalar. The output is a scalar value p, satisfying p∈[0,1], which represents the posterior probability that the target pixel belongs to the wear region.

[0034] S3 uses a clearly defined wear region mask as spatial attention to perform weighted pooling on the multi-scale feature map output by the encoder, generating a contextual semantic feature vector representing the texture and content inside the wear region. Simultaneously, along the contour line of the clearly defined wear region mask, statistical moments are calculated on the semantically guided multi-scale directional boundary feature map to generate a boundary representation vector representing the boundary geometry and gradient stability. Through a bilinear attention pooling module, the contextual semantic feature vector and the boundary representation vector are fused to generate a high-order fused feature that is stable against geometric deformation and texture noise. The high-order fused feature is input into the classifier to output the identification result of the tool wear state.

[0035] The mask of the well-defined wear region is adjusted to the same size as the output feature maps of each stage of the encoder. It is then multiplied element-wise with the corresponding feature maps using a Hadamard product. A global average pooling function is applied to the result, and the pooling results from all scales are concatenated into a context semantic feature vector. Simultaneously, the OpenCV function `cv2.findContours` is used to extract the contour coordinates of the well-defined wear region mask. For each pixel on the contour, gradient values ​​are extracted at the corresponding positions in the multi-scale directional boundary feature maps, and the first-order origin moment (mean), second-order central moment (variance), third-order central moment (skewness), and fourth-order central moment (kurtosis) of the gradient value set are calculated. The statistical moments calculated at all scales are concatenated into a boundary representation vector. Bilinear attention pooling is implemented by calculating the outer product of the context semantic feature vector and the boundary representation vector, resulting in a fused feature matrix. This matrix is ​​then subjected to element-wise signed square root transformation and L2 norm normalization, and finally flattened into a one-dimensional vector to obtain the higher-order fused features. The feature is input into a multilayer perceptron classifier consisting of two torch.nn.Linear fully connected layers and a ReLU activation function. The output layer uses the Softmax function to calculate the probability of different wear states, and the network is trained and optimized using the cross-entropy loss function. The class with the highest probability is output as the recognition result.

[0036] In an optional embodiment, a well-defined wear region mask is used as spatial attention to perform weighted pooling on the multi-scale feature map output by the encoder, generating a contextual semantic feature vector representing the texture and content within the wear region, including: The probability values ​​of the wear region mask with clear boundaries are scaled to the same spatial resolution as the feature maps of the second, third, fourth, and fifth stages output by the encoder through bilinear interpolation, resulting in four spatial attention maps. Each spatial attention map is multiplied element-wise with the feature map at the corresponding scale to enhance the feature response within the wear area; For each weighted feature map, perform average pooling based on spatial attention map area normalization to generate a feature vector with four fixed dimensions. The four feature vectors are concatenated along the channel dimension to obtain the contextual semantic feature vector.

[0037] Assuming the input image resolution is 256×256, the feature maps output by the ResNet-50 encoder from the second to the fifth stages... The resolutions are 64×64, 32×32, 16×16, and 8×8, with channel numbers of 256, 512, 1024, and 2048, respectively. The 256×256 mask for the clearly defined worn region is downsampled using bilinear interpolation to generate four spatial attention maps corresponding to the aforementioned resolutions. Calculate the weighted feature map. To generate feature vectors at various scales. Perform normalized average pooling:

[0038] in This indicates summation along spatial dimensions. For a very small positive number, such as To prevent the denominator from being zero, this operation yields four eigenvectors. , , , The dimensions are 256, 512, 1024, and 2048, respectively. Concatenating the four vectors along the channel dimensions yields a context semantic feature vector with a total dimension of 3840.

[0039] In an optional embodiment, statistical moments are calculated on the semantically guided multi-scale directional boundary feature map along the contour line of the well-defined wear region mask to generate a boundary representation vector representing the boundary geometry and gradient stability, including: The mask of the wear area with clear boundaries is binarized, and the coordinate set of all contour pixels is extracted by applying the edge detection operator; Based on the coordinates of the contour pixels, the boundary strength value corresponding to the pixel in the highest resolution semantically guided multi-scale directional boundary feature map is indexed. Based on the set of boundary intensity values ​​of all contour pixels, calculate the first moment (mean), the second central moment (variance), the third normalized moment (skewness), and the fourth normalized moment (kurtosis). The calculated first-order moment, second-order central moment, third-order normalized moment, and fourth-order normalized moment are concatenated to form the boundary representation vector.

[0040] The clearly defined wear area mask M is binarized using a threshold of 0.5 to obtain a binary mask. ,right The Suzuki contour search algorithm is applied to extract the N coordinates of all pixels on the outermost contour of the wear area. Using coordinates, N corresponding boundary strength values ​​are indexed in a semantically guided boundary feature map with the same resolution as the input image, forming a set. Based on set S, calculate four statistical moments: mean ;variance ; skewness ; kurtosis . Four scalar values They are concatenated into a 4-dimensional boundary representation vector.

[0041] In an optional embodiment, a bilinear attention pooling module is used to fuse the context semantic feature vector and the boundary representation vector to generate a high-order fused feature that is stable against geometric deformation and texture noise, including: Dimension is The context semantic feature vector is linearly projected through a fully connected layer to an intermediate vector of dimension 1024; Dimension is The boundary representation vector is linearly projected through another fully connected layer to an intermediate vector of dimension 1024; Multiply the two projected vectors of dimension 1024 element by element to obtain a fused vector of dimension 1024. The fused vectors are then subjected to sign square root processing and L2 norm normalization processing in sequence to obtain higher-order fused features.

[0042] The 3840-dimensional context semantic feature vector generated in the previous steps The input is fed into a fully connected layer that does not contain an activation function. The projection is a 1024-dimensional vector. Simultaneously, the 4-dimensional boundary representation vector... Input to another fully connected layer It is also projected as a 1024-dimensional vector. Bilinear pooling is achieved through element-wise multiplication. This yields a 1024-dimensional fusion vector. To stabilize training and enhance feature representation, [the following steps are taken]. Perform power normalization: Calculate the sign square root, that is, perform power normalization on each element x in the vector. Operation: Normalize the entire processed vector using the L2 norm, and the resulting 1024-dimensional vector is the higher-order fusion feature.

[0043] The fully connected layer projection and fusion process constitutes a high-order feature fusion module, which contains two parallel fully connected layers, neither of which has an activation function. The weight matrix of the first fully connected layer is 3840×1024, and that of the second is 4×1024. The outputs of the two fully connected layers are multiplied element-wise, and then subjected to sign square root and L2 norm normalization. The input consists of two feature vectors: a 3840-dimensional context semantic feature vector. and 4-dimensional boundary representation vector Output a 1024-dimensional high-order fused feature vector.

[0044] In an optional embodiment, the high-order fused features are input into a classifier, and the output is the identification result of the tool wear state, including: The classifier consists of two sequentially connected fully connected layers; The first fully connected layer maps the high-order fusion features from the input dimension to a 128-dimensional hidden layer and applies the ReLU activation function; The second fully connected layer maps the 128-dimensional hidden layer features to the output dimension corresponding to the number of tool wear state categories, and calculates the probability of each category through the Softmax function. The one with the highest probability is the recognition result.

[0045] A 1024-dimensional high-order fused feature vector is input into the classifier. The first layer of the classifier is a fully connected layer with a weight matrix of size 1024×128, mapping the input features to 128-dimensional hidden features, followed by a ReLU activation function to increase the model's expressive power. This 128-dimensional hidden feature is then fed into a second fully connected layer with a weight matrix of size [missing information]. ,in The number of predefined tool wear state categories. The output of this layer is a... The original score vector is transformed using the Softmax function into a probability distribution vector with a sum of 1, where each element represents the probability that the input image belongs to the corresponding wear state. The category with the highest probability value is selected as the tool wear recognition result.

[0046] The classifier is a feedforward neural network consisting of two sequentially connected fully connected layers. The first fully connected layer has a weight matrix of size 1024×128, followed by a ReLU activation function. The weight matrix of the second fully connected layer is... ,in This represents the number of categories of tool wear states. The network concludes with a Softmax function, which takes a 1024-dimensional high-order fused feature vector as input and outputs a... A probability distribution vector of dimension , where each element represents the probability that the input belongs to the corresponding wear state.

[0047] In the implementation, a ResNet-50 network pre-trained on the ImageNet dataset is used as the encoder backbone, and the classification layer is removed to extract multi-scale feature maps from the input tool image output in the second to fifth residual stages. Based on the features of the highest layer, an initial prediction module generates a coarse wear region mask and an initial boundary orientation field in parallel. To detect boundaries, the network uses this orientation field to guide gradient calculation: for each pixel, the cosine similarity between the predicted orientation and eight preset orientations is calculated, and the similarity is converted into weights using Softmax. The gradient responses of the eight operators are then weighted and summed to generate a content-related, anisotropic multi-scale boundary feature map.

[0048] The network employs a local information aggregation module. For each pixel to be optimized, a one-dimensional path containing 21 equidistant sampling points is constructed perpendicular to the initial boundary direction field, based on the pixel's orientation in that direction. For each point on the path, bilinear interpolation is used to obtain the contextual features in the encoder feature map and the boundary features in the semantic boundary map, which are then concatenated to obtain a feature sequence. This sequence is fed into a bidirectional gated recurrent unit network, which aggregates the neighborhood context and boundary cues. The extracted information is then concatenated with the initial probability value corresponding to the pixel in the initial wear region mask. Subsequently, a small prediction head updates the posterior probability that the center pixel belongs to the wear region, generating a well-defined wear region mask.

[0049] To classify wear states, the network extracts and fuses information from two dimensions. First, a clear wear region mask is used as spatial attention to weight the C2 to C5 multi-scale feature maps output by the encoder, followed by normalized average pooling. The results are concatenated into a 3840-dimensional contextual semantic feature vector, representing the texture and content within the wear region. Second, the clear mask is binarized and its contours are extracted. The mean, variance, skewness, and kurtosis of the intensity values ​​corresponding to all pixels on the contour in the highest-resolution boundary feature map are calculated, forming a 4-dimensional boundary representation vector representing the geometry and stability of the wear. Both vectors are projected onto a 1024-dimensional network through fully connected layers, multiplied element-wise, and enhanced using sign square root and L2 normalization to generate a high-order fused feature. This fused feature is then fed into a classifier consisting of two fully connected layers and a Softmax layer, outputting the probabilities of various wear states to complete the recognition task.

[0050] An embodiment of the image processing-based CNC machine tool wear recognition system provided by this invention: The image processing-based CNC machine tool wear identification system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the image processing-based CNC machine tool wear identification method described above.

[0051] The CNC machine tool wear recognition system based on image processing also includes other components well known to those skilled in the art, such as communication interfaces. Their settings and functions are known in the art and will not be described in detail here.

[0052] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device. Any application or module described in this invention can be implemented using computer-readable / executable instructions stored or otherwise maintained by such a computer-readable medium.

[0053] 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, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A method for identifying CNC machine tool wear based on image processing, characterized in that, Includes the following steps: The cutting edge image of the tool to be identified is acquired and input into a pre-trained boundary awareness thinning network. The boundary awareness thinning network extracts multi-scale feature maps through the encoder and uses the initial prediction module to generate a global probabilistic initial wear area mask and an initial boundary orientation field in parallel based on the highest-level semantic features output by the encoder. Based on the probabilistic initial wear region mask and the initial boundary orientation field, a semantically guided multi-scale directional boundary feature map and a wear region mask with clear boundaries are generated. A well-defined wear region mask is used as spatial attention to perform weighted pooling on the multi-scale feature map output by the encoder, generating a contextual semantic feature vector representing the texture and content inside the wear region. Simultaneously, statistical moments are calculated on the semantically guided multi-scale directional boundary feature map along the contour line of the well-defined wear region mask, generating a boundary representation vector representing the boundary geometry and gradient stability. The contextual semantic feature vector and the boundary representation vector are fused through a bilinear attention pooling module to generate a high-order fused feature that is stable against geometric deformation and texture noise. The high-order fused feature is then input into the classifier to output the identification result of the tool wear state.

2. The CNC machine tool wear identification method based on image processing according to claim 1, characterized in that, Based on the probabilistic initial wear region mask and the initial boundary orientation field, a semantically guided multi-scale directional boundary feature map and a wear region mask with clear boundaries are generated. This includes: a boundary-aware thinning network using the initial boundary orientation field as guidance to weight a set of preset structured gradient operators at each feature map scale to achieve anisotropic gradient calculation, thereby generating a semantically guided multi-scale directional boundary feature map; and a boundary-aware thinning network using a local information aggregation module to construct a local one-dimensional sampling path parallel to the local orientation for each pixel in the region to be identified, based on the local orientation of the pixel in the initial boundary orientation field. The module then bidirectionally aggregates the context information and boundary features of neighboring pixels along the local one-dimensional sampling path and updates the posterior probability of the pixel belonging to the wear region by combining the prior probability provided by the probabilistic initial wear region mask, thereby generating a wear region mask with clear boundaries.

3. The CNC machine tool wear identification method based on image processing according to claim 2, characterized in that, A set of predefined structured gradient operators is weighted at various feature map scales to achieve anisotropic gradient calculation, including: A set of eight 3×3 gradient operators is predefined, each gradient operator corresponds to a specific direction, and the directions are spaced 45° apart; For any pixel in the feature map, extract the normalized direction vector corresponding to the pixel in the initial boundary direction field; Calculate the cosine similarity between the direction vector and the preset directions of the eight gradient operators, and convert the similarity values ​​into a set of weights with a sum of 1 using the Softmax function; Eight gradient operators are applied to the neighborhood of a pixel, and the resulting eight gradient response values ​​are weighted and summed with their corresponding weights to obtain the anisotropic gradient values ​​of the pixel.

4. The CNC machine tool wear identification method based on image processing according to claim 2, characterized in that, The context information and boundary features of neighboring pixels are aggregated bidirectionally along the local one-dimensional sampling path, and combined with the prior probability provided by the probabilistic initial wear region mask, the posterior probability of a pixel belonging to the wear region is updated, including: Centered on the target pixel, a local one-dimensional sampling path is constructed along the corresponding direction of the pixel in the initial boundary direction field. Ten points are sampled at equal intervals in two opposite directions to obtain a sequence containing 21 sampling points. For each sampling point in the sequence, the context feature vector of the sampling point in the corresponding scale feature map of the encoder and the boundary feature value in the semantically guided multi-scale directional boundary feature map are obtained by bilinear interpolation, and the two are concatenated. The feature sequences are fed into two gated recurrent unit networks in opposite directions to obtain aggregated information vectors in two directions. The aggregated information vectors from the two directions are concatenated, and the initial probability value of the target pixel in the probabilistic initial wear region mask is obtained. The initial probability value is then concatenated with the concatenated aggregated information vector, and the updated posterior probability value of the target pixel belonging to the wear region is calculated through a prediction head containing two fully connected layers and a Sigmoid activation function.

5. The CNC machine tool wear identification method based on image processing according to claim 1 or 2, characterized in that, Using a well-defined wear region mask as spatial attention, the multi-scale feature map output by the encoder is weighted and pooled to generate a contextual semantic feature vector representing the texture and content within the wear region, including: The probability values ​​of the wear region mask with clear boundaries are scaled to the same spatial resolution as the feature maps of the second, third, fourth, and fifth stages output by the encoder through bilinear interpolation, resulting in four spatial attention maps. Each spatial attention map is multiplied element-wise with the feature map at the corresponding scale to enhance the feature response within the wear area; For each weighted feature map, perform average pooling based on spatial attention map area normalization to generate a feature vector with four fixed dimensions. The four feature vectors are concatenated along the channel dimension to obtain the contextual semantic feature vector.

6. The CNC machine tool wear identification method based on image processing according to claim 1 or 2, characterized in that, Along the contour lines of the clearly defined wear region mask, statistical moments are calculated on the semantically guided multi-scale directional boundary feature map to generate a boundary representation vector representing the boundary geometry and gradient stability, including: The mask of the wear area with clear boundaries is binarized, and the coordinate set of all contour pixels is extracted by applying the edge detection operator; Based on the coordinates of the contour pixels, the boundary strength value corresponding to the pixel in the highest resolution semantically guided multi-scale directional boundary feature map is indexed. Based on the set of boundary intensity values ​​of all contour pixels, calculate the first moment, second central moment, third normalized moment, and fourth normalized moment; The calculated first-order moment, second-order central moment, third-order normalized moment, and fourth-order normalized moment are concatenated to form the boundary representation vector.

7. The CNC machine tool wear identification method based on image processing according to claim 1 or 2, characterized in that, A bilinear attention pooling module is used to fuse the context semantic feature vector and the boundary representation vector to generate high-order fused features that are stable against geometric deformation and texture noise, including: Dimension is The context semantic feature vector is linearly projected through a fully connected layer to an intermediate vector of dimension 1024; Dimension is The boundary representation vector is linearly projected through another fully connected layer to an intermediate vector of dimension 1024; Multiply the two projected vectors of dimension 1024 element by element to obtain a fused vector of dimension 1024. The fused vectors are then subjected to sign square root processing and L2 norm normalization processing in sequence to obtain higher-order fused features.

8. The CNC machine tool wear identification method based on image processing according to claim 1 or 2, characterized in that, Boundary-aware refinement networks extract multi-scale feature maps through an encoder, including: The encoder uses a ResNet-50 network pre-trained on the ImageNet dataset as the backbone and removes the last global average pooling layer and fully connected layer. From the outputs of the second, third, fourth, and fifth residual modules of the ResNet-50 network, feature maps with decreasing resolution and increasing semantic information are extracted respectively to serve as multi-scale feature maps.

9. The CNC machine tool wear identification method based on image processing according to claim 1, characterized in that, The high-order fusion features are input into the classifier, and the output is the identification result of the tool wear state, including: The classifier consists of two sequentially connected fully connected layers; The first fully connected layer maps the high-order fusion features from the input dimension to a 128-dimensional hidden layer and applies the ReLU activation function; The second fully connected layer maps the 128-dimensional hidden layer features to the output dimension corresponding to the number of tool wear state categories, and calculates the probability of each category through the Softmax function. The one with the highest probability is the recognition result.

10. A CNC machine tool tool wear recognition system based on image processing, characterized in that, It includes a memory and a processor, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the image processing-based CNC machine tool wear identification method according to any one of claims 1-9 is implemented.