Anti-interference detection method and system for surface roughness of mechanical processing under complex environment
A surface roughness detection method for machining in complex environments, based on multi-dimensional interference analysis and enhanced neural network prediction, solves the problem of insufficient detection accuracy in complex environments, and achieves high-precision and rapid surface roughness detection, applicable to machined parts with multiple processes and materials.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG UNIV
- Filing Date
- 2026-01-19
- Publication Date
- 2026-04-21
AI Technical Summary
In the current technology for surface roughness detection of machining in complex environments, interference factors lead to insufficient detection accuracy and high error rate. There is a lack of quantitative characterization of interference factors and exploration of the correlation between interference and characteristic parameter errors. The existing error correction mechanism is too simple and cannot meet the actual production needs.
An anti-interference detection method employing multi-dimensional interference analysis, coupling error correction, and enhanced neural network prediction is adopted. This method forms a closed-loop interaction through four stages: image acquisition and feature optimization, quantitative characterization of interference, multi-dimensional coupling error correction, and enhanced neural network prediction. High-resolution acquisition is achieved using a 12-megapixel area array industrial camera, a low-distortion lens, and a six-axis robotic arm. Interference regions are identified by combining improved Otsu threshold segmentation and SVM classification. A multi-dimensional coupling error correction model is constructed, and a multi-head self-attention mechanism is introduced for feature fusion. Finally, the roughness prediction value is output.
It achieves high-precision surface roughness detection in complex environments, improving detection accuracy by 15% and error correction accuracy by 30.6%, meeting online inspection requirements. It is suitable for machined parts with multiple processes and materials, improving inspection efficiency by 40%, and the detection time for a single image is ≤1.2s.
Smart Images

