A wood color restoration method based on image fusion and matching
By clustering and image processing in the wood gallery, the sample gallery and the darkening gallery are generated, and color features matching and repairing are performed for wood images with insufficient lighting, which solves the problem of darkening and distortion of wood images under insufficient lighting, and achieves accurate restoration and repair of wood colors.
Patent Information
- Application Number
- CN202111557885.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2041-12-17
AI Technical Summary
In the case of insufficient lighting conditions, the color of the wood image will cause color difference due to changes in light, and it is difficult for the prior art to effectively reduce the color characteristics of the wood itself.
The color feature vector is calculated by the pictures in the wood gallery and K-means clustering is performed. Each category center is extracted, and the sample image gallery and darkening image gallery are generated based on the clustering results. Pictures with similar color features are extracted for images with insufficient lighting are counted in the darkening image gallery, and the histogram of the original image is accumulated, and the image is specified to repair the color.
Under insufficient lighting, the color of the wood image can be effectively repaired, ensuring the accurate reflection of the RGB color characteristics of the wood surface, and avoiding image color distortion caused by changes in lighting conditions.
Smart Images

Figure CN114266912B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of wood color recognition, and in particular to a wood color restoration method based on image fusion and matching under insufficient lighting conditions. Background Art
[0002] As people's quality of life continues to improve, people are increasingly concerned about the aesthetics of wood furniture. Therefore, industrial production requires that the colors of different boards be coordinated to achieve a satisfactory viewing effect.
[0003] In the process of collecting wood images, the color of the wood images will change due to changes in the projected light, and the photos collected under different lighting conditions will have different color differences. However, in actual industrial environments, the lighting conditions cannot always remain ideal. How to restore the color characteristics of the wood itself in the wood images poses a challenge to the wood industry.
[0004] Based on the traditional contrast enhancement, the image quality is improved, and the grayscale range of the image is enlarged, so that the image is clearer. However, simply using contrast enhancement will lose some details of the original bright area, and the image will appear slightly blurred, so that the color characteristics of the wood surface are lost. In order to solve this problem, the present invention selects multiple pictures with similar color characteristics based on the clustering results for regulation, so that the picture can restore the color characteristics of the wood itself to the maximum extent under insufficient lighting conditions.
[0005] The Chinese patent application number is: CN201910650743.6, and the name is: White balance correction method, device, equipment and storage medium. The embodiment of the invention discloses a white balance correction method, device, equipment and storage medium. The method includes: extracting features associated with at least two white balance correction algorithms from the image to be corrected, and determining feature values; determining weight values of at least two white balance correction algorithms according to the feature values; determining the fused white balance gain of each color channel in the image to be corrected according to the weight values of at least two white balance correction algorithms and the statistical values of grayscale data of at least two color channels in the image to be corrected corresponding to the at least two white balance algorithms, and then performing white balance correction on the image to be corrected. This method does not take into account the real-time performance in an industrial environment, and the algorithm runs for too long, so this method is not applicable to the present invention.
[0006] The Chinese patent application number is: CN201210529741.X, and the name is: Image white balance processing method and device. This invention example discloses an image white balance processing method and device, which includes obtaining the color value data of the image, judging whether each pixel unit is within the color temperature deviation threshold according to the color value data, selecting a point within the threshold range as a reference gray point, and calculating the white balance correction coefficient according to the color mean of the reference gray point. This method does not take into account the color difference between multiple light points and cannot be adjusted according to production needs. Summary of the invention
[0007] The purpose of the present invention is to provide a wood color restoration method based on image fusion and matching in order to restore the color characteristics of a collected wood image under insufficient lighting conditions. The method can effectively restore the color of the wood image under different degrees of insufficient lighting conditions.
[0008] To achieve the above purpose, the technical solution of the present invention is: a wood color restoration method based on image fusion and matching, firstly, the color feature vector is calculated through the pictures in the wood library and K-means clustering is performed to extract the center of each category, and the original picture is selected for each category according to the 3σ principle to generate a sample library P scr , and then darken to different degrees to generate gallery b scr ; For images collected when the light is insufficient, that is, dark images, in the gallery b scr Extract a pictures closest to the color feature vector of the dark picture, and select the a pictures closest to the sample library P scr The original image is extracted from the image processing unit, the histogram of the original image is counted and accumulated, and the dark image is normalized according to the accumulated histogram to obtain the restored image.
[0009] In one embodiment of the present invention, the color feature vector is calculated from the pictures in the wood library and K-means clustering is performed to extract the center of each category as follows:
[0010] For the wood color in N wood image libraries, all sample histograms are counted and accumulated. According to the accumulated histogram, the color interval range in each RGB channel is selected to obtain a subspace under the RGB color space. The interval is divided into n bins to obtain an n*n*n cubic matrix. The cubic matrix is expanded to obtain the feature vector The length of the characteristic frequency vector is n 3 , each value represents the proportion of the number of times each color appears in the color space of wood to the number of times all colors appear;
[0011] Select the number of categories K, perform K-means clustering on all feature vectors, and retain the center of each category.
[0012] In one embodiment of the present invention, the sample library P is generated by selecting original images for each category according to the 3σ principle. scr The implementation is:
[0013] For each category, calculate the distance between the samples of each category and the center of the category, sort the distances between the samples and the category center from small to large, and calculate the mean and variance respectively;
[0014] According to the 3σ principle, 8a images are selected equidistantly in the interval (u-3σ, u+3σ) and saved into the sample library P. scr , select a pictures in the interval (-∞, u-3σ) and (u+3σ, +∞) and save them into the sample map P scr .
[0015] In one embodiment of the present invention, the gallery b scr The generation method is:
[0016] Sample Gallery P scr The image in is linearly merged with a pure black image of the same size to achieve darkening. The linear fusion formula is: dst = scr 1 *α+scr 2 *β, where scr 1 YesP scr Pictures in scr 2 It is a pure black picture of the same size and pixel value of 0. α and β are the fusion coefficients respectively. After fusion, they are saved in the library b scr .
[0017] In one embodiment of the present invention, the image captured when the light is insufficient, i.e., the dark image, is stored in the image gallery b. scr Extract n pictures closest to the color feature vector of the dark picture, and select the nearest n pictures from the sample library P scr The implementation method of extracting the original image is as follows:
[0018] Calculate b scr The color feature vector set V of the wood image in t ;
[0019] For the wood images collected when the light is insufficient, calculate the color feature vector V of the collected dark image c ;
[0020] Calculate V c With V t The distance of all eigenvectors within ;
[0021] Sort the calculated distances from small to large;
[0022] In P scrExtract a original images corresponding to the distance from small to large.
[0023] In one embodiment of the present invention, the statistical histogram of the original image is accumulated, and the dark image is standardized according to the accumulated histogram in the following manner:
[0024] For a original image, the color distribution histograms of the three channels R, G, and B are counted and accumulated as the histogram of the template image. The template image histogram satisfies Among them Hist j ,j=R,G,B represents the j-channel color histogram of the template image, j=R,G,B represents the j-channel color histogram of the i-th original image used for superposition, The component can be expressed as Indicates the number of pixels distributed between 0 and 255;
[0025] For dark images, the color distribution histograms of the three channels R, G, and B are counted respectively. j =[h j1 ,h j2 ,...h j255 ],j=R,G,B;[h j0 ,h j1 ,...h j255 ] indicates the number of pixels distributed between 0 and 255;
[0026] Calculate the cumulative histogram probability density functions of the R, G, and B channels of the dark image and the cumulative histogram probability density functions of the R, G, and B channels of the histogram template image respectively;
[0027] A mapping list is extracted for the relationship with the smallest difference in the cumulative probability density distribution function of the R, G, and B channels of the dark image and the template image, and the R, G, and B channels of the dark image are regulated according to the mapping list. Finally, the grayscale images after the regulation of the R, G, and B channels are merged to obtain the repaired image.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] 1) A dataset of wood images of various categories saved through clustering results. This dataset contains different wood color features. Using this dataset as a restoration template ensures that different types of wood images can be correctly restored under insufficient lighting conditions.
[0030] 2) Under insufficient lighting conditions, the image is standardized to avoid the darkening of the collected wood image and the inability to reflect the RGB color characteristics of the wood surface, effectively preventing the image color distortion caused by changes in lighting conditions.
[0031] 3) By setting different degrees of darkening coefficients, insufficient lighting conditions can be simulated. The collected wood images can be effectively restored for different degrees of lighting conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 The flowchart of the wood library created based on clustering results of the present invention.
[0033] Figure 2 This is a flow chart of repairing dark pictures according to the present invention. DETAILED DESCRIPTION
[0034] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings.
[0035] The present invention discloses a wood color restoration method based on image fusion and matching. First, the color feature vector is calculated through the pictures in the wood library and K-means clustering is performed to extract the center of each category. Then, the original picture of each category is selected according to the 3σ principle to generate a sample library P. scr , and then darken to different degrees to generate gallery b scr ; For images collected when the light is insufficient, that is, dark images, in the gallery b scr Extract a pictures closest to the color feature vector of the dark picture, and select the a pictures closest to the sample library P scr The original image is extracted from the image processing unit, the histogram of the original image is counted and accumulated, and the dark image is normalized according to the accumulated histogram to obtain the restored image.
[0036] The following are specific implementation examples of the present invention.
[0037] like Figure 1 , 2 As shown, read the image collected under insufficient lighting conditions, calculate the color feature vector of the dark image, take the 10 images closest to the feature vector, find the corresponding original images for the 10 images, and add up the histograms of the 10 original images as the histogram of the template image. Finally, standardize the dark image. The specific steps are as follows:
[0038] (1) The wood color samples in the nearly 12,000 wood images were counted and the histograms of all samples were accumulated. The upper and lower limits of the intervals with a large proportion in each RGB channel were selected from the accumulated histograms to obtain a subspace in the RGB color space. The intervals were divided into 16 bins to obtain a 16*16*16 cubic matrix. The cubic matrix was expanded to obtain the feature vector The length of the eigenfrequency vector is 16 3 , each value represents the proportion of the number of times each color appears in the wood color space to the number of times all colors appear.
[0039] (2) The number of clustering categories is selected as 40, K-means clustering is performed on all feature vectors, and the center of each category is extracted.
[0040] (3) For each category, calculate the distance from each category’s samples to the center of that category, compile a histogram of the distance distribution from each category’s samples to the centroid, sort the distances from the samples to the centroid from small to large, and calculate the mean u and variance σ respectively.
[0041] (4) For each category, according to the 3σ principle, 8 images are selected equidistantly in the interval (u-3σ, u+3σ) and saved in the image library P scr , select one picture in the interval (-∞, u-3σ) and (u+3σ, +∞) as the data library P scr .
[0042] (5) P scr The image in is linearly merged with a pure black image of the same size to achieve darkening. The linear fusion formula is: dst = scr 1 *α+scr 2 *β, the fusion coefficient α is set to 1, and the fusion coefficients β are: 0.9, 0.85, 0.8, and the number of darkened images is 1200, generating b scr Gallery.
[0043] (6) Calculate the color feature vector set V of all darkened wood images t .
[0044] (7) For the wood images collected when the light is insufficient, calculate the color feature vector V for the dark image c .
[0045] (8) Calculate V c With V t The distance between the inner color feature vectors.
[0046] (9) Sort the calculated distances from small to large.
[0047] (10) In P scrExtract 10 original pictures corresponding to the distance from small to large.
[0048] (11) For the 10 original images, the color distribution histograms of the R, G, and B channels are counted and accumulated as the histogram of the template image. The template image histogram satisfies Among them Hist j ,j=R,G,B represents the j-channel color histogram of the template image, j=R,G,B represents the j-channel color histogram of the i-th original image used for superposition, The component can be expressed as Indicates the number of pixels distributed between 0 and 255.
[0049] (12) For dark images, the color distribution histograms of the three channels R, G, and B are counted respectively. j =[h j1 ,h j2 ,...h j255 ],j=R,G,B;[h j0 ,h j1 ,...h j255 ] indicates the number of pixels distributed between 0 and 255.
[0050] (13) Calculate the cumulative histogram probability density functions of the R, G, and B channels of the dark image and the cumulative histogram probability density functions of the R, G, and B channels of the histogram template image respectively.
[0051] (14) A mapping list is extracted for the relationship with the smallest difference in the cumulative probability density distribution function of the R, G, and B channels of the dark image and the template image, and the R, G, and B channels of the dark image are regulated according to the mapping list. Finally, the grayscale images after the regulation of the R, G, and B channels are merged to obtain the repaired image.
[0052] The above are preferred embodiments of the present invention. Any changes made according to the technical solution of the present invention, as long as the resulting functions do not exceed the scope of the technical solution of the present invention, belong to the protection scope of the present invention.
Claims
1. A wood color restoration method based on image fusion and matching, characterized in that: First, the color feature vectors are calculated from the pictures in the wood library and K-means clustering is performed to extract the center of each category. Then, the original pictures of each category are selected according to the 3σ principle to generate the sample library P. scr , and then darken to different degrees to generate gallery b scr ; For images collected when the light is insufficient, that is, dark images, in the gallery b scr Extract a pictures closest to the color feature vector of the dark picture, and select the a pictures closest to the sample library P scr Extract the original image, count the histogram of the original image and accumulate it, normalize the dark image according to the accumulated histogram, and obtain the restored image; The sample library P is generated by selecting the original image for each category through the 3σ principle. scr The implementation is: For each category, calculate the distance between each category's sample and the category center, sort the distances between the sample and the category center from small to large, and calculate the mean and variance respectively; according to the 3σ principle, select 8a pictures equally spaced in the interval (u-3σ, u+3σ) and save them into the sample library P scr , select a pictures in the interval (-∞, u-3σ) and (u+3σ, +∞) and save them into the sample map P scr ; The dark image is specified according to the accumulated histogram to obtain the restored image, that is: the cumulative histogram probability density functions of the R, G, and B channels of the dark image and the cumulative histogram probability density functions of the R, G, and B channels of the histogram template image are calculated respectively; a mapping list is extracted for the relationship with the smallest difference in the cumulative probability density distribution functions of the R, G, and B channels of the dark image and the template image respectively, the R, G, and B channels of the dark image are specified according to the mapping list respectively, and finally the grayscale images after the R, G, and B channels are specified are merged to obtain the restored image.
2. The method for wood color restoration based on image fusion and matching according to claim 1, characterized in that: The method of calculating the color feature vectors from the pictures in the wood library and performing K-means clustering to extract the centers of each category is as follows: For the wood color in N wood image libraries, all sample histograms are counted and accumulated. According to the accumulated histogram, the color interval range in each RGB channel is selected to obtain a subspace under the RGB color space. The interval is divided into n bins to obtain an n*n*n cubic matrix. The cubic matrix is expanded to obtain the feature vector The length of the characteristic frequency vector is n 3 , each value represents the proportion of the number of times each color appears in the color space of wood to the number of times all colors appear; Select the number of categories K, perform K-means clustering on all feature vectors, and retain the center of each category.
3. The method for wood color restoration based on image fusion and matching according to claim 2, characterized in that: The gallery b scr The generation method is: For the sample gallery P scr The image in the image is linearly merged with the pure black image of the same size to achieve darkening. The linear fusion formula is: dst = scr1*α+scr2*β, where scr1 is P scr The picture in, scr2 is a pure black picture of the same size and pixel value of 0, α and β are the fusion coefficients, and the fusion is saved in the library b scr .
4. The method for wood color restoration based on image fusion and matching according to claim 3, characterized in that: The image collected when the light is insufficient is a dark image. scr Extract n pictures closest to the color feature vector of the dark picture, and select the nearest n pictures from the sample library P scr The implementation method of extracting the original image is as follows: Calculate b scr The color feature vector set V of the wood image in t ; For the wood images collected when the light is insufficient, calculate the color feature vector V of the collected dark image c ; Calculate V c With V t The distance of all eigenvectors within ; Sort the calculated distances from small to large; In P scr Extract a original images corresponding to the distance from small to large.
5. The method for wood color restoration based on image fusion and matching according to claim 4, characterized in that: The method of counting the histogram of the original image and accumulating it, and regulating the dark image according to the accumulated histogram is as follows: For a original image, the color distribution histograms of the three channels R, G, and B are counted and accumulated as the histogram of the template image. The template image histogram satisfies Among them Hist j ,j=R,G,B represents the j-channel color histogram of the template image, represents the j-channel color histogram of the i-th original image used for superposition, The component can be expressed as Indicates the number of pixels distributed between 0 and 255; For dark images, the color distribution histogram raw_hist is calculated for the three channels of R, G, and B. raw_hist j =[h j0 ,h j2 ,...h j255 ],j=R,G,B;[h j0 ,h j1 ,...h j255 ] indicates the number of pixels distributed between 0 and 255; Calculate the cumulative histogram probability density functions of the R, G, and B channels of the dark image and the cumulative histogram probability density functions of the R, G, and B channels of the histogram template image respectively; A mapping list is extracted for the relationship with the smallest difference in the cumulative probability density distribution function of the R, G, and B channels of the dark image and the template image, and the R, G, and B channels of the dark image are regulated according to the mapping list. Finally, the grayscale images after the regulation of the R, G, and B channels are merged to obtain the repaired image.
Citation Information
Patent Citations
Image white balance processing method and device
CN103037224A
White balance correction method, device and equipment and storage medium
CN112243118A
Picture processing method and device
CN105205487A
SAR image oil depot area detection method based on joint significance analysis
CN108805057A