CN115239704B - Accurate detection and repair method for wood surface defects - Google Patents

Accurate detection and repair method for wood surface defects Download PDF

Info

Publication number
CN115239704B
CN115239704B CN202211134148.5A CN202211134148A CN115239704B CN 115239704 B CN115239704 B CN 115239704B CN 202211134148 A CN202211134148 A CN 202211134148A CN 115239704 B CN115239704 B CN 115239704B
Authority
CN
China
Prior art keywords
gray
image block
image
value
suspected
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211134148.5A
Other languages
Chinese (zh)
Other versions
CN115239704A (en
Inventor
张鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nantong Youlian New Material Technology Co ltd
Original Assignee
Nantong Youlian New Material Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nantong Youlian New Material Technology Co ltd filed Critical Nantong Youlian New Material Technology Co ltd
Priority to CN202211134148.5A priority Critical patent/CN115239704B/en
Publication of CN115239704A publication Critical patent/CN115239704A/en
Application granted granted Critical
Publication of CN115239704B publication Critical patent/CN115239704B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20021Dividing image into blocks, subimages or windows
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30161Wood; Lumber
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Quality & Reliability (AREA)
  • Image Processing (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)

Abstract

The application relates to the technical field of electric digital data processing, in particular to a method for accurately detecting and repairing defects on the surface of wood. Acquiring a gray image corresponding to a surface image of wood to be detected; acquiring suspected defective pixel points, acquiring the sizes of image blocks based on the maximum continuous number of the suspected defective pixel points in the horizontal direction and the vertical direction, and dividing a gray image into a plurality of image blocks; obtaining a defective image block based on kurtosis of a distribution curve corresponding to each image block; obtaining suspected defect areas of each defect image block, obtaining a distribution curve of the suspected defect areas after linear stretching, marking each gray value between gray values corresponding to the first peak and the last peak on the distribution curve as a threshold value, calculating weights of the thresholds according to distribution probabilities of peaks closest to the left side and the right side of the thresholds, further obtaining an optimal threshold value, obtaining the defect areas based on the optimal threshold value, and repairing the defect areas. The application can accurately obtain the defect of the wood surface.

Description

Accurate detection and repair method for wood surface defects
Technical Field
The application relates to the technical field of electric digital data processing, in particular to a method for accurately detecting and repairing defects on the surface of wood.
Background
The quality of wood plays a decisive role in the value of wood itself and wood products, wood defects being a key factor affecting the quality of wood; the most common defects on the surface of the wood are wormholes, movable joints and dead joints, which not only can influence the surface quality of the wood, change the normal performance of the wood and reduce the utilization rate and the use value of the wood, but also can directly influence the strength, the appearance and the grade of a wood product, so that the profile characteristics of the defects on the surface of the wood are accurately extracted, and the defect of the surface of the wood is an important link in the processing process of the wood product; the forestry industry in China is relatively undeveloped, wood resources are short, the defective wood is repaired, the wood resources are fully utilized, and great significance is provided for improving the commercial value and the economic value of the wood.
In the production process of wood products, common detection modes of wood surface defects include manual detection, mechanical detection, ray detection and the like. The result of manual detection is extremely easy to be influenced by external factors, such as high working strength, lack of concentration of workers and excessively noisy detection environment, and the factors can lead to inaccurate result of manual detection and easy occurrence of detection omission or false detection; the complexity and the diversity of the wood surface defects in the aspects of variety, size, shape, color and the like are easily affected by wood textures, so that the defect positioning by manual detection is more difficult; compared with manual detection, the mechanical detection has higher detection precision, but has higher detection cost, increases economic cost and is not well applicable; the radiation detection has high requirements on the protection condition and is difficult to realize.
Disclosure of Invention
In order to solve the technical problems, the application aims to provide a method for accurately detecting and repairing the surface defects of wood, which adopts the following technical scheme:
acquiring a surface image of wood to be detected, and preprocessing the surface image to obtain a gray image;
calculating a gray average value corresponding to the gray image, marking the gray average value as a first gray average value, marking pixel points corresponding to the gray average value larger than the first gray average value as suspected defect pixel points, respectively acquiring the maximum continuous number of the suspected defect pixel points corresponding to the horizontal direction and the vertical direction, acquiring the size of an image block based on the maximum continuous number, and dividing the gray image block into a plurality of image blocks; the image blocks comprise a defect image block and a normal image block;
fitting each gray value and the number of corresponding pixel points in each image block respectively to obtain a distribution curve corresponding to each image block; calculating kurtosis corresponding to each distribution curve, calculating a gray average value corresponding to each image block, marking the gray average value as a second gray average value, and obtaining each defective image block based on the kurtosis and the second gray average value;
based on the second gray level average value, obtaining a suspected defect area corresponding to each defect image block, performing linear stretching operation on the suspected defect area, obtaining a distribution curve corresponding to the suspected defect area after linear stretching, marking each gray level value between gray level values corresponding to a first peak and a last peak on the distribution curve as a threshold value, calculating the weight of each threshold value according to the distribution probability corresponding to the peak closest to the left side and the right side of each threshold value, and obtaining the optimal threshold value corresponding to each suspected defect area based on the weight; the suspected defect area comprises a defect area and a wood grain area;
and acquiring a defect area and a wood grain area based on the optimal threshold value, and repairing the defect area.
Further, the method for obtaining the size of the image block comprises the following steps: and acquiring a larger value of the maximum continuous number of the suspected defective pixel points corresponding to the horizontal direction and the maximum continuous number of the suspected defective pixel points corresponding to the vertical direction, and taking the value obtained by adding 1 to the larger value as the size of the image block.
Further, the image block includes a combined image block, and the method for obtaining the combined image block includes: taking the first image block at the upper left corner of the gray image as a starting image block, traversing the image blocks one by one from left to right and from top to bottom; when the image blocks in the traversal process and the adjacent image blocks contain suspected defective pixel points, judging whether two connected domains formed by the corresponding suspected defective pixel points in the two image blocks are connected, and if so, merging the corresponding two image blocks to obtain a merged image block; otherwise, the combination is not performed.
Further, the method for obtaining the distribution probability comprises the following steps: and acquiring a gray value corresponding to the peak, obtaining the number of pixels corresponding to the gray value, and recording the ratio of the number of pixels to the total number of pixels in the suspected defect area as the distribution probability corresponding to the peak.
Further, the abscissa of the distribution curve is a gray value, and the ordinate is the number of pixels.
Further, the method for obtaining the defective image block comprises the following steps: calculating average kurtosis based on kurtosis corresponding to all distribution curves; and marking the image block corresponding to the second gray level average value smaller than the first gray level average value and the kurtosis smaller than the average kurtosis as a defect image block.
Further, the suspected defect area is formed by pixel points corresponding to gray values smaller than the second gray average value in the image block.
Further, the method for obtaining the optimal threshold value comprises the following steps: calculating the product of the inter-class variance and the weight corresponding to each threshold, wherein the threshold corresponding to the maximum value of the product is the optimal threshold;
the weight is as follows:
wherein ,weight corresponding to threshold t +.>For the distribution probability of the gray value corresponding to the threshold t, < >>For the probability of the distribution of the gray values corresponding to the nearest peak to the left of the threshold t +.>The probability of the distribution of the corresponding gray values for the nearest peak to the right of the threshold t.
Further, the defect area is composed of pixels corresponding to the suspected defect area with gray values smaller than the optimal threshold, and the wood grain area is composed of pixels corresponding to the suspected defect area with gray values larger than the optimal threshold.
The embodiment of the application has at least the following beneficial effects:
the method comprises the steps of obtaining the size of an image block and dividing a gray image into a plurality of image blocks through the maximum continuous number of suspected defective pixel points in the horizontal direction and the vertical direction; the defect detection method and device have the advantages that a series of problems that detection of a defect area with smaller area becomes difficult due to overlarge image block division, and the defect detection speed is reduced due to the overlarge image block division, so that the defect area with larger area is positioned in different image blocks, and the defect area is difficult to position in the subsequent repair process are avoided; the method obtains a defective image block based on kurtosis of a distribution curve corresponding to each image block; the features of the distribution curves corresponding to different image blocks are different, and the kurtosis can intuitively represent the features of the distribution curves, so that the defect image blocks can be obtained based on the kurtosis. And then, carrying out linear stretching operation on the suspected defect area in the defect image block to ensure that the gray value range corresponding to the suspected defect area is consistent with the gray value range corresponding to the defect image block, enhancing the contrast of the suspected defect area, namely amplifying the difference between the defect area and the wood grain area in the suspected defect area, providing more convenient conditions for obtaining the defect area subsequently, and being capable of rapidly and accurately obtaining the defect area. The application also calculates the weight of each threshold value through the distribution probability of the wave crest closest to the left side and the right side of each threshold value, and obtains the optimal threshold value based on the weight, so that the obtained optimal threshold value is more accurate, and the defect area obtained based on the optimal threshold value is more accurate. Therefore, the application has the characteristics of high detection efficiency, high detection speed and capability of accurately acquiring the defect area.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the application, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of steps of an embodiment of a method for accurately detecting and repairing a defect on a surface of a wood material according to the present application;
FIG. 2 is a surface image of a wood board to be inspected;
fig. 3 is a normal image block;
FIG. 4 is a distribution curve corresponding to FIG. 3;
fig. 5 is a defective image block having a defective area 1;
FIG. 6 is a distribution curve corresponding to FIG. 5;
fig. 7 is a defective image block having a defective area 2;
FIG. 8 is a distribution curve corresponding to FIG. 7;
fig. 9 is a defective image block;
FIG. 10 is a schematic diagram of the suspected defect region of FIG. 9;
fig. 11 is a distribution curve corresponding to the suspected defect region after linear stretching.
Detailed Description
In order to further describe the technical means and effects adopted by the present application to achieve the preset purpose, the following detailed description of the specific embodiments, structures, features and effects thereof according to the present application is given with reference to the accompanying drawings and the preferred embodiments. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
Referring to fig. 1, a flowchart of a method for accurately detecting and repairing a defect on a wood surface according to an embodiment of the application is shown, the method includes the following steps:
step 1, obtaining a surface image of wood to be detected, and preprocessing the surface image to obtain a gray level image.
Specifically, set up the camera in the conveyer top, look down the image of gathering the timber that waits to detect on the conveyer through the camera, not only include the surface image of waiting to detect timber in the image still include the background image, consequently, this embodiment utilizes neural network model to acquire the surface image of waiting to detect timber, and the concrete process is: inputting the image into a trained neural network model, outputting a binary image, wherein a pixel point with a pixel value of 1 in the binary image is a pixel point corresponding to a surface image of the wood to be detected, multiplying the binary image with the image to obtain the surface image of the wood to be detected, and then obtaining the surface image of the single wood by morphological open operation; wherein, morphological opening operation is a known technique and will not be described in detail.
The neural network model in this embodiment is DNN, the data set for training DNN is a data set of wood images on a conveyor collected by looking down a camera, before DNN is trained, labels need to be marked, namely, pixels belonging to the background are marked as 0, pixels belonging to the wood surface are marked as 1, and the task of DNN is classification, so that the loss function of DNN is a cross entropy loss function, wherein the training process of DNN is a known technology and is not in the scope of protection of the present application, and is not repeated.
Further, in order to reduce the subsequent calculation amount, the embodiment adopts a weighted average method to carry out graying treatment on the surface image so as to obtain a gray image; as another embodiment, the practitioner may select a maximum value method, a component method, or the like to perform graying processing on the surface image, and the graying processing is a technique well known to those skilled in the art and will not be described in detail. Then, in order to reduce the influence of noise, a 3×3 window is adopted and a mean filtering method is utilized to carry out smooth denoising operation on the gray level image, so that a denoised gray level image is obtained, and the mean filtering is a known technology and is not repeated.
Step 2, calculating a gray average value corresponding to the gray image, marking the gray average value as a first gray average value, marking pixel points smaller than the first gray average value as suspected defective pixel points, respectively obtaining the maximum continuous number of the suspected defective pixel points corresponding to the horizontal direction and the vertical direction, obtaining the size of an image block based on the maximum continuous number, and dividing the gray image block into a plurality of image blocks; the image blocks include a defective image block and a normal image block.
Since the defect area on the surface of the wood often occupies only a small part of the total area of the wood, as shown in fig. 2, fig. 2 is a surface image of the wood board to be detected, and thus the surface image of the wood to be detected needs to be subjected to the blocking treatment. When the surface image of the wood to be detected is segmented into large blocks, the detection of the defect area with small area becomes difficult, and when the surface image of the wood to be detected is segmented into small blocks, the defect detection speed is reduced, and meanwhile, the defect area with large area is caused to be in different image blocks, so that the defect area is difficult to position in the subsequent repairing process; meanwhile, the divided image blocks cannot only contain the defect areas, and if the image blocks only contain the defect areas, the positioning and repairing of the subsequent defect areas can be affected; based on this, the present embodiment first acquires the suspected defective pixel point in the surface image, and then adaptively acquires the size of the image block by the maximum continuous number of the suspected defective pixel point in the ten-direction and the vertical direction.
Specifically, a gray average value corresponding to a gray image is calculated and recorded as a first gray average value, and a pixel point corresponding to the gray average value smaller than the first gray average value is recorded as a suspected defect pixel point.
Compared with the plank area, the gray value of the pixel corresponding to the defect area is smaller than the gray value of the pixel corresponding to the plank area, and the area of the defect area is smaller, namely the number of the pixel of the defect area is much smaller than the number of the pixel of the plank area, so that the first gray average value is more prone to the gray value of the pixel corresponding to the plank area, and therefore the pixel in the gray image can be roughly divided through the first gray average value to obtain the suspected defect pixel.
The method for acquiring the size of the middle image block comprises the following steps: and acquiring a larger value of the maximum continuous number of the suspected defective pixel points corresponding to the horizontal direction and the maximum continuous number of the suspected defective pixel points corresponding to the vertical direction, and taking the value obtained by adding 1 to the larger value as the size of the image block, namely the size of the image block is (q+1) x (q+1), wherein q is the larger value of the two values.
The method for obtaining the maximum continuous number of the suspected defective pixel points corresponding to the suspected defective pixel points in the horizontal direction comprises the following steps: firstly, marking suspected defective pixel points as 1, and marking the rest other pixel points as 0 to obtain a defect binary image; and counting the number of pixel points with continuous 1 in the defect binary image line by line, and recording the maximum value of the number of pixel points in each line as the continuous number of the suspected defect pixel points corresponding to the line, namely the continuous number of the suspected defect pixel points corresponding to the horizontal direction, so as to obtain the continuous number of the suspected defect pixel points corresponding to all horizontal directions, and further obtain the maximum continuous number of the suspected defect pixel points corresponding to the horizontal direction.
The method for obtaining the maximum continuous number of the suspected defective pixel points corresponding to the vertical direction comprises the following steps: counting the number of pixel points with continuous 1 in the defect binary image column by column, and recording the maximum value of the number of pixel points in each column as the corresponding continuous number of suspected defect pixel points in the column, namely the corresponding continuous number of the suspected defect pixel points in the vertical direction, so as to obtain the corresponding continuous number of the suspected defect pixel points in all vertical directions, and further obtain the corresponding maximum continuous number of the suspected defect pixel points in the vertical direction.
Further, since the defective areas of the wood are scattered at various portions of the surface image, in order to avoid that the same defective areas are distributed in different image blocks during the division of the image blocks, it is necessary to merge some of the image blocks to obtain merged image blocks, so as to avoid this phenomenon. The method for acquiring the combined image block comprises the following steps: taking the first image block at the upper left corner of the gray image as a starting image block, traversing the image blocks one by one from left to right and from top to bottom; if the image blocks in the traversal process and the adjacent image blocks contain suspected defective pixel points, judging whether two connected domains formed by the corresponding suspected defective pixel points in the two image blocks are connected, if so, merging the corresponding two image blocks to obtain a merged image block, otherwise, not merging.
The size of the image block is obtained by the maximum continuous number of the suspected defective pixel points corresponding to the vertical direction in the horizontal direction; the size of the image block can be obtained in a self-adaptive mode, the problem that the detection result is inaccurate due to the fact that the image block is too large or too small is solved, further, when two adjacent image blocks contain suspected defect pixel points, whether two connected domains formed by the corresponding suspected defect pixel points in the two image blocks are connected or not is judged, and if the two connected domains are connected, the corresponding two image blocks are combined to obtain a combined image block; the acquisition of the combined image blocks can ensure that the same defect area is divided into one image block, and the problems of inaccurate positioning and difficult repair of the defect area in the subsequent process caused by the fact that the same defect area is divided into a plurality of image blocks are avoided.
Step 3, fitting each gray value and the number of corresponding pixel points in each image block to obtain a distribution curve corresponding to each image block; and calculating kurtosis corresponding to each distribution curve, calculating a gray average value corresponding to each image block, marking the gray average value as a second gray average value, and obtaining each defective image block based on the kurtosis and the second gray average value.
Specifically, the abscissa of the distribution curve is a gray value, and the ordinate is the number of pixel points; the distribution curves corresponding to different image blocks are different, as shown in fig. 3 to 8, and fig. 3 is a normal image block; fig. 4 is a distribution curve corresponding to fig. 3, fig. 5 is a defective image block having a defective area 1, fig. 6 is a distribution curve corresponding to fig. 5, fig. 7 is a defective image block having a defective area 2, and fig. 8 is a distribution curve corresponding to fig. 7; as can be seen from fig. 5 and 7, the defect area 1 is different from the defect area 2, and the distribution curves corresponding to fig. 5 and 7 are different, but the distribution curves corresponding to fig. 5 and 7 have a common point, i.e., the distribution curves are shorter and fatter than the distribution curves corresponding to fig. 3.
Based on the analysis, it can be concluded that the distribution curve corresponding to the normal image block has the characteristics of small gray value range, narrow waveform range, high peak value and the like, while the distribution curve corresponding to the image block with other defect areas has the characteristics of large gray value range, wide waveform range relative to the normal image block, and double peaks appear in the distribution curve corresponding to the image block when the defect area is large; kurtosis can characterize the distribution curve, namely, the larger the kurtosis is, the higher the point of the distribution curve is, and the smaller the kurtosis is, the shorter the distribution curve is, so that the normal image block can be separated from the defect image block through the kurtosis of the distribution curve.
Specifically, the kurtosis corresponding to each image block is calculated according to the number of gray values in each image block and the number of pixel points corresponding to each gray value, and a specific process of obtaining kurtosis is described by taking an image block B as an example, wherein the specific process is as follows: counting the number of pixel points corresponding to each gray value according to the distribution curve to obtain a set, in the formula />The number of pixel points corresponding to the gray value i is n, and the number of the gray values is n; computing set->Is recorded as +.>And further obtaining the kurtosis corresponding to the image block B, wherein the calculation formula is as follows:
in the formula ,kurtosis corresponding to image block B, +.>For the number of pixels corresponding to the gray value i, < >>For the collection->N is the number of gray values; the numerator in the formula is the set +.>The denominator in the formula is the set +.>The calculation of kurtosis is a well-known technique and will not be described in detail.
The method for obtaining the defective image block in this embodiment is as follows: calculating average kurtosis based on kurtosis corresponding to all distribution curves; and marking the image block corresponding to the second gray level average value smaller than the first gray level average value and the kurtosis smaller than the average kurtosis as a defect image block.
It should be noted that, the features of the distribution curves corresponding to different image blocks are different, the kurtosis can intuitively reflect the features of the distribution curves, that is, the distribution curve with larger kurtosis is more sharp, the distribution curve with smaller kurtosis is more short and fat, the feature of the distribution curve corresponding to a normal image block is high and the feature of the distribution curve corresponding to a defective image block is short and fat; the second gray average value corresponding to the normal image block is closer to the first gray average value corresponding to the gray image; the deviation between the second gray average value corresponding to the defect image block and the first gray average value corresponding to the gray image is larger; because the defect exists in the defective image block, the gray value at the defect is smaller, and therefore, the second gray average value corresponding to the defective image block is smaller than the first gray average value; based on the peak value and the second gray level average value, each defective image block can be accurately obtained.
And 4, obtaining suspected defect areas corresponding to the defect image blocks based on the second gray level average value, performing linear stretching operation on the suspected defect areas, obtaining a distribution curve corresponding to the suspected defect areas after linear stretching, recording each gray level value between the gray level value corresponding to the first peak and the gray level value corresponding to the last peak on the distribution curve as a threshold value, calculating the weight of each threshold value according to the distribution probability of the gray level value corresponding to the peak nearest to the left side and the right side of each threshold value, and obtaining the optimal threshold value corresponding to each suspected defect area based on the weight.
The suspected defect area is formed by pixel points corresponding to the gray value smaller than the second gray average value in the image block. As shown in fig. 9 to 10, fig. 9 is a defective image block, and fig. 10 is a suspected defective area in fig. 9, wherein the suspected defective area includes a defective area and a wood grain area.
Further, the linear stretching operation is carried out on the suspected defect area, so that the gray value range corresponding to the suspected defect area is consistent with the gray value range corresponding to the defect image block, the contrast of the suspected defect area is enhanced, and the accurate defect area can be conveniently obtained later. Specifically, gray values in the suspected defect areas are arranged in order from small to large to obtain a gray value sequence corresponding to the suspected defect areas, and gray values corresponding to each gray value in the gray value sequence after linear stretching operation are calculated according to the gray value range corresponding to the defect image block, the gray value range corresponding to the suspected defect areas in the defect image block and the gray value sequence.
The formula of linear stretching is:
wherein ,maximum gray value for defective image block, < >>For the minimum gray value corresponding to the defective image block, is>For the maximum gray value corresponding to the suspected defective area in the defective image block,/for>For the minimum gray value corresponding to the suspected defective area in the defective image block,/for>For the y-th gray value in the sequence of gray values, is->The y-th gray value in the gray value sequence corresponds to the gray value after the linear stretching operation. The linear stretching is a known technique and will not be described in detail.
The linear stretching is performed on the suspected defect area, so that the contrast of the suspected defect area is increased, the gray value corresponding to the wood grain area in the suspected defect area after the linear stretching is greatly different from the gray value corresponding to the defect area, the distribution curve corresponding to the suspected defect area after the linear stretching is characterized by being obviously bimodal, and the distribution curve corresponding to the suspected defect area after the linear stretching is shown in fig. 11, but the gray values corresponding to the defect area are different due to the linear stretching of the suspected defect area, and the gray values corresponding to the wood grain area are also different, so that a plurality of peaks and troughs exist in the distribution curve, and the calculation of the optimal threshold value is influenced. Therefore, in this embodiment, each gray value between the gray value corresponding to the first peak and the gray value corresponding to the last peak on the distribution curve is recorded as a threshold value, the weight of each threshold value is calculated according to the distribution probability of the gray value corresponding to the peak nearest to the left and right sides of each threshold value, and the optimal threshold value corresponding to each suspected defect area is obtained based on the weight.
The method for obtaining the optimal threshold value comprises the following steps: calculating the product of the inter-class variance and the weight corresponding to each threshold, wherein the threshold corresponding to the maximum value of the product is the optimal threshold; the inter-class variance is a known technique and will not be described in detail.
The weight is as follows:
wherein ,weight corresponding to threshold t +.>For the distribution probability of the gray value corresponding to the threshold t, < >>For the probability of the distribution of the gray values corresponding to the nearest peak to the left of the threshold t +.>The probability of the distribution of the corresponding gray values for the nearest peak to the right of the threshold t.
The method for acquiring the middle distribution probability comprises the following steps: and acquiring a gray value corresponding to the peak, obtaining the number of pixels corresponding to the gray value, and recording the ratio of the number of pixels to the total number of pixels in the suspected defect image block as the distribution probability corresponding to the peak.
It should be noted that, the distribution probability is calculated from the gray value corresponding to the peak and the number of the pixels thereof, and the distribution probability can represent the height of the corresponding peak, so that the weight can be understood as being obtained based on the height of the peak, the greater the height difference between the corresponding peaks at the left side and the right side of the threshold is, the greater the weight corresponding to the threshold is, the threshold can better divide the wood grain region and the defect region in the suspected defect region, and the greater the probability that the threshold is the optimal threshold is, and the height difference and the weight of the peak are in positive correlation.
And step 5, acquiring a defect area and a wood grain area based on the optimal threshold value, and repairing the defect area.
The defect area is composed of pixels corresponding to the gray values smaller than the optimal threshold value in the suspected defect area, and the wood grain area is composed of pixels corresponding to the gray values larger than the optimal threshold value in the suspected defect area.
Further, performing morphological open operation processing on the defect area, removing isolated pixel points, and then performing morphological filling processing to obtain an accurate defect area; obtaining the minimum circumscribing circle corresponding to each defect area, counting the diameter of the minimum circumscribing circle, digging out the minimum circumscribing circle corresponding to each defect area by a processing method, filling a round wood plug with the diameter identical to the diameter of the minimum circumscribing circle and the height identical to the thickness of the wood into the corresponding position of the wood, and performing drying and polishing operations to repair the defect area on the surface of the wood. Wherein, morphological open operation and morphological filling are well known techniques and will not be described in detail.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application and are intended to be included within the scope of the application.

Claims (6)

1. The accurate detection and repair method for the wood surface defects is characterized by comprising the following steps of:
acquiring a surface image of wood to be detected, and preprocessing the surface image to obtain a gray image;
calculating a gray average value corresponding to the gray image, marking the gray average value as a first gray average value, marking pixel points smaller than the first gray average value as suspected defect pixel points, respectively acquiring the maximum continuous number of the suspected defect pixel points corresponding to the horizontal direction and the vertical direction, acquiring the size of an image block based on the maximum continuous number, and dividing the gray image block into a plurality of image blocks; the image blocks comprise a defect image block and a normal image block;
fitting each gray value and the number of corresponding pixel points in each image block respectively to obtain a distribution curve corresponding to each image block; calculating kurtosis corresponding to each distribution curve, calculating a gray average value corresponding to each image block, marking the gray average value as a second gray average value, and obtaining each defective image block based on the kurtosis and the second gray average value;
based on the second gray level average value, obtaining a suspected defect area corresponding to each defect image block, performing linear stretching operation on the suspected defect area, obtaining a distribution curve corresponding to the suspected defect area after linear stretching, marking each gray level value between gray level values corresponding to a first peak and a last peak on the distribution curve as a threshold value, calculating the weight of each threshold value according to the distribution probability corresponding to the peak closest to the left side and the right side of each threshold value, and obtaining the optimal threshold value corresponding to each suspected defect area based on the weight; the suspected defect area comprises a defect area and a wood grain area;
based on the optimal threshold value, obtaining a defect area and a wood grain area, and repairing the defect area;
the method for acquiring the optimal threshold value comprises the following steps: calculating the product of the inter-class variance and the weight corresponding to each threshold, wherein the threshold corresponding to the maximum value of the product is the optimal threshold;
the weight is as follows:
;
wherein ,weight corresponding to threshold t +.>For the distribution probability of the gray value corresponding to the threshold t, < >>For the probability of the distribution of the gray values corresponding to the nearest peak to the left of the threshold t +.>The probability of the distribution of the gray value corresponding to the nearest peak to the right of the threshold t;
the method for acquiring the size of the image block comprises the following steps: acquiring a larger value of the maximum continuous number of the suspected defect pixel points corresponding to the horizontal direction and the maximum continuous number of the suspected defect pixel points corresponding to the vertical direction, and taking the value obtained by adding 1 to the larger value as the size of an image block;
the image block comprises a combined image block, and the acquisition method of the combined image block comprises the following steps: taking the first image block at the upper left corner of the gray image as a starting image block, traversing the image blocks one by one from left to right and from top to bottom; when the image blocks in the traversal process and the adjacent image blocks contain suspected defective pixel points, judging whether two connected domains formed by the corresponding suspected defective pixel points in the two image blocks are connected, and if so, merging the corresponding two image blocks to obtain a merged image block; otherwise, the combination is not performed.
2. The method for accurately detecting and repairing the surface defects of the wood according to claim 1, wherein the method for obtaining the distribution probability is as follows: and acquiring a gray value corresponding to the peak, obtaining the number of pixels corresponding to the gray value, and recording the ratio of the number of pixels to the total number of pixels in the suspected defect area as the distribution probability corresponding to the peak.
3. The method for accurately detecting and repairing the surface defects of the wood according to claim 1, wherein the abscissa of the distribution curve is a gray value, and the ordinate is the number of pixels.
4. The method for accurately detecting and repairing the surface defects of the wood according to claim 1, wherein the method for acquiring the defective image blocks is as follows: calculating average kurtosis based on kurtosis corresponding to all distribution curves; and marking the image block corresponding to the second gray level average value smaller than the first gray level average value and the kurtosis smaller than the average kurtosis as a defect image block.
5. The method for accurately detecting and repairing the surface defects of the wood according to claim 1, wherein the suspected defect area is formed by pixel points corresponding to gray values smaller than the second gray average value in the image block.
6. The method for accurately detecting and repairing the surface defects of the wood according to claim 1, wherein the defect area is composed of pixels corresponding to gray values smaller than an optimal threshold value in a suspected defect area, and the wood grain area is composed of pixels corresponding to gray values larger than the optimal threshold value in the suspected defect area.
CN202211134148.5A 2022-09-19 2022-09-19 Accurate detection and repair method for wood surface defects Active CN115239704B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211134148.5A CN115239704B (en) 2022-09-19 2022-09-19 Accurate detection and repair method for wood surface defects

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211134148.5A CN115239704B (en) 2022-09-19 2022-09-19 Accurate detection and repair method for wood surface defects

Publications (2)

Publication Number Publication Date
CN115239704A CN115239704A (en) 2022-10-25
CN115239704B true CN115239704B (en) 2023-11-03

Family

ID=83681335

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211134148.5A Active CN115239704B (en) 2022-09-19 2022-09-19 Accurate detection and repair method for wood surface defects

Country Status (1)

Country Link
CN (1) CN115239704B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115457037B (en) * 2022-11-10 2023-03-24 澳润(山东)药业有限公司 Raw material quality inspection method for donkey-hide gelatin product production
CN115457035B (en) * 2022-11-10 2023-03-24 山东鲁旺机械设备有限公司 Machine vision-based construction hanging basket welding quality detection method
CN115861290B (en) * 2022-12-30 2024-01-19 南京林业大学 Skin-feel wood door surface defect detection method
CN116092015B (en) * 2023-04-06 2023-06-27 安徽乾劲企业管理有限公司 Road construction state monitoring method
CN116205911B (en) * 2023-04-27 2023-07-18 济南市莱芜区综合检验检测中心 Machine vision-based method for detecting appearance defects of leather sports goods
CN116309671B (en) * 2023-05-23 2023-08-11 浩珂科技有限公司 Geosynthetic fabric quality detection system
CN116630332B (en) * 2023-07-26 2023-09-26 山东华航高分子材料有限公司 PVC plastic pipe orifice defect detection method based on image processing
CN116823808B (en) * 2023-08-23 2023-11-17 青岛豪迈电缆集团有限公司 Intelligent detection method for cable stranded wire based on machine vision
CN117011292B (en) * 2023-09-28 2023-12-15 张家港飞腾复合新材料股份有限公司 Method for rapidly detecting surface quality of composite board
CN117078667B (en) * 2023-10-13 2024-01-09 山东克莱蒙特新材料科技有限公司 Mineral casting detection method based on machine vision

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112862773A (en) * 2021-01-29 2021-05-28 山东建筑大学 Shaving board image defect classification detection method and device
CN114913365A (en) * 2022-04-22 2022-08-16 海门王巢家具制造有限公司 Artificial board quality classification method and system based on machine vision
CN114627117B (en) * 2022-05-13 2022-07-15 启东市鸿盛纺织有限公司 Knitted fabric defect detection method and system based on projection method

Also Published As

Publication number Publication date
CN115239704A (en) 2022-10-25

Similar Documents

Publication Publication Date Title
CN115239704B (en) Accurate detection and repair method for wood surface defects
CN114842017B (en) HDMI cable surface quality detection method and system
CN114937055B (en) Image self-adaptive segmentation method and system based on artificial intelligence
CN115170576B (en) Aluminum pipe surface defect detection method based on machine vision
CN112651968B (en) Wood board deformation and pit detection method based on depth information
CN115082418A (en) Precise identification method for automobile parts
CN115345885A (en) Method for detecting appearance quality of metal fitness equipment
CN110930390B (en) Chip pin missing detection method based on semi-supervised deep learning
CN117152161B (en) Shaving board quality detection method and system based on image recognition
CN115953398B (en) Defect identification method for strip steel surface
CN115375686B (en) Glass edge flaw detection method based on image processing
CN111753794B (en) Fruit quality classification method, device, electronic equipment and readable storage medium
CN114820625B (en) Automobile top block defect detection method
CN115018827B (en) Automatic detection method for quality of building material weld joint
CN116188468B (en) HDMI cable transmission letter sorting intelligent control system
CN117635609B (en) Visual inspection method for production quality of plastic products
CN115171218A (en) Material sample feeding abnormal behavior recognition system based on image recognition technology
CN114549441A (en) Sucker defect detection method based on image processing
CN118096739B (en) Metal forging surface defect detection method based on image processing
CN117585399B (en) Coal mine conveyor belt tearing detection method based on image processing
CN117853494B (en) Visual inspection method for drug particle production process
CN117314901B (en) Scale-adaptive chip detection neural network system
CN117522778A (en) Hollow brick flaw detection system
CN116309561B (en) Surface defect identification method based on anti-creeping insulating material
CN115330769B (en) Defect detection method for aluminum pipe surface scratching and indentation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant