Wood block color detection method based on machine vision
By building a hierarchical support vector machine model and a multi-scale feature fusion mechanism, the complexity of multi-spectral data processing and multi-category color detection in the existing technology is solved, and high-precision and robust wood block color detection is achieved.
Patent Information
- Application Number
- CN202411894377.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-20
AI Technical Summary
When processing multi-spectral data, existing wood block color detection methods have problems such as high computational complexity and low classification efficiency, and it is difficult to adapt to complex multi-category color detection tasks.
Using a machine vision-based method, a nonlinear illumination correction model is constructed by acquiring and preprocessing image data, a multi-band image features are extracted and dimensionality reduction is performed to generate a spectral feature set. Then, a wood block color detection layered support vector machine model was constructed, and color classification detection was performed by combining the dynamic classification boundary adjustment mechanism and the multi-scale feature fusion mechanism.
It significantly improves the classification accuracy, robustness and efficiency of wood block color detection, and can more accurately identify complex and multi-category colors to adapt to different lighting conditions.
Smart Images

Figure CN119762602A_ABST
Abstract
Description
Technical Field
[0001] The 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 more and more extensive, 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, accurate identification of the color information on 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-spectrum 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; The current wood block color detection method has many major shortcomings. First, the dynamic changes of ambient light have a significant impact on the detection results. Traditional linear illumination correction is difficult to fully eliminate illumination interference, resulting in inaccurate color classification. Second, when using 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
[0003] In view of the above existing problems, the present invention is proposed.
[0004] 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.
[0005] In order to solve the above technical problems, the present invention provides the following technical solutions: 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; based on the preprocessed image data, constructing a nonlinear illumination correction model to correct the preprocessed image data, and outputting 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; based on the spectral feature set, constructing a hierarchical support vector machine model for wood block color detection, and outputting a wood block color classification detection result.
[0006] 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 a multi-spectral image.
[0007] 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.
[0008] 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: 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, and the image data after light source direction compensation is generated. The expression is: ; in, is the image data after light source direction compensation, is the light source direction compensation function, 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 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.
[0009] As a preferred solution of the wood block color detection method based on machine vision described in the present invention, wherein: the feature extraction from the multi-band image data sequence and dimension reduction to generate a spectral feature set, the specific steps are: 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 a spectral feature; Aggregate spectral features through spatial dimensions to form high-dimensional spectral features; Extracting the 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.
[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 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 wood block color classification detection result; The spectral feature set is used as a data set and divided into a training set and a test set; The spectral feature set is normalized and integrated with the 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 divide the wood block color into three categories: light color, dark color and neutral color; 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.
[0011] As a preferred solution of the wood block color detection method based on machine vision described in 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: The weight of each feature channel is dynamically generated through global average pooling and two-layer fully connected networks; The local texture features and the global texture features of the wood block surface are weightedly fused 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.
[0012] 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: 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 the support vector machine classifier, subdivide the white and light yellow in the light color category, and output the color category label; Use the dark category features as input data to train a support vector machine classifier to segment dark brown and black in the dark category and output color category labels; Use the neutral color category features as input data to train a support vector machine classifier to subdivide red, orange, and brown in the neutral color category and output color category labels; 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.
[0013] 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 wood block color based on machine vision as described in the first aspect of the present invention is implemented.
[0014] 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.
[0015] 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 colors, neutral colors, and dark colors, 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 a 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
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0017] Figure 1 This is a flow chart of the wood block color detection method based on machine vision in Example 1.
[0018] Figure 2 This is a schematic diagram of generating a joint feature set in Example 1. DETAILED DESCRIPTION
[0019] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0020] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and 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.
[0021] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0022] Example 1, reference Figure 1 and Figure 2, which is the first embodiment of the present invention, provides a method for detecting wood block color based on machine vision, comprising the following steps: S1. Collect image data and perform preprocessing.
[0023] Furthermore, the image data includes the surface image of the wood block, the ambient light intensity, the light source direction, the color temperature, and the multi-spectral image; Specifically, a multispectral camera or RGB camera is installed at a designated position of the assembly line to ensure that the camera field of view covers the entire movement area of the wood block and to collect the surface image of the wood block in real time; Configure a light sensor to record light parameters such as ambient light intensity, light source direction, and color temperature, and trigger it synchronously with the camera; Trigger the camera to collect image sequences or RGB images of the wood block surface in each band, and record the light intensity, light source direction and color temperature; The light source adopts a strictly designed diffuse reflection structure to ensure even light distribution and minimize interference between highlights and shadows.
[0024] S1.1, preprocessing, including noise removal, image alignment and illumination normalization; Specifically, Gaussian filtering or median filtering is applied to the image data to remove random noise and enhance image clarity while retaining edge details; 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; According to the light intensity data recorded by the light sensor, the normalization method is used to balance the light intensity of different bands to eliminate the impact of light changes on the image; 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; a synchronous trigger mechanism for the camera and the light sensor is installed to ensure the real-time and consistency of data acquisition; an optimized diffuse reflection light source structure is used to significantly reduce the interference of highlights and shadows on image quality; 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 the matching of pixels; the light intensity of different bands is balanced by combining the light intensity normalization method to eliminate the impact of lighting changes on the image; in summary, this step significantly improves the quality and consistency of the input data, and provides a reliable foundation for subsequent lighting correction and feature extraction.
[0025] 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.
[0026] Furthermore, the input is defined as the preprocessed image data, and the output is defined as the 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, and the image data after light source direction compensation is generated. The expression is: ; 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, is the adjustment of the image data by the light source direction, It is the preprocessed image data, which means at the pixel point and band The pixel intensity value under is the horizontal coordinate of the pixel in the image (i.e. the 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; This formula describes the correction process of the influence of the light source direction on the light intensity of the pixel point; through the light source direction compensation function, combined with the pre-processed image data and the angle between the light source direction and the surface normal of the object, the correction value of each pixel point in different bands is calculated; For the image data after light source direction compensation, combined with the ambient light intensity and the average ambient light intensity, the influence of the ambient light intensity on the pixel brightness in the image data is dynamically adjusted to obtain the corrected image data. The expression is: ; in, is the corrected image data, indicating that at the pixel point and spectral bands The final pixel intensity value after nonlinear illumination correction is is the ambient light compensation weight parameter, which controls the intensity of ambient light compensation. It is a manually set parameter. A higher value 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 in 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 is a small positive number used to avoid the denominator being zero and to provide numerical stability when the ambient light intensity is very small; 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; 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.
[0027] Check whether the corrected image data is evenly distributed, especially whether the brightness difference between highlight and shadow areas is significantly reduced; Compare the spectral characteristic curves before and after correction to verify whether the corrected image data retains the true spectral characteristics; According to the verification results, the parameters of the nonlinear illumination correction model are adjusted to adapt to the illumination conditions in different scenes; It should be noted that, by constructing a nonlinear illumination correction model, this step realizes dynamic illumination compensation for 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; then, 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 the highlight and shadow areas, while retaining the true spectral characteristics; this step significantly improves the consistency and robustness of the image data, and provides high-quality input for subsequent feature extraction and classification.
[0028] S3. Extract features from the multi-band image data sequence and perform dimension reduction to generate a spectral feature set.
[0029] Furthermore, the grayscale value of each pixel in all bands is extracted pixel by pixel using the corrected multi-band image data sequence, and recorded as spectral features; these spectral features represent the reflectance characteristics of each pixel in different bands, which are the core basis for subsequent color classification and detection; 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; Aggregate spectral features through spatial dimensions (i.e., pixel distribution of the entire image) to form high-dimensional spectral features; 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. Extracting wood block surface texture features (such as GLCM or LBP features) from the rectified multi-band image data sequence to enhance the accuracy of classification and detection; Specific extraction methods include: 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; Through the local binary pattern, the texture pattern of the local area is extracted to capture the detailed features of the wood block surface; Through multi-scale analysis, the hierarchical information of the wood block surface details is extracted and the multi-scale texture characteristics are recorded; 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, thereby reducing data redundancy and improving the efficiency and accuracy of subsequent classification; 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; Dimensionality reduction algorithms are used to simplify data to ensure that the extracted features are both compact and highly discriminative. Commonly used methods include: Extract the main characteristic components through principal component analysis to reduce redundant information; Enhance the feature classification ability through linear discriminant analysis and optimize the classification effect; 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. 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 value of each band is 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 grayscale symbiosis, local binary pattern and other methods to capture local details and multi-scale hierarchical information on the surface of the wood block; in order to optimize the high-dimensional spectral features, dimension 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 dimension 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.
[0030] 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.
[0031] Furthermore, the input is defined as a set of spectral features, and the output is the color classification detection result of the wood block; The spectral feature set is used as a data set and divided into a training set and a test set to ensure that the model will not be overfitted during training and testing; The spectral feature set is normalized to avoid the degradation of model performance due to feature scale differences, and a multi-scale feature fusion mechanism is incorporated to generate a joint feature set and enhance the 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 divide the wood block color into three categories: light color, dark color and neutral color; 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 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 is close to 1), 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 The value will tend to be lower (local information is sparse), indicating that the adjustment of classification boundaries 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.
[0032] This formula improves the classifier's ability to distinguish complex samples by dynamically adjusting the classification boundaries, especially when the category distribution is uneven or the boundaries are unclear; Outputs the primary color category (light, dark, and neutral) of each image pixel. 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; Light color category: subdivided into white and light yellow; Dark category: subdivided into dark brown and black; Neutral color category: subdivided into red, orange, brown, etc.; For each color category, an independent support vector machine classifier is constructed to obtain the specific color category label; For example: Light color classifier: distinguishes between white and light yellow; Dark classifier: distinguishes dark brown from black; Neutral color classifier: distinguish between red, orange, brown, etc.; 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; Verify the hierarchical support vector machine model for wood block color detection on the test set (use classification accuracy, precision, recall, and F1 score to evaluate the model effect); The specific color category of each image pixel is output as the wood block color classification detection result.
[0033] S4.1. Integrate the multi-scale feature fusion mechanism to generate a joint feature set. The specific steps are as follows: Furthermore, through global average pooling and two-layer fully connected networks, the weight of each feature channel is dynamically generated to ensure that different channels in the features can adapt to the requirements of the classification task; It should be noted that, first, the two-dimensional features (H×W, i.e., height×width) of each channel are compressed into a scalar using global average pooling to generate a preliminary global description of the channel; Next, enter the two-layer fully connected network: The first fully connected layer is used for dimensionality reduction (reducing the number of parameters); The second fully connected layer is used to restore the dimension (generate weights consistent with the original number of channels); Finally, the channel weights are normalized to the interval [0, 1] through an activation function (such as sigmoid); 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); 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); If the input is a joint feature, the channel weights of the joint feature (including the weights of the spectral feature channel and the texture feature channel) are generated; The local texture features and the global texture features of the wood block surface are weightedly fused to generate multi-scale texture features; 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); 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); 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: The local texture features and the global texture features are concatenated according to the channel dimension to form an initial feature set; 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); 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; The result after global pooling is input into a two-layer fully connected network, and the weight vectors of local and global features are generated through nonlinear transformation; Applying the dynamically generated weight vectors to the local texture features and the global texture features respectively; Multiply each channel of the local texture feature by a weight to generate a weighted local texture feature; Multiply each channel of the global texture feature by a weight to generate a weighted global texture feature; The weighted local texture features and global texture features are fused to generate the final multi-scale texture features; Finally, the fused multi-scale texture features are generated, which contain both local texture feature information and global texture feature information; The role 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; Combine spectral features and multi-scale texture features according to feature channel dimensions to generate a joint feature set that integrates color and texture information; 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); By integrating spectral features and multi-scale texture features, the spectral feature set has both the ability to distinguish colors and the ability to express surface structures; 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. For example: The weight of spectral features was set to 60% (0.6) to emphasize the dominant role of color classification; The weight of texture features is set to 40% (0.4) to supplement the auxiliary role of texture information; S4.2. Build an independent support vector machine classifier. The specific steps are: Furthermore, the primary classification results of the first-layer hierarchical support vector machine model for wood block color detection were 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; Light color category features: Contains the feature data of all pixels that are initially classified as light colors; Dark category features: Contains feature data of all pixels that are initially classified as dark; Neutral color category features: Contains the feature data of all pixels that are initially classified as neutral colors; Use the light color category features as input data to train the support vector machine classifier, subdivide the white and light yellow in the light color category, and output the specific color category label (white or light yellow label); Using the dark category features as input data, train the 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); Using neutral color category features as input data, train a support vector machine classifier to subdivide red, orange, and brown in the neutral color category and output specific color category labels; 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; 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 three-category 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; integrate multi-scale feature fusion mechanism, combine local and global texture features, and enhance the expression ability of wood block surface structure; at the same time, spectral and texture features are integrated, color and texture information are integrated, and a joint feature set is generated to balance the influence of the two; the multi-scale attention mechanism dynamically adjusts the feature weights to adapt the model to complex surface characteristics and improve the robustness and accuracy of classification; finally, the accuracy and applicability of wood block color classification are significantly improved, providing reliable support for practical applications.
[0034] 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 computer executable instructions to implement the wood block color detection method based on machine vision as proposed in the above embodiment.
[0035] The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0036] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the method for detecting the color of a wooden block based on machine vision as proposed in the above embodiment is implemented. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic storage device, a flash memory, a magnetic disk or an optical disk.
[0037] 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, which effectively combines 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.
[0038] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. 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 in that: 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 dimension 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.
2. The method for detecting wood block color based on machine vision according to claim 1, characterized in that: The image data includes a wood block surface image, ambient light intensity, light source direction, color temperature, and a multi-spectral image.
3. The method for detecting wood block color based on machine vision as claimed in claim 2, characterized in that: The preprocessing includes removing noise, completing image alignment and illumination normalization.
4. The method for detecting wood block color based on machine vision as claimed in claim 3, characterized in that: 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, and the image data after light source direction compensation is generated. The expression is: ; in, is the image data after light source direction compensation, is the light source direction compensation function, 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 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.
5. The method for detecting wood block color based on machine vision as claimed in claim 4, characterized in that: The method extracts features from the multi-band image data sequence and performs dimension reduction to generate a spectral feature set, and the specific steps are: 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 a spectral feature; Aggregate spectral features through spatial dimensions to form high-dimensional spectral features; Extracting the 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.
6. The method for detecting wood block color based on machine vision according to claim 5, characterized in that: 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 wood block color classification detection result; The spectral feature set is used as a data set and divided into a training set and a test 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 divide the wood block color into three categories: light color, dark color and neutral color; 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.
7. The method for detecting wood block color based on machine vision according to claim 6, characterized in that: 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 two-layer fully connected networks; The local texture features and the global texture features of the wood block surface are weightedly fused 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.
8. The method for detecting wood block color based on machine vision according to claim 7, characterized in that: 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 the support vector machine classifier, subdivide the white and light yellow in the light color category, and output the color category label; Use the dark category features as input data to train a support vector machine classifier to segment dark brown and black in the dark category and output color category labels; Use the neutral color category features as input data to train a support vector machine classifier to subdivide red, orange, and brown in the neutral color category and output color category labels; 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.
9. 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 described in any one of claims 1 to 8 are implemented.
10. 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 described in any one of claims 1 to 8 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
Under-forest wide-angle individual tree image segmentation method and system based on improved YOLOv8-Seg
CN118505995A
Image illumination correction method based on regularization extreme learning machine
CN118608403A
Defect detection method for loosening phenomenon of connecting piece of overhead line system suspension device
CN118657767A