A machine learning based method and system for sorting wooden boards
By establishing a multi-scale wooden board image database and training a detection model, the wooden board images are segmented and the defect index is calculated, which solves the problem that the influence of defect location is ignored in the existing technology, and achieves more accurate wooden board grading and quality assessment.
Patent Information
- Application Number
- CN202510587333.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-05-08
AI Technical Summary
Existing wood board sorting technology ignores the impact of defect location on the usability of wood boards and cannot accurately distinguish defect distribution characteristics, resulting in grading results that do not match actual usability.
A multi-scale normal wood board image database was established, and a multi-scale wood grain deviation detection model was trained. By segmenting the wood board image into sub-images and recording the location information, the defect index and continuity index were calculated. Taking into account the overall defects, distribution and continuity, the quality of the wood board was evaluated from multiple dimensions.
This has enabled a more scientific grading of wood boards, improved the accuracy and scientific nature of sorting, provided a more precise basis for quality assessment, and improved the utilization efficiency of timber resources.
Smart Images

Figure CN120510429B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and more particularly, to a wood board sorting method and system based on machine learning. BACKGROUND
[0002] With the continuous improvement of the degree of automation of industrial production, the wood processing industry has higher requirements for the accuracy and efficiency of wood board quality detection and sorting. As an important industrial raw material, the quality of wood board directly affects the quality and value of downstream products. Traditional wood board sorting mainly relies on manual visual inspection, which is not only inefficient, but also subjective, inconsistent in standards, and easily affected by fatigue, making it difficult to meet the needs of modern production.
[0003] In recent years, machine vision technology has been widely applied in the field of wood board quality detection. Existing machine vision detection systems can automatically identify obvious defects such as knots, cracks, and insect eyes on the surface of wood boards through image acquisition, processing, and analysis, greatly improving detection efficiency and consistency. However, these systems mainly focus on defect recognition when analyzing defects and sorting wood boards, i.e., determining whether there are defects on the surface of the wood board, but lack in-depth analysis of the distribution characteristics of defects. In fact, the location of defects has an important influence on the value of wood boards. For example, defects located in the central region of the wood board usually have a greater impact on product appearance and structural strength than defects located in the edge region, but existing systems often overlook this point and only use the presence or absence of defects or simple quantity statistics as a judgment standard. In addition, existing technology does not adequately consider the size and continuity of defects. In actual applications, the case of multiple small defects scattered distribution is significantly different from the case of a single large area defect concentrated distribution in terms of the impact on the value of wood boards. Existing systems usually only consider the total defect area or quantity, and cannot distinguish between these different cases, resulting in grading results that do not match the actual value. SUMMARY
[0004] To overcome the problem that the grading results of existing technology do not match the actual value, the present application proposes a wood board sorting method and system based on machine learning to solve the above problems.
[0005] The present application provides the following technical solutions:
[0006] A wood board sorting method based on machine learning, comprising:
[0007] Establishing a multi-scale normal wood board image database, the multi-scale normal wood board image database being used to store normal wood board images of different size scales;
[0008] A multi-scale wood grain deviation detection model set is formed by training a wood board detection model for judging whether a wood board image is normal for each different size specification based on a multi-scale normal wood board image database.
[0009] An image of the wood board to be sorted is acquired, and a segmentation size corresponding to different size specifications is acquired according to the size of the image of the wood board to be sorted and the different size specifications in the multi-scale normal wood board image database.
[0010] The wood board image is segmented into a plurality of sub-images according to the segmentation size, and spatial position information of each sub-image is recorded;
[0011] A wood grain deviation detection model corresponding to the size of the sub-image is selected, each sub-image is judged, and a sub-image with a judgment result of being not normal is marked as a defect image;
[0012] The grade of the wood board to be sorted is determined based on all the defect images and the image of the wood board to be sorted.
[0013] The wood board to be sorted is sorted according to the divided grade.
[0014] Preferably, the multi-scale normal wood board image database contains at least two preset different size specifications, and at least 100 normal wood board images are contained under each size specification, and the normal wood board images are pre-marked standard wood board images without defects.
[0015] Preferably, the multi-scale wood grain deviation detection model set includes:
[0016] Normal wood board images are extracted from the multi-scale normal wood board image database according to different size specifications;
[0017] The normal wood board images of each size specification are preprocessed;
[0018] Feature vectors of each preprocessed image are extracted, and the feature vectors include texture features, color features and structure features;
[0019] A feature sample library is constructed, and the feature vectors are grouped according to size specifications;
[0020] For each feature sample group of each size specification, a single-class classification algorithm is used to construct a feature space discrimination boundary, and the boundary inside is defined as a normal area;
[0021] Model training parameters are set, including algorithm core parameters and optimization variables;
[0022] The training parameters are optimized by a cross-validation method, and the optimal parameter combination is selected;
[0023] Save the model and its parameters trained in each size specification as a multi-scale wood grain deviation detection model set, and establish an index relationship between the sub-image size and the corresponding detection model.
[0024] Preferably, the obtaining of the segmentation size corresponding to different size specifications comprises:
[0025] Extract all preset different size specifications from the multi-scale normal wood board image database;
[0026] For each preset size specification, calculate the edge margin generated when the image of the wood board to be sorted is segmented using this size;
[0027] Compare the edge margins corresponding to all preset size specifications, and select the preset size specification with the smallest edge margin as the segmentation size;
[0028] The calculation step of the edge margin comprises:
[0029] Obtain the image size of the wood board to be sorted ; Obtain the preset size specification ;
[0030] Calculate and take the integer part to obtain the number of sub-regions that can be completely segmented in the horizontal direction ;
[0031] Calculate and take the integer part to obtain the number of sub-regions that can be completely segmented in the vertical direction ;
[0032] Calculate the horizontal edge margin using the formula ;
[0033] Calculate the vertical edge margin using the formula ;
[0034] Use the sum of the horizontal edge margin and the vertical edge margin as the edge margin.
[0035] Preferably, the wood board image is segmented into a plurality of sub-images according to the segmentation size, and the spatial position information of each sub-image is recorded, which comprises:
[0036] According to the segmentation size, the image of the wood board to be sorted is regularly segmented from the top left corner; the segmented image is divided into complete images and incomplete images; and the incomplete images are processed;
[0037] The complete image refers to an image that can be completely cut from the image of the wood board to be sorted according to the segmentation size; the incomplete image refers to an image that cannot be completely cut from the image of the wood board to be sorted according to the segmentation size;
[0038] The processing of the incomplete image includes: if the area of the intercepted image is less than a preset proportion of the segmentation size, the incomplete image is discarded; otherwise, the content of the intercepted image is mirrored and copied to the area where the image is not intercepted along the center line to fill the incomplete image, wherein the preset proportion is at least 50%.
[0039] After the segmentation and the processing of the incomplete image are completed, position information of each sub-image in the original image is recorded, and the position information is expressed by row and column coordinates.
[0040] Preferably, the determination of the grade of the wood board to be sorted based on all the defect images and the image of the wood board to be sorted includes:
[0041] A proportion value of the defect images in the total number of sub-images is calculated as a total defect index;
[0042] A defect distribution index is obtained according to the spatial position information of each defect image;
[0043] A defect continuity index is obtained by identifying adjacent defect sub-regions according to the spatial position information of each defect image;
[0044] The wood board to be sorted is divided into different grades based on the total defect index, the defect distribution index and the defect continuity index.
[0045] Preferably, the obtaining of the defect distribution index according to the spatial position information of each defect image includes:
[0046] A maximum horizontal coordinate in the spatial position information of the sub-image is obtained and a maximum vertical coordinate ;
[0047] For each defect image, a coordinate of the defect image is obtained, and a defect distribution value is calculated using the following formula :
[0048] ,
[0049] The maximum value of the defect distribution values in all the defect images is taken as the defect distribution index;
[0050] The obtaining of the defect continuity index by identifying adjacent defect sub-regions according to the spatial position information of each defect image includes:
[0051] A defect region connectivity graph is constructed based on the spatial position information of each defect image; all adjacent defect sub-images are identified and classified into the same connectivity region; the number of defect sub-images contained in each connectivity region is calculated; and the number of defect sub-images contained in the largest connectivity region is taken as the defect continuity index.
[0052] Preferably, the step of dividing the wood board to be sorted into different grades based on the overall defect index, the defect distribution index and the defect continuity index comprises:
[0053] setting preset thresholds for the overall defect index, the defect distribution index and the defect continuity index;
[0054] when the overall defect index, the defect distribution index and the defect continuity index are all lower than the respective preset thresholds, dividing the wood board to be sorted into the highest grade;
[0055] when one of the overall defect index, the defect distribution index and the defect continuity index exceeds the preset threshold thereof, dividing the wood board to be sorted into a higher grade;
[0056] when two of the overall defect index, the defect distribution index and the defect continuity index exceed the preset thresholds thereof, dividing the wood board to be sorted into a middle grade;
[0057] when all of the overall defect index, the defect distribution index and the defect continuity index exceed the preset thresholds thereof, dividing the wood board to be sorted into the lowest grade.
[0058] The application further provides a wood board sorting system based on machine learning, which is used to implement a wood board sorting method based on machine learning, and comprises:
[0059] a database establishing module, which is used to establish a multi-scale normal wood board image database for storing normal wood board images of different size scales;
[0060] a model training module, which is used to train a wood board detection model corresponding to each different size specification for judging whether a wood board image is normal based on the multi-scale normal wood board image database, so as to form a multi-scale wood grain deviation detection model set;
[0061] an image obtaining module, which is used to obtain an image of a wood board to be sorted, and obtain a segmentation size corresponding to each different size scale according to the size of the image of the wood board to be sorted and the different size scales in the multi-scale normal wood board image database;
[0062] an image segmentation module, which is used to segment the wood board image into a plurality of sub-images according to the segmentation size, and record spatial position information of each sub-image;
[0063] a defect detection module, which is used to select a wood grain deviation detection model corresponding to the size of the sub-image, judge each sub-image, and mark a sub-image with an abnormal judgment result as a defect image;
[0064] a grade determining module, which is used to determine the grade of the wood board to be sorted based on all the defect images and the image of the wood board to be sorted;
[0065] The sorting execution module is used for sorting the wood board to be sorted according to the divided grades.
[0066] The present application provides a kind of wood board sorting method and system based on machine learning, with the following beneficial effects:
[0067] By obtaining the maximum horizontal and vertical coordinates in the spatial position information of the sub-image, and calculating the position relationship of each defect image relative to the center of the wood board, the influence of defect distribution on the use value of the wood board can be scientifically quantified. This method pays special attention to the defects in the central region of the wood board, giving it a higher weight, thereby solving the problem of ignoring the importance of defect location in the prior art and achieving a more refined grading that better meets the needs of practical applications. By calculating the defect continuity index, the problem of insufficient consideration of defect size and continuity in the prior art is effectively solved. By constructing a connected graph of the defect region, adjacent defect sub-images are identified and grouped into the same connected region, and the number of defect sub-images contained in the largest connected region is calculated, which can accurately assess the actual size of a single defect and provide a more accurate quality assessment basis for the rational use of wood boards.
[0068] By comprehensively considering the overall defect index, defect distribution index and defect continuity index in three dimensions, the present scheme realizes comprehensive evaluation of the quality of the wood board, overcoming the limitations of single index evaluation in the prior art. This multi-dimensional evaluation system can more accurately reflect the actual use value of the wood board, improve the scientificity and practicality of wood board grading, and provide more accurate quality management tools for wood processing enterprises, improving the utilization efficiency of wood resources. BRIEF DESCRIPTION OF DRAWINGS
[0069] Figure 1 A flowchart of a wood board sorting method based on machine learning according to the present application;
[0070] Figure 2 A module diagram of a wood board sorting system based on machine learning according to the present application. DETAILED DESCRIPTION
[0071] The technical solutions in the embodiments of the present application will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0072] Embodiment 1
[0073] Please refer to Figure 1 In this embodiment, a wood board sorting method based on machine learning includes:
[0074] S1, establish a multi-scale normal board image database, the multi-scale normal board image database is used for storing normal board images of different size scales;
[0075] The multi-scale normal board image database contains at least two preset different size specifications, and at least 100 normal board images are contained under each size specification. The normal board image is a pre-labeled standard board image without defects.
[0076] In the embodiment, the multi-scale normal board image database can be established by the following steps:
[0077] Firstly, at least two preset different size specifications can be determined, for example, 128*128 pixels and 256*256 pixels can be selected as the basic specifications. The defect-free board can be photographed under the control of the lighting condition by using an industrial camera. When photographing, the camera can be kept perpendicular to the board surface to obtain the best image effect. The collected images can be pre-processed appropriately, such as denoising and light equalization processing. The images can be reviewed by personnel with experience in wood inspection, and after confirming that there are no obvious defects such as knots, cracks, and borer eyes in the images, they are marked as normal board images. The sub-images conforming to the preset size specifications can be cut from the original high-resolution images, and it is ensured that at least 100 normal board images are collected for each size specification.
[0078] S2, based on the multi-scale normal board image database, a corresponding wood board detection model for judging whether the board image is normal is trained for each different size specification, forming a multi-scale wood grain deviation detection model set;
[0079] The multi-scale wood grain deviation detection model set includes:
[0080] Normal board images are extracted from the multi-scale normal board image database according to different size specifications;
[0081] The normal board images of each size specification are pre-processed;
[0082] The feature vectors of each pre-processed image are extracted, including texture features, color features and structure features;
[0083] A feature sample library is constructed, and the feature vectors are grouped according to the size specifications;
[0084] For each size specification of the feature sample group, a single-class classification algorithm is used to construct a feature space discrimination boundary, and the boundary inside is defined as a normal area;
[0085] The model training parameters are set, including the algorithm core parameters and the optimization variables;
[0086] The training parameters are optimized by the cross-validation method, and the optimal parameter combination is selected;
[0087] The model and its parameters of each size specification after training are saved as a multi-scale wood grain deviation detection model set, and an index relationship between the sub-image size and the corresponding detection model is established.
[0088] In the present embodiment, the multi-scale wood grain deviation detection model set can be formed by the following steps:
[0089] Firstly, normal wood board images of different size specifications (such as 128x128 pixels and 256x256 pixels) can be extracted from the established multi-scale normal wood board image database. For images of each size specification, pre-processing operations can be performed, including contrast enhancement, Gaussian filter denoising and image normalization, so that the image features are more prominent and the influence of illumination changes is reduced.
[0090] Next, the feature vectors of each pre-processed image can be extracted. For texture features, statistical quantities such as energy, contrast, correlation and entropy can be extracted using a gray level co-occurrence matrix (GLCM); for color features, histogram features of hue, saturation and brightness can be extracted in the HSV color space; for structural features, the directionality and periodicity features of wood grain can be extracted using a local binary pattern (LBP) or a Gabor filter.
[0091] The extracted feature vectors can be constructed into a feature sample library and grouped and managed according to size specifications. For each size specification feature sample group, a single-class classification algorithm such as One-Class SVM or Isolation Forest can be used to construct a feature space discrimination boundary. These algorithms can learn the distribution characteristics of normal wood board samples and establish a closed boundary in the feature space, defining the interior of the boundary as a normal region.
[0092] During the model training process, key training parameters can be set, such as the kernel function type of One-Class SVM (RBF kernel can be selected), the penalty factor v (controls the proportion of abnormal points), and the kernel parameter γ (controls the smoothness of the decision boundary). These parameters can be optimized by a five-fold cross-validation method, specifically, the data set can be divided into 5 parts, 4 parts are used as the training set and 1 part is used as the validation set each time, and after 5 cycles, the parameter combination with the best average performance is taken.
[0093] After training, the model of each size specification and its optimal parameters can be saved as a multi-scale wood grain deviation detection model set. At the same time, an index relationship between the sub-image size and the corresponding detection model can be established, for example, 128x128 pixels correspond to model_128, 256x256 pixels correspond to model_256, etc.
[0094] When using these models to detect wood board images, the corresponding detection model can be automatically selected according to the size of the input image. For the wood board image to be detected, the same feature vector as in the training is extracted and then input into the corresponding model. The model will calculate the distance of the feature vector to the decision boundary or the anomaly score, and judge whether the image is a normal wood board image based on the preset threshold. If the feature vector falls within the normal region (i.e. the decision function value is greater than 0 or the anomaly score is lower than the threshold), it is determined to be a normal wood board; otherwise, it is determined to be an abnormal wood board with wood grain deviation.
[0095] Through this method, the multi-scale wood grain deviation detection model set formed can effectively distinguish normal / abnormal for wood board images of different sizes, providing reliable technical support for subsequent wood board sorting.
[0096] S3, obtaining an image of a wood board to be sorted, and obtaining a segmentation size corresponding to different size scales in the multi-scale normal wood board image database according to the size of the image of the wood board to be sorted and the different size scales;
[0097] Obtaining the segmentation size corresponding to the different size scales comprises:
[0098] Extracting all preset different size specifications from the multi-scale normal wood board image database;
[0099] For each preset size specification, calculating an edge margin generated when the wood board image to be sorted is segmented using the size;
[0100] Comparing the edge margins corresponding to all preset size specifications, and selecting the preset size specification with the smallest edge margin as the segmentation size;
[0101] The calculation step of the edge margin comprises:
[0102] Obtaining the size of the image of the wood board to be sorted ; obtaining the preset size specification ;
[0103] Calculating and rounding down to obtain the number of sub-regions that can be completely segmented in the horizontal direction ;
[0104] Calculating and rounding down to obtain the number of sub-regions that can be completely segmented in the vertical direction ;
[0105] Using the formula to calculate the horizontal edge margin;
[0106] Using the formula to calculate the vertical edge margin;
[0107] The sum of the horizontal edge margin and the vertical edge margin is used as the edge margin.
[0108] In the present embodiment, the segmentation size corresponding to different size scales can be obtained by the following steps:
[0109] Firstly, the complete image of the wood board to be sorted can be obtained by an industrial camera or a scanning device. After obtaining the image, the actual size of the image can be recorded.
[0110] Then, all the preset different size specifications can be extracted from the multi-scale normal wood board image database. In the present embodiment, it is assumed that the database contains two or more preset size specifications.
[0111] For each preset size specification, the edge margin generated when the wood board image to be sorted is segmented using the size can be calculated. The edge margin calculation steps are as follows:
[0112] Firstly, the image size of the wood board to be sorted and the preset size specification currently to be evaluated are obtained.
[0113] Then, the number of sub-regions that can be completely segmented in the horizontal direction can be calculated and rounded down, i.e. the length of the image is divided by the length of the preset size and rounded down. Similarly, the number of sub-regions that can be completely segmented in the vertical direction can be calculated and rounded down.
[0114] Next, the horizontal edge margin can be calculated, i.e. the length of the image minus the length occupied by all complete sub-regions multiplied by the width of the image. Similarly, the vertical edge margin can be calculated.
[0115] Finally, the sum of the horizontal edge margin and the vertical edge margin can be used as the total edge margin.
[0116] After the above calculation is performed for all preset size specifications, the total edge margins corresponding to them can be compared, and the preset size specification with the smallest edge margin can be selected as the final segmentation size.
[0117] By this method, it can be ensured that when the wood board image to be sorted is segmented, the image area is utilized to the maximum extent, the edge unused area is reduced, and the comprehensiveness and accuracy of detection are improved. The smaller the edge margin, the more fully the effective area in the wood board image is utilized, and the less the wasted edge blank area when the segmentation is performed according to the size specification.
[0118] S4, segmenting the wood board image into a plurality of sub-images according to the segmentation size, and recording spatial position information of each sub-image;
[0119] Segmenting the wood board image into a plurality of sub-images according to the segmentation size, and recording spatial position information of each sub-image includes:
[0120] According to the segmentation size, the image of the wood board to be sorted is regularly segmented from the top left corner; the segmented image is divided into a complete image and an incomplete image; and the incomplete image is processed;
[0121] The complete image refers to an image that can be completely cut from the image of the wood board to be sorted according to the segmentation size; and the incomplete image refers to an image that cannot be completely cut from the image of the wood board to be sorted according to the segmentation size.
[0122] The processing of the incomplete image includes: if the area of the cut image is less than a preset proportion of the segmentation size, the incomplete image is discarded; otherwise, the content of the cut image is mirrored and copied to the area of the image that is not cut along the center line to fill the incomplete image, wherein the preset proportion is at least 50%.
[0123] After the segmentation and the processing of the incomplete image are completed, the position information of each sub-image in the original image is recorded, and the position information is represented by row and column coordinates.
[0124] In this embodiment, after the optimal segmentation size is obtained, the image of the wood board to be sorted can be segmented into a plurality of sub-images through the following steps:
[0125] First, the image of the wood board to be sorted can be regularly segmented according to the segmentation size determined in the previous step. The segmentation process starts from the top left corner of the image and cuts sub-images according to the segmentation size along the horizontal and vertical directions. For example, if the determined segmentation size is 128x128 pixels, a sub-image of 128x128 pixels is cut from the top left corner of the image, then the next sub-image is cut by moving 128 pixels to the right, and this process is continued until the right boundary of the image is reached. Then, moving back to the left side, the next sub-image is cut by moving 128 pixels down, and this process is continued until the entire image area is processed.
[0126] During the segmentation process, the cut sub-images can be divided into two categories: complete images and incomplete images. The complete image refers to a sub-image that can be completely cut from the image of the wood board to be sorted according to the segmentation size (such as 128x128 pixels). The incomplete image refers to a sub-image that is located at the edge of the original image and cannot be completely cut according to the segmentation size, for example, only part of the area (such as 100x128 pixels or 128x80 pixels) falls within the range of the original image.
[0127] For the incomplete image, it can be processed according to the proportion of the cut area to the segmentation size. First, the proportion of the cut area to the segmentation size is calculated. If the proportion is less than a preset threshold (at least 50%), the incomplete image can be discarded and not included in subsequent analysis. If the proportion is greater than or equal to the preset threshold, the incomplete image needs to be filled.
[0128] The filling process can adopt a mirror flipping method. Specifically, the already captured image content can be flipped along the midline perpendicular to the missing boundary, and then copied to the un-captured area. For example, if the right edge is missing, the existing content is horizontally flipped along the midline of the right boundary; if the bottom edge is missing, the existing content is vertically flipped along the midline of the bottom boundary. In this way, the texture continuity of the filled area and the original area can be maintained, reducing the impact of boundary effects on subsequent analysis.
[0129] After completing the segmentation and processing of the incomplete image, the position information of each sub-image in the original image needs to be recorded. The position information can be represented by row and column coordinates, which can be counted from (1, 1). For example, the position of the first sub-image at the top left corner of the original image can be recorded as (1, 1), the position of the sub-image to the right of it as (1, 2), the position of the sub-image at the left of the second row as (2, 1), and so on. This way of recording position information facilitates quick positioning of the sub-image in the original image during subsequent analysis, especially when finding defects, it can accurately track the distribution of the defect area on the original board.
[0130] Through the above segmentation and position recording process, the complete image of the wood board to be sorted can be converted into a series of sub-images with uniform specifications and clear positions, laying a foundation for subsequent wood grain deviation detection. At the same time, the reasonable processing of incomplete images also ensures that the edge area of the wood board will not be ignored, improving the comprehensiveness of the detection.
[0131] S5, selecting a wood grain deviation detection model corresponding to the size of the sub-image, judging each sub-image, and marking the sub-image with an abnormal judgment result as a defect image;
[0132] In this embodiment, after completing the segmentation of the wood board image and recording the position information, the wood grain deviation of each sub-image can be detected by the following steps:
[0133] First, the corresponding detection model can be selected from the multi-scale wood grain deviation detection model set according to the size of the sub-image obtained by segmentation in the previous step. For example, if the size of the sub-image is 128x128 pixels, the wood grain deviation detection model trained for this size specification is selected. This matching selection ensures the adaptability of the model to the input image features.
[0134] Next, each sub-image can be preprocessed to ensure consistency with the image processing method used during model training. Then, feature vectors can be extracted from the preprocessed sub-image, including texture features, color features, and structure features, consistent with the feature extraction method used during model training. The extracted feature vectors are input into the selected wood grain deviation detection model, which outputs a judgment result indicating whether the sub-image is a normal wood board image.
[0135] For the sub-image with the abnormal judgment result, it can be marked as a defect image and its position information is recorded. In this way, effective defect detection can be performed on each sub-region of the board image, and basic data is provided for subsequent board grade classification.
[0136] S6, determining the grade of the wood board to be sorted based on all the defect images and the image of the wood board to be sorted;
[0137] Determining the grade of the wood board to be sorted based on all the defect images and the image of the wood board to be sorted includes:
[0138] Calculating the proportion value of the defect image in the total number of sub-images as the overall defect index;
[0139] According to the spatial position information of each defect image, the defect distribution index is obtained;
[0140] According to the spatial position information of each defect image, the adjacent defect sub-region is identified, and the defect continuity index is obtained;
[0141] Based on the overall defect index, the defect distribution index and the defect continuity index, the wood board to be sorted is divided into different grades.
[0142] According to the spatial position information of each defect image, the defect distribution index includes:
[0143] Obtaining the maximum horizontal coordinate in the spatial position information of the sub-image And the maximum vertical coordinate ;
[0144] For each defect image, its coordinates , the defect distribution value is calculated using the following formula :
[0145] ,
[0146] Take the maximum value of the defect distribution value in all defect images as the defect distribution index;
[0147] According to the spatial position information of each defect image, the adjacent defect sub-region is identified, and the defect continuity index is obtained, which includes:
[0148] Based on the spatial position information of each defect image, a defect region connected graph is constructed; all adjacent defect sub-images are identified and classified into the same connected region; the number of defect sub-images contained in each connected region is calculated; the number of defect sub-images contained in the largest connected region is taken as the defect continuity index.
[0149] Based on the overall defect index, the defect distribution index and the defect continuity index, the wood board to be sorted is divided into different grades, which includes:
[0150] setting preset thresholds for the overall flaw index, the flaw distribution index, and the flaw continuity index;
[0151] when all of the overall flaw index, the flaw distribution index, and the flaw continuity index are lower than the respective preset thresholds, the wood board to be sorted is classified as the highest grade;
[0152] when one of the overall flaw index, the flaw distribution index, and the flaw continuity index exceeds the preset threshold, the wood board to be sorted is classified as a higher grade;
[0153] when two of the overall flaw index, the flaw distribution index, and the flaw continuity index exceed the preset thresholds, the wood board to be sorted is classified as a middle grade;
[0154] when all of the overall flaw index, the flaw distribution index, and the flaw continuity index exceed the preset thresholds, the wood board to be sorted is classified as the lowest grade.
[0155] In this embodiment, after completing the flaw detection of the sub-image, the grade of the wood board to be sorted can be determined through the following steps:
[0156] Firstly, three key indicators can be calculated based on the detection results to evaluate the overall quality of the wood board. The first indicator is the overall flaw index, which can be obtained by calculating the proportion of the number of flaw images to the total number of sub-images. This index reflects the coverage of overall flaws on the wood board, and the value ranges from 0 to 1, with a higher value indicating more flaws on the wood board.
[0157] The second indicator is the flaw distribution index, which can be calculated based on the spatial position information of each flaw image. This index mainly reflects the distribution position of flaws on the wood board, especially whether the flaws are in the central area of the wood board. The flaw distribution index also takes a value between 0 and 1, with a higher value indicating that the flaws are closer to the central position of the wood board, which usually has a greater impact on the value of the wood board.
[0158] The third indicator is the flaw continuity index, which can be calculated by identifying adjacent flaw sub-regions. This index reflects the size or continuity of a single flaw and is an integer value representing the number of sub-images contained in the largest connected flaw region. A larger value indicates the presence of a larger single flaw, which usually means a more serious quality problem.
[0159] Next, the wood board to be sorted can be classified into different grades based on these three indicators. First, preset thresholds for the three indicators need to be set. For example, the threshold for the overall flaw index can be set to 0.1 (i.e., allowing up to 10% of the area to have flaws), the threshold for the flaw distribution index can be set to 0.6 (i.e., not allowing significant flaws in the central area), and the threshold for the flaw continuity index can be set to 3 (i.e., not allowing a single flaw larger than 3 consecutive sub-images).
[0160] Based on these thresholds, the wooden boards can be divided into four grades:
[0161] When the overall defect index, defect distribution index, and defect continuity index are all below their respective preset thresholds, the wood boards to be sorted can be classified as Grade A (the highest grade). These wood boards have almost no obvious defects and are suitable for use on high-end furniture surfaces or other applications with extremely high appearance requirements.
[0162] When any one of the three indicators exceeds its preset threshold, the wooden boards to be sorted can be classified as Grade B (second highest grade). These boards have minor defects, but the overall quality is still good, and they are suitable for general furniture or internal structural components.
[0163] When two of the three indicators exceed their preset thresholds, the wooden boards to be sorted can be classified as Grade C (medium grade). These boards have more obvious defects and are suitable for structural components or industrial applications where appearance is not a primary concern.
[0164] When all three indicators exceed their preset thresholds, the wooden boards to be sorted can be classified as Grade D (the lowest grade). These boards have serious defects and are only suitable for applications where appearance is not a requirement or where further processing is needed.
[0165] This multi-indicator comprehensive evaluation method can comprehensively and objectively grade the quality of wood boards, taking into account not only the number of defects but also the impact of the location and size of defects on the usability of the wood boards, providing a scientific basis for subsequent wood board sorting and utilization.
[0166] S7. Sort the wooden boards to be sorted according to the classification.
[0167] In this embodiment, after the wood planks are graded, an automated conveyor system and mechanical sorting device can be used to guide the different grades of wood planks to their corresponding storage areas, achieving automated wood plank sorting. This process can be seamlessly integrated with existing industrial automated sorting systems, improving the efficiency and accuracy of wood sorting.
[0168] Example 2
[0169] Please see Figure 2 This invention provides a machine learning-based wooden board sorting system for implementing a machine learning-based wooden board sorting method, comprising:
[0170] The database creation module is used to create a multi-scale normal wooden board image database, which stores normal wooden board images of different sizes.
[0171] The model training module is configured to train, based on the multi-scale normal wood board image database, a wood board detection model corresponding to each different size specification for judging whether a wood board image is normal, thereby forming a multi-scale wood grain deviation detection model set;
[0172] The image acquisition module is configured to acquire an image of the wood board to be sorted, and acquire a segmentation size corresponding to different size scales according to the size of the image of the wood board to be sorted and the different size scales in the multi-scale normal wood board image database.
[0173] The image segmentation module is configured to segment the wood board image into a plurality of sub-images according to the segmentation size, and record spatial position information of each sub-image.
[0174] The defect detection module is configured to select a wood grain deviation detection model corresponding to the size of the sub-image, judge each sub-image, and mark a sub-image with an abnormal judgment result as a defect image.
[0175] The grade determination module is configured to determine the grade of the wood board to be sorted based on all the defect images and the image of the wood board to be sorted.
[0176] The sorting execution module is configured to sort the wood board to be sorted according to the divided grade.
[0177] In the several embodiments of the present application, it should be understood that the disclosed system, device, and method can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is only one of many, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0178] The above description is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any modification or replacement within the technical range disclosed by the present application can be easily thought of by those skilled in the art, and should be included in the protection scope of the present application.
[0179] Finally, the above description is only the preferred embodiment of the present application, and is not used to limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. A machine learning-based method for sorting wooden boards, characterized in that, include: A multi-scale normal wooden board image database is established, which is used to store normal wooden board images of different sizes; Based on a multi-scale normal wooden board image database, corresponding wooden board detection models for judging whether wooden board images are normal are trained for each different size and specification, forming a multi-scale wood grain deviation detection model set; Obtain an image of the wooden board to be sorted, and obtain the segmentation size corresponding to the different size scales based on the size of the image of the wooden board to be sorted and the different size scales in the multi-scale normal wooden board image database; The wooden board image is divided into multiple sub-images according to the segmentation size, and the spatial location information of each sub-image is recorded at the same time. Select a wood grain deviation detection model corresponding to the size of the sub-image, judge each sub-image, and mark the sub-images with abnormal judgment results as defective images; The grade of the planks to be sorted is determined based on all defect images and images of the planks to be sorted; The wooden boards to be sorted are sorted according to their grade. The process of obtaining the segmentation dimensions corresponding to different size scales includes: Extract all preset different size specifications from a multi-scale normal wooden board image database; For each preset size specification, calculate the edge allowance generated when segmenting the image of the wooden board to be sorted using that size; Compare the edge allowances corresponding to all preset size specifications, and select the preset size specification with the smallest edge allowance as the segmentation size; The calculation steps for the edge margin include: Obtain the image size of the wooden boards to be sorted Get preset size specifications ; calculate The number of horizontally divisible subregions is obtained by rounding down. ; calculate The number of vertically divisible subregions is obtained by rounding down. ; Use formula Calculate the horizontal edge allowance; Use formula Calculate the vertical edge allowance; Use the sum of the horizontal edge allowance and the vertical edge allowance as the edge allowance; The step of dividing the wooden board image into multiple sub-images according to the segmentation size, and simultaneously recording the spatial location information of each sub-image, includes: According to the segmentation size, the image of the wooden board to be sorted is regularly segmented starting from the top left corner; the segmented image is divided into complete image and incomplete image; and the incomplete image is processed. Among them, a complete image refers to an image that can be cropped from the image of the wooden board to be sorted exactly according to the segmentation size; an incomplete image refers to an image that cannot be cropped from the image of the wooden board to be sorted exactly according to the segmentation size. The processing of incomplete images includes: if the area of the cropped image is smaller than a preset proportion of the segmentation size, then the incomplete image is discarded; otherwise, the content of the cropped image is mirrored and copied along the midline to the area where no image was cropped, thus filling the incomplete image, wherein the preset proportion is at least 50%. After completing the segmentation and processing of incomplete images, the position information of each sub-image in the original image is recorded, and the position information is represented by row and column coordinates.
2. The machine learning-based plank sorting method according to claim 1, characterized in that, The multi-scale normal wooden board image database contains at least two preset different size specifications, and each size specification contains at least 100 normal wooden board images, which are pre-labeled flawless standard wooden board images.
3. The machine learning-based plank sorting method according to claim 2, characterized in that, The multi-scale wood grain deviation detection model set includes: Images of normal wooden boards were extracted from a multi-scale normal wooden board image database and categorized according to different size specifications. Preprocess the images of normal wooden boards for each size specification; Extract the feature vector of each preprocessed image, the feature vector including texture features, color features and structural features; Construct a feature sample library and group the feature vectors according to their size specifications; For each size specification of feature sample group, a single-class classification algorithm is used to construct the feature space discrimination boundary, and the area inside the boundary is defined as the normal region; Set the model training parameters, including the core algorithm parameters and optimization variables; Optimize training parameters using cross-validation and select the optimal parameter combination; The trained models and their parameters for each size specification are saved as a multi-scale wood grain deviation detection model set, and an index relationship between sub-image size and corresponding detection model is established.
4. The machine learning-based plank sorting method according to claim 3, characterized in that, The process of determining the grade of the planks to be sorted based on all defect images and images of the planks to be sorted includes: The proportion of defective images to the total number of sub-images is calculated as the overall defect index. Based on the spatial location information of each defect image, obtain the defect distribution index; Based on the spatial location information of each defect image, adjacent defect sub-regions are identified, and the defect continuity index is obtained; Based on the overall defect index, defect distribution index, and defect continuity index, the wooden boards to be sorted are divided into different grades.
5. The machine learning-based plank sorting method according to claim 4, characterized in that, The step of obtaining the defect distribution index based on the spatial location information of each defect image includes: Obtain the maximum x-coordinate from the spatial location information of the sub-image and maximum ordinate ; For each defective image, obtain its coordinates. The defect distribution value is calculated using the following formula. : , The defect distribution index is taken as the value with the largest defect distribution value among all defective images. The step of identifying adjacent defect sub-regions and obtaining the defect continuity index based on the spatial location information of each defect image includes: Based on the spatial location information of each defective image, a connected graph of defective regions is constructed; all adjacent defective sub-images are identified and grouped into the same connected region; the number of defective sub-images contained in each connected region is calculated; and the number of defective sub-images contained in the largest connected region is taken as the defect continuity index.
6. The machine learning-based plank sorting method according to claim 5, characterized in that, The process of classifying the wood boards to be sorted into different grades based on the overall defect index, defect distribution index, and defect continuity index includes: Set preset thresholds for the overall defect index, defect distribution index, and defect continuity index; When the overall defect index, defect distribution index, and defect continuity index are all lower than their respective preset thresholds, the wooden boards to be sorted are classified into the highest grade. When any one of the overall defect index, defect distribution index, and defect continuity index exceeds its preset threshold, the wood planks to be sorted will be classified as the second highest grade. When two of the overall defect index, defect distribution index, and defect continuity index exceed their preset thresholds, the wood boards to be sorted are classified as medium grade. When the overall defect index, defect distribution index, and defect continuity index all exceed their preset thresholds, the wooden boards to be sorted are classified into the lowest grade.
7. A machine learning-based wooden board sorting system, used to implement the machine learning-based wooden board sorting method as described in any one of claims 1-6, characterized in that, include: The database establishment module is used to establish a multi-scale normal wooden board image database, which is used to store normal wooden board images of different sizes. The model training module is used to train corresponding wood detection models for judging whether a wood image is normal based on a multi-scale normal wood image database, forming a multi-scale wood grain deviation detection model set; The image acquisition module is used to acquire images of the wooden boards to be sorted, and to acquire the segmentation size corresponding to different size scales based on the size of the images of the wooden boards to be sorted and the different size scales in the multi-scale normal wooden board image database. The image segmentation module is used to segment the wooden board image into multiple sub-images according to the segmentation size, and at the same time record the spatial location information of each sub-image; The defect detection module is used to select the wood grain deviation detection model corresponding to the size of the sub-image, judge each sub-image, and mark the sub-images with abnormal judgment results as defective images; The grading module is used to determine the grade of the wooden boards to be sorted based on all defect images and images of the boards to be sorted. The sorting execution module is used to sort the wooden boards to be sorted according to the classified grades.
Citation Information
Patent Citations
Defect level judgment method and storage medium
CN111223078A
Defect detection method and system, electronic equipment and medium
CN116385331A
Ceramic tile sorting method and system based on opc and ceramic tile surface defect recognition model
CN117523307A