A new building timber defect detection method based on histogram equalization
Patent Information
- Application Number
- CN202211161308.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2042-09-23
AI Technical Summary
[0005]本发明提供一种基于直方图均衡化的新型建筑木材缺陷检测方法,解决活死节检测时浪费材料的问题,采用如下技术方案:
[0038]This paper utilizes intelligent defect detection technology to detect live and dead knots in new building timber. The method involves acquiring high-grayscale and low-grayscale regions on the timber surface, clustering pixels in the low-grayscale regions, creating windows for each pixel class and calculating the density of each class within each window size. The image of each live and dead knot region is determined based on the maximum density. Histogram equalization is then applied to each live and dead knot region image to enhance contrast. A convex hull algorithm is used to obtain the convex hull connected components, and a mask operation is performed between the convex hull connected components and the original image to obtain the grayscale image of each live and dead knot region. For example, the high and low grayscale regions in the grayscale image of each live and dead knot region are separated. Using the midpoint of the convex hull connected component of the grayscale image of each live and dead knot region as the center, a size-amplified window is established to calculate the density of the grayscale image of each live and dead knot region under different size windows. The degree of change is calculated based on the change in density before and after the amplification. The information entropy of the degree of change is obtained based on the frequency of the degree of change. The information entropy of each degree of change is used as the peeling degree of the grayscale image of the live and dead knot region. The live and dead knots in the grayscale image of the wood surface are judged based on the peeling degree, which saves production materials while ensuring quality.
Smart Images

