Image edge fluctuation feature intelligent detection method
By combining gradient entropy-based dynamic wavelet decomposition and a dual-channel CNN model with an attention mechanism, the problems of multi-scale feature adaptation, feature interference suppression, and quantitative evaluation in wood template edge detection are solved, enabling automatic determination of the defect level of wood templates and improving the accuracy and efficiency of detection.
Patent Information
- Application Number
- CN202511492390.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-10-20
AI Technical Summary
Existing wood formwork edge detection technologies suffer from insufficient multi-scale feature adaptability, weak feature interference suppression capabilities, lack of quantitative evaluation systems, and rigid post-processing mechanisms, resulting in high false detection rates and low efficiency, failing to meet engineering acceptance standards.
A gradient entropy-based dynamic wavelet decomposition strategy is adopted, combined with a dual-channel CNN model and attention mechanism. Through reinforcement learning, feature fusion is optimized and edge fluctuation quantification index is calculated to achieve automatic determination of the defect level of wooden templates.
It improves the accuracy and efficiency of edge detection for wooden formwork, and can automatically identify minor, moderate and severe defects to meet project acceptance standards and reduce false detection and missed detection rates.
Smart Images

Figure CN120976566A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of wood formwork detection, and particularly relates to an image edge fluctuation feature intelligent detection method. BACKGROUND
[0002] In the field of building construction, wood formwork is a key tooling equipment for concrete pouring and forming, and the edge quality of the wood formwork directly determines the dimensional accuracy and surface flatness of the concrete structure. With the rapid development of building industrialization, the turnover efficiency and reusability of wood formwork are increasingly required, and in the process of repeated use of wood formwork, the edge is prone to wear, deformation, cracking and other defects due to factors such as load impact, environmental humidity change and material fatigue, which is manifested as irregular fluctuation of the edge contour. Therefore, accurate detection of the edge fluctuation feature of the wood formwork has important engineering value for timely screening of qualified formwork and preventing construction quality hazards. Current wood formwork edge detection technology mainly relies on traditional computer vision algorithms and preliminary deep learning methods, but there are significant technical bottlenecks in actual application: First, the multi-scale feature adaptability is insufficient. Traditional wavelet decomposition uses fixed basis functions and decomposition layers, which cannot dynamically adjust the feature extraction scale according to the wear degree of the wood formwork edge. For slight wear of fine fluctuations, fixed parameters are easy to cause high-frequency features to be overwhelmed by noise; for severe deformation of large fluctuations, the decomposition scale is insufficient to lose the global contour information, resulting in a high edge miss rate of more than 30% under complex working conditions. Second, the feature interference suppression ability is weak. The natural texture lines on the surface of the wood formwork are highly similar to the real defect fluctuations in visual features, and existing single modal feature extraction methods cannot effectively distinguish the difference between the two. Traditional edge detection operators (such as Canny and Sobel) are sensitive to texture interference, and basic CNN models lack targeted feature screening mechanisms, resulting in a defect false detection rate of more than 25% for a long time, which cannot meet the engineering acceptance standards. Third, the quantitative evaluation system is missing. Existing technologies are mostly limited to qualitative detection of edge contours, and lack quantitative description indicators of fluctuation features, making it impossible to automatically classify defects into “slight”, “moderate” and “severe” levels. The detection results rely on manual experience for judgment, which has large subjective bias and low efficiency, and is difficult to meet the quality control needs of large-scale construction. Fourth, the post-processing mechanism is rigid. Traditional morphological operations use fixed structure elements and parameters, which cannot dynamically adjust the processing strategy according to the edge connectivity. For the repair of broken edges, simple interpolation methods are often used, which can easily cause distortion of the edge shape and affect the reliability of the final detection results. In summary, the existing wood template edge fluctuation detection technology has obvious deficiencies in multi-scale adaptation, feature anti-interference, quantitative evaluation and post-processing optimization, and a new detection technology with dynamic adaptive ability, multi-modal feature fusion and intelligent decision function is urgently needed to break through the limitations of existing technology and improve the intelligent level of wood template quality detection. SUMMARY
[0003] The application provides an image edge fluctuation feature intelligent detection method to solve the above problems.
[0004] The application is implemented by the following technical solutions: An image edge fluctuation feature intelligent detection method, comprising the following steps: Obtain a wood template original image and perform preprocessing to obtain a preprocessed image; Design a dynamic wavelet decomposition strategy based on gradient entropy, and perform multi-scale wavelet decomposition on the preprocessed image through the dynamic wavelet decomposition strategy to obtain a low-frequency sub-band image reflecting the overall contour of the preprocessed image and a high-frequency sub-band image containing edge details of the preprocessed image; Extract wavelet high-frequency coefficients of the high-frequency sub-band image, and map the wavelet high-frequency coefficients to a feature space to obtain a high-frequency coefficient feature vector; Construct a dual-channel CNN model composed of a texture suppression channel and an edge enhancement channel, simultaneously introduce an attention mechanism module containing spatial attention weights and channel attention weights, extract a joint feature vector of the high-frequency sub-band image through the dual-channel CNN model, and optimize the joint feature vector through the attention mechanism module to obtain a deep feature vector; Use a reinforcement learning dynamic optimization method to weight and fuse the deep feature vector and the high-frequency coefficient feature vector to obtain a fusion feature vector, then calculate an edge fluctuation quantitative index based on the fusion feature vector, and input the edge fluctuation quantitative index, the contour curvature change rate of the low-frequency sub-band image and the fusion feature vector into a trained neural network model to obtain a defect grade of the original image.
[0005] As an optimization, the specific steps for preprocessing the original image are as follows: Convert the original image into an initial gray image through an image format conversion algorithm; Perform adaptive noise suppression processing on the initial gray image to obtain a first intermediate gray image after noise reduction; Perform contrast enhancement optimization on the first intermediate gray image to obtain a second intermediate gray image with improved contrast; calculating the image definition index and the signal-to-noise ratio of the second intermediate gray-scale image, and if the image definition index or the signal-to-noise ratio meets the requirement, regarding the second intermediate gray-scale image as the preprocessed image, otherwise, jumping to the next step; judging whether the maximum iteration number is reached, if not, returning to the second step to adjust the noise suppression parameter, and if yes, regarding the second intermediate gray-scale image as the preprocessed image.
[0006] As an optimization, the dynamic wavelet decomposition strategy based on gradient entropy is specifically as follows: S2.1, initial selection of wavelet parameters based on the gradient entropy value: calculating the global gradient entropy value mean of the preprocessed image, and comparing the global gradient entropy value mean with a set gradient entropy value threshold, so as to select a corresponding wavelet base function and a decomposition layer number; S2.2, performing multi-scale wavelet decomposition on the preprocessed image according to the wavelet base function and the decomposition layer number selected in step S2.1 to obtain an initial low-frequency sub-band image; S2.3, calculating the contour irregularity of the initial low-frequency sub-band image, the contour irregularity D = Σ|Pk-Pk'| / N, wherein Pk is an actual contour sampling point coordinate, Pk' is a standard rectangular contour corresponding point coordinate, the sampling point number N ≥ min(200, L / 5), L is a template length (pixels), and comparing the contour irregularity with a set contour irregularity threshold, so as to select a new wavelet base function and a decomposition layer number; S2.4, performing multi-scale wavelet decomposition on the preprocessed image according to the new wavelet base function and the decomposition layer number to obtain a final low-frequency sub-band image and a high-frequency sub-band image.
[0007] As an optimization, the specific process of S2.1 is as follows: S2.1.1, gradient entropy value calculation: for the preprocessed image, dividing the image according to a local window of 16x16 pixels, calculating the gradient entropy value of each window , wherein, is the probability distribution of the gradient amplitude in the local window, n is the gradient amplitude quantization level, and the window size is optimized to satisfy: ; L is the template length pixel value, and is the probability distribution of the gradient amplitude in the window, n is the possible value number of the gradient amplitude. By traversing the whole image through the sliding window, the gradient entropy value distribution of all local regions is obtained, so as to obtain the global gradient entropy value mean of the preprocessed image; S2.1.2, wavelet base function type selection: setting gradient entropy value thresholds and , and when the global gradient entropy value mean of the preprocessed image is less than When the mean of the global gradient entropy is within a certain range, the sym4 wavelet basis function is selected; when the mean of the global gradient entropy is within a certain range... to When the mean of the global gradient entropy is greater than 1, choose the sym6 wavelet basis function; when the mean of the global gradient entropy is greater than 1. When choosing, select the db6 wavelet basis function; S2.1.3 Initial Determination of Decomposition Layers: The initial decomposition layers are determined based on the mean of the global gradient entropy values. When the mean is less than... When the initial decomposition level is set to 3, and the mean is within a certain range... to When the mean is between 4 and 5, the initial decomposition level is set to 4-5; when the mean is greater than 100, the initial decomposition level is set to 4-5. At that time, the initial number of decomposition layers was set to 6.
[0008] As an optimization, the specific process of S2.3 is as follows: S2.3.1 Calculation of contour irregularity: Extract the actual overall contour of the wooden template from the initial low-frequency sub-band image, compare the actual overall contour with the standard contour, and obtain the contour irregularity D; S2.3.2 Decomposition Layer Update Judgment: Set Contour Irregularity Threshold ,like No need to adjust the number of decomposition levels; maintain the initially selected number of decomposition levels. When the initial decomposition level is reached, add one level; if At this time, 2 more layers are added to the initial decomposition layer number, but the maximum decomposition layer number does not exceed 6 layers; S2.3.3, Secondary selection of wavelet basis functions: If the number of decomposition levels is updated, the new number of decomposition levels... If the number of new decomposition layers is 6 and the original wavelet basis function is sym4, then the wavelet basis function is adjusted to sym6; if the number of new decomposition layers is 6 and the original wavelet basis function is sym6, then the wavelet basis function is adjusted to db6.
[0009] As an optimization, the high-frequency sub-band image consists of an LH sub-band image containing horizontal low-pass filtering and vertical high-pass filtering, an HL sub-band image containing horizontal high-pass filtering and vertical low-pass filtering, and an HH sub-band image containing two high-pass filters. The specific process of extracting wavelet high-frequency coefficients from the high-frequency sub-band image and mapping the wavelet high-frequency coefficients to the feature space to obtain high-frequency coefficient feature vectors is as follows: The LH sub-band image and / or HL sub-band image and / or HH sub-band image are selected as input sub-band images based on the directional attributes of the edge fluctuation features; Reading the wavelet coefficient matrix of the input sub-band image, screening the coefficients in the wavelet coefficient matrix by soft threshold filtering, retaining the coefficients with absolute value greater than threshold T, and setting the coefficients with absolute value not greater than threshold T to 0, thereby obtaining the high-frequency coefficient matrix after denoising; Performing block processing on the high-frequency coefficient matrix, and calculating statistical features in each block, the statistical features including coefficient mean, variance and maximum point number; Extracting global features of the high-frequency coefficient matrix, the global features including non-zero coefficient proportion and histogram distribution of coefficient absolute value; Splicing the statistical features and global features to form a high-frequency coefficient feature vector with fixed dimension; Mapping the high-frequency coefficient feature vector to a feature space homologous to the multi-modal attention feature through a fully connected layer, and performing Standardization on the mapped features to make the length of the feature vector 1, and finally obtaining the high-frequency coefficient feature vector of the high-frequency sub-band image.
[0010] As an optimization, a dual-channel CNN model composed of a texture suppression channel and an edge enhancement channel is constructed, and an attention mechanism module containing spatial attention weights and channel attention weights is introduced. The specific process of extracting the initial deep feature vector of the high-frequency sub-band image through the dual-channel CNN model and optimizing the initial deep feature vector through the attention mechanism module to obtain the final deep feature vector is as follows: Merge the LH sub-band image, the HL sub-band image and the HH sub-band image into a three-channel input tensor; Construct a dual-channel CNN model, the dual-channel CNN model including a texture suppression channel and an edge enhancement channel, wherein the texture suppression channel filters natural wood texture by using a hollow convolution, and the edge enhancement channel strengthens fluctuation features through residual connection; Input the three-channel input tensor into the texture suppression channel and the edge enhancement channel respectively to obtain a texture suppression feature vector and an edge enhancement feature vector; Splice the texture suppression feature vector and the edge enhancement feature vector to obtain a joint feature vector; Compress the channel dimension of the joint feature vector by global average pooling, and then generate a spatial attention weight map through 2-layer full connection+Sigmoid activation , H is the height, and W is the width; Compress the spatial dimension of the joint feature vector by global average pooling, and then generate a channel attention weight vector through 2-layer full connection+Sigmoid activation , C is the dimension; Generate a deep feature vector through a feature optimization formula: , wherein, represents matrix multiplication, F represents joint feature vector, represents element-wise multiplication.
[0011] As optimization, the edge fluctuation quantification index comprises fluctuation frequency, fluctuation amplitude and fluctuation continuity of the preprocessed image edge, wherein the fluctuation frequency is the number of fluctuations per unit length of the edge, the fluctuation amplitude is the gray difference between the peak value and the valley value of the vertical distance of the sampling point on the edge profile to the reference line, and the fluctuation continuity is the proportion of continuous fluctuation segments.
[0012] As optimization, the weight of the deep feature vector and the high-frequency coefficient feature vector is determined by using a reinforcement learning dynamic optimization method, and then the two are weighted and fused to obtain a fusion feature vector. Then, based on the fusion feature vector, the edge fluctuation quantification index is calculated, and the edge fluctuation quantification index, the profile curvature change rate of the low-frequency sub-band image and the fusion feature vector are jointly input into the trained neural network model to obtain the specific process of the defect level of the original image: The deep feature vector and the high-frequency coefficient feature vector are preliminarily weighted and fused to obtain a fusion feature vector, wherein the weight of the deep feature vector and the high-frequency coefficient feature vector is obtained by a reinforcement learning dynamic optimization method. Based on the fusion feature vector, the fluctuation frequency, the fluctuation amplitude and the fluctuation continuity of the edge graph corresponding to the fusion feature vector are calculated. The fusion feature vector, the profile curvature change rate, the fluctuation frequency, the fluctuation amplitude and the fluctuation continuity are input into the trained neural network model, so as to obtain the defect level of the original image.
[0013] As optimization, the specific calculation process of the fluctuation frequency, the fluctuation amplitude and the fluctuation continuity of the preprocessed image edge based on the fusion feature is: Fluctuation frequency: Calculate the direction angle of the connecting line of adjacent sampling points to obtain a direction angle sequence , M represents the number of sampling points of the preprocessed image edge profile, represents the coordinates of the i-th sampling point of the edge profile; Set the direction angle mutation threshold , when , determine as a fluctuation inflection point; Statistical total length of edge , while the total number of fluctuation inflection points K is also counted, then the fluctuation frequency is , wherein L is the total length of the preprocessed image edge, and K represents the total number of fluctuation inflection points; Fluctuation amplitude: The baseline line function B(x) is obtained by fitting a reference line to the edge contour points P of the preprocessed image using the least squares method. Calculate each sampling point vertical distance to the baseline ; Filter the maximum value among all sampled points Minimum value ; Fluctuation range Through the grayscale mapping formula Converted to grayscale difference, where, , These represent the maximum and minimum grayscale values of the edge region, respectively. The maximum edge length; Fluctuation continuity: Set the maximum allowable distance between adjacent contour points ,when When the edge breaks at this point, the break location is recorded. A continuous, unbroken edge segment is defined as an effective fluctuation segment, and the total length of all effective segments is calculated. ; Calculating the continuity of fluctuations .
[0014] Compared with the prior art, the present invention has the following advantages and beneficial effects: This invention effectively improves the quality of the original image of the wooden template through preprocessing steps such as image format conversion, adaptive noise suppression, and contrast enhancement optimization. It removes noise interference and enhances image contrast, providing clearer and more reliable image data for subsequent feature detection. For example, adaptive noise suppression can specifically address salt-and-pepper noise and Gaussian noise, making image details more prominent; contrast enhancement optimization can reasonably improve contrast based on the image histogram distribution, making features such as edges easier to identify.
[0015] This invention presents a dynamic wavelet decomposition strategy based on gradient entropy, which adaptively selects the wavelet basis function type and the number of decomposition layers according to the edge complexity of the preprocessed image. This allows for more accurate acquisition of low-frequency sub-band images that reflect the overall image contour and high-frequency sub-band images that contain edge details. For example, when edge complexity varies, selecting appropriate wavelet basis functions (such as sym4, sym6, db6, etc.) and the number of decomposition layers can better preserve image contour and edge detail information, laying the foundation for subsequent feature extraction.
[0016] The application can extract effective high-frequency coefficient feature vectors through coefficient screening, block processing, feature splicing and mapping standardization operations on high-frequency sub-band images. At the same time, a dual-channel CNN model is constructed to extract deep feature vectors, and an attention mechanism module is introduced to optimize the features, highlight the defect area features, suppress irrelevant texture interference, and make the extracted features more targeted and representative.
[0017] The application combines the dual-channel CNN architecture with the attention mechanism, the texture suppression channel can filter the natural texture of wood, the edge enhancement channel can strengthen the fluctuation features, the attention mechanism dynamically focuses on the defect area, and the optimized features can more accurately reflect the key features such as the edge fluctuation of the wood template.
[0018] The application fuses multiple features, calculates edge fluctuation quantitative indicators (fluctuation frequency, amplitude, continuity) and contour curvature change rate auxiliary features, and can comprehensively describe the fluctuation of the wood template edge. For example, the fluctuation frequency reflects the number of fluctuations per unit length of the edge, the fluctuation amplitude reflects the degree of deviation of the edge from the reference, and the fluctuation continuity represents the proportion of the effective fluctuation section of the edge. These indicators describe the edge features from different dimensions.
[0019] The application inputs the fused features into the trained neural network to realize automatic judgment of the wood template defect grade (slight, moderate, severe). Through dynamic optimization of the feature fusion weight by reinforcement learning and judgment combined with multiple features, the accuracy and reliability of the defect grade judgment can be improved, and the different degrees of defect of the wood template edge can be effectively identified, providing a basis for wood template quality evaluation and subsequent processing. BRIEF DESCRIPTION OF DRAWINGS
[0020] The drawings described herein are used to provide further understanding of the embodiments of the application, constitute a part of the application, and do not constitute a limitation on the embodiments of the application. In the drawings: Figure 1 A flowchart of an image edge fluctuation feature intelligent detection method according to the application. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical scheme and advantages of the application clearer, further detailed description of the application will be given below combined with examples and drawings. The illustrative embodiments of the application and their descriptions are only used to explain the application and do not limit the application.
[0022] Embodiment 1 provides an image edge fluctuation feature intelligent detection method, as shown in Figure 1 The method comprises the following steps: S1, obtaining a wood template original image and performing preprocessing to obtain a preprocessed image.
[0023] The specific steps of S1 are: S1.1 The original image is uniformly converted into an initial grayscale image using an image format conversion algorithm.
[0024] The acquired raw images are typically color images, i.e., RGB images. An image format conversion algorithm converts these RGB images to 8-bit grayscale images, eliminating redundant information in the color channels. The conversion formula is as follows: Where R, G, and B are the pixel values of the red, green, and blue channels, respectively, this ensures that the grayscale value range is normalized to [0, 255], and the output initial grayscale image retains the brightness characteristics of the wooden template edges and textures.
[0025] S1.2. Perform adaptive noise suppression processing on the initial grayscale image to obtain the first intermediate grayscale image after denoising.
[0026] The initial grayscale image may contain salt-and-pepper noise, Gaussian noise, and ambient noise from the shooting environment. Therefore, adaptive noise suppression processing of the initial grayscale image involves the following steps: A noise type identification algorithm is used to automatically determine the dominant noise type by calculating the proportion of impulse noise (the proportion of pixels with a jump value of more than 100) and the variance of Gaussian noise in local image regions. If the proportion of salt and pepper noise Enable 3×3 or 5×5 adaptive median filtering (window size dynamically adjusts with noise density) to suppress impulse noise by sorting the median values of neighboring pixels; If the proportion of salt and pepper noise A 2×2 small-size median filter window is enabled, and isolated noise points are specifically suppressed by sorting the local neighboring pixels and taking the median. Combined with the edge protection mechanism, median filtering is skipped for areas with pixel gradient values >30 (suspected edges), and weighted average filtering is used instead (edge pixels weight 0.7, neighboring pixels weight 0.3) to avoid edge blurring. For local areas with noise density <5% (specifically referring to the proportion of pixels contaminated by salt and pepper noise in the area to the total number of pixels in the area is <5%, such as the smooth area of the wooden template surface), a threshold judgment method is directly used: if the difference between the pixel value and the neighborhood mean is >50, the neighborhood mean is replaced; otherwise, the original pixel value is retained.
[0027] If Gaussian noise variance ,use Gaussian filtering ( The value is linearly adjusted with the noise variance: for every 5 increase in variance, the σ value increases by 0.2), and the noise is smoothed by Gaussian kernel convolution. If Gaussian noise variance ,use Adaptive Gaussian filter (the sigma value is linearly adjusted with the noise variance: the sigma value increases by 0.2 for every 5 increase in variance) is used to smooth the noise by small-scale Gaussian kernel convolution; a bilateral filter enhancement algorithm is introduced to balance the noise removal and edge preservation by increasing the spatial similarity weight (the closer the distance, the higher the weight) and the gray scale similarity weight (the smaller the gray scale difference, the higher the weight) on the basis of Gaussian filter; for texture-dense areas (such as wood annual ring areas), the filter window is reduced to 3x3 to reduce texture blurring; for smooth areas (such as template edge transition areas), the window is kept at 5x5 to improve the denoising effect.
[0028] For the mixed noise scene, a cascade operation of median filter and Gaussian filter is performed. That is, the operation of removing salt and pepper noise is performed first, and then the operation of removing Gaussian noise is performed.
[0029] S1.3, contrast enhancement optimization is performed on the first intermediate gray image to obtain a second intermediate gray image with improved contrast.
[0030] The first intermediate gray image after denoising may have a local brightness unevenness problem (such as edge blurring in the shadow area), so the first intermediate gray image needs to be processed as follows: S1.3.1, calculate the image gray histogram: S1.3.1.1, if the histogram distribution is concentrated (entropy value ), the limited contrast adaptive histogram equalization (CLAHE) algorithm is enabled; the grid size of CLAHE is set to 8x8, and the contrast limit threshold is 2.0-3.0 (adjusted dynamically according to image brightness); histogram equalization is performed on the local area to avoid over-amplification of noise.
[0031] S1.3.1.2, if the histogram distribution is not concentrated, targeted strategies are needed to avoid noise amplification or detail loss caused by over-enhancement, and the specific processing steps are as follows: S1.3.1.2.1, local area differentiation judgment: The first intermediate gray image is divided into 16x16 local sub-blocks, and the gray standard deviation and entropy value of each sub-block are calculated; the area with entropy value less than 4.5 and gray standard deviation less than 10 is selected (determined as a local low-contrast area, such as the shadow area on the surface of a wooden template); the remaining sub-blocks (high-contrast areas) are marked as "no enhancement".
[0032] S1.3.1.2.2, local contrast fine-tuning: a) For low-contrast sub-blocks, local adaptive gamma correction is adopted, with gamma value y dynamically adjusted according to the average brightness of the sub-block: y = 1.2-1.5 (compress high light) for the area with high brightness (average > 180), and y = 0.5-0.8 (enhance dark part) for the area with low brightness (average < 80); limit the correction amplitude to ensure that the sub-block gray value change range does not exceed 20% of the original range, avoiding the destruction of overall gray balance.
[0033] b) For high-contrast sub-blocks, directly skip the enhancement processing and keep the original gray distribution; only the block edges are processed for smooth transition (using 5x5 Gaussian blur weight fusion) to avoid obvious brightness jump between sub-blocks.
[0034] S1.3.1.2.3, enhancement effect verification: Calculate the global entropy value of the enhanced image to ensure that the entropy value is still greater than 5 (maintain the richness of gray levels); check the gray standard deviation improvement amplitude of the low-contrast area, which needs to reach 30%-50% of the original standard deviation (ensure the visibility improvement of local details); compare with the original image using structural similarity index (SSIM), and SSIM needs to be > 0.9 (ensure overall visual consistency).
[0035] A second intermediate gray image is obtained by step S1.3.
[0036] S1.4, calculate the image sharpness index and signal-to-noise ratio of the second intermediate gray image, if the image sharpness index or signal-to-noise ratio meets the requirements, the second intermediate gray image is regarded as the pre-processed image, otherwise, jump to S1.5.
[0037] S1.5, determine whether the maximum number of iterations is reached, if not, return to S1.2 and adjust the noise suppression parameter, if yes, the second intermediate gray image is regarded as the pre-processed image.
[0038] Steps S1.4 and S1.5 are image quality evaluation and reprocessing processes.
[0039] The input is a gray image after contrast enhancement, and the specific process is: Calculate the image sharpness index (such as Tenengrad gradient operator response value) and signal-to-noise ratio (SNR); if the sharpness index is < 50 or the SNR is < 20 dB, automatically backtrack to the noise suppression step and adjust the filtering parameters for reprocessing; repeat the iteration until the image quality meets the standard or the maximum number of iterations (3 times) is reached.
[0040] Finally, output the pre-processed image that meets the detection standard as the input data for dynamic wavelet decomposition. The pre-processed image is a gray image containing original visual information such as wood template surface texture and edge contour.
[0041] S2, a dynamic wavelet decomposition strategy based on gradient entropy is designed, and the preprocessed image is decomposed by the dynamic wavelet decomposition strategy to obtain a low-frequency sub-band image reflecting the overall outline of the preprocessed image and a high-frequency sub-band image containing edge details of the preprocessed image.
[0042] In some embodiments, the dynamic wavelet decomposition strategy based on gradient entropy is: According to the gradient entropy value of the local region of the preprocessed image calculated in real time, the edge complexity of the preprocessed image is quantified, the wavelet basis function type and the decomposition layer number are dynamically selected according to the gradient entropy value, and the preprocessed image is decomposed by multi-scale wavelet according to the selected wavelet basis function and decomposition layer number, so as to obtain a low-frequency sub-band image reflecting the overall outline of the preprocessed image and a high-frequency sub-band image containing edge details of the preprocessed image, and according to the outline irregularity of the obtained low-frequency sub-band image, secondary check adjustment is carried out to update the selected decomposition layer number, wherein the calculation formula of the gradient entropy value is: , E represents the gradient entropy value, n represents the number of value categories, n is 256 in the gray image, represents the probability of the i-th value.
[0043] More specific process is: S2.1, initial selection of wavelet parameters based on gradient entropy value: S2.1.1, gradient entropy value calculation: for the preprocessed image (i.e. the preprocessed wooden template gray image), the image is divided according to the local window of 16x16 pixels, and the gradient entropy value of each window is calculated , wherein, is the probability distribution of the gradient amplitude in the window, that is, is the probability distribution of the gradient amplitude in the 16x16 local window, n is the number of possible gradient amplitude values, that is, n is the gradient amplitude quantization level. Of course, the window size can also be optimized to meet L is the length of the wooden template (pixels), that is, the number of pixels of the long side of the template. By sliding window traversal of the whole image, the gradient entropy value distribution of all local regions is obtained, and the average value of all gradient entropy values is calculated to obtain the global gradient entropy value average of the preprocessed image.
[0044] S2.1.2, wavelet basis function type selection: set the gradient entropy value threshold and , and , in this embodiment, , When the global gradient entropy value average of the preprocessed image is less than When the edge complexity is low, the sym4 wavelet basis function is chosen (good symmetry, suitable for smooth edge processing); when the mean global gradient entropy value is within... to Between (inclusive) and This indicates moderate marginal complexity, so the sym6 wavelet basis function is chosen; when the mean global gradient entropy is greater than... When the edge complexity is high, the db6 wavelet basis function is selected (it has strong tight support and is suitable for capturing complex edge details).
[0045] S2.1.3 Initial Determination of Decomposition Layers: The initial number of decomposition layers is determined based on the mean global gradient entropy value. When the mean is less than... When the initial decomposition level is set to 3, and the mean is within a certain range... to Between (inclusive) and The initial decomposition level is set to 4-5 levels; when the mean is greater than At that time, the initial number of decomposition layers was set to 6.
[0046] S2.2 Multi-scale wavelet decomposition execution: Using the wavelet basis function and initial decomposition level selected in step S2.1, multi-scale wavelet decomposition is performed on the preprocessed image to obtain a low-frequency sub-band image (LL) containing the overall contour and a high-frequency sub-band image (LH, HL, HH) containing edge details.
[0047] S2.3, Secondary verification and adjustment based on the irregularity of low-frequency sub-band image contours: S2.3.1 Contour Irregularity Calculation: Extract the overall contour of the wooden template from the low-frequency sub-band image and compare it with the standard contour (set according to the actual size of the wooden template). Calculate the Euclidean distance from each point on the contour to the corresponding point on the standard rectangular contour, and take the average of these distances as the contour irregularity D.
[0048] The contour irregularity D is used to quantify the deviation between the actual contour and the standard rectangular contour in the low-frequency subband image of the wooden template. The contour irregularity D = Σ|Pk-Pk'| / N, where Pk is the coordinate of the actual contour sampling point, Pk' is the coordinate of the corresponding point of the standard rectangular contour, the number of sampling points N≥min(200, L / 5), and L is the template length (pixels). The specific calculation formula is as follows: Where D represents the contour irregularity (unit: pixels), the larger the value, the more significant the deviation between the actual contour and the standard contour; N represents the total number of contour sampling points (points are taken evenly according to the contour length, usually...). To ensure accuracy, the value of N can also be N≥min(200, L / 5), where L is the template length (pixels). coordinates of the kth sampling point on the actual contour (extracted from the initial low-frequency sub-band image), coordinates of the kth sampling point on the actual contour (extracted from the initial low-frequency sub-band image),
[0049] Actual contour extraction: binaryzation of the initial low-frequency sub-band image (LL) (threshold value is the average gray value), Canny edge detection algorithm is used to extract the closed contour of the wood mold, Douglas-Peucker algorithm is used to simplify the contour and uniformly collect N sampling points, and the coordinates are recorded Standard contour generation: according to the nominal size of the wood mold (such as length L, width W), a standard rectangular contour is generated in the image coordinate system, and N reference points are taken at the same sampling interval as the actual contour, and the coordinates are recorded Distance calculation: the Euclidean distance between the actual sampling point and the corresponding reference point is calculated point by point, and the average value is obtained after summation, which is the contour irregularity D.
[0050] For example, if the standard size of the wood mold is 1000x500 pixels, the total distance between the actual contour sampling points and the standard contour reference points is 800 pixels, and the number of sampling points N=200, then D=800 / 200=4 pixels, indicating that the average deviation is 4 pixels.
[0051] S2.3.2, decomposition layer number update judgment: set the contour irregularity threshold (determined according to the quality standard of the wood mold, for example, 5 pixels). If , it indicates that the low-frequency contour is regular, and there is no need to adjust the decomposition layer number, and the initial selected decomposition layer number is maintained; if , it indicates that the low-frequency contour is irregular, and the decomposition layer number needs to be increased to better capture the edge details. The specific update rule is: when , increase 1 layer based on the initial decomposition layer number; when , increase 2 layers based on the initial decomposition layer number, but the maximum decomposition layer number does not exceed 6 layers.
[0052] S2.3.3, secondary selection of wavelet basis function: if the new decomposition layer number is 6 layers, and the original wavelet basis function is sym4, then the wavelet basis function is adjusted to sym6; if the new decomposition layer number is 6 layers, and the original wavelet basis function is sym6, then the wavelet basis function is adjusted to db6, to adapt to the capture demand of complex edges under higher decomposition layer number.
[0053] S2.4, final wavelet decomposition is performed: according to the wavelet basis function and the number of decomposition layers determined after the secondary check adjustment, the preprocessed image is re-decomposed by multi-scale wavelet decomposition to obtain the final low-frequency sub-band image and high-frequency sub-band image, and accurate multi-scale feature data is provided for subsequent feature extraction and other steps.
[0054] The preprocessed image is decomposed by the gradient entropy-based dynamic wavelet decomposition strategy of the application, which has the following advantages: Improving the accuracy of feature extraction: By quantifying the edge complexity with gradient entropy and matching the wavelet basis function, the wavelet decomposition can better fit the actual features of the wood template edge. For example, for images with complex edges, db6 wavelet with strong tight support can accurately capture subtle fluctuations; for images with simple edges, sym4 wavelet can reduce redundant calculations. The initial setting of the number of decomposition layers is linked to the edge complexity, which avoids the problem of under-extraction (missing details due to insufficient layers) or over-extraction (introducing noise due to excessive layers) caused by fixed layers. Enhancing the adaptability of the algorithm to complex scenes: In practical applications, the wood template may have local edge complexity but regular overall contour, or overall deformation but simple local edge. The secondary check introduces low-frequency contour irregularity, which can correct the decomposition parameters from a global perspective. For example, when the global gradient entropy value shows that the edge complexity is moderate (corresponding to 4 layers of decomposition), but the low-frequency contour irregularity exceeds the threshold, the number of decomposition layers is increased to 5-6 layers, which can ensure sufficient extraction of edge features of the overall deformation and avoid the influence of local feature misjudgment on global detection. Balancing detection efficiency and accuracy: The initial parameter selection is based on the global gradient entropy value, which can quickly determine the approximate decomposition strategy; the secondary check only adjusts the parameters when necessary (the contour irregularity exceeds the threshold), avoiding unnecessary increase in computational load for the entire scene. For example, for a regular contour wood template, maintaining the initial 3 layers of decomposition can meet the requirements and reduce unnecessary multi-layer decomposition time; for a severely deformed template, the number of layers is increased to improve accuracy, achieving a dynamic balance of "as accurate as needed, as fast as needed". Providing high-quality feature data for subsequent processing: The final output low-frequency and high-frequency sub-band images are optimized in parameters, retaining complete global contour information and highlighting the detailed features of edge fluctuations. This enables multi-modal attention feature extraction to more efficiently focus on defect areas, and the feature complementarity is stronger when heterogeneous fusion is performed, thereby improving the accuracy of defect grade determination and reducing false positives and false negatives caused by insufficient feature quality.
[0055] S3, extracting the wavelet high-frequency coefficients of the high-frequency sub-band image and mapping the wavelet high-frequency coefficients to a feature space to obtain a high-frequency coefficient feature vector.
[0056] In some embodiments, the specific process of S3 is: S3.1, filtering the LH subband map and / or HL subband map and / or HH subband map as input subband images according to the direction attribute of the edge fluctuation feature.
[0057] The extracted high-frequency subband image refers to the high-frequency detail image containing edge details generated in the wavelet decomposition process, and does not cover the low-frequency subband image.
[0058] In two-dimensional wavelet transform, the image is decomposed into four subbands, LL, LH, HL and HH. Among them, the low-frequency subband LL is filtered twice (horizontal and vertical directions), which reflects the outline of the image at the next scale, contains the overall shape of the template, large area of gray gradient and overall structure information, like the skeleton of the image. And high-frequency detail subband images, i.e. LH (horizontal low-pass filtering, vertical high-pass filtering, containing horizontal edge information of the image, reflecting high-frequency changes in the vertical direction), HL (horizontal high-pass filtering, vertical low-pass filtering, containing vertical edge information of the image, reflecting high-frequency changes in the horizontal direction) and HH (twice high-pass filtering, containing high-frequency information of the image diagonal direction, reflecting the details and texture of the image). They capture the edges, textures, local mutations and other subtle but key information of the image, like the texture and detail brushes of the image. In the wood template edge fluctuation feature detection technology process, the high-frequency detail subband image output by dynamic wavelet decomposition is used as the input of the multi-modal attention feature extraction step, and its importance lies in providing detailed features directly related to edge fluctuations for subsequent feature extraction. The edge information in these high-frequency detail images helps the texture suppression channel and the edge enhancement channel in the subsequent dual-channel CNN architecture for further processing, filters the natural texture interference of wood through dilated convolution, strengthens the fluctuation features through residual connection, and focuses on the defect area through attention mechanism, so as to realize the accurate extraction and analysis of the edge fluctuation features of the wood template.
[0059] Step S3.1 is the screening of high-frequency subband images. In step S3.1, the input is a set of high-frequency subband images (including three directions of LH, HL and HH multi-scale subband images, such as 3-6 groups of high-frequency subbands corresponding to 3-6 layers of decomposition) after dynamic wavelet decomposition.
[0060] The specific processing process is: According to the direction attribute of the edge fluctuation characteristics, the target sub-band is screened: horizontal edge fluctuation (such as wood template transverse bending) preferentially selects an HL sub-band graph (horizontal direction high-pass filtering), vertical edge fluctuation preferentially selects an LH sub-band graph (vertical direction high-pass filtering), and diagonal direction fluctuation preferentially selects an HH sub-band graph; the multi-scale sub-band is subjected to significance evaluation, the edge energy (gradient amplitude square sum) of each sub-band is calculated, the scale sub-band with the top 2 energy is retained, and the redundant sub-band with too low energy (sub-band with energy proportion less than 5%) is removed.
[0061] The screened 1-2 groups of high-frequency sub-band images (such as HL4, LH5, the number represents the decomposition layer number) are output, and the high-frequency information related to the edge fluctuation is focused.
[0062] S3.2, the wavelet coefficient matrix of the input sub-band image is read, the coefficients in the wavelet coefficient matrix are screened by using soft threshold filtering, the coefficients with absolute values not less than a threshold T are retained, and the coefficients with absolute values less than the threshold T are set to 0, so as to obtain a high-frequency coefficient matrix after denoising.
[0063] Specifically, the wavelet coefficient matrix (each pixel point corresponds to a high-frequency coefficient value, reflecting the edge change intensity at the position) of the sub-band image is read, the coefficient screening is performed by using soft threshold filtering, and the threshold T is dynamically calculated according to the sub-band noise level: , wherein, is a fluctuation sensitive factor, , represents a sub-band coefficient set, median is a median, then the coefficients with absolute values greater than T (regarded as effective edge fluctuation coefficients) are set to 0 (noise coefficients are suppressed), and finally the high-frequency coefficient matrix after denoising is output, the coefficient information of the effective edge fluctuation is highlighted.
[0064] S3.3, the high-frequency coefficient matrix is subjected to block processing (such as 8*8 pixel blocks), the statistical characteristics in each block are calculated, and the statistical characteristics include a coefficient mean value (reflecting an average fluctuation intensity), a variance (reflecting a fluctuation stability) and a maximum value point number (reflecting a fluctuation frequency); S3.4, global features of the high-frequency coefficient matrix are extracted, and the global features include a non-zero coefficient proportion (reflecting a fluctuation region coverage rate) and a histogram distribution of coefficient absolute values (reflecting a fluctuation intensity distribution law); S3.5, the statistical characteristics and the global features are spliced to form a high-frequency coefficient feature vector with fixed dimensions.
[0065] In the embodiment, the high-frequency coefficient feature vector has a fixed dimension of 1212, including 1200 block statistical characteristics (400 blocks*3 dimensions) and 12 global features; if the matrix size is insufficient, the standardization is realized by edge zero padding or interception of the first 400 blocks.
[0066] Steps S3.3-S3.5 belong to the quantization and feature construction of the high-frequency coefficient matrix, and output the structured high-frequency coefficient feature vector which can be directly input into the fully connected layer for feature mapping.
[0067] The block statistical feature and the global feature are spliced into a high-frequency coefficient feature vector with fixed dimensions, which needs to be realized through three core links of feature dimension standardization, ordered splicing and dimension verification. The specific implementation process of S3.5 is as follows: S3.5.1, Dimension standardization of block statistical feature: S3.5.1.1, Block parameter setting: for the high-frequency coefficient matrix after denoising (assuming the size is , H and W are the number of rows and columns respectively), a fixed block size of 8x8 pixels is used for division. If the matrix size does not meet the integer multiple of 8, zero is added to the edge to the nearest multiple of 8 (such as 120x160 matrix divided into 15x20=300 blocks). S3.5.1.2, Single block feature extraction: 3 statistical features are extracted from each 8x8 block, including coefficient mean (1 dimension), variance (1 dimension) and maximum value point number (1 dimension), and the feature dimension of a single block is 3 dimensions. S3.5.1.3, Dimension unification of block feature: if the image size fluctuates (such as different wooden template image resolutions differ slightly), dimension standardization is realized by fixing the number of blocks. For example, set the maximum number of blocks to 400 (corresponding to 32x32 blocks, covering the maximum high-frequency coefficient matrix of 256x256 pixels), and fill the zero vector to 400 blocks for the case where the number of blocks is less than 400; and for more than 400 blocks, the first 400 blocks are truncated. At this time, the total dimension of the block statistical feature is 400*3=1200.
[0068] S3.5.2, Dimension fixing of global feature: S3.5.2.1, Global feature extraction: 5 global features are extracted from the high-frequency coefficient matrix, including the proportion of non-zero coefficients (1 dimension), the distribution of coefficient absolute value histogram (8 intervals, 8 dimensions), the maximum coefficient value (1 dimension), the minimum coefficient value (1 dimension) and the total sum of coefficients (1 dimension), and the total dimension of the global feature is fixed at 1+8+1+1+1=12. S3.5.2.2, Feature normalization: min-max normalization is performed on the global feature to map each feature value to the interval [0, 1], avoiding the influence of numerical range difference on the spliced feature vector.
[0069] S3.5.3, Feature ordered splicing and dimension locking: S3.5.3.1, splicing order definition: adopt the fixed order splicing of "block statistical features first, global features last", to ensure the structural consistency of the feature vector. For example, after splicing the 1200-dimensional block features and the 12-dimensional global features, the total dimension is 1200+12=1212. S3.5.3.2, dimension verification mechanism: after splicing, the feature dimension checking module is used. If the total dimension is not equal to the preset 1212, the backtracking mechanism is triggered to recheck whether the block number is 400 and the global feature is 12-dimensional, and automatically correct the zero padding or truncation operation until the dimension meets the requirements. S3.5.3.3, vector format conversion: convert the spliced feature matrix into a 1x1212 row vector format as the input data format of the full connection layer.
[0070] Take a certain high-frequency coefficient matrix (size 240x320, divided into 30x40=1200 blocks) as an example: Block statistical features: 1200 blocks x 3 dimensions = 3600 dimensions, because it exceeds the maximum block number 400, the first 400 blocks are truncated to get 400x3=1200 dimensions; Global features: extract 12 dimensions according to the fixed dimension; Spliced feature vector: 1200+12=1212 dimensions, output after dimension verification to ensure that the feature vectors extracted from different high-frequency sub-band images are completely consistent, providing standardized input for subsequent full connection layer mapping and heterogeneous fusion.
[0071] S3.6, map the high-frequency coefficient feature vector to a feature space homologous to the multi-modal attention feature through the full connection layer, and perform standardization on the mapped features to make the length of the feature vector 1, and finally obtain the high-frequency coefficient feature vector of the high-frequency sub-band image.
[0072] This step maps the feature vector obtained in S3.5 to a feature space homologous to the multi-modal attention feature through a full connection layer (the number of hidden layer neurons is 1.5 times the dimension of the feature vector). The mapping function is , W is the weight matrix, b is the bias term, and the mapped features are standardized to make the length of the feature vector 1, eliminating the influence of dimensional differences on subsequent fusion.
[0073] Standardization refers to transforming the feature vector (d is the feature dimension) so that the transformed vector satisfies the Euclidean norm (norm) norm) is equal to 1, that is: ; is transformed elements, wherein, ).
[0074] Finally, the normalized high-frequency coefficient feature vector is output, which can be directly weighted and fused with the multi-modal deep features to provide high-frequency details for defect grade determination.
[0075] This step can eliminate the dimension effect: in the mapped high-frequency coefficient feature vector, different dimensions of features may have different numerical ranges (for example, the "non-zero coefficient ratio" is in the interval [0, 1], and the "coefficient sum" may reach thousands). After normalization, all feature values are scaled to the interval [-1, 1] to avoid being dominated by a dimension with a large numerical value in subsequent fusion calculations.
[0076] At the same time, the comparability of the features can be enhanced: after normalization, the "direction" of the feature vector becomes the core information, and the "length" is unified. For example, two feature vectors respectively describing slight fluctuations and moderate fluctuations can more accurately reflect their differences through the vector angle after normalization, improving the rationality of weight allocation when fusing heterogeneous features.
[0077] And it can stabilize the model training: in the subsequent BP neural network training, the normalized features can speed up the gradient descent convergence speed, reduce the model oscillation caused by the numerical fluctuation of the features, and improve the stability of the defect grade determination.
[0078] S4, a dual-channel CNN model is constructed to extract a deep feature vector of the high-frequency sub-band image.
[0079] The specific process of S4 is: S4.1, the LH sub-band image, the HL sub-band image and the HH sub-band image are merged into a three-channel input tensor.
[0080] The high-frequency sub-band image obtained based on the gradient entropy dynamic wavelet decomposition strategy (size: 256x256 pixels, pixel value range: [0, 1], normalized) contains edge details in horizontal (HL), vertical (LH), and diagonal (HH) directions. The high-frequency sub-band image has a size of HxWxC (H is the height, W is the width, and C is the number of channels, such as 3 channels of RGB or a single channel of grayscale image), and contains original features such as wood texture and edge fluctuations. The edge details in the horizontal / vertical / diagonal directions are included.
[0081] The high-frequency sub-band image is preprocessed first: the high-frequency sub-band image is channel spliced to merge the high-frequency sub-band images in three directions into a 3-channel input tensor (shape: 256x256x3), which is used as the common input of the dual-channel CNN.
[0082] S4.2, a dual-channel CNN model is constructed, the dual-channel CNN model comprising a texture suppression channel and an edge enhancement channel, wherein the texture suppression channel adopts a cavity convolution to filter the natural texture of the wood, and the edge enhancement channel strengthens the fluctuation features through a residual connection.
[0083] Specifically, the texture suppression channel comprises: The first layer is a cavity convolution layer: 64 3x3 convolution kernels are adopted, the expansion rate is set to 2, the step length is 1, and the padding mode is "same" (keeping the output size consistent with the input); The activation function is LeakyReLU (slope 0.01), which suppresses the low-frequency interference signals generated by the wood texture; The output feature map size is 256x256x64, which preliminarily filters the dense texture information. The second layer is batch normalization and pooling: The batch normalization operation (mean 0, variance 1) is performed on the convolution output to stabilize the training process; 2x2 maximum pooling (step length 2) is adopted, and the output feature map size is compressed to 128x128x64. The third layer is a multi-scale cavity convolution: Three groups of convolution kernels are set in parallel: 3x3 (expansion rate 3), 5x5 (expansion rate 2), and 7x7 (expansion rate 1), each group having 32 convolution kernels; The three groups of output feature maps are spliced (channel number 32x3=96) and compressed to 64 channels through 1x1 convolution; The output feature map size is 128x128x64, which further suppresses the texture interference of different scales. The fourth layer is global average pooling: Global average pooling is performed on the feature map, outputting a 1x1x64 texture suppression feature vector.
[0084] The edge enhancement channel comprises: The first layer is a regular convolution layer: 64 3x3 convolution kernels are adopted, the step length is 1, and the padding is "same", and the activation function is ReLU; The output feature map size is 256x256x64, which preliminarily extracts edge primitive features. The second layer is a residual module: It contains two 3x3 convolution layers (each with 64 channels), and batch normalization and ReLU activation are added in between; The input features and the convolution output are added through a jump connection (F(x)+x) to strengthen the propagation of edge features; The output feature map size is 256x256x64, which alleviates the gradient vanishing problem of deep networks. Third layer: downsampling and residual stacking: 2x2 max pooling (step 2) is adopted, and the feature map size is compressed to 128x128x64; Stack 2 residual modules (each containing 2 convolution layers), and the output channel number remains 64; The output feature map size is 128x128x64, which enhances the hierarchical features of edge contours. Fourth layer: global average pooling: Global average pooling is performed on the feature map, outputting a 1x1x64 edge enhancement feature vector.
[0085] S4.3, input the three-channel input tensor into the texture suppression channel and the edge enhancement channel respectively to obtain a texture suppression feature vector and an edge enhancement feature vector.
[0086] S4.4, concatenate the texture suppression feature vector and the edge enhancement feature vector to obtain a joint feature vector.
[0087] The specific process is as follows: Feature concatenation: 64-dimensional feature vector of texture suppression channel and 64-dimensional feature vector of edge enhancement channel are concatenated to form 128-dimensional joint feature vector.
[0088] S4.5, compress the channel dimension of the joint feature vector (such as 256x256x64) by global average pooling, and then generate a spatial attention weight map through 2 layers of full connection + Sigmoid activation (size and input feature Figure 1 such as 256x256), H is the height, and W is the width.
[0089] The weight of each pixel point reflects the spatial correlation degree of the position and the defect area (high weight of defect area, low weight of texture area).
[0090] S4.6, compress the spatial dimension of the joint feature vector by global average pooling (get 1x1xC, C is the channel number), and then generate a channel attention weight vector through 2 layers of full connection + Sigmoid activation , C is the dimension (the dimension is consistent with the channel number, such as 64 dimensions).
[0091] The weight of each channel reflects the contribution degree of the channel to the defect feature (high weight of edge fluctuation channel, low weight of texture channel).
[0092] S4.7, generate a depth feature vector through a feature optimization formula: wherein, denotes matrix multiplication (spatial attention weight map is multiplied with joint feature vector F per spatial location, highlighting defect regions), F denotes joint feature vector, denotes element-wise multiplication (channel attention weight vector is multiplied with joint feature vector F per channel, highlighting effective channels).
[0093] S5, a reinforcement learning dynamic optimization method is used to determine the weights of the deep feature vector and the high-frequency coefficient feature vector, and the deep feature vector and the high-frequency coefficient feature vector are weighted and fused to obtain a fusion feature vector. Then, based on the fusion feature, an edge fluctuation quantification index (fluctuation frequency, amplitude, continuity) is calculated, and the edge fluctuation quantification index and the profile curvature change rate of the low-frequency sub-band image are jointly input into the trained neural network model to obtain the defect level of the original image.
[0094] In some embodiments, the specific process of S5 is: S5.1, the deep feature vector and the high-frequency coefficient feature vector are preliminarily weighted and fused to obtain a fusion feature vector, wherein the weights of the deep feature vector and the high-frequency coefficient feature vector are obtained by a reinforcement learning dynamic optimization method; In the preliminary weighted fusion of the deep feature vector (CNN extraction, 128-dimensional) and the high-frequency coefficient feature vector (1212-dimensional), the core logic of dynamically optimizing the weights by reinforcement learning is: through the interaction between the agent and the environment, the weight parameters that make the discrimination ability of the fusion feature optimal are found, and the specific implementation steps are as follows: S5.1.1, reinforcement learning core element design: S5.1.1.1, state space (State): The state is defined as the feature distribution statistics of the current batch of training data, including: the mean of the deep feature vector , variance (reflecting the overall distribution of the deep feature); the mean of the high-frequency coefficient feature vector , variance (reflecting the overall distribution of the high-frequency feature); the cosine similarity of the two types of features (measuring feature redundancy). 、 are the deep feature vector and the high-frequency coefficient feature vector, respectively.
[0095] state vector , the dimension is 5, which ensures that the key information of the feature distribution is included.
[0096] S5.1.1.2, Action space: Action is defined as the adjustment amount of deep feature weight and high-frequency coefficient feature weight , satisfying and (avoiding too small weight leading to feature failure).
[0097] The action space adopts a discretization design, dividing the possible values of into 9 levels: 0.1, 0.2, ···, 0.9, corresponding to automatically determined as 0.9, 0.8, ···, 0.1, a total of 9 selectable actions.
[0098] S5.1.1.3, Reward function (Reward): The core reward is the accuracy of the defect level determination of the fused features, and the formula is: ; Where acc is the accuracy of the model on the validation set under the current weight (value [0,1]); loss is the cross-entropy loss function value (value [0,1]); is the weight difference penalty term, to avoid excessive neglect of certain features; hyperparameters , , , (determined by grid search).
[0099] When , an additional penalty r = r - 0.2 is applied to accelerate the elimination of inferior weights.
[0100] S5.1.2, Reinforcement learning optimization process: S5.1.2.1, Agent initialization: Deep Q Network (DQN) is used as the agent, and the network structure is: input layer (5-dimensional state) → hidden layer 1 (64-dimensional, ReLU) → hidden layer 2 (32-dimensional, ReLU) → output layer (9-dimensional Q value, corresponding to the value of 9 actions).
[0101] Initialize weight parameters , as the initial fusion weight.
[0102] S5.1.2.2, Interaction iteration process: S5.1.2.2.1, state observation: for the current training batch data, the state vector s is calculated and input into the DQN to obtain the Q value estimation of each action.
[0103] S5.1.2.2.2, action selection: the e-greedy strategy is used to select the action: with a probability of e=0.8, the action with the maximum Q value is selected, and with a probability of 0.2, the action is randomly selected (balance exploration and utilization), and the action is determined and .
[0104] S5.1.2.2.3, execute action and calculate reward: fuse the feature vector according to the selected weight ), input the neural network for training, and calculate the reward r on the validation set.
[0105] S5.1.2.2.4, experience replay and network update: store (s, a, r, s') in the experience pool (capacity 10000), randomly sample 32 experiences, and update the DQN parameters through the loss function , where is the discount factor.
[0106] S5.1.2.2.5, termination condition: when the reward r of 10 consecutive iteration periods fluctuates less than 0.02, or the total number of iterations reaches 500, stop training, and output the current optimal weight and .
[0107] S5.1.2.3, weight dynamic adjustment mechanism: trigger reinforcement learning optimization once every 1 training epoch, and update the weight according to the new state; use the optimal weight obtained by training in the test phase to ensure the stability of the inference process.
[0108] This method uses the trial-and-error mechanism of reinforcement learning to dynamically adjust the weight parameters with the data distribution, solving the problem of fixed weight that is difficult to adapt to multiple sample scenarios, and providing more optimal fused features for subsequent dual-branch neural network input.
[0109] S5.2, based on the fused feature vector, calculate the fluctuation frequency, fluctuation amplitude and fluctuation continuity of the edge graph corresponding to the fused feature vector (the fluctuation frequency is the number of fluctuations of the unit length edge, the fluctuation amplitude is the gray difference between the peak and valley of the vertical distance of the sampling point on the edge contour to the reference line, and the fluctuation continuity is the proportion of continuous fluctuation section) In some embodiments, the specific process of S5.2 is as follows: S5.2.1, Edge contour extraction and sampling: Input: Edge probability map generated by fully connected layer mapping of fusion feature vector (size 2048x1536, pixel value represents edge probability).
[0110] Processing process: Adaptive threshold segmentation (threshold value is the mean value of probability map + 1.2 times standard deviation) is adopted to obtain a binary edge image; Complete edge contour is extracted by 8-neighbor connected component analysis, and isolated edge segments with length < 50 pixels are removed; Isometric sampling is performed on the retained edge contour, and the sampling interval is 2 pixels to obtain a contour point sequence , is the pixel coordinate, and M is the total number of sampling points.
[0111] S5.2.2, Wave frequency calculation: Direction angle sequence generation: calculate the direction angle of the connecting line between adjacent sampling points , to obtain the direction angle sequence (unit: radian), M represents the number of sampling points of the edge contour of the preprocessed image, represents the coordinates of the i-th sampling point of the edge contour; Wave point identification: set the direction angle mutation threshold , (converted to radian 0.523), when , determine as a wave inflection point; Frequency calculation: statistics the total length of the edge (unit: pixel), and statistics the total number of wave inflection points K, then the wave frequency (unit: times / pixel), that is, the number of waves per unit length of edge, wherein L is the total length of the edge of the preprocessed image, and K represents the total number of wave inflection points; S5.2.3, Wave amplitude calculation: Reference line fitting: least squares method is used to fit the reference straight line (for curve edge, Bezier reference curve) for the edge contour point P of the preprocessed image, to obtain the reference line function B(x); Deviation calculation: calculate the vertical distance of each sampling point to the reference line (for curve edge, Euclidean distance); Amplitude determination: Screen the maximum value and the minimum value in all sampling points; Wave amplitude is converted to gray scale difference by gray scale mapping formula , wherein, , are the maximum and minimum gray value of the edge region respectively, is the maximum edge length.
[0112] S5.2.4, Wave continuity: Break detection: set the maximum allowed distance between adjacent contour points , for example , when , it is determined that the edge is broken here, and the broken position is recorded; Define the continuous edge segment without break as an effective wave segment, and count the total length of all effective segments ; Calculate the wave continuity (the value range is [0, 1]).
[0113] S5.2.5, Contour curvature rate of change: For each sampling point (i=2 to M-1, excluding the first and last points), take its adjacent points , Construct a local three-point group; Calculate the circumradius of the triangle formed by the three points , the formula is: , where, is the area of the triangle (calculated by vector cross product: ); Ri Contour point curvature (curvature is inversely proportional to radius, unit: 1 / pixel), if the three points are collinear , then , so as to obtain the curvature sequence (length M-2); S5.2.6, Rate of change calculation: Calculate the curvature difference of adjacent points for the curvature sequence: ; Calculate the arc length distance of adjacent sampling points (unit: pixel); Contour curvature rate of change (unit: 1 / ), which represents the change amplitude of curvature per unit arc length.
[0114] S5.3, input the contour curvature rate of change, wave frequency, wave amplitude and wave continuity to the trained neural network model, so as to obtain the defect grade of the original image.
[0115] Before inputting the profile curvature change rate, fluctuation frequency, fluctuation amplitude and fluctuation continuity to the trained neural network model, the profile curvature change rate, fluctuation frequency, fluctuation amplitude and fluctuation continuity are normalized.
[0116] Normalization of fluctuation frequency, fluctuation amplitude and fluctuation continuity: The calculated fluctuation frequency f, fluctuation amplitude gray difference and continuity are mapped to the [0, 1] interval by min-max standardization.
[0117] , , ; , , , are the maximum and minimum values of the fluctuation frequency, and the maximum and minimum values of the amplitude gray difference, respectively.
[0118] , , are the normalized fluctuation frequency, fluctuation amplitude and continuity, which are part of the input data to the neural network subsequently.
[0119] The profile curvature change rate is normalized as follows: Local extreme value extraction: screen the local maximum values (greater than the curvature change rate of the adjacent points before and after) in the curvature change rate sequence , these extreme points correspond to the positions of sharp curvature changes (such as edge mutations).
[0120] Statistical feature generation: calculate the global curvature change rate mean ; Count the number of local maximum values and the maximum value ; Generate a three-dimensional feature vector ; Standardization: use min-max standardization to map to the [0, 1] interval, and input it to the neural network together with the normalized fluctuation frequency, amplitude and other indicators.
[0121] In this embodiment, the neural network uses a BP neural network, and the process of training the BP neural network is as follows: A large number of original images of wooden template samples labeled with defect levels (minor, moderate, severe) were collected. The fused comprehensive features and corresponding edge fluctuation quantification indicators were extracted as input, and the defect level was used as the output to train a backpropagation (BP) neural network. During training, the weights and biases of the BP neural network were adjusted to make its output as close as possible to the true defect level of the samples. Commonly used loss functions include the mean squared error loss function.
[0122] Using fused feature vectors and edge fluctuation quantization indicators as input data into a BP neural network has the following advantages: Fine-grained features can be added: fused features include texture details of edges (such as gray-level gradient changes in undulating regions) and hierarchical features (such as edge morphology at multiple scales), which can provide richer discrimination criteria for neural networks. For example, the edge orientation histogram in the CNN depth features can help the network distinguish between "sawtooth undulations" and "smooth undulations," and these two types of undulations may have similar f and A values.
[0123] Enhancing feature robustness: The comprehensive features, after multimodal fusion and attention weighting, have filtered out interfering information such as wood texture, focusing on defect-related features. By inputting these features in conjunction with quantitative indicators, a complementary structure of "coarse-grained statistics (indicators) + fine-grained details (comprehensive features)" can be formed, reducing the impact of noise interference on individual features. For example, when local blurring in the edge image leads to calculation errors, the high-frequency coefficient distribution in the comprehensive features can provide redundant information to correct these errors.
[0124] Specifically, the input layer of the BP neural network adopts a two-branch input structure, with branch 1 inputting the edge fluctuation quantization index (...). , , ) and the rate of change of contour curvature ( The first branch has 6 quantized features; the second branch inputs a standardized fusion feature vector (e.g., 1212-dimensional high-frequency coefficient features + 128-dimensional CNN deep features, totaling 1340 dimensions).
[0125] During the processing of input data in the BP network, feature interactions occur in the network's hidden layers: Branch 1 is mapped to 64 dimensions through a fully connected layer, and branch 2 is compressed to 64 dimensions through dimensionality-reducing convolution (1×1 convolution kernel); An attention-gating mechanism is used to weight and fuse the 64-dimensional features of the two branches to generate 128-dimensional joint features. The combined features are input into the subsequent fully connected layer to determine the defect level (minor / moderate / severe).
[0126] The results of the control experiment show that the accuracy of the model with double-branch input (92.3%) is significantly higher than that of single-index input (78.5%) and single-comprehensive-feature input (85.7%), and the model performs better in distinguishing similar defects (such as moderate bending and near severe bending).
[0127] The above specific embodiments further explain the purpose, technical solutions and advantages of the present application. It should be understood that the above description is only a specific embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. An intelligent detection method for image edge fluctuation features, characterized in that, Includes the following steps: Obtain the original image of the wooden template and perform preprocessing to obtain the preprocessed image; Design a dynamic wavelet decomposition strategy based on gradient entropy, and perform multi-scale wavelet decomposition on the preprocessed image through the dynamic wavelet decomposition strategy to obtain a low-frequency sub-band image that reflects the overall contour of the preprocessed image and a high-frequency sub-band image that contains the edge details of the preprocessed image. Extract the wavelet high-frequency coefficients from the high-frequency sub-band image, and map the wavelet high-frequency coefficients to the feature space to obtain the high-frequency coefficient feature vector; A dual-channel CNN model consisting of a texture suppression channel and an edge enhancement channel is constructed. Attention mechanism module containing spatial attention weights and channel attention weights is introduced. The joint feature vector of the high-frequency sub-band image is extracted through the dual-channel CNN model, and the joint feature vector is optimized through the attention mechanism module to obtain a depth feature vector. The weights of the deep feature vector and the high-frequency coefficient feature vector are determined by a reinforcement learning dynamic optimization method. The deep feature vector and the high-frequency coefficient feature vector are then weighted and fused to obtain a fused feature vector. Then, the edge fluctuation quantization index is calculated based on the fused feature vector. The edge fluctuation quantization index, together with the contour curvature change rate of the low-frequency sub-band image and the fused feature vector, is input into the trained neural network model to obtain the defect level of the original image.
2. The intelligent detection method for image edge fluctuation features according to claim 1, characterized in that, The specific steps for preprocessing the original image are as follows: The original image is uniformly converted into an initial grayscale image using an image format conversion algorithm; The initial grayscale image is subjected to adaptive noise suppression processing to obtain a denoised first intermediate grayscale image; The first intermediate grayscale image is subjected to contrast enhancement optimization to obtain a second intermediate grayscale image with improved contrast. Calculate the image sharpness index and signal-to-noise ratio of the second intermediate grayscale image. If the image sharpness index or signal-to-noise ratio meets the requirements, the second intermediate grayscale image is regarded as the preprocessed image; otherwise, proceed to the next step. Determine if the maximum number of iterations has been reached. If not, return to step two and adjust the noise suppression parameters. If yes, treat the second intermediate grayscale image as the preprocessed image.
3. The intelligent detection method for image edge fluctuation features according to claim 1, characterized in that, The dynamic wavelet decomposition strategy based on gradient entropy is as follows: S2.1 Initial selection of wavelet parameters based on the gradient entropy value: Calculate the mean global gradient entropy value of the preprocessed image, and compare the mean global gradient entropy value with the set gradient entropy value threshold, thereby selecting the corresponding wavelet basis function and decomposition level; S2.
2. Perform multi-scale wavelet decomposition on the preprocessed image according to the wavelet basis function and decomposition level selected in step S2.1 to obtain the initial low-frequency sub-band image; S2.3 Calculate the contour irregularity of the initial low-frequency sub-band image and compare the contour irregularity with the set contour irregularity threshold to select a new wavelet basis function and decomposition layer. S2.
4. Perform multi-scale wavelet decomposition on the preprocessed image according to the new wavelet basis function and the number of decomposition levels to obtain the final low-frequency subband image and high-frequency subband image.
4. The intelligent detection method for image edge fluctuation features according to claim 3, characterized in that, The specific process of S2.1 is as follows: S2.1.1 Gradient Entropy Calculation: For the preprocessed image, divide the image into 16×16 pixel local windows and calculate the gradient entropy value of each window. ,in, Let n be the probability distribution of gradient magnitudes within a local window, and n be the quantization series of the gradient magnitudes. The window size optimization satisfies: L is the template length in pixels, which is the probability distribution of the gradient magnitude within the window, and n is the number of possible values of the gradient magnitude. By traversing the entire image through a sliding window, the gradient entropy distribution of all local regions is obtained, thus obtaining the mean global gradient entropy of the preprocessed image. S2.1.2 Wavelet basis function type selection: Setting the gradient entropy threshold and ,and When the mean global gradient entropy value of the preprocessed image is less than When the mean of the global gradient entropy is within a certain range, the sym4 wavelet basis function is selected; when the mean of the global gradient entropy is within a certain range... to When the mean of the global gradient entropy is greater than 1, choose the sym6 wavelet basis function; when the mean of the global gradient entropy is greater than 1. When choosing, select the db6 wavelet basis function; S2.1.3 Initial Determination of Decomposition Layers: The initial decomposition layers are determined based on the mean global gradient entropy value. When the mean is less than... When the initial decomposition level is set to 3, and the mean is within a certain range... to When the mean is between 4 and 5, the initial decomposition level is set to 4-5; when the mean is greater than 100, the initial decomposition level is set to 4-5. At that time, the initial number of decomposition layers was set to 6.
5. The intelligent detection method for image edge fluctuation features according to claim 3, characterized in that, The specific process of S2.3 is as follows: S2.3.1 Calculation of contour irregularity: Extract the actual overall contour of the wooden template from the initial low-frequency sub-band image, compare the actual overall contour with the standard contour, and obtain the contour irregularity D; S2.3.2 Decomposition Layer Update Judgment: Set Contour Irregularity Threshold ,like No need to adjust the number of decomposition levels; maintain the initially selected number of decomposition levels. When the initial decomposition level is reached, add one level; if At this time, 2 more layers are added to the initial decomposition layer number, but the maximum decomposition layer number does not exceed 6 layers; S2.3.3, Secondary selection of wavelet basis functions: If the number of decomposition levels is updated, the new number of decomposition levels... If the number of new decomposition layers is 6 and the original wavelet basis function is sym4, then the wavelet basis function is adjusted to sym6; if the number of new decomposition layers is 6 and the original wavelet basis function is sym6, then the wavelet basis function is adjusted to db6.
6. The intelligent detection method for image edge fluctuation features according to claim 1, characterized in that, The high-frequency subband image consists of an LH subband image containing horizontal low-pass filtering and vertical high-pass filtering, an HL subband image containing horizontal high-pass filtering and vertical low-pass filtering, and an HH subband image containing two high-pass filters. The specific process of extracting wavelet high-frequency coefficients from the high-frequency subband image and mapping the wavelet high-frequency coefficients to the feature space to obtain high-frequency coefficient feature vectors is as follows: The LH sub-band image and / or HL sub-band image and / or HH sub-band image are selected as input sub-band images based on the directional attributes of the edge fluctuation features; Read the wavelet coefficient matrix of the input sub-band image, use soft thresholding to filter the coefficients in the wavelet coefficient matrix, retain the coefficients whose absolute value is greater than the threshold T, and set the coefficients whose absolute value is not greater than the threshold T to 0, thereby obtaining the denoised high-frequency coefficient matrix; The high-frequency coefficient matrix is divided into blocks, and the statistical characteristics within each block are calculated. The statistical characteristics include the mean, variance, and number of maximum points of the coefficients. Extract the global features of the high-frequency coefficient matrix, including the proportion of non-zero coefficients and the histogram distribution of the absolute values of the coefficients; The statistical features are concatenated with the global features to form a high-frequency coefficient feature vector with fixed dimensions; The high-frequency coefficient feature vectors are mapped to a feature space that is homologous to the multimodal attention features through a fully connected layer, and the mapped features are then processed. Standardization is performed so that the modulus of the feature vector is 1, and the high-frequency coefficient feature vector of the high-frequency subband image is finally obtained.
7. The intelligent detection method for image edge fluctuation features according to claim 6, characterized in that, A dual-channel CNN model consisting of a texture suppression channel and an edge enhancement channel is constructed. An attention mechanism module containing spatial attention weights and channel attention weights is introduced. The initial depth feature vector of the high-frequency sub-band image is extracted using the dual-channel CNN model, and the initial depth feature vector is optimized using the attention mechanism module to obtain the final depth feature vector. The specific process is as follows: The LH subband graph, HL subband graph and HH subband graph are merged into a three-channel input tensor; A dual-channel CNN model is constructed, which includes a texture suppression channel and an edge enhancement channel. The texture suppression channel uses dilated convolution to filter the natural texture of wood, and the edge enhancement channel enhances the fluctuation features through residual connections. The three-channel input tensor is input into the texture suppression channel and the edge enhancement channel respectively to obtain the texture suppression feature vector and the edge enhancement feature vector; The texture suppression feature vector and the edge enhancement feature vector are concatenated to obtain the joint feature vector; The joint feature vector is compressed by global average pooling to reduce the channel dimension, and then processed through two fully connected layers plus sigmoid activation to generate a spatial attention weight map. H is the height, and W is the width; The joint feature vector is compressed in terms of spatial dimension through global average pooling, and then processed through two fully connected layers plus sigmoid activation to generate a channel attention weight vector. C represents the dimension; Generate deep feature vectors using feature optimization formulas: ,in, This represents matrix multiplication, and F represents the joint eigenvector. This indicates element-wise multiplication.
8. The intelligent detection method for image edge fluctuation features according to claim 1, characterized in that, The edge fluctuation quantification index includes the fluctuation frequency, fluctuation amplitude, and fluctuation continuity of the preprocessed image edge, wherein the fluctuation frequency is the number of fluctuations per unit length of edge, the fluctuation amplitude is the gray difference between the peak and valley values of the vertical distance from the sampling point on the edge contour to the baseline, and the fluctuation continuity is the proportion of continuous fluctuation segments.
9. The intelligent detection method for image edge fluctuation features according to claim 8, characterized in that, The specific process of using a reinforcement learning dynamic optimization method to weight and fuse the weights of the deep feature vector and the high-frequency coefficient feature vector to obtain a fused feature vector, then calculating the edge fluctuation quantization index based on the fused feature vector, and finally inputting the edge fluctuation quantization index, the contour curvature change rate of the low-frequency sub-band image, and the fused feature vector into a trained neural network model to obtain the defect level of the original image is as follows: The deep feature vector and the high-frequency coefficient feature vector are initially weighted and fused to obtain a fused feature vector, wherein the weights of the deep feature vector and the high-frequency coefficient feature vector are obtained through a reinforcement learning dynamic optimization method; Based on the fused feature vector, calculate the fluctuation frequency, fluctuation amplitude, and fluctuation continuity of the edge graph corresponding to the fused feature vector; The fused feature vector, contour curvature change rate, fluctuation frequency, fluctuation amplitude, and fluctuation continuity are input into the trained neural network model to obtain the defect level of the original image.
10. The intelligent detection method for image edge fluctuation features according to claim 9, characterized in that, The specific calculation process for calculating the fluctuation frequency, fluctuation amplitude, and fluctuation continuity of the preprocessed image edges based on the fusion features is as follows: Fluctuation frequency: Calculate the direction angle of the line connecting adjacent sampling points The direction angle sequence is obtained. M represents the number of sampling points for the edge contours of the preprocessed image. This represents the coordinates of the i-th sampling point of the edge contour; Set the direction angle abrupt change threshold ,when At that time, the judgment This is the inflection point of the fluctuation; Total length of the statistical edge Simultaneously, count the total number K of fluctuation inflection points, then the fluctuation frequency... Where L is the total length of the preprocessed image edge, and K represents the total number of fluctuation inflection points; Fluctuation range: The baseline line function B(x) is obtained by fitting a reference line to the edge contour points P of the preprocessed image using the least squares method. Calculate each sampling point vertical distance to the baseline ; Filter the maximum value among all sampled points Minimum value ; Fluctuation range Through the grayscale mapping formula Converted to grayscale difference, where, , These represent the maximum and minimum grayscale values of the edge region, respectively. The maximum edge length; Fluctuation continuity: Set the maximum allowable distance between adjacent contour points ,when When the edge breaks at this point, the break location is recorded. A continuous, unbroken edge segment is defined as an effective fluctuation segment, and the total length of all effective segments is calculated. ; Calculating the continuity of fluctuations .
Citation Information
Patent Citations
Cable identification method and system based on image processing
CN118628983A
Intelligent identification method and system for asymmetric plate shape defects
CN120580506A
Discharge channel extraction method and system based on edge detection and texture feature fusion
CN120599285A
Wood surface defect detection method based on multi-scale characteristics
CN120612282A
Resistor disc defect online detection system and grading method based on machine vision
CN120765532A
Cited By
Image processing method, device and equipment and readable storage medium
CN122066593A