A wood block color detection method based on machine vision
Through the nonlinear illumination correction and hierarchical support vector machine model combined with multi-scale feature fusion, the accuracy problem of wood block color detection under ambient light changes is solved, and efficient multi-category color detection is achieved.
Patent Information
- Application Number
- CN202411894377.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-12-20
AI Technical Summary
The existing wood block color detection methods are not accurate enough under ambient light changes, the multi-spectral data processing efficiency is low, and it is difficult to adapt to complex multi-category color detection tasks.
The nonlinear illumination correction model is used to correct image data, combine multi-band image data to extract features and reduce dimensionality, and build a hierarchical support vector machine model for color classification, and fuse spectrum and texture features for multi-scale feature fusion.
The classification accuracy and robustness of wood block color detection are improved, the calculation complexity is reduced, and the model's adaptability and efficiency to complex multi-category color detection is enhanced.
Smart Images

Figure CN119762602B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-classification detection, in particular to a wood block color detection method based on machine vision. Background Art
[0002] With the rapid development of machine vision technology, its application in industrial production is becoming increasingly widespread, especially in the field of wood processing. Automatic detection technology based on visual systems has gradually replaced traditional manual detection methods. For the detection of wood block color, accurately identifying the color information of the wood surface is an important basis for judging its quality, classification and subsequent processing; At present, traditional color detection methods are mostly based on single-spectral images, and classification is performed by extracting the color features of the image; However, due to the complex texture of the wood surface and its susceptibility to changes in ambient light, these methods have great limitations in detection accuracy and robustness; In addition, in recent years, the introduction of multispectral imaging technology has provided a new technical means for wood color detection. By acquiring image data of multiple spectral bands, the color characteristics of the wood surface can be more comprehensively reflected; However, how to effectively process multi-band data, eliminate light interference and optimize classification performance is still a difficulty in existing technologies;
[0003] Current wood block color detection methods have many major shortcomings. First, the dynamic changes in ambient light have a significant impact on the detection results. Traditional linear illumination correction cannot fully eliminate illumination interference, resulting in inaccurate color classification. Second, when utilizing multispectral data, existing methods are mostly limited to the direct use of high-dimensional features and do not fully perform dimensionality reduction optimization, which easily leads to high computational complexity and low classification efficiency. Finally, color classification models are mostly single-layer structures, which are difficult to adapt to complex multi-category color detection tasks. Summary of the Invention
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, the present invention provides a wood block color detection method based on machine vision to solve the problem of low efficiency in high-dimensional feature processing.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a method for detecting wood block color based on machine vision, which includes collecting image data and performing preprocessing; constructing a nonlinear illumination correction model based on the preprocessed image data to correct the preprocessed image data and output a multi-band image data sequence; extracting features from the multi-band image data sequence and performing dimensionality reduction to generate a spectral feature set; constructing a hierarchical support vector machine model for wood block color detection based on the spectral feature set, and outputting a wood block color classification detection result.
[0008] As a preferred solution of the wood block color detection method based on machine vision described in the present invention, the image data includes a wood block surface image, ambient light intensity, light source direction, color temperature and multispectral image.
[0009] As a preferred solution of the wood block color detection method based on machine vision described in the present invention, the preprocessing includes removing noise, completing image alignment and illumination normalization.
[0010] As a preferred solution of the wood block color detection method based on machine vision of the present invention, the specific steps of constructing a nonlinear illumination correction model are as follows:
[0011] Define the input as preprocessed image data and the output as corrected image data;
[0012] According to the light source direction in the image data, the influence of the light source direction on the reflected light intensity of each pixel on the surface of the wood block is calculated to generate image data after light source direction compensation. The expression is:
[0013] ;
[0014] in, is the image data after light source direction compensation, is the light source direction compensation function, It is the adjustment of the image data by the light source direction. is the preprocessed image data, is the horizontal coordinate of the pixel in the image, is the vertical coordinate of the pixel in the image, is the identifier of the spectral band, It is the angle between the light source direction and the surface normal of the object;
[0015] The image data after light source direction compensation is combined with the ambient light intensity and the average ambient light intensity to dynamically adjust the effect of ambient light intensity on the pixel brightness in the image data to obtain the corrected image data. The expression is:
[0016] ;
[0017] in, is the corrected image data, is the ambient light compensation weight parameter, is the average ambient light intensity, is the current spectral band The ambient light intensity under is a small positive number;
[0018] generating an image data sequence according to the corrected image data;
[0019] Traverse all bands in the image data sequence to generate a multi-band image data sequence.
[0020] As a preferred solution of the wood block color detection method based on machine vision of the present invention, wherein: the feature extraction from the multi-band image data sequence and dimension reduction are performed to generate a spectral feature set, the specific steps are as follows:
[0021] Using the corrected multi-band image data sequence, the grayscale value of each pixel in all bands is extracted pixel by pixel and recorded as spectral features;
[0022] Aggregate spectral features through spatial dimensions to form high-dimensional spectral features;
[0023] Extracting texture features of the wood block surface from the rectified multi-band image data sequence;
[0024] For the extracted high-dimensional spectral features, a dimensionality reduction algorithm is used to optimize the high-dimensional spectral features to generate spectral features after dimensionality reduction;
[0025] The spectral features and texture features after dimension reduction are fused to generate a spectral feature set, which is used as the input of the hierarchical support vector machine model for wood block color detection.
[0026] As a preferred solution of the wood block color detection method based on machine vision of the present invention, wherein: the construction of the wood block color detection hierarchical support vector machine model comprises the following steps:
[0027] Define the input as a set of spectral features and the output as the color classification detection result of the wood block;
[0028] The spectral feature set is divided into a training set and a test set as a data set;
[0029] The spectral feature set is normalized and integrated with a multi-scale feature fusion mechanism to generate a joint feature set;
[0030] Define the input of the first-layer wood block color detection hierarchical support vector machine model as a set of spectral features, and classify the wood block colors into three categories: light, dark, and neutral colors;
[0031] Use the multi-classification support vector machine model to achieve the classification task of three color categories;
[0032] Calculate the classification optimization amount for each category and dynamically adjust the classification boundary. The expression is:
[0033] ;
[0034] in, is the dynamic adjustment of the classification boundary, is the class interval mean, is the standard deviation of the classifier output, is the classification uncertainty ratio, is the local information density of the sample;
[0035] Outputs the primary color category of each image pixel;
[0036] Define the second layer of wood block color detection hierarchical support vector machine model input as the primary color category of the first layer;
[0037] For each color category, an independent support vector machine classifier is constructed to obtain the color category label;
[0038] Use the training set to label the color data and adjust the hyperparameters;
[0039] Validate the hierarchical support vector machine model for wood block color detection on the test set;
[0040] Output the color category of each image pixel as the wood block color classification detection result.
[0041] As a preferred solution of the wood block color detection method based on machine vision of the present invention, wherein: the multi-scale feature fusion mechanism is integrated to generate a joint feature set, and the specific steps are as follows:
[0042] The weight of each feature channel is dynamically generated through global average pooling and a two-layer fully connected network;
[0043] Perform weighted fusion of local texture features and global texture features in the texture features of the wood block surface to generate multi-scale texture features;
[0044] The spectral features and multi-scale texture features are combined according to the feature channel dimension to generate a joint feature set.
[0045] As a preferred solution of the wood block color detection method based on machine vision of the present invention, wherein: the construction of an independent support vector machine classifier comprises the following specific steps:
[0046] The primary classification results of the first-layer wood block color detection hierarchical support vector machine model are used as input;
[0047] According to the primary classification results, the spectral feature set is grouped by color category, and the feature data of light color, dark color and neutral color are extracted respectively to form sub-features for each category;
[0048] Use the light color category features as input data to train a support vector machine classifier, subdivide the white and light yellow in the light color category, and output the color category label;
[0049] Using dark category features as input data, train a support vector machine classifier to segment dark brown and black in the dark category and output color category labels;
[0050] Using the neutral color category features as input data, a support vector machine classifier is trained to subdivide the red, orange, and brown in the neutral color category and output the color category label;
[0051] According to the specific color category label of each image pixel output by the independent support vector machine classifier, the classification results of the color category labels are summarized to determine the color classification detection result of the wood block.
[0052] In a second aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, any step of the method for detecting the color of a wooden block based on machine vision as described in the first aspect of the present invention is implemented.
[0053] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, any step of the method for detecting wood block color based on machine vision as described in the first aspect of the present invention is implemented.
[0054] The beneficial effects of the present invention are as follows: the present invention effectively solves the difficult problem of complex multi-category color detection tasks by constructing a hierarchical support vector machine model for wood block color detection; the first-layer model divides colors into three categories: light, neutral and dark, reducing the complexity of multi-classification tasks; the second-layer model further refines specific color categories for each major category, and improves the pertinence and accuracy of classification through independent classifiers; at the same time, combined with the dynamic classification boundary adjustment mechanism, the category interval is optimized, and the model's adaptability to uneven category distribution is enhanced; in addition, the model incorporates a multi-scale feature fusion mechanism, effectively combining spectral features with texture features, making the classification results more comprehensive and accurate, and significantly improving the classification accuracy, robustness and efficiency of wood block color detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0056] Figure 1 Flowchart of the wood block color detection method based on machine vision in Example 1.
[0057] Figure 2 This is a schematic diagram of generating a joint feature set in Example 1. DETAILED DESCRIPTION
[0058] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0059] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0060] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0061] Example 1, reference Figure 1 and Figure 2 , which is the first embodiment of the present invention, provides a method for detecting the color of a wood block based on machine vision, comprising the following steps:
[0062] S1. Collect image data and perform preprocessing.
[0063] Furthermore, the image data includes the surface image of the wood block, ambient light intensity, light source direction, color temperature, and multispectral image;
[0064] Specifically, a multispectral camera or RGB camera is installed at a designated location on the assembly line to ensure that the camera's field of view covers the entire moving area of the wood block and to collect images of the wood block's surface in real time;
[0065] Configure a light sensor to record lighting parameters such as ambient light intensity, light source direction, and color temperature, and trigger it synchronously with the camera;
[0066] Trigger the camera to collect image sequences or RGB images of the wood block surface in various bands, and record the light intensity, light source direction, and color temperature;
[0067] The light source adopts a strictly designed diffuse reflection structure to ensure uniform light distribution and minimize the interference of highlights and shadows.
[0068] S1.1. Preprocessing, including noise removal, image alignment and illumination normalization;
[0069] Specifically, Gaussian filtering or median filtering is applied to the image data to remove random noise, enhance image clarity, and preserve edge details;
[0070] The multi-band image uses a feature point detection algorithm (such as SIFT algorithm) to extract key points, and all band images are aligned with the reference band to ensure that the image pixels are completely matched;
[0071] Based on the light intensity data recorded by the light sensor, a normalization method is used to balance the light intensity of different bands to eliminate the impact of light changes on the image;
[0072] It should be noted that by collecting multispectral images and lighting parameters (such as ambient light intensity, light source direction, and color temperature), this step achieves comprehensive acquisition of information on the surface of the wood block and the lighting environment; installing a synchronous trigger mechanism for the camera and light sensor ensures the real-time and consistency of data acquisition; using an optimized diffuse reflection light source structure, the interference of highlights and shadows on image quality is significantly reduced; further, Gaussian filtering or median filtering is used to remove image noise and enhance image clarity; a feature point detection algorithm is used to complete the alignment of multi-band images to ensure pixel matching; the light intensity of different bands is balanced in combination with the light intensity normalization method to eliminate the impact of lighting changes on the image; comprehensively, this step significantly improves the quality and consistency of the input data, providing a reliable foundation for subsequent lighting correction and feature extraction.
[0073] S2. Based on the preprocessed image data, a nonlinear illumination correction model is constructed to correct the preprocessed image data and output a multi-band image data sequence.
[0074] Furthermore, the input is defined as the preprocessed image data and the output is defined as the corrected image data;
[0075] According to the light source direction in the image data, the influence of the light source direction on the reflected light intensity of each pixel on the surface of the wood block is calculated to generate image data after light source direction compensation. The expression is:
[0076] ;
[0077] in, It is the image data after light source direction compensation. This is the output result of light source direction compensation, indicating that the intensity value of the current pixel has been adjusted according to the influence of the light source direction. is the light source direction compensation function, It is the adjustment of the image data by the light source direction. It is the preprocessed image data, which means that at the pixel point and band The pixel intensity value under is the horizontal coordinate of the pixel in the image (i.e. column number, from left to right), is the vertical coordinate of the pixel in the image (i.e. the row number, from top to bottom), It is the identifier of the spectral band, corresponding to a specific wavelength range. It is the angle between the light source direction and the surface normal of the object;
[0078] This formula describes the correction process for the effect of light source direction on pixel light intensity. The light source direction compensation function is combined with the preprocessed image data and the angle between the light source direction and the surface normal of the object to calculate the correction value for each pixel in different bands.
[0079] For the image data after light source direction compensation, the ambient light intensity and average ambient light intensity are combined to dynamically adjust the effect of ambient light intensity on the pixel brightness in the image data to obtain the corrected image data. The expression is:
[0080] ;
[0081] in, is the corrected image data, which means at the pixel point and spectral bands The final pixel intensity value after nonlinear illumination correction is It is the ambient light compensation weight parameter, which controls the intensity of ambient light compensation. It is a manually set parameter. A value of 0 will provide a stronger correction for the effects of ambient light. Is the average ambient light intensity, which represents the average value of the ambient light intensity of all spectral bands, and is used to balance the difference in ambient light intensity in different bands. is the current spectral band The ambient light intensity under It is a small positive number used to avoid the denominator from being zero and to provide numerical stability when the ambient light intensity is very low;
[0082] This formula further dynamically adjusts the ambient light intensity of the data after light source direction compensation; by combining the average ambient light intensity and the ambient light intensity of the current band, the correction value of the pixel brightness is calculated to generate the final corrected image data;
[0083] generating an image data sequence according to the corrected image data;
[0084] Traverse all bands in the image data sequence to generate a multi-band image data sequence.
[0085] Check whether the corrected image data is evenly distributed, especially whether the brightness difference between highlight and shadow areas is significantly reduced;
[0086] Compare the spectral characteristic curves before and after correction to verify whether the corrected image data retains the true spectral characteristics;
[0087] According to the verification results, the nonlinear illumination correction model parameters are adjusted to adapt to the lighting conditions in different scenes;
[0088] It should be noted that by constructing a nonlinear illumination correction model, this step realizes dynamic illumination compensation of the preprocessed image data. First, through the light source direction compensation function, the light intensity of the pixel point and the angle between the light source direction and the surface normal of the object are combined to correct the influence of the light source direction on the reflected light intensity of the pixel point, which significantly reduces the problem of uneven illumination caused by changes in the light source direction. Subsequently, the pixel brightness is dynamically adjusted in combination with the ambient light intensity and the average ambient light intensity to balance the illumination differences in different bands, further reducing the interference of ambient light changes on the image, and ensuring numerical stability through small positive parameters. Finally, the generated multi-band image data sequence effectively reduces the brightness difference between highlight and shadow areas while retaining the true spectral characteristics. This step significantly improves the consistency and robustness of the image data, providing high-quality input for subsequent feature extraction and classification.
[0089] S3. Extract features from the multi-band image data sequence and perform dimensionality reduction to generate a spectral feature set.
[0090] Furthermore, using the corrected multi-band image data sequence, the grayscale value of each pixel in all bands is extracted pixel by pixel and recorded as spectral features. These spectral features represent the reflectance characteristics of each pixel in different bands and are the core basis for subsequent color classification and detection.
[0091] If the data source is an RGB image, the red, green, and blue channel values of each pixel are directly extracted as spectral features; if it is multispectral data, the grayscale values of all bands are extracted to form a complete spectral feature vector;
[0092] Summarize spectral features through spatial dimensions (i.e., pixel distribution of the entire image) to form high-dimensional spectral features;
[0093] This high-dimensional spectral feature is a multidimensional data structure that contains the spectral characteristics of all pixels in all bands. Therefore, the data dimension is high and suitable as the input of the subsequent classification model, but it needs to be optimized.
[0094] Extracting wood block surface texture features (such as GLCM or LBP features) from the rectified multi-band image data sequence to enhance classification and detection accuracy;
[0095] Specific extraction methods include:
[0096] Through grayscale symbiosis, the spatial relationship of grayscale values in local areas of the image is analyzed to extract texture features such as contrast, correlation, and energy;
[0097] Through the local binary pattern, the texture pattern of the local area is extracted to capture the detailed features of the wood block surface;
[0098] Through multi-scale analysis, the hierarchical information of the wood block surface details is extracted and the multi-scale texture characteristics are recorded;
[0099] For the extracted high-dimensional spectral features, a dimensionality reduction algorithm is used to optimize the high-dimensional spectral features, retain key feature information, and generate spectral features after dimensionality reduction, reducing data redundancy and improving the efficiency and accuracy of subsequent classification;
[0100] High-dimensional spectral features often contain a lot of redundant information, which increases the processing complexity, so they need to be optimized through dimensionality reduction algorithms;
[0101] Dimensionality reduction algorithms are used to simplify data to ensure that the extracted features are both compact and highly discriminative. Commonly used methods include:
[0102] Extract the main characteristic components through principal component analysis to reduce redundant information;
[0103] Enhance the feature classification ability through linear discriminant analysis and optimize the classification effect;
[0104] The spectral features after dimension reduction and texture features are fused to generate a spectral feature set, which is used as the input of the hierarchical support vector machine model for wood block color detection.
[0105] It should be noted that this step comprehensively reflects the color and texture characteristics of the wood block surface by extracting spectral features and texture features from the corrected multi-band image data; the grayscale values of each band are extracted pixel by pixel to generate high-dimensional spectral features, which completely retains the reflectance characteristics of the wood block in multi-spectral dimensions; at the same time, texture features are extracted through methods such as grayscale symbiosis and local binary patterns to capture local details and multi-scale hierarchical information on the wood block surface; in order to optimize the high-dimensional spectral features, dimensionality reduction methods such as principal component analysis or linear discriminant analysis are used to retain key features, reduce redundant information, and improve data processing efficiency and classification accuracy; finally, the spectral features and texture features after dimensionality reduction are fused to form a compact and efficient spectral feature set, which provides high-quality input for subsequent color classification models; this step significantly improves the distinguishing ability of feature expression, reduces computational complexity, and enhances classification performance.
[0106] S4. Based on the spectral feature set, a hierarchical support vector machine model for wood block color detection is constructed to output the wood block color classification detection results.
[0107] Furthermore, the input is defined as a set of spectral features, and the output is the color classification detection result of the wood block;
[0108] The spectral feature set is used as a dataset and divided into a training set and a test set to ensure that the model will not overfit during training and testing;
[0109] Normalize the spectral feature set to avoid the degradation of model performance due to feature scale differences, and integrate the multi-scale feature fusion mechanism to generate a joint feature set and enhance the feature set;
[0110] Define the input of the first-layer wood block color detection hierarchical support vector machine model as a set of spectral features, and classify the wood block colors into three categories: light, dark, and neutral colors;
[0111] Use the multi-classification support vector machine model to achieve the classification task of three color categories;
[0112] Calculate the classification optimization amount for each category and dynamically adjust the classification boundary. The expression is:
[0113] ;
[0114] in, is the dynamic adjustment of the classification boundary to optimize the classification performance, is the mean of the class intervals, reflecting the average distance of the classification boundary and describing the separation ability of the classifier. is the standard deviation of the classifier output, describing the volatility of the current category distribution, is the classification uncertainty ratio, which measures the confidence of the classification result (when the uncertainty is high Approaching 1), It is the local information density of the sample, capturing the distribution characteristics of pixels in the feature space. is the adjustment factor for classification uncertainty, when High (large classification uncertainty) and Lower (local information is sparse), the value will tend to a lower value, indicating that the adjustment of the classification boundary needs to be more cautious. Low (high classification confidence) and Higher (local information is dense), a larger value means that the classification boundaries can be adjusted more aggressively.
[0115] This formula improves the classifier's ability to discriminate complex samples by dynamically adjusting the classification boundaries, especially when the class distribution is uneven or the boundaries are unclear;
[0116] Outputs the primary color category (light, dark, and neutral) for each image pixel;
[0117] Define the second-layer wood block color detection hierarchical support vector machine model input as the primary color category of the first layer to obtain the specific color category;
[0118] Light color category: subdivided into white and light yellow;
[0119] Dark category: subdivided into dark brown and black;
[0120] Neutral color category: subdivided into red, orange, brown, etc.;
[0121] For each color category, an independent support vector machine classifier is constructed to obtain the specific color category label;
[0122] For example:
[0123] Light color classifier: distinguishes between white and light yellow;
[0124] Dark classifier: distinguishes dark brown from black;
[0125] Neutral color classifier: distinguish between red, orange, brown, etc.;
[0126] Use the training set to label the color data, train the first and second layer classifiers, adjust the hyperparameters, and select the best configuration through cross-validation;
[0127] Validate the wood block color detection hierarchical support vector machine model on the test set (using classification accuracy, precision, recall, and F1 score to evaluate the model effect);
[0128] Output the specific color category of each image pixel as the wood block color classification detection result.
[0129] S4.1. Integrate the multi-scale feature fusion mechanism to generate a joint feature set. The specific steps are as follows:
[0130] Furthermore, through global average pooling and a two-layer fully connected network, the weight of each feature channel is dynamically generated to ensure that different channels in the feature can adapt to the requirements of the classification task;
[0131] It should be noted that, first, global average pooling is used to compress the two-dimensional features (H×W, i.e., height × width) of each channel into a scalar to generate a preliminary global description of the channel;
[0132] Next, enter the two-layer fully connected network:
[0133] The first fully connected layer is used for dimensionality reduction (reducing the number of parameters);
[0134] The second fully connected layer is used to restore the dimension (generate weights consistent with the original number of channels);
[0135] Finally, the channel weights are normalized to the interval [0, 1] through an activation function (such as sigmoid);
[0136] It should be noted that if the input feature here is a spectral feature, what is generated is the channel weight of the spectral feature (i.e. the weight of the spectral band);
[0137] If the input is a multi-scale texture feature, what is generated is the channel weight of the multi-scale texture feature (i.e. the weight of the local or global texture);
[0138] If the input is a joint feature, the channel weight of the joint feature (including the weights of the spectral feature channel and the texture feature channel) is generated;
[0139] Perform weighted fusion of local texture features and global texture features in the texture features of the wood block surface to generate multi-scale texture features;
[0140] It should be noted that the local texture features are extracted by capturing the detailed information of the surface texture of the wood block through a small receptive field window (such as 3×3 or 5×5);
[0141] Extract global texture features: Obtain overall texture patterns (such as directionality, uniformity, etc.) through a large receptive field window (such as the entire image or a large area);
[0142] The local and global texture features are weightedly fused through an attention mechanism (such as channel attention or spatial attention) to dynamically adjust the contribution ratio of the two. The steps include:
[0143] Concatenate local texture features and global texture features according to the channel dimension to form an initial feature set;
[0144] Assume that the dimensions of local texture features and global texture features are (C1, H, W) and (C2, H, W) respectively, and the concatenated dimensions are (C1+C2, H, W);
[0145] Perform global average pooling on each channel of the initial feature set to obtain a weight vector (C1+C2, 1) that represents the global importance of each channel;
[0146] The global pooling result is input into a two-layer fully connected network, and the weight vectors of local and global features are generated through nonlinear transformation;
[0147] Apply the dynamically generated weight vectors to the local texture features and the global texture features respectively;
[0148] Multiply each channel of the local texture feature by a weight to generate a weighted local texture feature;
[0149] Multiply each channel of the global texture feature by a weight to generate a weighted global texture feature;
[0150] The weighted local texture features and global texture features are fused to generate the final multi-scale texture features;
[0151] Finally, the fused multi-scale texture features are generated, which contain both local texture feature information and global texture feature information;
[0152] The purpose of this is to combine local texture features and global texture features to generate multi-scale texture features that can fully express the surface structural information of the wood block, improve the expression ability of texture features, and adapt to the complex structural characteristics of the wood block surface;
[0153] Combine spectral features and multi-scale texture features according to the feature channel dimension to generate a joint feature set that integrates color and texture information;
[0154] It should be noted that if the dimension of the spectral feature is (m, n, c1) (where m is the image height, n is the image width, and c1 is the number of spectral bands), and the dimension of the multi-scale texture feature is (m, n, c2), then the dimension of the joint feature set after splicing is (m, n, c1+c2);
[0155] By fusing spectral features and multi-scale texture features, the spectral feature set can simultaneously possess the ability to distinguish colors and express surface structures;
[0156] According to the dependence of the wood block color detection task on the joint feature set, proportional weights are assigned to spectral features and multi-scale texture features respectively to ensure that the classification model can balance the influence of the two;
[0157] For example:
[0158] The weight of spectral features is set to 60% (0.6) to emphasize the dominant role of color classification;
[0159] The weight of texture features is set to 40% (0.4) to supplement the auxiliary role of texture information;
[0160] S4.2. Build an independent support vector machine classifier. The specific steps are:
[0161] Furthermore, the primary classification results of the first-layer wood block color detection hierarchical support vector machine model are used as input;
[0162] According to the primary classification results, the spectral feature set is grouped by color category, and the feature data of light color, dark color and neutral color are extracted respectively to form sub-features for each category;
[0163] Light color category features: Contains the feature data of all pixels that are initially classified as light colors;
[0164] Dark category features: Contains the feature data of all pixels that are initially classified as dark;
[0165] Neutral color category features: Contains the feature data of all pixels that are initially classified as neutral colors;
[0166] Use the light color category features as input data to train a support vector machine classifier to subdivide the white and light yellow categories in the light color category and output a specific color category label (white or light yellow label);
[0167] Using the dark category features as input data, train a support vector machine classifier to segment dark brown and black in the dark category and output a specific color category label (dark brown or black label);
[0168] Using neutral color category features as input data, a support vector machine classifier is trained to subdivide the neutral color category into red, orange, and brown, and output specific color category labels.
[0169] According to the specific color category label of each image pixel output by the independent support vector machine classifier, the classification results of the specific color category labels are summarized to determine the color classification detection result of the wood block;
[0170] It should be noted that by constructing a hierarchical support vector machine model, this step utilizes spectral features and multi-scale texture features to complete the accurate classification of wood block colors; first, a dynamic classification boundary adjustment mechanism is used to optimize the classification performance under the condition of uneven category distribution, ensuring the accurate classification of light, neutral and dark colors; further subdivide specific color categories (such as white, light yellow, etc.), and improve the precision of color detection through independent classifiers; incorporate a multi-scale feature fusion mechanism, combine local and global texture features, and enhance the expression ability of the surface structure of wood blocks; at the same time, fuse spectral and texture features, integrate color and texture information, generate a joint feature set, and balance the influence of the two; the multi-scale attention mechanism dynamically adjusts the feature weights, so that the model adapts to complex surface characteristics and improves the robustness and accuracy of classification; ultimately, the accuracy and applicability of wood block color classification are significantly improved, providing reliable support for practical applications.
[0171] This embodiment also provides a computer device, which is suitable for the case of a wood block color detection method based on machine vision, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the wood block color detection method based on machine vision proposed in the above embodiment.
[0172] The computer device may be a terminal, comprising a processor, memory, a communication interface, a display, and an input device connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores an operating system and computer programs. The internal memory provides an environment for the operating system and computer programs stored in the non-volatile storage media. The communication interface of the computer device is used to communicate with external terminals via wired or wireless communication. Wireless communication may be achieved via Wi-Fi, a carrier network, NFC (near-field communication), or other technologies. The display of the computer device may be a liquid crystal display or an electronic ink display. The input device may be a touchscreen overlay on the display, buttons, a trackball, or a touchpad on the computer device housing, or an external keyboard, touchpad, or mouse.
[0173] This embodiment further provides a storage medium having a computer program stored thereon. When the program is executed by a processor, the computer program implements the method for detecting the color of a wooden block based on machine vision as proposed in the above embodiment. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0174] In summary, the present invention effectively solves the difficult problem of complex multi-category color detection tasks by constructing a hierarchical support vector machine model for wood block color detection; the first-layer model divides colors into three categories: light, neutral and dark, reducing the complexity of multi-classification tasks; the second-layer model further refines the specific color categories for each major category, and improves the pertinence and accuracy of classification through independent classifiers; at the same time, combined with the dynamic classification boundary adjustment mechanism, the category interval is optimized, and the model's adaptability to uneven category distribution is enhanced; in addition, the model incorporates a multi-scale feature fusion mechanism, effectively combining spectral features with texture features, making the classification results more comprehensive and accurate, and significantly improving the classification accuracy, robustness and efficiency of wood block color detection.
[0175] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for detecting wood block color based on machine vision, characterized by: include, Collect image data and perform preprocessing; Based on the preprocessed image data, a nonlinear illumination correction model is constructed to correct the preprocessed image data and output a multi-band image data sequence; Extract features from multi-band image data sequences and perform dimensionality reduction to generate a spectral feature set; Based on the spectral feature set, a hierarchical support vector machine model for wood block color detection is constructed to output the wood block color classification detection results; The specific steps of constructing the nonlinear illumination correction model are as follows: Define the input as preprocessed image data and the output as corrected image data; According to the light source direction in the image data, the influence of the light source direction on the reflected light intensity of each pixel on the surface of the wood block is calculated to generate image data after light source direction compensation. The expression is: ; in, is the image data after light source direction compensation, is the light source direction compensation function, It is the adjustment of the image data by the light source direction. is the preprocessed image data, is the horizontal coordinate of the pixel in the image, is the vertical coordinate of the pixel in the image, is the identifier of the spectral band, It is the angle between the light source direction and the surface normal of the object; The image data after light source direction compensation is combined with the ambient light intensity and the average ambient light intensity to dynamically adjust the effect of ambient light intensity on the pixel brightness in the image data to obtain the corrected image data. The expression is: ; in, is the corrected image data, is the ambient light compensation weight parameter, is the average ambient light intensity, is the current spectral band The ambient light intensity under is a small positive number; generating an image data sequence according to the corrected image data; Traverse all bands in the image data sequence to generate a multi-band image data sequence; The specific steps of constructing a hierarchical support vector machine model for wood block color detection are as follows: Define the input as a set of spectral features and the output as the color classification detection result of the wood block; The spectral feature set is divided into a training set and a test set as a data set; The spectral feature set is normalized and integrated with a multi-scale feature fusion mechanism to generate a joint feature set; Define the input of the first-layer wood block color detection hierarchical support vector machine model as a set of spectral features, and classify the wood block colors into three categories: light, dark, and neutral colors; Use the multi-classification support vector machine model to achieve the classification task of three color categories; Calculate the classification optimization amount for each category and dynamically adjust the classification boundary. The expression is: ; in, is the dynamic adjustment of the classification boundary, is the class interval mean, is the standard deviation of the classifier output, is the classification uncertainty ratio, is the local information density of the sample; Outputs the primary color category of each image pixel; Define the second layer of wood block color detection hierarchical support vector machine model input as the primary color category of the first layer; For each color category, an independent support vector machine classifier is constructed to obtain the color category label; Use the training set to label the color data and adjust the hyperparameters; Validate the hierarchical support vector machine model for wood block color detection on the test set; Output the color category of each image pixel as the wood block color classification detection result.
2. The method for detecting wood block color based on machine vision according to claim 1, wherein: The image data includes a wood block surface image, ambient light intensity, light source direction, color temperature, and a multispectral image.
3. The method for detecting wood block color based on machine vision according to claim 2, wherein: The preprocessing includes noise removal, image alignment and illumination normalization.
4. The method for detecting wood block color based on machine vision according to claim 1, wherein: The steps of extracting features from the multi-band image data sequence and performing dimensionality reduction to generate a spectral feature set are as follows: Using the corrected multi-band image data sequence, the grayscale value of each pixel in all bands is extracted pixel by pixel and recorded as spectral features; Aggregate spectral features through spatial dimensions to form high-dimensional spectral features; Extracting texture features of the wood block surface from the rectified multi-band image data sequence; For the extracted high-dimensional spectral features, a dimensionality reduction algorithm is used to optimize the high-dimensional spectral features to generate spectral features after dimensionality reduction; The spectral features and texture features after dimension reduction are fused to generate a spectral feature set, which is used as the input of the hierarchical support vector machine model for wood block color detection.
5. The method for detecting wood block color based on machine vision according to claim 1, wherein: The multi-scale feature fusion mechanism is integrated to generate a joint feature set. The specific steps are: The weight of each feature channel is dynamically generated through global average pooling and a two-layer fully connected network; Perform weighted fusion of local texture features and global texture features in the texture features of the wood block surface to generate multi-scale texture features; The spectral features and multi-scale texture features are combined according to the feature channel dimension to generate a joint feature set.
6. The method for detecting wood block color based on machine vision according to claim 1, wherein: The specific steps of constructing an independent support vector machine classifier are as follows: The primary classification results of the first-layer wood block color detection hierarchical support vector machine model are used as input; According to the primary classification results, the spectral feature set is grouped by color category, and the feature data of light color, dark color and neutral color are extracted respectively to form sub-features for each category; Use the light color category features as input data to train a support vector machine classifier, subdivide the white and light yellow in the light color category, and output the color category label; Using dark category features as input data, train a support vector machine classifier to segment dark brown and black in the dark category and output color category labels; Using the neutral color category features as input data, a support vector machine classifier is trained to subdivide the red, orange, and brown in the neutral color category and output the color category label; According to the specific color category label of each image pixel output by the independent support vector machine classifier, the classification results of the color category labels are summarized to determine the color classification detection result of the wood block.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the wood block color detection method based on machine vision according to any one of claims 1 to 6 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the wood block color detection method based on machine vision according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method for detecting mechanical strength of heat-treated wood
CN112345382A
Object detection method, system and equipment based on multi-picture real-time splicing and medium
CN113723272A