Figure CN115239729B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent defect detection, specifically to a novel method for detecting defects in building timber based on histogram equalization. Background Technology
[0002] New fire-resistant timber is a type of building material with good fire resistance. Therefore, when producing new fire-resistant timber, it is essential to ensure that the timber used meets production requirements and guarantees production quality.
[0003] Dead and live knots are common defects in wood. Dead knots indicate that the wood tissue has separated from the wood, while live knots indicate that the wood tissue has not yet separated from the wood. Therefore, when producing new fire-resistant building wood, dead knots or live knots with partial tissue separation will cause the fire-resistant coating of the new fire-resistant building wood to peel off, affecting its fire resistance performance.
[0004] Conventional methods for detecting timber defects include detecting live and dead knots. Once live and dead knots are detected, they are marked as defects, which leads to waste of timber. Therefore, this solution proposes an intelligent defect detection method to identify live and dead knot defects in timber. The degree of connection between the live and dead knot area and the timber tissue is used as the basis for defect detection, which saves production materials while ensuring quality. Summary of the Invention
[0005] This invention provides a novel method for detecting defects in building timber based on histogram equalization, solving the problem of material waste during the detection of live and dead knots. The technical solution is as follows:
[0006] Obtain a grayscale image of the wood surface;
[0007] High grayscale regions and low grayscale regions in the grayscale image of the wood surface were obtained by k-means clustering.
[0008] Perform mean-shift clustering on pixels in low grayscale regions;
[0009] A window with expanded size is established centered on the coordinates of the center pixel of each type of pixel to calculate the density of each type of pixel under each window size;
[0010] Obtain the maximum density of each type of pixel under different sized windows, and determine the live and dead node region image based on the maximum density.
[0011] Histogram equalization is performed on the live and dead node region map to obtain a live and dead node region image with enhanced contrast;
[0012] Obtain the convex hull connected components in the contrast-enhanced live and dead knot region image, and perform a masking operation between the convex hull connected components and the grayscale image of the wood surface to obtain the grayscale image of the live and dead knot region.
[0013] k-means clustering was used to separate high and low gray value regions in the grayscale image of live and dead nodes;
[0014] Using the midpoint of the convex hull connected region of the grayscale image of the live and dead node region as the center, a window with expanded size is established to calculate the density of the grayscale image of the live and dead node region under different window sizes.
[0015] The degree of variation of the grayscale image of the live and dead nodal region under each window size is obtained by combining the density of the grayscale image of the live and dead nodal region under different window sizes and the density of the image of the live and dead nodal region to which the grayscale image of the live and dead nodal region is located.
[0016] The method for calculating the degree of change is as follows:
[0017]
[0018] In the formula, For the grayscale image of the living and dead junction region in size The degree of change under the window, The grayscale image of the live and dead knot region is in size [size missing]. Density under the window, The grayscale image of the live / dead node region is located in the image of the live / dead node region with a size of Density under the window;
[0019] The information entropy of the degree of change of the grayscale image of each live and dead node region is obtained based on the frequency of the degree of change of the grayscale image of each live and dead node region under each window size.
[0020] The method for calculating the frequency of variation of the grayscale image of each live and dead node region under each window size is as follows:
[0021] The degree of change of the grayscale image of each live and dead node region under each size window is calculated, and all degrees of change of the grayscale image of the live and dead node region under all size windows are obtained; the frequency of the degree of change of the grayscale image of each live and dead node region under each size window among all degrees of change is taken as the frequency of the degree of change of the grayscale image of the live and dead node region under each size window.
[0022] The information entropy of the degree of change in the grayscale image of the live and dead knot region is used as the peeling degree of the grayscale image of the live and dead knot region. Based on the peeling degree of the grayscale image of the live and dead knot region, it is determined whether the live and dead knot region in the grayscale image of the wood surface belongs to a live and dead knot.
[0023] The method for obtaining the density of each type of pixel under each window size is as follows:
[0024] Obtain the coordinates of the center pixel of each type of pixel;
[0025] Establish with this coordinate as the center point Window size;
[0026] The ratio of the number of low grayscale pixels in the window to the total number of pixels in the window is taken as the density of that type of pixel in the window.
[0027] The method for obtaining the image of each live / dead node region is as follows:
[0028] Expand the window size until it reaches the threshold;
[0029] After each expansion of the window size, the density of each type of pixel within the current window size is calculated;
[0030] Select the maximum density value for all window sizes for each type of pixel;
[0031] If the maximum density value is greater than the threshold, then the window region corresponding to the maximum density value is the live / dead node region image.
[0032] The method for calculating the information entropy of the degree of change in the grayscale image of each live and dead node region is as follows:
[0033]
[0034] In the formula, For the first Information entropy of the degree of change in grayscale image of each living and dead node region. For the first The degree of variation of the grayscale image of the nodal region across all window sizes is the [number]th. The frequency value of the degree of change.
[0035] The method for determining live and dead knots in grayscale images of wood surfaces is as follows:
[0036] Information entropy of the degree of change in grayscale image of each living and dead node region With threshold In comparison, if If the live / dead node region is positive, then it is a defect; otherwise, it is not a defect.
[0037] The beneficial effects of this invention are:
[0038] This paper utilizes intelligent defect detection technology to detect live and dead knots in new building timber. The method involves acquiring high-grayscale and low-grayscale regions on the timber surface, clustering pixels in the low-grayscale regions, creating windows for each pixel class and calculating the density of each class within each window size. The image of each live and dead knot region is determined based on the maximum density. Histogram equalization is then applied to each live and dead knot region image to enhance contrast. A convex hull algorithm is used to obtain the convex hull connected components, and a mask operation is performed between the convex hull connected components and the original image to obtain the grayscale image of each live and dead knot region. For example, the high and low grayscale regions in the grayscale image of each live and dead knot region are separated. Using the midpoint of the convex hull connected component of the grayscale image of each live and dead knot region as the center, a size-amplified window is established to calculate the density of the grayscale image of each live and dead knot region under different size windows. The degree of change is calculated based on the change in density before and after the amplification. The information entropy of the degree of change is obtained based on the frequency of the degree of change. The information entropy of each degree of change is used as the peeling degree of the grayscale image of the live and dead knot region. The live and dead knots in the grayscale image of the wood surface are judged based on the peeling degree, which saves production materials while ensuring quality. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a flowchart illustrating a novel method for detecting defects in building timber based on histogram equalization, according to the present invention. Detailed Implementation
[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0042] An embodiment of a novel method for detecting defects in building timber based on histogram equalization according to the present invention is as follows: Figure 1 As shown, it includes:
[0043] Step 1: Obtain a grayscale image of the wood surface; use k-means clustering to identify high and low grayscale regions in the wood surface grayscale image;
[0044] The purpose of this step is to acquire images of the wood surface and obtain the darker areas in the images.
[0045] In this process, when acquiring images of the wood surface, the camera is used to view the surface of the wood directly, and the surface image is then converted into a grayscale image.
[0046] The method for obtaining high grayscale and low grayscale regions in an image is as follows:
[0047] Obtain the grayscale values of all pixels in the grayscale image of the wood surface. Then, perform binary classification on the grayscale values of all pixels using the k-means, k=2 clustering algorithm to separate the regions with high grayscale values and low grayscale values.
[0048] It should be noted that since the live and dead knots on the wood surface are darker areas in the image, the low gray value areas after k-means binary classification may be areas with defects or areas with relatively dark wood texture.
[0049] Step 2: Perform mean-shift clustering on pixels in low grayscale regions; calculate the density of each pixel in each category under each size window by establishing a window with the coordinates of the center pixel of each category as the center;
[0050] The purpose of this step is to classify the pixels in the low grayscale region (darker region) obtained in step one, and to build an amplification window in each category to calculate the density of pixels in that category.
[0051] The method for classifying pixels in low grayscale regions is as follows:
[0052] Obtain the coordinates of the pixels corresponding to the low grayscale value regions. Use the mean shift algorithm to classify the low grayscale value regions according to their coordinate information. Cluster the pixels with dense low grayscale values into one category, resulting in a total of i categories.
[0053] The method for obtaining the density of each type of pixel under each window size is as follows:
[0054] (1) Obtain the coordinates of the cluster center pixel of the i-th category pixel (which can be obtained directly after clustering);
[0055] (2) Establish a system with the center point coordinates as the center. The window size, in this embodiment, is taken as... =3;
[0056] (3) Obtain the number of pixels corresponding to the low grayscale value category in the current window, and use the ratio of this number to the total number of pixels in the window as the density of this type of pixel in the current size window. .
[0057] The window amplification method is as follows:
[0058] This embodiment will The size of the window is expanded to A window of a certain size is used, and then the pixel values for each class are calculated. The density in the window of the specified size is calculated sequentially until the window size is expanded to Cr, where Cr is a threshold that can be adjusted by the implementer according to the specific implementation scenario. In this scheme, Cr is set to 100.
[0059] Step 3: Obtain the maximum density of each type of pixel under different window sizes, and determine the live and dead node region image based on the maximum density.
[0060] The purpose of this step is to determine the image of the live and dead knot regions of the wood by amplifying the calculated density values of each type of pixel in a window of different sizes.
[0061] The method for determining each live and dead node region image based on the maximum density is as follows:
[0062] Calculate the maximum density of each type of pixel under different window sizes. , the maximum density value With threshold Compare;
[0063] if The current region is considered to be a region of live and dead knots in the wood, and the density of the live and dead knot region is considered to be... The area obtained by the size of the corresponding window at that time;
[0064] if The current area is considered to be part of the wood grain. This solution can be adjusted by the implementer according to the specific implementation scenario. =0.4.
[0065] It should be noted that if it is a live or dead node, the density will be relatively stable, and then it will continue to decrease after the mutation. If it is noise, it will always be in the decreasing part.
[0066] Step 4: Perform histogram equalization on the live and dead knot region image to obtain a contrast-enhanced live and dead knot region image; obtain the convex hull connected components in the contrast-enhanced live and dead knot region image, and perform a masking operation between the convex hull connected components and the grayscale image of the wood surface to obtain the grayscale image of the live and dead knot region.
[0067] The purpose of this step is to perform contrast enhancement and convex hull connectivity analysis on each live / dead node region map to obtain the grayscale image corresponding to each live / dead node region.
[0068] The method for obtaining the grayscale image of each live / dead node region is as follows:
[0069] Based on the j-th live / dead node region found in step three:
[0070] (1) The histogram equalization method is used for the j-th live and dead knot region to improve the contrast in the region. If the wood tissue in this region is still connected to the wood, its internal texture will still have a certain circular regularity. If the wood tissue in this region is not connected to the wood, its internal texture is irregular.
[0071] (2) Use the convex hull algorithm to obtain the corresponding convex hull connected component for the j-th live-dead node region;
[0072] (3) Multiply the convex hull connected component as a mask with the original image to obtain the grayscale image part corresponding to the j-th live dead node region, that is, the grayscale image of the j-th live dead node region.
[0073] Following the method described above, grayscale images of all live and dead node regions can be obtained.
[0074] Step 5: Use k-means clustering to separate the high and low grayscale regions in the grayscale image of the live and dead node regions;
[0075] Using the midpoint of the convex hull connected region of the grayscale image of the live and dead node region as the center, a window with expanded size is established to calculate the density of the grayscale image of the live and dead node region under different window sizes.
[0076] The purpose of this step is to calculate the density by windowing the grayscale image of each live and dead node.
[0077] The method for windowing the grayscale image of each live / dead node is as follows:
[0078] (1) For the gray values of pixels in the gray map corresponding to the j-th live and dead node region, the k-means,k=2 clustering algorithm is used to perform binary classification to separate the high gray value and low gray value regions.
[0079] If the j-th live-dead node region is a live node region, then its interior will have a ring-shaped texture; if the j-th live-dead node region is a dead node region, then its interior will have an irregular grayscale distribution.
[0080] (2) Obtain the center of the convex hull connected region corresponding to the j-th live-dead node region, and use the above window expansion method (as in step 2) to obtain the new density value of each live-dead node region image under a window of different sizes. .
[0081] Step 6: Based on the density of the grayscale image of the live and dead node region under different window sizes and the density of the image of the live and dead node region to which the grayscale image of the live and dead node region is located, obtain the degree of change of the grayscale image of the live and dead node region under each window size;
[0082] The purpose of this step is to compare the density of each type of pixel in step two during amplification with the density of the corresponding live and dead node region image during the amplification window to calculate the degree of change.
[0083] The method for calculating the degree of change in grayscale image for each live / dead node region under each window size is as follows:
[0084]
[0085] In the formula, For the grayscale image of the living and dead junction region in size The degree of change under the window, The grayscale image of the live and dead knot region is in size [size missing]. Density under the window, The grayscale image of the live / dead node region is located in the image of the live / dead node region with a size of The density under the window, where the grayscale image of the live and dead node region is the live and dead node region image corresponding to the grayscale image of the live and dead node region in step three.
[0086] Step 7: Obtain the information entropy of the degree of change of the grayscale image of each live and dead node region based on the frequency of the degree of change of the grayscale image of each live and dead node region under each window size;
[0087] The purpose of this step is to calculate the degree of disorder in the grayscale image of each live and dead node region.
[0088] The method for calculating the frequency of variation in grayscale image for each live / dead node region under each window size is as follows:
[0089] (1) Calculate the degree of change of the grayscale image of each live and dead node region under each size window, and obtain the degree of change of the grayscale image of the live and dead node region under all size windows;
[0090] (2) The frequency of the degree of change of the grayscale image of each live and dead node region under each size window is taken as the frequency of the degree of change of the grayscale image of the live and dead node region under each size window.
[0091] The method for calculating the information entropy of the grayscale image change degree in each live / dead node region is as follows:
[0092]
[0093] In the formula, For the first Information entropy of the degree of change in grayscale image of each living and dead node region. For the first The degree of variation of the grayscale image of the nodal region across all window sizes is the [number]th. The frequency value of the degree of change.
[0094] Step 8: Use the information entropy of the degree of change in the grayscale image of the live and dead knot region as the peeling degree of the grayscale image of the live and dead knot region. Determine whether the live and dead knot region in the grayscale image of the wood surface belongs to a live or dead knot based on the peeling degree of the grayscale image of the live and dead knot region.
[0095] The purpose of this step is to use the information entropy of the degree of change in the grayscale image of the live and dead knot region calculated in step seven to determine the live and dead knot defects on the wood surface.
[0096] The method for determining whether a region in a grayscale image of a wood surface is a live or dead knot is as follows:
[0097] Set a threshold r, where r is a hyperparameter that can be adjusted by the implementer according to the specific implementation scenario. If the tissue within the j-th live / dead node region has detached from the wood, then the j-th live / dead node region is considered a defect. If the tissue in the j-th live-dead knot region has not completely separated from the wood, then the j-th live-dead knot region is not considered a defect. In this scheme, r=8 is set.
[0098] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A novel method for detecting defects in building timber based on histogram equalization, characterized in that, include: Obtain a grayscale image of the wood surface; High grayscale regions and low grayscale regions in the grayscale image of the wood surface were obtained by k-means clustering. Perform mean-shift clustering on pixels in low grayscale regions; A window with expanded size is established centered on the coordinates of the center pixel of each type of pixel to calculate the density of each type of pixel under each window size; Obtain the maximum density of each type of pixel under different sized windows, and determine the live and dead node region image based on the maximum density. Histogram equalization is performed on the live and dead node region map to obtain a live and dead node region image with enhanced contrast; Obtain the convex hull connected components in the contrast-enhanced live and dead knot region image, and perform a masking operation between the convex hull connected components and the grayscale image of the wood surface to obtain the grayscale image of the live and dead knot region. k-means clustering was used to separate high and low gray value regions in the grayscale image of live and dead nodes; Using the midpoint of the convex hull connected region of the grayscale image of the live and dead node region as the center, a window with expanded size is established to calculate the density of the grayscale image of the live and dead node region under different window sizes. The degree of variation of the grayscale image of the live and dead nodal region under each window size is obtained by combining the density of the grayscale image of the live and dead nodal region under different window sizes and the density of the image of the live and dead nodal region to which the grayscale image of the live and dead nodal region is located. The method for calculating the degree of change is as follows: In the formula, For the grayscale image of the living and dead junction region in size The degree of change under the window, The grayscale image of the live and dead knot region is in size [size missing]. Density under the window, The grayscale image of the live / dead node region is located in the image of the live / dead node region with a size of Density under the window; The information entropy of the degree of change of the grayscale image of each live and dead node region is obtained based on the frequency of the degree of change of the grayscale image of each live and dead node region under each window size. The method for calculating the frequency of variation of the grayscale image of each live and dead node region under each window size is as follows: The degree of change of the grayscale image of each live and dead node region under each size window is calculated, and all degrees of change of the grayscale image of the live and dead node region under all size windows are obtained; the frequency of the degree of change of the grayscale image of each live and dead node region under each size window among all degrees of change is taken as the frequency of the degree of change of the grayscale image of the live and dead node region under each size window. The information entropy of the degree of change in the grayscale image of the live and dead knot region is used as the stripping degree of the grayscale image of the live and dead knot region. Based on the stripping degree of the grayscale image of the live and dead knot region, it is determined whether the live and dead knot region in the grayscale image of the wood surface belongs to a live and dead knot. The method for obtaining the density of each type of pixel under each window size is as follows: Obtain the coordinates of the center pixel of each type of pixel; Establish with this coordinate as the center point Window size; The ratio of the number of low grayscale pixels in the window to the total number of pixels in the window is taken as the density of that type of pixel in the window.
2. The novel method for detecting defects in building timber based on histogram equalization according to claim 1, characterized in that, The method for obtaining the image of each live / dead node region is as follows: Expand the window size until it reaches the threshold; After each expansion of the window size, the density of each type of pixel within the current window size is calculated; Select the maximum density value for all window sizes for each type of pixel; If the maximum density value is greater than the threshold, then the window region corresponding to the maximum density value is the live / dead node region image.
3. The novel method for detecting defects in building timber based on histogram equalization according to claim 1, characterized in that, The method for calculating the information entropy of the degree of change in the grayscale image of each live and dead node region is as follows: In the formula, For the first Information entropy of the degree of change in grayscale image of each living and dead node region. For the first The degree of variation of the grayscale image of the nodal region across all window sizes is the [number]th. The frequency value of the degree of change.
4. The novel method for detecting defects in building timber based on histogram equalization according to claim 3, characterized in that, The method for determining live and dead knots in grayscale images of wood surfaces is as follows: Information entropy of the degree of change in grayscale image of each living and dead node region With threshold In comparison, if If the live / dead node region is positive, then it is a defect; otherwise, it is not a defect.
Citation Information
Patent Citations
Building board classification method utilizing electronic equipment data processing
CN114882275A