Image processing leather surface defect identification method and system
By constructing a region association graph and a graph attention network, the problem of insufficient inter-regional correlation in leather surface defect identification was solved, enabling accurate identification and segmentation of complex defects and improving identification accuracy and consistency.
Patent Information
- Application Number
- CN202511756812.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-01-02
AI Technical Summary
Existing technologies cannot effectively model the correlation between regions in leather surface defect identification, resulting in inaccurate segmentation boundaries and a high misjudgment rate. In particular, it is difficult to achieve accurate instance segmentation and counting in scenarios with complex textures, multiple defects adhering or partially overlapping.
By constructing a regional association graph and updating node embeddings using a graph attention network, combined with multi-scale feature extraction, attention-driven mechanisms, and classification networks, a defect heatmap is generated and regional clustering is performed to optimize defect boundaries and achieve accurate instance segmentation.
It improves the model's recognition accuracy and consistency against complex leather texture backgrounds, effectively handles leather defects with blurred boundaries, fragmented shapes, or dense distribution, and achieves precise delineation and separation of each individual defect instance.
Smart Images

Figure CN121258970A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, specifically to a method and system for identifying defects on leather surfaces using image processing. Background Technology
[0002] In the industrial leather manufacturing sector, automated detection of surface defects is a crucial step in ensuring product quality. Currently, this field primarily relies on two types of deep learning-based visual detection methods. One type generates candidate bounding boxes using region proposal networks and independently segments and classifies the regions within each box. This method treats each candidate region as an isolated analytical unit, lacking modeling of the relationships between regions. The other type can achieve pixel-level defect region localization but cannot distinguish between different defect instances, often identifying multiple adjacent defects as a single entity. Both types of methods face significant challenges when dealing with common defects on leather surfaces that are irregular in shape, have blurred boundaries, and are densely distributed.
[0003] The core flaw of existing technologies lies in their inadequacy in handling complex contextual information. Instance segmentation methods, by processing each candidate region independently, ignore the potential feature similarities and spatial relationships between defect regions. When faced with scenarios involving complex textures, multiple overlapping or partially joined defects, the model struggles to utilize global context to aid decision-making, leading to inaccurate segmentation boundaries and increased false positive rates. Semantic segmentation methods, due to their inherent limitations, cannot output independent defect instances, making it difficult to meet the stringent requirements of accurate defect counting, localization, and contour extraction in industrial inspection.
[0004] Current leather surface defect identification technology needs to break through existing paradigms and urgently requires a new method that can explicitly model the correlation between regions and achieve accurate instance clustering, so as to improve the accuracy and stability of identifying complex defects through innovative technical approaches. Summary of the Invention
[0005] The purpose of this invention is to provide a method and system for identifying defects on the surface of leather using image processing, so as to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides a method for identifying leather surface defects through image processing, the method comprising: Images of the leather surface were acquired and preprocessed using illumination normalization and noise filtering to generate enhanced image data; The enhanced image data is input into a multi-scale feature extraction network, which uses a combination of convolutional and pooling layers to extract feature maps at different scales and fuses contextual information to generate a global feature representation. Based on global feature representation, an attention-driven mechanism is used to focus on potential defect regions, calculate the defect saliency score for each pixel, and generate a defect heatmap. Based on the defect heatmap, the image is divided into multiple candidate regions, and the defect probability distribution of each candidate region is calculated. Based on the defect probability distribution, a region association graph is constructed, where nodes represent candidate regions and edges represent feature similarity between regions. A graph attention network is used to update node embeddings. Defect regions are clustered using a region association graph to form defect instance segmentation results, and a classification network is used to identify the type of each defect instance. Based on the defect type and spatial distribution, the defect boundary is optimized and the final identification result is output.
[0007] Preferably, the acquisition of leather surface images is preprocessed through illumination normalization and noise filtering to generate enhanced image data, including: Images of the leather surface are captured using a high-resolution camera, and a white balance algorithm is applied to correct for uneven lighting, generating images with consistent colors. A Gaussian filter is applied to an image with uniform color to remove high-frequency noise while preserving edge information, resulting in a denoised image. Histogram equalization is used to enhance the contrast of the denoised image, highlighting the difference between defects and the background, and generating enhanced image data.
[0008] Preferably, the step of inputting the enhanced image data into a multi-scale feature extraction network, extracting feature maps of different scales using a combination of convolutional and pooling layers, and fusing contextual information to generate a global feature representation includes: Construct a network with an encoder-decoder structure. The encoder part uses convolutional layers to downsample and extract local features, while the decoder part uses deconvolutional layers to upsample and restore spatial resolution. Spatial pyramid pooling is applied to multi-scale feature maps to capture feature information from different receptive fields, and multi-scale features are spliced together to generate rich feature representations. By fusing temporal context information through gated recurrent units, dynamic changes in video sequence images are modeled, enhancing the robustness of global feature representation.
[0009] Preferably, the step of using a global feature representation and an attention-driven mechanism to focus on potential defect regions, calculating a defect saliency score for each pixel, and generating a defect heatmap includes: The importance weight of each position in the feature map is calculated using a self-attention mechanism, and an attention feature map is generated based on the weighted features. The attention feature map is then multiplied point by point with the original feature map to highlight defect-related features and suppress background interference. The attention weights are normalized using the softmax function to generate a defect saliency score for each pixel, which is then interpolated to the original image size to generate a defect heatmap.
[0010] Preferably, the step of dividing the image into multiple candidate regions based on the defect heatmap and calculating the defect probability distribution for each candidate region includes: The optimal segmentation threshold for the defect heatmap is calculated using the maximum inter-class variance method, and an adaptive threshold map is generated by adjusting the threshold based on the local gradient. Connectivity analysis is performed based on adaptive threshold maps, each connected region is labeled as a candidate region, and region shape features are extracted. The support vector machine classifier is used to calculate the defect probability distribution of each candidate region based on shape features, including the probabilities of normal, minor defects, and severe defects.
[0011] Preferably, the step of constructing a region association graph based on the defect probability distribution, where nodes represent candidate regions and edges represent feature similarity between regions, and using a graph attention network for node embedding updates, includes: Each candidate region is represented as a node, and the node features include region area, perimeter, and defect probability. Calculate the Euclidean distance between nodes as feature similarity, and construct an adjacency matrix to define edge weights; The graph attention network layer is used to aggregate neighbor node information, update node embeddings, and output updated node features through a multilayer perceptron. The Euclidean distance between the computed nodes is used as the feature similarity to construct an adjacency matrix that defines edge weights, including: Normalize the node feature vectors to a unit length and calculate the Euclidean distance between each pair of node feature vectors; The distance is converted into a similarity score using a Gaussian kernel function; the higher the score, the greater the similarity. Set a similarity score threshold and retain only edges with scores higher than the threshold to construct a sparse adjacency matrix.
[0012] Preferably, the step of clustering defect regions using a region association graph to form defect instance segmentation results, and using a classification network to identify the type of each defect instance, includes: Density clustering algorithm is used to cluster the updated node features, and similar nodes are grouped into defect instances; For each defect instance, generate the minimum bounding rectangle as the bounding box and extract the image patch within the box; Image patches are input into a pre-trained convolutional neural network classifier, which outputs defect type labels such as scratches, blemishes, or damage.
[0013] Preferably, the step of acquiring images of the leather surface using a high-resolution camera and applying a white balance algorithm to correct for uneven illumination and generate an image with consistent color includes: Set camera parameters, including exposure time and gain value, to ensure uniform image brightness; White balance correction is performed using the gray world assumption, and the RGB channel gain is adjusted to make the image color temperature consistent. The image is converted to a standard color space using a color correction matrix, resulting in an image with consistent colors.
[0014] Preferably, the step of calculating the optimal segmentation threshold of the defect heatmap using the Otsu's method and adjusting the threshold according to the local gradient to generate an adaptive threshold map includes: Calculate the grayscale histogram of the defect heatmap, iterate through each possible threshold to calculate the inter-class variance, and select the threshold corresponding to the largest variance as the initial threshold. Calculate the local gradient map of the heatmap, and dynamically adjust the threshold according to the gradient magnitude. Use a lower threshold in high gradient areas to preserve details. The adjusted threshold is applied for binarization segmentation to generate an adaptive threshold map.
[0015] Preferably, the present invention also includes an image processing leather surface defect identification system, the system including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor, when executing the computer program, implements the steps of the image processing leather surface defect identification method described above.
[0016] Compared with the prior art, the beneficial effects of the present invention are: By constructing a region association graph and updating node embeddings using a graph attention network, the model can transcend isolated analysis of individual candidate regions. This method treats each candidate region as a node in a graph structure and establishes connecting edges based on feature similarity, thereby expressing the potential connections between different regions. The graph attention mechanism allows each node to adaptively focus on and aggregate feature information from its neighboring nodes, and the final node embedding represents a fusion of local features and global context. This graph-based information transfer enables the model to re-evaluate and enhance the features of ambiguous or weak candidate regions based on semantic relevance and spatial relationships between regions. This effectively overcomes the recognition difficulties caused by local occlusion, uneven lighting, or texture interference, improving the accuracy and consistency of the model's judgment against complex leather texture backgrounds.
[0017] This method employs a process of generating candidate regions from a defect heatmap and then using graph clustering to form instance segmentation results. It initially locates all possible defect pixels using pixel-level saliency scores, and then divides the candidate regions based on probability distribution. Instead of simply thresholding the heatmap, it places the candidate regions in a region association graph and clusters them based on the similarity of the features embedded in the updated nodes. This mechanism allows pixel regions belonging to the same physical defect but potentially slightly separated spatially or exhibiting color variations to be correctly aggregated, while accurately separating contiguous regions with significant feature differences that do not belong to the same instance. This process is particularly suitable for handling leather defects with blurred boundaries, fragmented shapes, or dense distributions, and can self-organize and form segmentation contours based on the deep feature correlations between regions, thereby achieving accurate delineation and separation of each independent defect instance. Attached Figure Description
[0018] Figure 1 This is a schematic diagram illustrating the working principle of the image processing method for identifying leather surface defects according to the present invention. Figure 2 A flowchart for image preprocessing; Figure 3 This is a flowchart of multi-scale feature extraction and global feature generation; Figure 4 The training loss curve for the attention network; Figure 5 A comparison chart of the accuracy of the training and validation sets for each defect type. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Please see Figure 1This invention provides a method for identifying defects on leather surfaces using image processing. The method includes: acquiring leather surface images and preprocessing them through illumination normalization and noise filtering to generate enhanced image data; inputting the enhanced image data into a multi-scale feature extraction network, extracting feature maps at different scales using a combination of convolutional and pooling layers, and fusing contextual information to generate a global feature representation; based on the global feature representation, using an attention-driven mechanism to focus on potential defect regions, calculating the defect saliency score for each pixel, and generating a defect heatmap; dividing the image into multiple candidate regions according to the defect heatmap, and calculating the defect probability distribution for each candidate region; constructing a region association graph based on the defect probability distribution, where nodes represent candidate regions and edges represent feature similarity between regions, and using a graph attention network for node embedding and updating; clustering defect regions through the region association graph to form defect instance segmentation results, and using a classification network to identify the type of each defect instance; optimizing defect boundaries according to defect type and spatial distribution, and outputting the final recognition result.
[0021] Example 1: See Figure 2 In practice, a high-resolution camera is used to acquire images of the leather surface, and a white balance algorithm is applied to correct for uneven lighting to generate a color-consistent image. Camera parameters, including exposure time and gain value, are set to ensure uniform image brightness. White balance correction is performed using the gray-world assumption, and the RGB channel gain is adjusted to make the image color temperature consistent. The image is then converted to a standard color space using a color correction matrix to generate a color-consistent image. Gaussian filtering is performed on the color-consistent image to remove high-frequency noise while preserving edge information, resulting in a denoised image. Histogram equalization is then used to enhance the contrast of the denoised image, highlighting the difference between defects and the background, and generating enhanced image data.
[0022] In practical implementation, the color correction matrix is a 3x3 real matrix that maps the original RGB values captured by the camera to the standard sRGB color space through matrix multiplication. The specific calculation process is as follows: Select n color patches (n≥24) from the standard color chart, measure the RGB value of each color patch in the original image of the camera, denoted as matrix R (n×3), and simultaneously obtain the XYZ values of these color patches in the standard sRGB color space. Convert the XYZ values to the target RGB values using the standard conversion formula, denoted as matrix T (n×3). Solving the color correction matrix M (3×3) is transformed into a least squares optimization problem. To ensure the stability of the color correction matrix, it is usually necessary to acquire multiple color chart images under different exposures, average them, and then calculate the matrix. The application implementation of the color correction matrix includes the following steps: Read the RGB value of each pixel in the input image and construct a 3-dimensional column vector [R;G;B]. Multiply the color correction matrix M with the RGB vector to obtain the new RGB values: [R';G';B']=M×[R;G;B]. The calculation results are constrained to a range, truncating values outside the range [0, 255] to the valid range. When processing floating-point images, precision is maintained without truncation. The color-converted image is in the standard sRGB color space, with accurate color representation. In some embodiments, the color correction matrix can be expanded to a 3×4 matrix, adding an offset term to better fit the color conversion relationship; in this case, the transformation formula is [R';G';B'] = M×[R;G;B;1]. The color correction matrix can be calculated using weighted least squares, assigning different weights based on the importance of color patches. For high dynamic range images, the color correction matrix can be designed as a piecewise linear function to adapt to different brightness ranges. The verification method for the color correction matrix includes photographing a verification color chart, calculating the color difference ΔE between the converted color value and the standard value, and considering the color correction matrix as qualified when the average color difference is less than 3. The color correction matrix needs to be individually calibrated for each camera and updated regularly to ensure color accuracy. In embedded systems, the color correction matrix can be implemented using a lookup table, pre-calculating all possible input-output correspondences to improve processing speed.
[0023] The selection of high-resolution cameras is based on the texture characteristics of leather surfaces, typically employing full-frame sensors with pixel resolutions exceeding 20 megapixels to capture subtle imperfections and details. Exposure times are set to a range of 1 / 100 to 1 / 500 second, dynamically adjusted according to ambient light. Gain values are controlled between ISO 100 and 400 to prevent overexposure or underexposure. White balance correction is based on the grayscale world assumption, calculating the average value of all RGB channels in the image and adjusting the gain of each channel to make the average value equal, achieving color consistency. The color correction matrix uses conversion parameters of the standard sRGB color space to map the image from the camera's original color space to the target space, eliminating device-related color differences. Gaussian filtering uses Gaussian filters with kernel sizes of 3x3 or 5x5 and standard deviations set to 1.0-2.0, effectively smoothing image noise without blurring edges. Histogram equalization applies a contrast-limited adaptive histogram equalization method, dividing the image into multiple local regions, calculating histograms for each region, and performing equalization to enhance local contrast. The preprocessed image data is stored in grayscale or RGB format for use by subsequent modules.
[0024] In practical implementation, the parameter configuration of high-resolution cameras needs to be finely adjusted according to leather type and lighting conditions. The choice of exposure time depends on the ambient light intensity. For example, in strong light environments, a shorter exposure time, such as 1 / 500 second, is used to avoid overexposure. In low light environments, the exposure time is extended to 1 / 100 second to ensure sufficient image brightness. The gain value setting works in conjunction with the exposure time. A lower ISO value reduces noise but may require a longer exposure time, while a higher ISO increases brightness but introduces more noise. Therefore, a balance must be struck to achieve optimal image quality. During white balance correction, the grayscale world hypothesis calculates the mean of the RGB components of the entire image and adjusts the gain to make the R, G, and B mean values close, thereby correcting color cast. The color correction matrix is generated based on camera calibration data, linearly converting the image from the device-dependent RGB space to the sRGB space to ensure color fidelity. Gaussian filtering is implemented using convolution operations. The Gaussian kernel is generated based on a two-dimensional Gaussian function. The kernel size is chosen considering the image resolution. High-resolution images can use a 5x5 kernel to better smooth noise. The standard deviation controls the filtering intensity; a larger value results in a stronger smoothing effect but may lose detail. Therefore, it is adaptively selected according to the noise level. In histogram equalization, limiting the contrast parameter setting is used to prevent over-enhancement. The histogram is cropped to a certain range before equalization to avoid local areas being too bright or too dark.
[0025] In some embodiments, multi-frame averaging techniques can be introduced during the image acquisition stage. By continuously acquiring multiple images and calculating the pixel average, random noise can be further reduced, and the image signal-to-noise ratio can be improved. Lens selection for high-resolution cameras needs to consider distortion and chromatic aberration correction, using low-distortion lenses and applying software correction algorithms to reduce geometric distortion. In addition to the gray-world assumption, white balance algorithms can also incorporate color temperature sensor data to monitor ambient color temperature in real time and dynamically adjust RGB gain, improving correction accuracy. The color correction matrix is generated by photographing a standard color chart and calculating the transformation matrix to ensure accurate color reproduction. Gaussian filtering can be replaced with bilateral filtering, which better preserves edges while smoothing noise, but has higher computational complexity and needs to be selected based on processing speed requirements. Histogram equalization methods can employ variations of adaptive histogram equalization, such as contrast-limited adaptive histogram equalization, which prevents noise amplification by limiting the range of local contrast enhancement.
[0026] Optionally, the image preprocessing workflow can integrate an illumination estimation module to synchronously record illumination data during image acquisition for more accurate white balance correction. The trigger mode of the high-resolution camera is set to external trigger, capturing leather images synchronously with the conveyor belt to avoid motion blur. After white balance correction, a color saturation enhancement algorithm can be applied to adjust the image saturation parameters, making the defect area more contrasting with the background. Before Gaussian filtering, noise assessment is performed, and the filtering method is selected according to the noise type; for example, median filtering is more effective for salt-and-pepper noise. After histogram equalization, a sharpening filter can be superimposed to enhance edge details, but the intensity must be controlled to prevent artifacts. It can be understood that the image acquisition and preprocessing stages are fundamental to the defect recognition system. The raw images captured by the high-resolution camera contain environmental noise and illumination variations. Through systematic processing, these are transformed into standardized data, providing consistent input for subsequent feature extraction. White balance correction ensures color consistency under different lighting conditions, avoiding color difference interference with defect detection. Gaussian filtering removes high-frequency noise while preserving structural edges, and histogram equalization enhances overall contrast, making subtle defects easier to identify. The settings of preprocessing parameters need to be optimized based on a large amount of experimental data. For example, the optimal range of exposure time and gain value is determined by trial and error. The standard deviation of Gaussian filtering is calculated based on the image noise model. The partition size of histogram equalization affects the local enhancement effect and needs to be adjusted according to the defect size.
[0027] In practical implementation, the operation process of a high-resolution camera includes initializing the camera driver, setting the acquisition resolution and frame rate, configuring the exposure mode and gain mode to automatic or manual, adjusting parameters according to ambient light in manual mode, and optimizing in real time using the camera's built-in algorithm in automatic mode. During image acquisition, the camera ensures a smooth leather surface and uniform lighting, avoiding shadows and reflections. The white balance correction algorithm is the first step in the image processing pipeline. It reads the raw image data, calculates the global mean of the RGB channels, then scales the channel values to balance the mean, generating an intermediate image. Finally, a color correction matrix is applied for color space conversion, outputting an image with consistent colors. Gaussian filtering is implemented using a convolution library, such as OpenCV's Gaussian blur function, taking the image and kernel parameters as input and outputting a smooth image. Histogram equalization uses library functions to calculate the histogram and map pixel values, limiting the contrast parameter to between 40 and 50 to prevent over-enhancement.
[0028] In some embodiments, the preprocessing module can be deployed in an embedded system to optimize computational efficiency, such as using a GPU to accelerate convolution operations and reduce processing latency. For high-resolution cameras, the interface can be GigE or USB 3.0 protocols to ensure data transfer speed. White balance correction can be implemented in hardware within the camera, directly outputting the corrected image and reducing software burden. The parameters of Gaussian filtering and histogram equalization can be automatically optimized using machine learning algorithms, learning optimal settings based on historical data to adapt to different leather types. Optionally, a quality check step is added after image enhancement to calculate image sharpness and noise level indicators, such as using Laplacian variance to assess blurriness. If the image is below a threshold, it is re-acquired to ensure input data quality. The white balance correction effect is evaluated using color difference indicators, and if it exceeds a threshold, it is re-corrected. The Gaussian filter kernel size can be dynamically adjusted according to the image size; a larger kernel is used for large images to maintain a smooth effect. The number of histogram equalization partitions is proportional to the image resolution; high-resolution images are divided into more partitions to preserve details.
[0029] Example 2: See Figure 3In the specific implementation, the enhanced image data is input into a multi-scale feature extraction network. A combination of convolutional and pooling layers is used to extract feature maps at different scales, and contextual information is fused to generate a global feature representation. An encoder-decoder network is constructed. The encoder uses convolutional layers for downsampling to extract local features, while the decoder uses deconvolutional layers for upsampling to restore spatial resolution. Spatial pyramid pooling is applied to the multi-scale feature maps to capture feature information from different receptive fields, and the multi-scale features are concatenated to generate a rich feature representation. Temporal contextual information is fused through gated recurrent units to model dynamic changes in video sequence images, enhancing the robustness of the global feature representation. Based on the global feature representation, an attention-driven mechanism is used to focus on potential defect regions, calculating the defect saliency score for each pixel to generate a defect heatmap. A self-attention mechanism is used to calculate the importance weight of each position within the feature map, generating an attention feature map based on the weighted features. The attention feature map is multiplied point-by-point with the original feature map to highlight defect-related features and suppress background interference. The attention weights are normalized using a softmax function to generate a defect saliency score for each pixel, which is then interpolated to the original image size to generate the defect heatmap.
[0030] The encoder part of the multi-scale feature extraction network consists of multiple convolutional blocks, each containing a convolutional layer, a batch normalization layer, and a ReLU activation function. The kernel size is set to 3x3, with a stride of 2 for downsampling, gradually reducing the feature map size while increasing the number of channels. The decoder part uses deconvolutional layers or bilinear interpolation for upsampling, gradually restoring spatial resolution and skipping connections with the feature maps of the corresponding encoder layers to preserve detail. The spatial pyramid pooling layer uses multiple pooling windows of different sizes, such as 1x1, 2x2, and 4x4, to pool the feature maps, concatenating the output features into a fixed-dimensional vector. When processing video sequences, the gated recurrent unit takes the feature maps of consecutive frames as input, passing temporal information through hidden states to capture the dynamic change patterns of defects. In the attention-driven mechanism, the self-attention module calculates the query, key, and value vectors, calculates the weight matrix through dot product attention, and generates an attention feature map through weighted summation. The defect saliency score is calculated using the softmax function, normalized along the spatial dimension, with a score ranging from 0 to 1, representing the probability that each pixel belongs to a defect. Heatmap generation uses bilinear interpolation to upsample the score map to the original image size, thus visualizing defect areas.
[0031] In its implementation, the encoder-decoder network is designed with a symmetrical structure. The encoder consists of five downsampling stages, each using two convolutional layers to extract features followed by a max-pooling layer. The number of channels increases progressively from 64 to 512. The decoder uses five upsampling stages, each using deconvolution to double the size of the feature map and concatenating it with the encoder's feature map at the same scale. Finally, a 1x1 convolution is used to output the feature map. Spatial pyramid pooling is performed on the encoder's output feature map, inputting the feature map into adaptive pooling layers of different scales. After pooling, the features are flattened and concatenated to form a multi-scale feature vector. The gated recurrent unit (GRU) uses a single-layer design, with the hidden layer dimension matching the number of channels in the feature map. It takes a sequence of three consecutive frames of feature maps as input and outputs a feature representation that incorporates temporal information. The self-attention mechanism involves linearly transforming the input feature map to obtain a query matrix, a key matrix, and a value matrix. The dot product of the query matrix and the key matrix is calculated and scaled. Attention weights are obtained through softmax, and the weights are multiplied by the value matrix to obtain a weighted output.
[0032] In some embodiments, the multi-scale feature extraction network can employ a residual connection structure, adding skip connections to each convolutional block to alleviate the gradient vanishing problem and improve network training stability. The pooling scale of spatial pyramid pooling can be expanded to more levels, such as adding 8x8 pooling to capture more global features. The gated recurrent unit can be replaced with a long short-term memory network to enhance long sequence modeling capabilities. The self-attention mechanism can be expanded to multi-head self-attention, using multiple sets of queries, key and value matrices for parallel computation, fusing attention information from different subspaces. Optionally, the feature extraction network can be pre-trained on a large image dataset, such as ImageNet, to improve feature representation capabilities through transfer learning. An attention module can be added after spatial pyramid pooling to weightedly fuse multi-scale features, highlighting important scale features. The input of the gated recurrent unit can include optical flow information to enhance motion feature modeling. The self-attention computation can introduce relative position encoding, making the attention weights include positional information.
[0033] As can be understood, multi-scale feature extraction captures feature information from local to global through an encoder-decoder structure; spatial pyramid pooling integrates features from different receptive fields to adapt to defect detection of different sizes; and gated recurrent units introduce temporal context, providing better robustness to dynamic defects in video sequences. The attention-driven mechanism calculates feature importance through self-attention, highlighting defect regions and suppressing background interference. Defect saliency scores provide pixel-level defect probabilities, and heatmaps visually display defect distribution.
[0034] In the implementation, the encoder-decoder network is trained using the cross-entropy loss function and the Adam optimizer, with a learning rate of 0.001, a batch size of 16, and 100 training cycles. Data augmentation methods include random rotation, flipping, and scaling to improve the model's generalization ability. The output feature vector of the spatial pyramid pooling is of a fixed dimension, such as 256, and is then input into subsequent modules after dimensionality reduction through fully connected layers. The hidden state of the gated recurrent unit is initialized to a zero vector. At each time step, the current frame feature map is input to update the hidden state, and the hidden state at the last time step is output as the temporal feature. In the calculation of the self-attention mechanism, the dimensions of the query, key, and value vectors are set to 64. The dot product result is scaled by dividing the dimension by the square root to prevent gradient vanishing. The generation of the defect heatmap uses a bilinear interpolation algorithm to enlarge the low-resolution score map to the original image size while maintaining smooth edges.
[0035] In some embodiments, the network structure can be optimized to a U-Net architecture, using dense skip connections between the encoder and decoder to retain more spatial information. Spatial pyramid pooling can be replaced with dilated spatial pyramid pooling, using dilated convolutions with different dilation rates to capture multi-scale features. Gated recurrent units can be stacked into a two-layer network to enhance sequence modeling capabilities. A self-attention mechanism can be combined with convolution operations to form a convolutional attention module, preserving local correlations while calculating attention. Optionally, deformable convolutions can be introduced into the feature extraction process to adaptively adjust the shape of the convolution kernel, better adapting to irregular defect contours. After feature concatenation from spatial pyramid pooling, a channel attention mechanism can be added to recalibrate channel weights. Training of the gated recurrent units can use a curriculum learning strategy, gradually transitioning from simple sequences to complex sequences. Residual connections and layer normalization can be added to the self-attention computation to stabilize the training process.
[0036] Example 3: In specific implementation, the image is divided into multiple candidate regions based on the defect heatmap, and the defect probability distribution of each candidate region is calculated. The optimal segmentation threshold of the defect heatmap is calculated using the maximum inter-class variance method, and the threshold is adjusted according to the local gradient to generate an adaptive threshold map. The gray-level histogram of the defect heatmap is calculated, and the inter-class variance is calculated iteratively for each possible threshold. The threshold corresponding to the maximum variance is selected as the initial threshold. The local gradient map of the heatmap is calculated, and the threshold is dynamically adjusted according to the gradient magnitude. A lower threshold is used for high gradient regions to preserve details. The adjusted threshold is applied for binarization segmentation to generate an adaptive threshold map. Connectivity analysis is performed based on the adaptive threshold map, and each connected region is labeled as a candidate region, and the region shape features are extracted. A support vector machine classifier is used to calculate the defect probability distribution of each candidate region based on the shape features, including the probabilities of normal, minor defects, and severe defects.
[0037] The Otsu's method iterates through all possible thresholds of the heatmap, calculating the inter-class variance of the foreground and background regions. The threshold corresponding to the maximum variance is used as the global segmentation point. The local gradient map calculates the horizontal and vertical gradients of the heatmap using the Sobel operator. Regions with high gradient magnitudes indicate rich edges or details, and these regions are given lower thresholds to avoid over-segmentation. After the adaptive threshold map is generated, morphological operations such as opening and closing operations are performed to eliminate isolated points caused by noise. Connectivity analysis uses the 8-connectivity rule to label regions and calculates the area, perimeter, and roundness of each region. The Support Vector Machine (SVM) classifier learns the decision boundaries of shape features using labeled data during the training phase. During the testing phase, it takes the region feature vector as input and outputs the probability value belonging to each defect category. The probability distribution is represented as a three-dimensional vector, with the sum of the probabilities of normal, minor, and severe defects being 1.
[0038] In its implementation, the maximum inter-class variance (MOV) method involves converting the defect heatmap into a grayscale image, statistically analyzing the grayscale histogram distribution, iterating through all integer thresholds from 0 to 255, classifying pixels into foreground and background classes for each threshold, calculating the mean and variance of the two classes, and then calculating the inter-class variance. The threshold that maximizes the inter-class variance is selected as the initial global threshold. The local gradient map is calculated using Sobel convolution kernels: horizontal kernels [-1,0,1;-2,0,2;-1,0,1], and vertical kernels [-1,-2,-1;0,0,0;1,2,1]. These kernels are convolved to obtain gradient components, which are then merged into a gradient magnitude map. The threshold adjustment strategy sets adjustment coefficients based on the gradient magnitude. Regions with gradient magnitudes higher than the average have their thresholds reduced by 10%-20% to preserve detail information; regions with lower gradient magnitudes retain their original thresholds. The adaptive threshold map generates a binary image by comparing the heatmap values pixel-by-pixel with the adjusted thresholds.
[0039] In some embodiments, the maximum inter-class variance (MOV) method can be combined with multi-threshold segmentation techniques to divide the image into multiple gray levels, adapting to defect heatmaps with complex backgrounds. Local gradient calculation can use the Prewitt or Roberts operators instead of the Sobel operator to obtain different edge response characteristics. The threshold adjustment strategy can introduce an adaptive weighting mechanism to dynamically adjust the threshold change based on gradient direction consistency. Morphological operations can use combinations of basic operations such as erosion and dilation to eliminate noise points while maintaining the integrity of the region shape. Optionally, connected component analysis can employ a fast connected component labeling algorithm, achieving efficient region labeling based on pixel scanning and equivalence class parsing. Shape feature extraction can add texture feature descriptors, such as gray-level co-occurrence matrix features, to improve region representation capabilities. The support vector machine classifier can be replaced with a random forest or neural network classifier to adapt to more complex feature distribution patterns. It can be understood that the MOV method determines the optimal segmentation point through statistical characteristics, ensuring maximum separation between the foreground and background. Local gradient adjustment enhances sensitivity to edge regions, avoiding detail loss. Adaptive threshold map generation uses spatially variable thresholding to balance overall segmentation performance with local detail preservation. Connected component analysis transforms binary images into discrete region objects, shape features quantify the geometric properties of the regions, and support vector machine classifiers provide reliable probability outputs based on statistical learning theory.
[0040] In practical implementation, the specific steps of connected component analysis include scanning the binary image, checking the labeling status of the neighboring pixels for each foreground pixel, managing equivalent labels using a disjoint-set data structure, and finally assigning a unique identifier to each connected component. Shape feature calculation includes features such as area, perimeter, roundness, and aspect ratio. The support vector machine classifier is trained using a radial basis function kernel, employing a one-to-one strategy to handle multi-class problems. The probability output is achieved through Platt scaling, converting the classification decision value into a posterior probability. The region labeling process can be optimized into a two-pass scanning algorithm: the first pass assigns temporary labels and records equivalence relations, and the second pass parses the equivalence relations and assigns the final labels. The shape feature set can be expanded into seven-dimensional invariant moment features, providing rotation- and scaling-invariant region descriptions. The kernel function of the support vector machine classifier can be a multinomial kernel or a linear kernel, selecting the optimal kernel function based on the feature distribution characteristics. Optionally, the defect probability distribution calculation can incorporate a Bayesian inference framework, combining prior probabilities to optimize posterior probability estimation. The region segmentation results can be post-processed and filtered to remove regions with excessively small areas or abnormal shapes, improving the quality of candidate regions. The probability output can be supplemented with uncertainty metrics.
[0041] Example 4: In a specific implementation, a region association graph is constructed based on the defect probability distribution, where nodes represent candidate regions and edges represent the feature similarity between regions. A graph attention network is used to update node embeddings. Each candidate region is represented as a node, and node features include region area, perimeter, and defect probability. The Euclidean distance between nodes is calculated as feature similarity, and an adjacency matrix is constructed to define edge weights. Node feature vectors are normalized to unit length, and the Euclidean distance between each pair of node feature vectors is calculated. A Gaussian kernel function is used to convert the distance into a similarity score; a higher score indicates greater similarity. A similarity score threshold is set, and only edges with scores higher than the threshold are retained to construct a sparse adjacency matrix. A graph attention network layer is used to aggregate neighbor node information, update node embeddings, and output the updated node features through a multilayer perceptron.
[0042] Referring to Table 1, the node feature vector is formed by concatenating normalized region area, perimeter, and defect probability values. The normalization method uses min-max scaling to map the feature values to the 0-1 range. After Euclidean distance calculation, a Gaussian kernel function is used to convert the distance into similarity, and the kernel width parameter is adjusted according to the feature distribution. The sparse adjacency matrix only retains edges with similarity higher than 0.5 to reduce computational complexity. The graph attention network layer calculates the attention coefficient between each node and its neighbors, and updates the node features through weighted summation. The multilayer perceptron contains two fully connected layers and a ReLU activation function, and the output dimension is consistent with the input feature dimension. The construction process of the node feature vector includes three components: the region area is obtained by counting the number of pixels in the candidate region, the region perimeter is calculated by the boundary tracking algorithm to count the number of boundary pixels, and the defect probability comes from the three-dimensional probability vector output by the support vector machine classifier. Feature normalization uses the min-max scaling method, processing each feature dimension separately, and the calculation formula is (current value - minimum value) / (maximum value - minimum value), ensuring that all feature values are in the range of 0 to 1. The normalized feature vectors are then L2-norm normalized to ensure a vector magnitude of 1, eliminating the influence of feature dimensions. Euclidean distance is calculated using the standard formula, taking the square root of the sum of squares of the differences in each dimension of the feature vectors of two nodes. A Gaussian kernel function maps the Euclidean distance to a similarity score, with the kernel width parameter σ set to 0.5. The similarity score is calculated using the formula exp(-distance² / (2σ²)). When constructing the adjacency matrix, a similarity score threshold of 0.5 is set, retaining only edges with scores above the threshold and setting the weights of the remaining edges to 0, thus forming a sparse matrix structure.
[0043] Table 1. Composition of node feature vectors: In its implementation, the graph attention network layer adopts the standard architecture of graph attention networks. Each graph attention network layer contains a multi-head attention mechanism with 8 heads, and each attention head calculates independent attention coefficients. The attention coefficient calculation process includes obtaining query and key vectors from node features through linear transformation, calculating the dot product attention between the query and key vectors, processing it with the LeakyReLU activation function, and finally normalizing it using the softmax function to obtain the attention weights. Node feature updates are achieved by weighted summation of neighboring node features. The multi-head attention outputs are concatenated and then linearly transformed to obtain the updated node features. The multilayer perceptron consists of two fully connected layers. The first layer maps the feature dimension to 128 dimensions, and the second layer maps it back to the original dimension, using the ReLU activation function in between. The graph attention network has 2 layers, and the output dimension of each layer remains consistent with the input.
[0044] The specific computational steps of the graph attention network layer include: For each node, firstly, its feature vector is transformed through a weight matrix to obtain a query vector, and simultaneously, the features of neighboring nodes are transformed through another weight matrix to obtain key vectors. The dot product of the query vector and all neighbor key vectors is calculated to obtain an unnormalized attention score. The attention score is input into the LeakyReLU activation function, with the negative slope parameter set to 0.2. The attention score is normalized using the softmax function to obtain the attention weights for each neighboring node. Finally, the attention weights are multiplied by the corresponding neighboring node features and summed to obtain the updated features for that node. The multi-head attention mechanism executes the above calculations in parallel eight times, concatenating the output features of the eight heads and fusing them through a linear transformation. The first fully connected layer of the multilayer perceptron maps the feature dimension from the original dimension to 128 dimensions using the ReLU activation function, and the second fully connected layer maps the 128-dimensional features back to the original dimension. The two graph attention network layers are stacked, with the output of the first layer serving as the input of the second layer, ultimately outputting the updated node feature matrix.
[0045] In some embodiments, node feature vectors can be expanded to include more geometric features, such as region density and eccentricity, enhancing region representation capabilities. Residual connections can be introduced into the graph attention network layer to add input features to updated features, avoiding gradient vanishing. Gating mechanisms can be incorporated into attention coefficient calculation to dynamically adjust the importance of attention weights. Optionally, cosine similarity can be used instead of Euclidean distance for similarity calculation, better capturing feature orientation consistency. A k-nearest neighbor strategy can be introduced in adjacency matrix construction, where each node connects only to its k most similar nodes. A label propagation strategy can be used for graph attention network training, utilizing a small number of labeled nodes to guide feature updates. In essence, the region association graph construction organizes discrete candidate regions into graph-structured data, with node features comprehensively describing region attributes and edge connections reflecting similarity relationships between regions. The graph attention network aggregates neighbor information through a message passing mechanism, enhancing node feature representation. The sparse adjacency matrix reduces computational complexity, making the method suitable for large-scale image processing.
[0046] In practice, the training of the graph attention network is unsupervised, and the loss function is designed as a weighted sum of feature smoothing loss and structure preservation loss. Feature smoothing loss encourages similarity in features between adjacent nodes, while structure preservation loss maintains the original feature distribution characteristics. The optimizer uses the Adam algorithm with a learning rate of 0.001 and 100 training iterations. The forward propagation process includes feature normalization, similarity calculation, adjacency matrix construction, graph attention network feature update, and multilayer perceptron transformation. Backpropagation calculates the gradient and updates the network parameters. The specific training process of the graph attention network includes: initializing the network weight matrix, inputting the node feature matrix and adjacency matrix. Forward propagation calculates the updated node features, calculates the feature smoothing loss function to measure the degree of difference in features between adjacent nodes. Calculates the structure preservation loss function to measure the consistency of the node feature distribution before and after the update. The total loss function is a weighted sum of the two losses, with weight coefficients set to 0.7 and 0.3. Backpropagation calculates the gradient of the loss function with respect to the network parameters, and the Adam optimizer is used to update the parameters. During training, the loss value is validated every 10 epochs. Training is terminated early when the loss value stops decreasing for 10 consecutive epochs. After training, the network parameters are saved for subsequent node feature updates. During the inference phase, the trained model is loaded directly, new node features and adjacency matrices are input, and updated node features are output.
[0047] See Figure 4This paper demonstrates the trends of total loss, feature smoothing loss, and structure preservation loss in a graph attention network during training, with the number of iterations. The total loss, obtained by weighted summation of feature smoothing loss and structure preservation loss, shows an overall decreasing trend over 100 iterations, reflecting the convergence process of the model under unsupervised training. Feature smoothing loss encourages similarity in features between adjacent nodes, and its curve continuously decreases, indicating that the smoothness of node features gradually increases. Structure preservation loss maintains the original feature distribution characteristics, exhibiting fluctuations but generally stabilizing. The changes in these three factors collectively reflect that the graph attention network gradually learns effective node feature representations through the Adam optimizer (learning rate 0.001), achieving a balance between feature smoothing and structure preservation. This provides reliable node embedding update capabilities for subsequent association analysis and instance segmentation of leather surface defect regions.
[0048] Example 5: In specific implementation, the defect region clustering and classification stages are involved. Defect region clustering is performed through a region association graph to form defect instance segmentation results, and a classification network is used to identify the type of each defect instance. Density clustering algorithm is used to cluster the updated node features, and similar nodes are merged into defect instances; a minimum bounding rectangle is generated as a bounding box for each defect instance, and image patches within the box are extracted; the image patches are input into a pre-trained convolutional neural network classifier, which outputs defect type labels such as scratches, stains, or damage.
[0049] The density-based clustering algorithm uses the DBSCAN method, which automatically determines the number of clusters based on the density distribution of node features. Parameters such as the neighborhood radius and minimum number of points are adjusted according to the dataset. After clustering, each cluster represents a defect instance, and the minimum bounding rectangle of the nodes within the cluster is calculated as the bounding box. During image patch extraction, the bounding box is expanded by 10% of the edge region to capture the complete defect context. The pre-trained convolutional neural network adopts the ResNet architecture, with the input image patch scaled to 224x224 pixels. The defect type probability is output through a fully connected layer and normalized using the softmax function. The DBSCAN method of the density-based clustering algorithm requires setting two key parameters: the neighborhood radius ε and the minimum number of points minPts. The neighborhood radius ε controls the neighborhood range, and an initial value is determined by calculating the average distance between all node features, then fine-tuned based on the clustering effect. The minimum number of points minPts determines the minimum number of neighbors required to form the core object, and is generally set to 5% of the total number of nodes. The DBSCAN algorithm executes by randomly selecting unvisited nodes, finding all their neighboring nodes, and creating a new cluster if the number of neighbors reaches minPts, then recursively expanding the cluster members. Boundary points are assigned to adjacent core object clusters. Noise points are marked as -1, indicating they do not belong to any cluster. After clustering, each cluster corresponds to a defect instance, and the candidate regions represented by nodes within the cluster are merged into a complete defect region.
[0050] The minimum bounding rectangle is calculated using a rotating caliper algorithm, traversing the boundary points of all nodes within the cluster to find the smallest rectangle that can contain all points. The rectangle is defined by its center point coordinates, width, height, and rotation angle. The bounding box expansion operation extends the rectangle's four sides outwards by 10% of its original size, ensuring complete coverage of the defect area. During image patch extraction, the corresponding region is cropped from the original image based on the expanded rectangle coordinates; if the rectangle exceeds the image boundary, boundary padding is performed. The cropped image patches are uniformly scaled to 224x224 pixels using bilinear interpolation and then normalized, with pixel values scaled to the range [0,1].
[0051] The pre-trained convolutional neural network uses the ResNet-50 architecture and is pre-trained on the ImageNet dataset. Finally, the fully connected layers are replaced with three output nodes corresponding to the three defect types. The network input is a 224x224x3 image patch, which extracts features through convolutional layers, batch normalization layers, and ReLU activation functions. Finally, it outputs classification logits through global average pooling layers and fully connected layers. The softmax function transforms the logits into a probability distribution, as shown in the formula: ; in: This represents the probability that image patch x belongs to category c. It is the logits value of category c. It is the logits value of category j, and the denominator is... It is the exponential summation of the logits of all categories. The category with the highest probability is used as the final defect type label.
[0052] In its implementation, the DBSCAN clustering algorithm employs a grid search method for parameter tuning, evaluating the clustering quality of different parameter combinations on a validation set. Clustering quality is assessed using the silhouette coefficient metric, which measures intra-cluster compactness and inter-cluster separation. The calculation of the minimum bounding rectangle is optimized to an incremental update approach; when adding new nodes, the rectangle is simply expanded from the existing one, avoiding redundant calculations. A high-quality resampling algorithm is used for image patch extraction to preserve defect details. Fine-tuning of the ResNet-50 network employs a hierarchical learning rate strategy: lower learning rates are used in the lower convolutional layers to maintain general features, while higher learning rates are used in the upper fully connected layers to quickly adapt to new tasks. The specific implementation steps of the DBSCAN clustering algorithm include: constructing a distance matrix for node features and using a KD-tree to accelerate nearest neighbor search. For each node, all neighboring nodes within its neighborhood are queried, and core and boundary objects are labeled. Clusters are formed by connecting nodes with reachable density through a depth-first search. Post-processing of the clustering results includes merging excessively close small clusters and filtering out excessively small noisy clusters. The minimum bounding rectangle is calculated using the convex hull algorithm to first find the convex hull of the point set, and then the minimum area bounding rectangle is found using the rotating caliper method. When extracting image patches, the rectangle rotation angle is considered; coordinate rotation correction is performed before cropping to ensure the correct orientation of the image patches. The ResNet-50 network is trained using the cross-entropy loss function, and the optimizer uses stochastic gradient descent with momentum. The momentum parameter is set to 0.9, the initial learning rate is set to 0.001, and it decays every 10 epochs.
[0053] In some embodiments, the density clustering algorithm can employ the OPTICS method to automatically determine a multi-density hierarchical clustering structure, adapting to unevenly distributed node features. Shape constraints can be incorporated into the minimum bounding rectangle calculation to ensure the rectangle's aspect ratio conforms to common defect proportions. Image patch extraction can utilize a multi-scale cropping strategy, extracting image patches at different magnifications for fusion classification. The convolutional neural network can employ the EfficientNet architecture, balancing depth, width, and resolution through composite scaling to improve classification efficiency. The network input can have increased channel counts, combining the original image and heatmap as input to provide more discriminative information. The classification head can be designed as a multi-task learning structure, simultaneously predicting defect type and severity. Constraint information can be introduced into the clustering process, utilizing partially labeled nodes to guide the clustering process and improve clustering accuracy. Bounding box generation can employ the minimum bounding rectangle of the instance segmentation mask to provide more accurate defect localization. Image patch enhancement can apply methods such as random rotation and color dithering to improve the model's generalization ability.
[0054] Optionally, defect instance merging can be based on semantic similarity, merging adjacent instances of the same type into a single entity. The classification network can integrate predictions from multiple models, improving classification robustness through voting or averaging. Post-processing can add rule filters to validate classification results based on features such as defect size and shape. In essence, density clustering algorithms automatically group defect instances based on feature similarity, without requiring a pre-defined cluster size, adapting to varying numbers of defect instances. The minimum bounding rectangle provides accurate defect localization, and bounding box expansion avoids loss of edge information during clipping. Pre-trained convolutional neural networks leverage transfer learning to quickly adapt to new tasks, and the softmax function outputs an interpretable probability distribution. The entire process achieves end-to-end processing from region clustering to type recognition.
[0055] See Figure 5 This figure shows the training and validation set accuracy of the leather surface defect recognition model across four categories: scratches, stains, damage, and no defects. As can be seen from the figure, for the scratch category, the training set accuracy is 88%, and the validation set accuracy is 82%; for the stain category, the training set accuracy is 92%, and the validation set accuracy is 89%; for the damage category, the training set accuracy is 85%, and the validation set accuracy is 80%; and for the no-defect category, the training set accuracy is 99%, and the validation set accuracy is 98%. Overall, the no-defect category has the highest recognition accuracy, and the model's generalization ability in this category is also good, with a small difference between the training and validation set accuracies. The validation set accuracy for the damage category is relatively low, which may indicate overfitting or difficulty in extracting features for this category. These data reflect the model's classification performance under different leather surface defect types and no-defect conditions, providing a basis for further model optimization. For example, data augmentation or improvements to the feature extraction network could be made for the damage category to improve its recognition accuracy and generalization ability.
[0056] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0057] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for identifying leather surface defects using image processing, characterized in that, The method includes the following steps: Images of the leather surface were acquired and preprocessed using illumination normalization and noise filtering to generate enhanced image data; The enhanced image data is input into a multi-scale feature extraction network, which uses a combination of convolutional and pooling layers to extract feature maps at different scales and fuses contextual information to generate a global feature representation. Based on global feature representation, an attention-driven mechanism is used to focus on potential defect regions, calculate the defect saliency score for each pixel, and generate a defect heatmap. Based on the defect heatmap, the image is divided into multiple candidate regions, and the defect probability distribution of each candidate region is calculated. Based on the defect probability distribution, a region association graph is constructed, where nodes represent candidate regions and edges represent feature similarity between regions. A graph attention network is used to update node embeddings. Defect regions are clustered using a region association graph to form defect instance segmentation results, and a classification network is used to identify the type of each defect instance. Based on the defect type and spatial distribution, the defect boundary is optimized and the final identification result is output.
2. The image processing method for identifying leather surface defects according to claim 1, characterized in that, The acquired leather surface image is preprocessed through illumination normalization and noise filtering to generate enhanced image data, including: Images of the leather surface are captured using a high-resolution camera, and a white balance algorithm is applied to correct for uneven lighting, generating images with consistent colors. A Gaussian filter is applied to an image with uniform color to remove high-frequency noise while preserving edge information, resulting in a denoised image. Histogram equalization is used to enhance the contrast of the denoised image, highlighting the difference between defects and the background, and generating enhanced image data.
3. The image processing method for identifying leather surface defects according to claim 1, characterized in that, The process involves inputting the enhanced image data into a multi-scale feature extraction network, extracting feature maps at different scales using a combination of convolutional and pooling layers, and fusing contextual information to generate a global feature representation, including: Construct a network with an encoder-decoder structure. The encoder part uses convolutional layers to downsample and extract local features, while the decoder part uses deconvolutional layers to upsample and restore spatial resolution. Spatial pyramid pooling is applied to multi-scale feature maps to capture feature information from different receptive fields, and multi-scale features are spliced together to generate rich feature representations. By fusing temporal context information through gated recurrent units, dynamic changes in video sequence images are modeled, enhancing the robustness of global feature representation.
4. The image processing method for identifying leather surface defects according to claim 1, characterized in that, The process, based on global feature representation, employs an attention-driven mechanism to focus on potential defect regions, calculates the defect saliency score for each pixel, and generates a defect heatmap, including: The importance weight of each position in the feature map is calculated using a self-attention mechanism, and an attention feature map is generated based on the weighted features. The attention feature map is then multiplied point by point with the original feature map to highlight defect-related features and suppress background interference. The attention weights are normalized using the softmax function to generate a defect saliency score for each pixel, which is then interpolated to the original image size to generate a defect heatmap.
5. The image processing method for identifying leather surface defects according to claim 1, characterized in that, The step of dividing the image into multiple candidate regions based on the defect heatmap and calculating the defect probability distribution for each candidate region includes: The optimal segmentation threshold for the defect heatmap is calculated using the maximum inter-class variance method, and an adaptive threshold map is generated by adjusting the threshold based on the local gradient. Connectivity analysis is performed based on adaptive threshold maps, each connected region is labeled as a candidate region, and region shape features are extracted. The support vector machine classifier is used to calculate the defect probability distribution of each candidate region based on shape features, including the probabilities of normal, minor defects, and severe defects.
6. The image processing method for identifying leather surface defects according to claim 1, characterized in that, The method involves constructing a region association graph based on the defect probability distribution, where nodes represent candidate regions and edges represent the feature similarity between regions. A graph attention network is then used for node embedding updates, including: Each candidate region is represented as a node, and the node features include region area, perimeter, and defect probability. Calculate the Euclidean distance between nodes as feature similarity, and construct an adjacency matrix to define edge weights; The graph attention network layer is used to aggregate neighbor node information, update node embeddings, and output updated node features through a multilayer perceptron. The Euclidean distance between the computed nodes is used as the feature similarity to construct an adjacency matrix that defines edge weights, including: Normalize the node feature vectors to a unit length and calculate the Euclidean distance between each pair of node feature vectors; The distance is converted into a similarity score using a Gaussian kernel function; the higher the score, the greater the similarity. Set a similarity score threshold and retain only edges with scores higher than the threshold to construct a sparse adjacency matrix.
7. The image processing method for identifying leather surface defects according to claim 1, characterized in that, The process of clustering defect regions using a region association graph to form defect instance segmentation results, and then using a classification network to identify the type of each defect instance, includes: Density clustering algorithm is used to cluster the updated node features, and similar nodes are grouped into defect instances; For each defect instance, generate the minimum bounding rectangle as the bounding box and extract the image patch within the box; Image patches are input into a pre-trained convolutional neural network classifier, which outputs defect type labels such as scratches, blemishes, or damage.
8. The image processing method for identifying leather surface defects according to claim 2, characterized in that, The process of acquiring images of the leather surface using a high-resolution camera and applying a white balance algorithm to correct for uneven lighting and generate an image with consistent color includes: Set camera parameters, including exposure time and gain value, to ensure uniform image brightness; White balance correction is performed using the gray world assumption, and the RGB channel gain is adjusted to make the image color temperature consistent. The image is converted to a standard color space using a color correction matrix, resulting in an image with consistent colors.
9. The image processing method for identifying leather surface defects according to claim 5, characterized in that, The step of calculating the optimal segmentation threshold of the defect heatmap using the maximum inter-class variance method and generating an adaptive threshold map by adjusting the threshold based on the local gradient includes: Calculate the grayscale histogram of the defect heatmap, iterate through each possible threshold to calculate the inter-class variance, and select the threshold corresponding to the largest variance as the initial threshold. Calculate the local gradient map of the heatmap, and dynamically adjust the threshold according to the gradient magnitude. Use a lower threshold in high gradient areas to preserve details. The adjusted threshold is applied for binarization segmentation to generate an adaptive threshold map.
10. A leather surface defect identification system for image processing, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the image processing leather surface defect identification method according to any one of claims 1 to 9.
Citation Information
Cited By
Bearing surface defect classification method and system based on artificial intelligence
CN121564445A
Power distribution network tower defect automatic identification and classification method and system based on deep learning
CN121564557A
Digital ray image splicing and identification method and system based on high-contrast characteristic
CN122066577A
Wear-resistant pipe surface wear detection method and system based on image processing
CN122115436A