CN-122023372-A - Shaving board image enhancement method for complex illumination condition
Abstract
The invention discloses a shaving board image enhancement method for complex illumination conditions, which comprises the steps of collecting and constructing a shaving board image data set containing a plurality of illumination conditions, constructing a DA-GAN model, training the DA-GAN model, obtaining a trained DA-GAN model by jointly optimizing model parameters through total discrimination scores output by a global and local double-branch discriminator and constraint losses output by a multi-scale feature constraint module, inputting shaving board images with low illumination or uneven illumination to be enhanced into the trained DA-GAN model, and outputting the enhanced shaving board images by a defect perception generator. The invention can realize the cooperative optimization of global brightness improvement and defect feature fidelity, and provides high-quality image input for the defect detection of the follow-up shaving board so as to solve the technical defects existing at present.
Inventors
- LIU YING
- HUANG ZHIXIN
- ZHOU HAIYAN
- XIA HAIFEI
- CHEN JIANSHENG
- YANG YUTU
- Fan Chenlong
- XI SHUANG
Assignees
- 南京林业大学
Dates
- Publication Date
- 20260512
- Application Date
- 20260210
Claims (10)
- 1. A shaving board image enhancement method facing complex illumination conditions is characterized by comprising the following steps: Step 1, collecting and constructing a shaving board image data set containing various illumination conditions, wherein the data set at least contains images under three illumination conditions of low illumination, uneven illumination and normal illumination, and the data set is divided into a training set and a verification set; Step 2, constructing a defect perception type image enhancement network model, namely a DA-GAN model, wherein the DA-GAN model at least comprises: The defect perception generator based on the U-Net comprises an encoding path and a decoding path, wherein the encoding path comprises N downsampling levels which are sequentially connected, and the decoding path comprises N upsampling levels which are sequentially connected; global and local dual-branch discriminators for cooperative work to produce a total discrimination score that comprehensively evaluates the global illumination attribute and the local feature fidelity of the enhanced image; The multi-scale feature constraint module is used for calculating constraint losses comprising defect feature retention losses and low-frequency consistency losses in the training process; Training the DA-GAN model by utilizing the training set in the step 1, and jointly optimizing model parameters by the total discrimination score output by the global and local double-branch discriminators and the constraint loss output by the multi-scale feature constraint module to obtain a trained DA-GAN model; And 4, inputting the shaving board image with low or uneven illuminance to be enhanced into a trained DA-GAN model, and outputting the enhanced shaving board image by a defect perception generator.
- 2. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 1, wherein the step 1 specifically comprises: step 1.1, collecting an original image of a high-resolution shaving board containing three defect types of oil spots, dust spots and large shavings; step 1.2, cutting and screening the original image of the high-resolution shaving board to obtain an image sample with uniform size; Step 1.3, classifying the obtained image samples according to illumination conditions, and dividing the image samples into a training set and a verification set; The illumination conditions comprise three illumination conditions of low illumination, uneven illumination and normal illumination, and each illumination condition comprises three defect types of oil spots, dust spots and large shavings.
- 3. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 1, wherein in the defect perception generator, the defect priori module sequentially comprises a local feature difference calculation layer, a global linear normalization layer, a Sigmoid activation function layer and a mean value pooling layer; The defect prior module is configured to receive a feature map output by a certain downsampling level of an encoding path, obtain a defect score map by calculating local feature differences of the feature map, and output a defect soft mask with the same resolution as the feature map after normalization, nonlinear mapping and mean pooling operations; The defect soft mask is transferred to the corresponding up-sampling level of the decoding path by a jump connection and performs a pixel-by-pixel multiplication operation with the feature map from the encoding path to achieve differential feature enhancement.
- 4. The method for enhancing particle board image under complex illumination according to claim 3, wherein the local feature difference calculation layer is processed by calculating the feature value L1 distance average value of all pixels in 3×3 neighborhood of each pixel on the feature map to generate a defect fraction map ; The specific calculation formula is as follows: ; Wherein, the Representing a characteristic diagram Upper coordinates are Is a feature value corresponding to the target pixel of (c), Representing a characteristic diagram Upper coordinates are 3X3 neighborhood of target pixel of (2) Any one pixel in Corresponding characteristic values; For defect score map Upper coordinates are A defect score value corresponding to the target pixel of (c), Representing the total number of pixels in the neighborhood, =9; Receiving a defect score map G, performing global scale linear transformation on all defect score values in the defect score map G, and mapping the defect score values to a [0, 1] interval to obtain a normalized score map H; the specific calculation formula is as follows: ; Wherein, the Representing the coordinates on the normalized score plot H as A normalized score value corresponding to the target pixel of (c), Representing the minimum of all defect score values in the defect score map G, Representing the maximum value of all defect score values in the defect score map G; receiving a normalized score map H, and carrying out nonlinear mapping on normalized score values corresponding to each pixel in the normalized score map H through a Sigmoid function to obtain a preliminary soft mask I; The calculation formula of the nonlinear mapping is as follows: ; Wherein, the The value range is (0, 1), the pixel with the value approaching 1 corresponds to the defect area, and the pixel with the value approaching 0 corresponds to the background area; the process of the averaging layer is that a preliminary soft mask I is received, and the preliminary soft mask I is subjected to averaging operation to obtain a final defect soft mask J with smooth edge transition; the calculation formula of the mean value pooling operation is as follows: ; Wherein, the Soft mask J for final defect , Pixels in 3 x 3 neighborhood Aggregate as The total number of pixels in the neighborhood is k=9.
- 5. The method for enhancing a particle board image for a complex lighting condition according to claim 4, wherein said final defect soft mask Corresponding up-sampling levels passed to decoding paths through a jump connection of U-Net as spatial weight matrix with the decoding paths and with The output feature images of the corresponding downsampling levels with the same spatial resolution execute pixel-by-pixel Hadamard product operation, wherein the Hadamard product operation formula is as follows: ; Is a characteristic diagram obtained after operation Upper part , Is from the coding path and is connected with Output feature map of corresponding downsampling hierarchy with same spatial resolution Upper part , Is a pixel-by-pixel Hadamard product operation.
- 6. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 1, wherein the global and local double-branch discriminator comprises: The global discriminator branch comprises at least one global feature extraction layer adopting cavity convolution and is used for extracting global features of an input image and outputting global discrimination scores; A local discriminator branch for receiving a plurality of local image blocks randomly cut from an input image, extracting fine-grained features and outputting local discrimination scores; and the global discrimination score and the local discrimination score are subjected to weighted fusion to obtain the total discrimination score of the global and local double-branch discriminators, and the total discrimination score is used for guiding the countermeasure training of the DA-GAN model.
- 7. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 6, The global arbiter branch sequentially comprises 4 global feature extraction layers and 1 global output layer, wherein the global feature extraction layers adopt a serial structure of a cavity convolution layer with a convolution kernel size of 3 multiplied by 3, a spectrum normalization layer and LeakyReLU activation function layers, the cavity convolution layers of the global feature extraction layers adopt incremental cavity rate, and spectrum normalization processing is applied after each cavity convolution operation so as to restrict the spectrum norm of the weight matrix; the processing procedure of the hole convolution operation of the hole convolution layer calculates a feature map according to the following formula: ; wherein, the feature diagram of the branch input of the global arbiter is The feature map of the cavity convolution output is , For the output characteristic diagram , For input feature maps ; Is a convolution kernel The cavity rate of the cavity convolution layer is r, For the sampling interval of the hole convolution in the horizontal direction, Sampling intervals in the vertical direction are convolved for the holes; the processing procedure of the spectrum normalization layer updates the convolution kernel weight according to the following formula: ; Wherein, the For the weight matrix after the normalization of the spectrum, Is a spectral norm; an original weight matrix of a hollow convolution layer in a global discriminator branch; The LeakyReLU activation function layer slope of the global arbiter branch is set to 0.2; The global output layer comprises a cavity convolution layer with the convolution kernel size of 1 multiplied by 1, a spectrum normalization layer and LeakyReLU activation function layers and is used for outputting global discrimination scores; the local discriminator branch sequentially comprises 4 local feature extraction layers and 1 local output layer, wherein the local feature extraction layers adopt a series structure of a convolution layer with a convolution kernel size of 3 multiplied by 3 and LeakyReLU activation function layers; The local discriminator branch is used for extracting fine granularity characteristics and outputting local discrimination scores, wherein the input of the local discriminator branch is 5 local blocks with 128 multiplied by 128 size which are randomly cut out from the enhanced shaving board image and the corresponding shaving board image with real normal illumination output by the defect perception generator; the slope of LeakyReLU activation function layer of the local arbiter branch is set to 0.2; The local output layer comprises a convolution layer with the convolution kernel size of 1 multiplied by 1 and a LeakyReLU activation function layer, and outputs local discrimination scores after the local output layer is processed by the convolution layer with the convolution kernel size of 1 multiplied by 1 and the LeakyReLU activation function.
- 8. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 1, wherein, The defect feature retention loss is formed by weighted summation of gradient loss and local variance loss and is used for restraining the enhancement image to retain defect edge sharpness and texture fluctuation features of the original input image; The low-frequency consistency loss is obtained by calculating the weighted difference between the low-frequency components of the enhanced image and the corresponding real normal illumination image after low-pass filtering, and is used for inhibiting global artifacts and brightness fluctuation generated in the enhancement process; The constraint loss is obtained by weighted summation of defect feature preserving loss and low frequency consistency loss.
- 9. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 8, The calculation formula of the gradient loss is as follows: ; Wherein, the For the total number of pixels of the image, For the gradient of the image in the horizontal direction, For the gradient of the image in the vertical direction, For defect-aware generator to input images An enhanced image generated for the input; For the pixel value corresponding to the i-th pixel in the enhanced image G (a) output by the defect-aware generator, A pixel value corresponding to an ith pixel in the image A representing the original input with low illuminance or uneven illuminance; the calculation formula of the local variance loss is as follows: ; Wherein, the Is the local variance of the whole image; For the local variance feature map of the entire enhanced image G (a), A local variance feature map of the whole original input image A; The calculation formula of the low-frequency consistency loss is as follows: ; Wherein, the For the pixel level weight corresponding to the i-th pixel acquired in accordance with the buffered defect soft mask J, To generate enhanced images Is used for the low frequency component of (c), Is a true normal illumination image Is included in the low frequency component of (a).
- 10. The method for enhancing the image of the particle board facing the complex illumination condition according to claim 1, wherein the step 3 specifically comprises: Step 3.1, taking the training set in the step 1 as the input of the DA-GAN model, setting the iteration number to be 200, inputting the sample number to be 2 in one iteration, selecting Adam by an optimizer, and setting the learning rate to be 1 multiplied by 10- 4 ; step 3.2, the input image is subjected to convolution and pooling operation of the encoded path through a defect perception generator of the DA-GAN model to extract multi-scale features, and differential enhancement is completed by combining a soft mask generated by a defect priori module, so that a preliminary enhanced image is output; step 3.3, the enhanced image output by the defect perception generator and the corresponding real normal illumination shaving board image are input into the global and local double-branch discriminators together, and the total discrimination score is output; And 3.4, calculating the countermeasures based on the total discrimination score, and simultaneously updating network parameters of the defect perception generator and the global and local double-branch discriminators by combining the constraint losses output by the multi-scale feature constraint module.
Description
Shaving board image enhancement method for complex illumination condition Technical Field The invention relates to the technical field of machine vision and image processing, in particular to a shaving board image enhancement method facing complex illumination conditions. Background The shaving board is used as a core base material in the fields of wooden furniture, indoor decoration, packaging building materials and the like, and the surface quality of the shaving board directly determines the product grade and the market value. Industry data shows that the shaving board with the defects of oil spots, dust spots, large shavings and the like on the surface can reduce the selling price of finished products by more than 30 percent, and the whole batch of products can be scrapped when serious. With the continuous improvement of the requirements of furniture manufacturing on material quality, the surface quality detection of the shaving board has become a key link of the high-quality development of industry. The traditional manual visual detection mode has low efficiency, is greatly influenced by subjective experience of detection personnel, is difficult to meet the high-speed detection requirement of a modern production line, and an automatic detection technology based on machine vision has become a main solution for quality control of the particle board industry. However, the problems of uneven illumination, backlight shooting, light source aging and the like commonly existing in a production workshop lead to the acquired shaving board images weakening the characteristic difference between defects and normal areas, so that the defects with fine original characteristics are more easily mixed up, and the accuracy of subsequent defect detection is seriously affected. In the existing image enhancement method, the traditional method is limited by a technical principle, and has the defects of excessive enhancement, loss of details of dark areas, weak noise suppression capability and the like. Although the deep learning-based method achieves a certain effect in the general image enhancement task, the adaptation degree in the industrial defect detection scene is low, and the dual requirements of global brightness improvement and defect feature fidelity cannot be met at the same time. Therefore, developing a complex illumination condition (such as low illumination and uneven illumination) image enhancement technology which adapts to the defect characteristics of the shaving board, solves the problem of image quality reduction caused by illumination of a production line, and has important significance for improving the quality control level of the shaving board industry. Disclosure of Invention The invention aims to solve the technical problem of providing the shaving board image enhancement method facing the complex illumination condition aiming at the defects of the prior art, and the shaving board image enhancement method facing the complex illumination condition can realize the cooperative optimization of global brightness improvement and defect feature fidelity, and provide high-quality image input for the follow-up shaving board defect detection so as to solve the technical defects existing at present. In order to achieve the technical purpose, the invention adopts the following technical scheme: a shaving board image enhancement method facing complex illumination conditions comprises the following steps: Step 1, collecting and constructing a shaving board image data set containing various illumination conditions, wherein the data set at least contains images under three illumination conditions of low illumination, uneven illumination and normal illumination, and the data set is divided into a training set and a verification set; Step 2, constructing a defect perception type image enhancement network model, namely a DA-GAN model, wherein the DA-GAN model at least comprises: The defect perception generator based on the U-Net comprises an encoding path and a decoding path, wherein the encoding path comprises N downsampling levels which are sequentially connected, and the decoding path comprises N upsampling levels which are sequentially connected; The encoding path (encoder) has 5 downsampling levels, and the number of channels convolved per layer after the 3-channel image is input is 64, 128, 256, 512 and 1024. The decoding path takes as input 1024 channel images output by the encoding path (decoder) in total of 5 up-sampling levels, and the number of channels convolved in each layer is 512, 256, 128, 64 and 3. The system comprises a global and local dual-branch discriminator, a local discriminator branch, a total discrimination score, a local characteristic spectrum analyzer and a local spectrum analyzer, wherein the global and local dual-branch discriminator is used for introducing cavity convolution and spectrum normalization into the global discriminator branch and adding the local discriminator branch; The mu