Figure CN121544610B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of intelligent detection technology for machining quality, specifically to a method and system for detecting interference-resistant surface roughness of machining surfaces under complex environments. Background Technology
[0002] The statements in this section are merely background information relating to this disclosure and do not necessarily constitute prior art.
[0003] Technological advancements and innovations in manufacturing often drive overall societal productivity growth. However, issues such as low precision in machined parts and insufficient performance consistency remain major bottlenecks in the transformation process. Among these, surface roughness, as a core indicator for evaluating the surface quality of parts, directly determines the assembly compatibility, fatigue life, and operational reliability of the parts through its detection accuracy.
[0004] With the iteration of machine vision technology, existing surface roughness detection methods can achieve high-precision detection in ideal laboratory environments with fixed materials, uniform backgrounds, and no interference. However, in actual production scenarios, the complexity of the processing environment leads to the easy adhesion of various interferences to the surface of parts: residual metal scraps from additive manufacturing, cutting chips from subtractive manufacturing, and oil stains from the cooling and lubrication system. These interferences are highly similar to the inherent features of the part surface in terms of grayscale distribution and texture morphology, which can cause significant deviations in the feature parameters such as difference and contrast extracted by traditional detection methods, ultimately resulting in a roughness prediction error rate that generally exceeds 15%.
[0005] In summary, current research still has the following key shortcomings:
[0006] (1) Most studies are based on ideal images without interference, lacking quantitative characterization of interference factors and exploration of the correlation between interference and feature parameter errors;
[0007] (2) Existing methods have a single error correction mechanism and mostly use simple linear models. They do not consider the coupling relationship between feature parameters and the differences in interference types, resulting in the detection accuracy of the interfered images failing to meet actual production needs. Summary of the Invention
[0008] To address the aforementioned issues, this disclosure proposes a method and system for detecting the surface roughness of machined surfaces under complex environments, which is designed to resist interference. It proposes an anti-interference detection scheme that integrates multi-dimensional interference analysis, coupled error correction, and enhanced neural network prediction. Each stage forms a closed-loop interaction through "data output - precise input". The interference quantification results directly drive the error correction model, and the corrected precise parameters serve as the input to the enhanced neural network to achieve high-precision prediction.
[0009] According to some embodiments, the present disclosure adopts the following technical solutions:
[0010] Methods for detecting interference-resistant surface roughness of machined surfaces under complex environments include:
[0011] Acquire images of the workpiece surface and preprocess them to extract the core feature parameters of the image texture;
[0012] Based on the core feature parameters, a two-level intelligent segmentation strategy is used to quantitatively analyze the interference factors of the surface image, extract the features of the interference area, and construct the interference quantification matrix.
[0013] A multi-dimensional coupling error correction model is constructed. The interference quantization matrix and core feature parameters are input into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed into a feature matrix.
[0014] Combine the feature matrix and the grayscale features of the original image. Figure 1 The input is fed into the enhanced neural network model. After feature enhancement, a multi-head self-attention mechanism is introduced to calculate the attention weights of the parameter features and image features. The parameter features and image features are fused to obtain a fused feature vector. The fused feature vector is then input into the fully connected layer for prediction, and the roughness prediction value is output.
[0015] According to some embodiments, the present disclosure adopts the following technical solutions:
[0016] A surface roughness detection system for machining under complex environments with interference resistance includes:
[0017] The parameter acquisition module is used to acquire images of the workpiece surface, preprocess them, and extract the core feature parameters of the image texture.
[0018] The quantitative analysis module is used to quantitatively analyze the interference factors of the surface image based on the core feature parameters and adopt a two-level intelligent segmentation strategy, extract the features of the interference area and construct the interference quantification matrix.
[0019] The correction module is used to construct a multi-dimensional coupling error correction model. The interference quantization matrix and core feature parameters are input into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed into a feature matrix.
[0020] The prediction module is used to combine the feature matrix with the grayscale features of the original image. Figure 1 The input is fed into the enhanced neural network model. After feature enhancement, a multi-head self-attention mechanism is introduced to calculate the attention weights of the parameter features and image features. The parameter features and image features are fused to obtain a fused feature vector. The fused feature vector is then input into the fully connected layer for prediction, and the roughness prediction value is output.
[0021] According to some embodiments, the present disclosure adopts the following technical solutions:
[0022] A computer program product includes a computer program that, when executed by a processor, implements the method for detecting the surface roughness of machined surfaces under complex environments to resist interference.
[0023] According to some embodiments, the present disclosure adopts the following technical solutions:
[0024] A non-transitory computer-readable storage medium is provided for storing computer instructions, which, when executed by a processor, implement the method for detecting the surface roughness of machined surfaces under complex environments to resist interference.
[0025] According to some embodiments, the present disclosure adopts the following technical solutions:
[0026] An electronic device includes a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to enable the electronic device to perform the method for detecting the surface roughness of machined surfaces under complex environments.
[0027] Compared with the prior art, the beneficial effects of this disclosure are as follows:
[0028] This disclosure presents an anti-interference detection method for surface roughness in complex environments. It proposes an anti-interference detection method integrating multi-dimensional interference analysis, coupled error correction, and enhanced neural network prediction, filling the technological gap in high-precision surface roughness detection under complex environments. Anti-interference detection is achieved through four core stages: image acquisition and feature optimization, quantitative interference characterization, multi-dimensional coupled error correction, and enhanced neural network prediction. Each stage forms a closed-loop interaction through "data output - precise input." Preprocessed feature parameters provide basic data for interference analysis, interference quantification results directly drive the error correction model, and the corrected precise parameters serve as neural network input to achieve high-precision prediction.
[0029] This disclosure discloses a method for detecting the surface roughness of machined surfaces under complex environments. In the image acquisition and feature optimization stage, a 12-megapixel area array industrial camera, a low-distortion lens, and a ring-shaped coaxial cold light source are used to construct the acquisition device. A six-axis robotic arm and machine vision positioning technology are combined to adaptively adjust the camera's working distance. Preprocessing employs a combination of guided filtering and linear grayscale normalization. Feature selection is based on Spearman correlation coefficients to remove redundant parameters, enabling high-resolution acquisition and adaptive positioning. This avoids the loss of texture information caused by shooting angle and distance deviations, improving sample coverage by 40%. Compared to traditional Gaussian filtering, guided filtering removes Gaussian and salt-and-pepper noise while improving texture detail retention by 23%, providing high-quality images for subsequent feature extraction. Based on correlation coefficient-based feature selection, four core parameters are retained from eight initial features. While retaining over 90% of key information, the data dimensionality is reduced by 50%, significantly reducing subsequent computational redundancy and improving detection efficiency.
[0030] This disclosure presents a method for detecting interference-resistant roughness of machined surfaces under complex environments. It employs a two-stage intelligent segmentation strategy combining "improved Otsu threshold segmentation + SVM classification." The improved Otsu algorithm introduces gray-level gradient weights to dynamically determine the threshold. For three types of interference, it selects five core features: gray-level, morphology, and texture. The SVM uses the RBF kernel function and optimizes parameters through grid search. Compared to traditional algorithms, this improved Otsu algorithm achieves an 18% increase in segmentation accuracy for low-contrast oil stain images, with a false negative rate of ≤2.1% for interference regions, solving the problem of inaccurate identification of low-gray-level interference in traditional segmentation. The multi-dimensional feature combination optimizes SVM classification, achieving an overall classification accuracy of ≥96% for the three types of interference, with an oil stain identification accuracy of 97.1%, enabling precise differentiation of different types of interference. The interference quantification matrix transforms abstract interference into quantifiable numerical indicators, providing precise interference input for subsequent error correction and filling the gap in the lack of quantitative interference characterization in existing technologies.
[0031] This disclosure presents a method for detecting the anti-interference of surface roughness in complex environments. It constructs a composite model consisting of a basic linear term, an interference correction term, and a coupling compensation term. The basic coefficients are fitted using the least squares method, the coupling coefficients are derived from Spearman's correlation coefficient, and the weighting coefficients are optimized using particle swarm optimization. A three-dimensional verification system—group verification, accuracy comparison, and robustness testing—is implemented. Compared to the traditional single linear correction model, the introduction of the coupling compensation term reduces the average error of feature parameter correction by 30.6% under complex interference scenarios. Specifically, the accuracy of contrast parameter correction decreases from 3.2% to 1.9% under debris interference. All coefficients are optimized using statistical methods and intelligent algorithms, with correction errors for all four core parameters ≤2.1%, and the energy parameter showing the best result (≤1.5%). The goodness-of-fit R² ≥ 0.93 ensures the accuracy of the corrected parameters. The three-dimensional verification system covers different interference types and proportions, demonstrating high robustness within the 5%-30% interference range, making it suitable for scenarios with varying interference in actual production.
[0032] This disclosure presents a method for detecting surface roughness in complex environments under anti-interference conditions. It employs a dual-input mode of "corrected parameter matrix + grayscale feature map," combining a fully connected network and a convolutional module in the feature enhancement layer. A four-head self-attention mechanism is introduced to fuse features, and a Transformer encoder and a bidirectional LSTM are connected in series. A composite loss function of "MSE+MAPE" and an Adam optimizer are used, along with an early stopping mechanism. This dual-input mode balances parameter accuracy with image texture integrity, doubling the feature representation dimension and laying the foundation for high-precision prediction. The multi-head self-attention mechanism accurately captures the correlation weights between parameters and image features. The Transformer+LSTM combination captures both global feature correlations and temporal dependencies, improving prediction accuracy by more than 15% compared to traditional BP networks. The composite loss function avoids model sensitivity to extreme values, and the early stopping mechanism improves model convergence speed by 40%, with a single image detection time ≤1.2s, meeting the efficiency requirements of online detection.
[0033] The surface roughness detection method for machining under complex environments disclosed herein is a surface roughness detection method for complex manufacturing scenarios (including interference from additive manufacturing metal scraps, subtractive manufacturing cutting chips and cooling lubricating oil stains, etc.). It is applicable to high-precision online detection of surface roughness of multi-processes such as milling, grinding, and 3D printing, as well as multi-material parts such as metals, ceramics, and composite materials. Attached Figure Description
[0034] The accompanying drawings, which form part of this disclosure, are used to provide a further understanding of this disclosure. The illustrative embodiments of this disclosure and their descriptions are used to explain this disclosure and do not constitute an undue limitation of this disclosure.
[0035] Figure 1This is a schematic flowchart of a method for detecting the surface roughness of machined surfaces under complex environments according to an embodiment of this disclosure. Detailed Implementation
[0036] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.
[0037] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains.
[0038] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this disclosure. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0039] Example 1
[0040] One embodiment of this disclosure provides a method for detecting interference-resistant surface roughness of machined surfaces under complex environments, the method steps including:
[0041] Step 1: Acquire an image of the workpiece surface and preprocess it to extract the core feature parameters of the image texture;
[0042] Step 2: Based on the core feature parameters, a two-level intelligent segmentation strategy is used to quantitatively analyze the interference factors of the surface image, extract the features of the interference area, and construct the interference quantification matrix.
[0043] Step 3: Construct a multi-dimensional coupling error correction model. Input the interference quantization matrix and core feature parameters into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed as a feature matrix.
[0044] Step 4: Combine the feature matrix and the grayscale features of the original image. Figure 1 The input is fed into the enhanced neural network model. After feature enhancement, a multi-head self-attention mechanism is introduced to calculate the attention weights of the parameter features and image features. The parameter features and image features are fused to obtain a fused feature vector. The fused feature vector is then input into the fully connected layer for prediction, and the roughness prediction value is output.
[0045] As one embodiment, this disclosure discloses a method for detecting the surface roughness of machined surfaces under complex environments. This method achieves anti-interference detection through four core stages: image acquisition and feature optimization, quantitative interference characterization, multi-dimensional coupled error correction, and enhanced neural network prediction. Each stage forms a closed-loop interaction through "data output and precise input." Preprocessed feature parameters provide basic data for interference analysis, the interference quantification results directly drive the error correction model, and the corrected precise parameters serve as neural network input to achieve high-precision prediction. The specific implementation process is as follows:
[0046] Step 1: Acquire an image of the workpiece surface and preprocess it to extract the core feature parameters of the image texture; specifically, the implementation process is as follows:
[0047] (1) Acquire images of the surface of the workpiece using an image acquisition device;
[0048] This disclosure employs a 12-megapixel area array industrial camera, a 16mm low-distortion industrial lens, and a ring coaxial cold light source to build a high-resolution image acquisition device. The image acquisition device is integrated into the end of a six-axis robotic arm, and the contour of the workpiece is automatically identified through machine vision positioning technology. The working distance of the camera is adaptively adjusted (50-150mm) to ensure that the detection area completely covers more than three representative texture areas on the surface of the part (each area ≥2mm×2mm).
[0049] As one example, machine vision positioning technology can employ existing deep learning model algorithms.
[0050] Furthermore, during image acquisition, images of the processed surface covering three typical types of interference were collected: scrap (particle size 0.1-0.5mm), debris (flaky / granular), and oil stains (film thickness 0.01-0.05mm). The interference coverage area accounted for 5%-30%, and each type of interference corresponded to more than 500 sets of sample images of different processing techniques.
[0051] (2) Perform preprocessing operations such as noise suppression, grayscale normalization, region cropping, and feature redundancy removal on the surface image of the workpiece. The specific contents are as follows:
[0052] ① Noise suppression: A guided filtering algorithm is used (filter radius r=5, regularization parameter...) By removing Gaussian noise and salt-and-pepper noise, the texture detail retention rate is improved by 23% compared to traditional filtering.
[0053] ② Gray-scale normalization: The image gray-scale values are mapped to the 0-255 range using a linear stretching formula to eliminate the influence of light source intensity fluctuations. The formula is:
[0054]
[0055] in, The original grayscale value. , These are the minimum and maximum grayscale values of the image, respectively. The standardized grayscale value;
[0056] ③ Region cropping: Edge detection is performed based on the Sobel operator (horizontal / vertical convolution kernel size 3×3), and the contour is optimized by combining morphological closing operation (structural element 5×5). The background region is cropped to obtain an ROI image containing only the surface of the part and the interference.
[0057] ④ Feature Redundancy Removal: Based on gray-level co-occurrence matrix (distance 1, mean of angles 0° / 45° / 90° / 135°), texture statistical analysis, and other methods, eight types of surface texture feature parameters were initially extracted. The complete list and physical meaning are shown in Table 1 below. Subsequently, the Spearman correlation coefficients among the eight types of features were calculated, and features were removed. The redundant parameters (i.e. extended parameters that are highly linearly correlated with the core parameters) are removed, and finally four types of core feature parameters (difference, contrast, entropy, and energy) are retained. The screening results are directly used as the benchmark parameters for feature extraction of interference regions in "quantitative analysis of interference factors", reducing subsequent computational redundancy.
[0058] Table 1 Surface Texture Feature Parameters
[0059]
[0060] Furthermore, the screening criteria were based on the absolute value of the Spearman correlation coefficient. This means that the extended features have a very strong monotonic correlation with a certain type of core features, and the information overlap is high. Removing them can reduce the data dimensionality while retaining key information. For example, both moment of inertia and energy reflect the concentration of gray-level distribution, and their correlation coefficient is 0.91. Therefore, only the energy parameter, which has a more intuitive physical meaning, is retained.
[0061] Step 2: Based on the core feature parameters, a two-level intelligent segmentation strategy is used to quantitatively analyze the interference factors in the surface image, extract the features of the interference region, and construct an interference quantification matrix. Specific content includes:
[0062] (1) Based on the gray-level histogram characteristics of the surface image, an improved Otsu thresholding algorithm is adopted, which introduces gray-level gradient weights to dynamically determine the segmentation threshold and segment the interference candidate region. The content includes:
[0063] This disclosure performs adaptive thresholding for initial segmentation. Based on the gray-level histogram characteristics of the surface image, it employs an improved Otsu thresholding algorithm. This improved Otsu algorithm introduces gray-level gradient weights to dynamically determine the segmentation threshold T. The improved Otsu thresholding algorithm determines the optimal threshold by calculating the maximum value of the product of the gray-level inter-class variance and the gradient mean, as shown in the formula:
[0064]
[0065] in, The inter-class variance is the difference between the foreground (disturbing) and the background (normal surface). This represents the mean gradient of the image.
[0066] Compared with traditional Otsu threshold segmentation, the method disclosed herein improves the segmentation accuracy of low-contrast oil stain images by 18%. It can initially extract and segment the surface image into "interference candidate regions" (grayscale values ∈ [T-15, T+20]) and "normal surface regions". The false negative rate of interference regions after initial segmentation is ≤2.1%.
[0067] (2) Based on the differences in physical characteristics of the three interference sources—fragments, debris, and oil stains—multiple core interference features in three dimensions—grayscale, morphology, and texture—are selected, including:
[0068] To address the differences in physical properties among fragments (blocky solids), debris (flaky / granular solids), and oil stains (liquid diffusion), five core interference features across three dimensions—grayscale, morphology, and texture—were selected. All features were normalized (mapped to the [0,1] interval) to eliminate the influence of dimensions. The calculation methods, physical meanings, and distinguishing criteria for each feature type are detailed below:
[0069] 1) Features of the grayscale dimension include the grayscale mean. and grayscale standard deviation The grayscale mean and grayscale standard deviation are calculated as follows:
[0070] ;
[0071] ;
[0072] in, is the grayscale value of the pixels within the region, and N is the total number of pixels in the region.
[0073] Furthermore, the core distinguishing criteria for grayscale mean and grayscale standard deviation are the significant difference in grayscale center between oil stains (μ=50-120) and solid interference (μ=30-80) and the uniform distribution of oil stains, respectively. ), scrap / debris due to rough surface .
[0074] 2) The features of the morphological dimension include the morphological factor FF and the contour complexity CC. The calculation of the morphological factor FF and the contour complexity CC are as follows:
[0075] ;
[0076] CC = (Number of concave and convex points on the contour / Total number of points on the contour) × 100%;
[0077] Where S is the area of the region and L is the perimeter of the region's outline; concave and convex points are detected by curvature abrupt change (curvature threshold = 0.8).
[0078] Furthermore, the core distinguishing criteria for morphological factor FF and contour complexity CC are as follows: fragments (FF=0.6-0.8, blocky and regular) > debris (FF=0.3-0.5, flaky and irregular) > oil stains (FF=0.1-0.2, diffuse and amorphous) and debris (CC=35%-50%, broken edges) > fragments (CC=15%-25%, relatively smooth edges) > oil stains (CC<5%, smooth edges).
[0079] 3) Texture dimension features include texture energy TE, which is calculated based on a 5×5 gray-level co-occurrence matrix:
[0080]
[0081] in, This represents the probability of grayscale co-occurrence.
[0082] Furthermore, the core distinguishing criterion for texture energy TE is that solid interference (TE=0.02-0.08, dense texture) is much greater than oil stains (TE<0.01, no obvious texture).
[0083] (3) The core interference features are used to construct feature vectors and input into the support vector machine for interference classification to identify various interference regions;
[0084] Specifically, the Support Vector Machine (SVM) classifier is first trained to achieve accurate interference region identification. A feature vector is constructed using five classes of normalized interference features, and then input into the SVM to classify the interference. The classifier design and training details are as follows:
[0085] 1) Dataset construction: Collect 1500 sets of interference samples (500 sets of scrap, 500 sets of debris, and 500 sets of oil stains). Each set of samples corresponds to a 5-dimensional feature vector and interference type label (0-scraps, 1-debris, 2-oil stains). The samples are divided into a training set (1050 sets) and a test set (450 sets) in a 7:3 ratio.
[0086] 2) Kernel function and parameter optimization: Radial basis function (RBF) was selected as the kernel function. The parameters were optimized by grid search (γ∈[0.1,10], penalty coefficient C∈[1,100]). The optimal parameters were finally determined to be γ=2.5 and C=50. This parameter combination achieved a cross-validation accuracy of 97.2% on the training set.
[0087] 3) The specific process of classification: The 5-dimensional feature vector of the candidate region is input into the trained SVM classifier, which outputs the interference type prediction label. At the same time, a second verification is performed by combining the "feature similarity threshold" (Euclidean distance ≤ 3.2 with the central features of various interference types) to eliminate abnormal classification results.
[0088] 4) Classification performance verification: The test set verification results show that the classification accuracy of the three types of interference is 96.8% for scrap, 95.3% for debris, and 97.1% for oil stains. The overall classification accuracy is ≥96%, which meets the needs of subsequent quantitative analysis of type interference.
[0089] Solid interference optimization: For scrap / debris, small noise with an area ≤5 pixels is removed by 3×3 structuring element opening operation, while preserving the complete interference area;
[0090] Liquid interference optimization: For oil stains, the segmentation threshold is optimized by combining the regional grayscale standard deviation to avoid misjudging low-roughness textures as interference.
[0091] (4) Count the number of pixels in various interference regions, perform quantitative interference calculation based on image calibration parameters, calculate the area of a single type of interference and the proportion of the total interference area, and calculate the difference between the mean gray value of each type of interference region and the mean gray value of the normal surface; construct an interference quantification matrix based on the calculated proportions and differences; the specific contents include:
[0092] 1) Area quantization: Count the number of pixels in each type of interference region, and calculate the area of each type of interference by combining the image calibration parameters (pixel spacing = 0.01mm / pixel). ( i =1, 2, 3 correspond to scrap, debris, and oil stains (unit: mm²) and the percentage of total interference area. (This represents the actual area of the ROI region, in mm²).
[0093] 2) Gray-scale feature quantization: Calculate the mean gray-scale value of various interference regions. ( (corresponding to scrap, debris, and oil stains respectively) and the average grayscale value of a normal surface Differences Constructing the interference quantization matrix (Where R is the percentage of the total interference area,) Due to differences in the grayness of the fragments, Due to differences in the grayscale of the debris, (For the difference in grayscale of oil stains), this matrix will serve as the core input variable for the subsequent error correction model construction, achieving a multi-dimensional and accurate representation of the interference.
[0094] Step 3: Construct a multi-dimensional coupling error correction model. Input the interference quantization matrix and core feature parameters into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed as a feature matrix. The specific implementation process is as follows:
[0095] (1) Analysis of the error law of characteristic parameters, the specific implementation steps are as follows:
[0096] ① Construction of Standard Sample Library: Ten sets each of metal (aluminum alloy 6061) and ceramic (alumina) specimens processed by three typical processes—milling, grinding, and 3D printing—were selected. The Ra values (0.1-10μm) were measured using a stylus-type roughness tester (model: Taylor Hobson Surtronic S-100) and used as standard roughness benchmarks. Interference-free images of the standard specimens were acquired using the image acquisition device disclosed in this publication, and four types of core feature parameters (difference C, contrast D, entropy E, and energy En) were extracted to establish a "standard Ra value - standard feature parameter" benchmark library. The parameter extraction repeatability accuracy was ≤1.2%.
[0097] Furthermore, the four core feature parameters are difference C, contrast D, entropy E, and energy En. Difference C reflects the degree of difference in surface gray values and is calculated using the gray-level co-occurrence matrix (distance 1, angle 0°). Contrast D characterizes the degree of surface texture undulation and is calculated by summing the absolute values of neighborhood gray-level differences and dividing by the total number of pixels. Entropy E describes the disorder of gray-level distribution and reflects texture complexity. It is calculated by the logarithmic weighted sum of the probabilities of the gray-level histogram. Energy En measures the uniformity of gray-level distribution and is negatively correlated with roughness. It is calculated by the sum of squares of the elements of the gray-level co-occurrence matrix.
[0098] ② Gradient interference sample preparation: Based on standard images, digital scrambling technology was used to add interference in a two-factor design—the type of interference (fragment / debris / oil) was the first factor, and the proportion of interference area (5% / 10% / 15% / 20% / 25% / 30%) was the second factor, for a total of 27 interference scenarios; among them, fragments / debris were synthesized from images of processed particles of the same material (particle size 0.1-0.5mm randomly distributed), and oil was simulated using grayscale gradient (film thickness 0.01-0.05mm corresponding to a grayscale mean of 50-120), to ensure that the interference simulation closely resembled actual production;
[0099] ③ Error data calculation and preprocessing: Feature parameters were extracted from each of the 27 scrambled images. (i=1→C,2→D,3→E,4→En), combined with the corresponding standard parameters in the benchmark library ( ), calculate the rate of change of error according to the formula ( i For feature parameter type, j (For interference type); outlier removal was performed on the 1200 sets of data (27 scenes × 4 types of parameters × 11 sets of duplicate samples) obtained from the calculation (using... Based on the criteria of eliminating ≤2.3%, 1172 sets of valid data were ultimately retained, which were compared with the interference quantification matrix output by the interference quantification analysis. One-to-one correspondence, building an associated database;
[0100] ④ Error Correlation Pattern Mining: SPSS software was used to perform correlation analysis on the correlation database. The results showed that the proportion of interference area R and... The Pearson correlation coefficient was ≥0.68 (P<0.01), indicating a difference in interference grayscale. ( j =1,2,3) and The correlation coefficient ≥ 0.52 (P < 0.01) confirms the significant association between multidimensional interference indicators and parameter errors, providing a statistical basis for the selection of model variables.
[0101] Furthermore, the interference characteristics include the total interference area ratio R and the grayscale difference of the fragments. , difference in grayscale of debris and differences in the grayness of oil stains The total interference area percentage R is the ratio of all interference areas to the ROI area, and the calculation process is as follows: , For single-type interference area; gray scale difference of fragments The difference in grayscale mean between the fragmented area and the normal surface is calculated as follows: , The average gray value of the debris; the difference in gray value of the debris. The difference in grayscale mean between the debris area and the normal surface is calculated as follows: , The gray value represents the average gray value of debris; the gray value difference represents the gray value of oil stains. The difference in grayscale mean between the oil-stained area and the normal surface is calculated as follows: , This represents the average gray level of the oil stains.
[0102] (2) Establish a multi-dimensional coupling error correction model. The multi-dimensional coupling error correction model is a composite model of the basic linear correction model and the multi-dimensional compensation model. Its input is the interference quantization matrix and the core feature parameters. The model expression continues the structure of "basic linear term + interference correction term + coupling compensation term". The specific model structure is as follows:
[0103]
[0104] The first image of the interfered image i Class feature parameters; P k干扰 The first image of the interfered image k Class feature parameters.
[0105] Furthermore, the solution and interpretation of various coefficients in the model structure are as follows:
[0106] As one example, the base coefficient The solution is obtained by fitting the least squares method. For the first i The area interference coefficient of the class feature parameter is used to quantify the proportion of the total interference area. R Impact on parameter error; For the first i Class feature parameters for the first j The grayscale sensitivity coefficient for interference-like phenomena is used for quantization. The impact; For the first i The correction constant for the class characteristic parameters is used to compensate for system errors.
[0107] Furthermore, taking the difference parameter C (i=1) as an example, the following fit is obtained: , (Scrap materials) (Debris) = 0.41 (Oil stains) goodness of fit The fitting results for the remaining parameters are shown in Table 2.
[0108] Table 2 Parameter Fitting Results
[0109]
[0110] Furthermore, the coupling coefficient For the first k Class feature parameters for the first i The interference propagation coefficient of class feature parameters quantifies the coupling effect between parameters. Its core is to first calculate the parameter correlation degree using the Spearman correlation coefficient, and then convert it into a coupling coefficient. The specific steps and formulas are as follows:
[0111] 1. Spearman correlation coefficient Calculation: Used to measure the monotonic correlation between feature parameters of class i and class k, the formula is:
[0112]
[0113] in: is the rank difference between the feature parameters of class i and class k in the m-th sample (the difference in rank after sorting the parameter values by size); n is the number of samples (here n=1172); The value range is [-1, 1]. The larger the value, the stronger the coupling between parameters.
[0114] 2. Coupling coefficient Transformation: To eliminate the negative correlation and achieve weight allocation, Normalize the absolute value of to obtain The formula is:
[0115]
[0116] Where the denominator is the first i The sum of the absolute values of the Spearman correlation coefficients of the class feature parameter and all other feature parameters ensures This allows for the quantitative allocation of the coupling effect. Calculations show that the difference (C) and contrast (D) are... , with entropy (E) , with energy (En) Therefore This process continues to derive all coupling coefficients.
[0117] Taking entropy (E, i=3) as an example, its difference from that of difference (C, k=1) , and contrast (D, k=2) , with energy (En, k=4) Calculated , , This clearly quantifies the interference and transmission effect of other parameters on entropy.
[0118] Furthermore, the weighting coefficients include , The basic weights of the disturbed feature parameters, For the weight of the interference correction term, The weights of the parameter coupling terms satisfy the following conditions: The particle swarm optimization algorithm was used for optimization; the population size was set to 50, the number of iterations to 100, and the inertia weight was set to... Learning factor The mean square error (MSE) between the corrected parameters and the standard parameters is used as the criterion. (where N is the number of samples) is the fitness function, and the weight coefficients of the four classes of parameters are finally obtained (Table 3).
[0119] Table 3 Weighting Coefficients
[0120]
[0121] As one embodiment, the inputs of the multi-dimensional coupling error correction model include , R and , The first image of the interfered image i The class feature parameters (i=1→C, 2→D, 3→E, 4→En) have the following values: C: 50-200; D: 10-80; E: 2-8; En: 0.01-0.1. Their correlation formula is as follows: ;
[0122] R represents the percentage of the total interference area. Its value ranges from 5% to 30%. , =Number of pixels × 0.01mm² / pixel; For the first j The difference in grayscale mean between interference-like and normal surfaces ( j =1→Scrap material, 2→Debris, 3→Oil stain), the value range is: :10-40; 15-50; :5-35; among which, , This represents the average gray level of the region. The output is the corrected value for the [number]th [unit]. i Class feature parameters (and P) i Interference response) The value range is ≤2.1% deviation from the standard parameter.
[0123] (3) Model Validation and Output Integration: A three-dimensional validation system of "group validation - accuracy comparison - robustness testing" is adopted to ensure model reliability. The actual area of a single type of interference (unit: mm², calculated from the number of pixels in the interference area × 0.01 mm / pixel). The actual area of the ROI region (unit: mm², same pixel conversion logic). is the Spearman correlation coefficient between the feature parameters of class i and class k (the value ranges from [-1,1], and the larger the absolute value, the stronger the correlation).
[0124] (4) Group validation: The 1172 sets of data were divided into a training set (820 sets) and a test set (352 sets) in a 7:3 ratio. The training set was used for parameter solving, and the test set was used for validation. Within the range of 5%-30% of the interference area, the correction error of the four types of feature parameters was ≤2.1%, among which the energy parameter had the best correction accuracy (error ≤1.5%). The specific validation results are shown in Table 4.
[0125] Table 4 Validation Results
[0126]
[0127] (5) Accuracy comparison: In complex scenarios such as debris (30%) and oil stains (25%), the correction error of this model is reduced by an average of 30.6%. Among them, the correction accuracy of contrast parameter is most significantly improved in the debris interference scenario (from 3.2% to 1.9%).
[0128] (6) Output connection: The modified 4 types of feature parameters are constructed into a feature matrix in the format of "[C,D,E,En]" and transmitted directly to the "roughness prediction" module through the data interface as the core input of the subsequent enhanced hybrid neural network; at the same time, the interference type label and the correction error value are output to provide a basis for the credibility evaluation of the subsequent prediction results, and realize the seamless data flow between the two modules.
[0129] Step 4: Combine the feature matrix and the grayscale features of the original image. Figure 1 The input is fed into the enhanced neural network model. After feature enhancement, a multi-head self-attention mechanism is introduced to calculate the attention weights of the parameter features and image features. The parameter features and image features are fused to obtain a fused feature vector. The fused feature vector is then input into the fully connected layer for prediction, and the roughness prediction value is output.
[0130] Specifically, the enhanced neural network model includes an input layer, a feature enhancement layer, an attention weighting layer, a fusion prediction layer, and a fully connected layer. The input layer uses a dual-input mode, with the core input being the corrected feature parameter matrix and the auxiliary input being the grayscale feature map of the original surface image. The feature enhancement layer extracts deep texture features through a two-layer fully connected network. After each convolutional layer, a batch normalization layer and a ReLU activation function are applied, and finally, global average pooling is used to obtain image features. The attention weighting layer introduces a multi-head self-attention mechanism, calculates the attention weights of the parameter features and image features, and fuses them to obtain a fused feature vector. The attention-weighted fused feature vector is input into a Transformer encoder to capture global correlations, then connected to a bidirectional LSTM network to capture temporal dependencies of features. Finally, the LSTM output is fused with the initial fused feature vector through residual connections and input to the fully connected layer to output the roughness prediction value.
[0131] As an example, the specific content and calculation process of each layer structure of the enhanced neural network model are as follows:
[0132] ① Input layer: Dual input mode, the core input is the 4-corrected feature parameter matrix output by the "error correction model", and the auxiliary input is the 256×256 grayscale feature map of the original ROI image. The combination of dual inputs improves the integrity of feature representation.
[0133] ② Feature enhancement layer: The parameter branch uses a 2-layer fully connected network (64 and 32 neurons respectively) to enhance the dimension, and the image branch uses a 4-layer convolutional module (3×3 kernel size, stride 1, padding=1) to extract deep texture features. Each convolutional layer is followed by a batch normalization (BN) layer and a ReLU activation function. Finally, a 64-dimensional image feature vector is obtained through global average pooling.
[0134] ③ Attention-weighted layer: Introducing a multi-head self-attention mechanism (number of heads = 4), the attention weights of parametric features and image features are calculated using the following formula:
[0135]
[0136] Q (query vector), K (key vector), and V (value vector) are generated by fusing the corrected feature parameters with image features, respectively. The dimension of the key vector (here) (consistent with the dimension of the image feature vector), highlighting feature information strongly related to roughness through weight allocation, the weighted result combines the advantages of the corrected parameters and image features;
[0137] ④ Fusion prediction layer: The attention-weighted feature vector is input into the Transformer encoder (6 coding layers) to capture global correlations, and then connected to a bidirectional LSTM network (hidden layer units = 128) to capture temporal dependencies of features. Finally, the LSTM output is fused with the initial feature vector through residual connections and input into the fully connected layer to output the roughness prediction value.
[0138] ⑤ Loss Function Optimization: A composite loss function of "Mean Squared Error (MSE) + Mean Absolute Percentage Error (MAPE)" is adopted, with the following formula:
[0139]
[0140] in To balance the effects of the two types of errors and avoid the model being overly sensitive to extreme values; in the formula This is the true Ra value of the nth sample (measured with a stylus probe). The model predicts the Ra value, where N is the number of samples;
[0141] As one embodiment, the model training and prediction process disclosed herein includes:
[0142] ① Training data preparation: Using the four standard feature parameters and corresponding grayscale images of interference-free images as input, and Ra values measured by a stylus roughness meter (accuracy ±0.001μm) as output labels, 8000 training sets and 2000 test sets are constructed.
[0143] ② Model Training: The Adam optimizer (learning rate = 0.001, batch size = 32) was used for training, and an early stopping mechanism was introduced (the model stopped if the loss on the validation set did not decrease after 10 consecutive rounds). The model converged after 60 iterations, and the convergence speed was improved by 40% compared with the original BP network.
[0144] ③ Anti-interference prediction: After the image to be detected is processed by "preprocessing-interference analysis-error correction", the correction parameters and grayscale image are input into the trained hybrid network, and the roughness prediction value is output. The detection time of a single image is ≤1.2s, which is 10% faster than the original method.
[0145] Example 2
[0146] One embodiment of this disclosure provides a surface roughness anti-interference detection system for machining in complex environments, comprising:
[0147] The parameter acquisition module is used to acquire images of the workpiece surface, preprocess them, and extract the core feature parameters of the image texture.
[0148] The quantitative analysis module is used to quantitatively analyze the interference factors of the surface image based on the core feature parameters and adopt a two-level intelligent segmentation strategy, extract the features of the interference area and construct the interference quantification matrix.
[0149] The correction module is used to construct a multi-dimensional coupling error correction model. The interference quantization matrix and core feature parameters are input into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed into a feature matrix.
[0150] The prediction module is used to combine the feature matrix with the grayscale features of the original image. Figure 1 The input is fed into the enhanced neural network model. After feature enhancement, a multi-head self-attention mechanism is introduced to calculate the attention weights of the parameter features and image features. The parameter features and image features are fused to obtain a fused feature vector. The fused feature vector is then input into the fully connected layer for prediction, and the roughness prediction value is output.
[0151] Example 3
[0152] One embodiment of this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the method for detecting the surface roughness of machined surfaces under complex environments to resist interference.
[0153] Example 4
[0154] One embodiment of this disclosure provides a non-transitory computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, they implement the method for detecting the surface roughness of machined surfaces under complex environments to resist interference.
[0155] Example 5
[0156] One embodiment of this disclosure provides an electronic device, including a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to enable the electronic device to perform the method for detecting the surface roughness of machined surfaces under complex environments.
[0157] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0158] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0159] While the specific embodiments of this disclosure have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of this disclosure. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this disclosure are still within the scope of protection of this disclosure.
Claims
1. A method for detecting the surface roughness of machined surfaces under complex environments, characterized in that, include: Acquire images of the workpiece surface and preprocess them to extract the core feature parameters of the image texture; Based on the core feature parameters, a two-level intelligent segmentation strategy is used to quantitatively analyze the interference factors of the surface image, extract the features of the interference area, and construct the interference quantification matrix. A multi-dimensional coupling error correction model is constructed. The interference quantization matrix and core feature parameters are input into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed into a feature matrix. The multi-dimensional coupled error correction model is a composite model of a basic linear correction model and multi-dimensional compensation. Its inputs are the interference quantization matrix and core feature parameters. The specific model structure is as follows: Among them, the basic coefficient The solution is obtained by fitting the least squares method. For the first i The area interference coefficient of the class feature parameter is used to quantify the proportion of the total interference area. R Impact on parameter error; For the first i Class feature parameters for the first j The grayscale sensitivity coefficient for interference-like phenomena is used for quantization. The impact; For the first i Correction constants for class characteristic parameters, used to compensate for system errors; coupling coefficients For the first k Class feature parameters for the first i The interference propagation coefficient of class feature parameters quantifies the coupling effect between parameters. Its core is to first calculate the parameter correlation degree using the Spearman correlation coefficient, and then convert it into a coupling coefficient; weighting coefficients include... , The basic weights of the disturbed feature parameters, For the weight of the interference correction term, The weights of the parameter coupling terms satisfy the following conditions: The particle swarm optimization algorithm is used for optimization. The first image of the interfered image i Class feature parameters; P k干扰 The first image of the interfered image k Class feature parameters; The feature matrix and the grayscale feature map of the original image are input into the augmented neural network model. After feature enhancement, a multi-head self-attention mechanism is introduced to calculate the attention weights of the parameter features and the image features. The parameter features and the image features are fused to obtain a fused feature vector. The fused feature vector is input into the fully connected layer for prediction, and the roughness prediction value is output.
2. The method for detecting the surface roughness of machined surfaces under complex environments as described in claim 1, characterized in that, The process of acquiring a surface image of the workpiece and preprocessing it to extract the core feature parameters of the image texture includes: Use an image acquisition device to acquire images of the surface of the workpiece; Preprocessing operations such as noise suppression, grayscale normalization, region cropping, and feature redundancy removal are performed on the surface image of the workpiece. The feature redundancy removal process includes initial extraction of multiple surface texture feature parameters based on gray-level co-occurrence matrix and texture statistical analysis methods. Then, the Spearman correlation coefficient between the multiple texture feature parameters is calculated, and extended parameters that are highly linearly correlated with the core parameters are removed. Finally, the core feature parameters are extracted and retained. The core feature parameters are difference, contrast, entropy, and energy.
3. The method for detecting the surface roughness of machined surfaces under complex environments as described in claim 1, characterized in that, The method, based on core feature parameters, employs a two-level intelligent segmentation strategy to quantitatively analyze interference factors in surface images, extracts interference region features, and constructs an interference quantification matrix, including: Based on the gray-level histogram characteristics of surface images, an improved Otsu thresholding algorithm is adopted, which introduces gray-level gradient weights and dynamically determines the segmentation threshold to segment interference candidate regions. Based on the differences in physical characteristics of three interference sources—fragments, debris, and oil stains—multiple core interference features in three dimensions—grayscale, morphology, and texture—we selected. The core interference features are used to construct feature vectors, which are then input into a support vector machine for interference classification to identify various types of interference regions. The number of pixels in various interference regions is counted, and interference is quantitatively calculated by combining image calibration parameters. The area of a single type of interference and the proportion of the total interference area are calculated. The difference between the gray-scale mean of various interference regions and the gray-scale mean of the normal surface is calculated. An interference quantification matrix is constructed based on the calculated proportions and differences.
4. The method for detecting the surface roughness of machined surfaces under complex environments as described in claim 1, characterized in that, The enhanced neural network model includes an input layer, a feature enhancement layer, an attention weighting layer, a fusion prediction layer, and a fully connected layer. The input layer is a dual-input mode, with the core input being the corrected feature parameter matrix and the auxiliary input being the grayscale feature map of the original surface image. The feature enhancement layer extracts deep texture features through a two-layer fully connected network. After each convolutional layer, a batch normalization layer and a ReLU activation function are connected. Finally, global average pooling is used to obtain the image features.
5. The method for detecting the surface roughness of machined surfaces under complex environments as described in claim 4, characterized in that, The attention-weighted layer introduces a multi-head self-attention mechanism to calculate the attention weights of parametric features and image features, and fuse them to obtain a fused feature vector. The attention-weighted fused feature vector is then input into the Transformer encoder to capture global correlations, and then connected to a bidirectional LSTM network to capture temporal dependencies of features. Finally, the LSTM output is fused with the initial fused feature vector through residual connections and input into the fully connected layer to output the roughness prediction value.
6. A surface roughness anti-interference detection system for machined surfaces under complex environments, specifically implementing the surface roughness anti-interference detection method for machined surfaces under complex environments as described in any one of claims 1-5, characterized in that, include: The parameter acquisition module is used to acquire images of the workpiece surface, preprocess them, and extract the core feature parameters of the image texture. The quantitative analysis module is used to quantitatively analyze the interference factors of the surface image based on the core feature parameters and adopt a two-level intelligent segmentation strategy, extract the features of the interference area and construct the interference quantification matrix. The correction module is used to construct a multi-dimensional coupling error correction model. The interference quantization matrix and core feature parameters are input into the multi-dimensional coupling error correction model. After interference correction and coupling compensation, the parameters are corrected and optimized. The corrected core feature parameters are output and constructed into a feature matrix. The prediction module is used to input the feature matrix and the grayscale feature map of the original image into the augmented neural network model. After feature enhancement, the attention weights of the parameter features and image features are calculated by introducing a multi-head self-attention mechanism. The parameter features and image features are fused to obtain a fused feature vector. The fused feature vector is input into the fully connected layer for prediction, and the roughness prediction value is output.
7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the anti-interference detection method for surface roughness of machined surfaces under complex environments as described in any one of claims 1-5.
8. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium is used to store computer instructions, which, when executed by a processor, implement the anti-interference detection method for surface roughness of machined surfaces under complex environments as described in any one of claims 1-5.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to enable the electronic device to perform the anti-interference detection method for surface roughness of machined surfaces under complex environments as described in any one of claims 1-5.
Citation Information
Patent Citations
Surface quality monitoring method and system based on image-signal multi-modal data
CN120105250A
Contour detection method and system for aluminum bar quality inspection based on image recognition technology
CN121114073A