Wood color quantification method based on HSV space

By converting wood images to HSV space, counting the frequency, removing irrelevant colors and quantifying them, the problem of insufficient accuracy of wood color quantization in the existing technology is solved, efficient and accurate wood color quantization is achieved, and cutting planning efficiency is improved.

CN119693474APending Publication Date: 2025-03-25FUJIAN SHUNJING MACHINERY IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411785868.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The prior art has problems such as insufficient accuracy, high equipment cost, and inability to fully reflect complex textures or multi-color wood color characteristics in the quantification of wood images, resulting in low cutting planning efficiency.

Method used

Using the wood color quantization method based on HSV space, the wood image is converted from the RGB color space to the HSV color space, the frequencies of the H, S, and V channels are counted, the upper and lower limit ranges are determined, the irrelevant colors are removed, and the N colors with the most frequency are filtered out, and the area number is finally performed.

Benefits of technology

It improves the accuracy of wood image color quantization, reduces image noise interference, simplifies data processing, is suitable for large-scale data management, and provides accurate color information for subsequent cutting planning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119693474A_ABST
    Figure CN119693474A_ABST
Patent Text Reader

Abstract

The invention provides a wood color quantification method based on an HSV space. The method comprises the following steps: S1, reducing a wood image to obtain a low-magnification wood image, and then converting the image from an RGB color space to an HSV color space; s2, counting the occurrence frequencies of all the images in three channels H, S and V, and determining the upper and lower limit ranges of each channel; s3, processing the wood HSV image according to the upper limit and the lower limit, and removing irrelevant colors; then, the image is quantized according to the self-set quantization lengths of three channels H, S and V; s4, performing color statistics on the quantized image, screening out N colors with the highest occurrence frequency, quantizing the wood into N colors to obtain a final accurate color quantization result, and performing region numbering on the result; when the method is applied to color quantification of the wood image, the problem of quantification difficulty caused by factors such as wood types and textures in the wood image can be solved, and the efficiency of subsequent cutting planning is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image color quantization, in particular to a wood color quantization method based on HSV space. Background Art

[0002] In the process of two-dimensional wood cutting planning, in order to improve the efficiency of cutting planning, it is necessary to divide more obvious areas of different wood colors from the acquired images. At the same time, the real-time requirements in industrial scenarios are high, so it is necessary to quantify the wood color efficiently.

[0003] The area of ​​wood materials used for processing in industry is large, and line array cameras are usually used to capture images of them. The captured images have the characteristics of high clarity and large aspect ratio. Wood of different tree species has different colors, which makes it difficult to plan the cutting of wood accessories. Through color quantification, wood of different tree species can be distinguished more objectively and accurately, which helps to identify and classify, and improve the efficiency of cutting planning. Traditional wood color quantification methods are mostly based on colorimeter measurement and spectrophotometry. Although these methods have high accuracy, their equipment costs are high, and for wood with textures or multiple tones, they may not be able to fully reflect their color characteristics, which greatly reduces the efficiency of cutting planning.

[0004] The color processing algorithm combined with the HSV color space can analyze the color distribution and texture of wood, provide more comprehensive color information, and is suitable for large-area measurement and can quickly process large amounts of data. In addition, it can be used to evaluate the color of complex-textured wood while taking into account both accuracy and reliability. This color quantification method plays a very important role in the production process of the wood industry.

[0005] The Chinese patent application number is: CN201510276541.1, and the name is: Color quantization method and system. The method analyzes the image to be processed to obtain a first set number of N different colors, takes out a second set number of M different colors from the first set number of N different colors, and obtains a combination containing the second set number of M different colors; quantifies the differences between the colors in the combination containing the second set number of M different colors, and obtains P different colors with the largest differences. The method screens based on the difference in color occurrence frequency, but the color difference of wood in industry is small, and there are many types of color combinations. This method cannot be directly applied to the color quantification of wood.

[0006] The Chinese patent application number is: CN201510946525.9, and the name is: Color quantization system and color quantization method based on HMMD color space. This method converts the RGB components of the original image space into HSD components through the RGB to HMMD unit, and then determines the subspace to which the image belongs according to the D component and the histogram size to calculate the quantization level dimensions corresponding to different histograms, and then calculates the hue quantization level according to the H component, and then calculates the brightness quantization level according to the S component, and finally calculates the quantization level dimension, hue quantization level, and brightness quantization level to obtain the color quantization value and outputs the color quantization value. This method only performs scalar quantization in the HMMD color space, and the color distribution obtained on the wood image is not uniform, and accurate quantization cannot be achieved. Summary of the invention

[0007] The present invention proposes a wood color quantization method based on HSV space. When applied to the color quantization of wood images, it can effectively solve the quantization difficulty problem in wood images caused by factors such as wood species and texture, and improve the efficiency of subsequent cutting planning.

[0008] The present invention adopts the following technical solutions.

[0009] A wood color quantification method based on HSV space is used to perform color quantification on a long strip of wood image collected by a linear array camera at an industrial site, comprising the following steps:

[0010] Step S1, reducing the wood image to obtain a low-magnification wood image, and then converting the image from the RGB color space to the HSV color space;

[0011] Step S2: Count the frequencies of all images appearing in the three channels H, S, and V, and determine the upper and lower limits of each channel;

[0012] Step S3, processing the wood HSV image according to the upper and lower limits to remove irrelevant colors; then quantizing the image according to the quantization lengths of the three channels H, S, and V set by yourself;

[0013] Step S4: Perform color statistics on the quantized image, screen out the N colors with the highest frequency, and then quantify the wood into N colors to obtain the final accurate color quantization result, and perform region numbering on the result.

[0014] The method of reducing the wood image in step S1 is as follows: obtaining an original wood image, scaling the original wood image with a length and width size of H×W, setting the scaling ratio to r, and obtaining a length and width size of The scaled image of .

[0015] In step S1, the range of the H channel is (0, 180), and the range of the S and V channels is (0, 256).

[0016] After the wood image of the historical image data is converted to the HSV color space in step S1, in step S2, the occurrence frequency of the pixel values ​​of each color channel in all images is counted respectively to generate the HSV space color distribution map of the wood image; then, the color range of each channel is determined according to the distribution map result, that is,

[0017] [H min ,H max ],[S min ,S max ],[V min ,V max ], used for subsequent quantization processing.

[0018] In step S3, when removing irrelevant colors of the background, the method is to set the pixel values ​​outside the statistical HSV color range to 0, that is, convert them into black.

[0019] The method of quantizing the image in step S3 is color quantization, which is as follows: extract the height, width and number of channels of the image, which are H, W and C respectively, and set LH, LS and LV as the quantization levels of hue, saturation and brightness respectively, loop through each pixel in the image, and determine whether the HSV value of the pixel is within the specified range. If it is within the range, color quantization is performed. Quantize each color channel, which can be expressed as:

[0020] This process ensures that color values ​​are quantized to the specified level, plus half a quantization level for adjustment.

[0021] In step S4, when counting the frequencies of occurrence of different colors, the HSV value of each pixel after quantization is regarded as a set of data, and the frequency of occurrence of each HSV value is counted and sorted in order from large to small to help further analyze the color distribution.

[0022] When the wood is quantified into N colors to obtain the final accurate color quantization result in step S4, the wood is quantified into the N colors that appear most frequently, and the method used includes the following specific steps:

[0023] Step A1, set the N value to be selected according to the actual situation;

[0024] Step A2: determine whether the HSV value of the current pixel is in the first N HSV values. If not, continue to process the pixel;

[0025] Step A3, searching for a neighborhood within the p-pixel range of the current pixel, that is, within the p-pixel ranges above, below, left, and right, and recording the HSV value of each pixel in the neighborhood;

[0026] Step A4, count the frequency of each HSV value in the neighborhood, return the unique value and its corresponding number of occurrences; Step A5, traverse the HSV values ​​and their frequencies in the neighborhood, and find the color max_count_hsv that appears the most and exists in the first N HSV values;

[0027] Step A6: If a color that meets the conditions is found, replace the HSV value of the current pixel with max_count_hsv;

[0028] Step A7: Repeat the above steps for each pixel point, and the final image obtained uses the neighborhood information to enhance the color consistency of the image.

[0029] When step S4 is to perform region numbering on the quantized result, the method is: each region number is set to consist of three values ​​(h, s, v), and the numbering formula is: k = 0, 1, 2, where area_num(i, j, k) is the area number, image(i, j, k) is the color value of the current pixel in the kth channel, lower_range[k] is the lower bound of the kth channel, L k is the corresponding quantization parameter, which includes LH, LS or LV.

[0030] After completing the region numbering in step S4, the color quantized image and the region numbering result are tabulated, and the obtained tabular result is input into the subsequent cutting planning process for further processing.

[0031] The beneficial effects of the present invention are:

[0032] 1) The present invention effectively improves the accuracy of wood image color quantization. The statistics and range limitation of the HSV three-channel frequency reduce the interference of image noise when processing wood images, and the quantized color data is easy to further analyze.

[0033] 2) The present invention can effectively reduce the redundancy of image data and improve storage and processing efficiency by mapping multiple color values ​​to limited quantized values, and is suitable for the management of large-scale wood image data.

[0034] 3) The present invention adopts a processing framework of color quantization followed by numbering, and adds numbering information to different color regions, which facilitates subsequent operations such as classification, recognition, and cutting, thereby improving efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:

[0036] Attached Figure 1It is a schematic diagram of the flow of the algorithm for quantizing the N colors that appear most frequently in the present invention;

[0037] Attached Figure 2 It is a schematic diagram of the frequency range of the HSV three channels statistically obtained according to the present invention. DETAILED DESCRIPTION

[0038] As shown in the figure, a wood color quantification method based on HSV space is used to perform color quantification on a long strip of wood image collected by a linear array camera at an industrial site, including the following steps;

[0039] Step S1, reducing the wood image to obtain a low-magnification wood image, and then converting the image from the RGB color space to the HSV color space;

[0040] Step S2: Count the frequencies of all images appearing in the three channels H, S, and V, and determine the upper and lower limits of each channel;

[0041] Step S3, processing the wood HSV image according to the upper and lower limits to remove irrelevant colors; then quantizing the image according to the quantization lengths of the three channels H, S, and V set by yourself;

[0042] Step S4: Perform color statistics on the quantized image, screen out the N colors with the highest frequency, and then quantify the wood into N colors to obtain the final accurate color quantization result, and perform region numbering on the result.

[0043] The method of reducing the wood image in step S1 is as follows: obtaining an original wood image, scaling the original wood image with a length and width size of H×W, setting the scaling ratio to r, and obtaining a length and width size of The scaled image of .

[0044] In step S1, the range of the H channel is (0, 180), and the range of the S and V channels is (0, 256).

[0045] After the wood image of the historical image data is converted to the HSV color space in step S1, in step S2, the occurrence frequency of the pixel values ​​of each color channel in all images is counted respectively to generate the HSV space color distribution map of the wood image; then, the color range of each channel is determined according to the distribution map result, that is,

[0046] [H min ,H max ],[S min ,S max ],[V min ,V max ], used for subsequent quantization processing.

[0047] In step S3, when removing irrelevant colors of the background, the method is to set the pixel values ​​outside the statistical HSV color range to 0, that is, convert them into black.

[0048] The method of quantizing the image in step S3 is color quantization, which is as follows: extract the height, width and number of channels of the image, which are H, W and C respectively, and set LH, LS and LV as the quantization levels of hue, saturation and brightness respectively, loop through each pixel in the image, and determine whether the HSV value of the pixel is within the specified range. If it is within the range, color quantization is performed. Quantize each color channel, which can be expressed as:

[0049] This process ensures that color values ​​are quantized to the specified level, plus half a quantization level for adjustment.

[0050] In step S4, when counting the frequencies of occurrence of different colors, the HSV value of each pixel after quantization is regarded as a set of data, and the frequency of occurrence of each HSV value is counted and sorted in order from large to small to help further analyze the color distribution.

[0051] When the wood is quantified into N colors to obtain the final accurate color quantization result in step S4, the wood is quantified into the N colors that appear most frequently, and the method used includes the following specific steps:

[0052] Step A1, set the N value to be selected according to the actual situation;

[0053] Step A2: determine whether the HSV value of the current pixel is in the first N HSV values. If not, continue to process the pixel;

[0054] Step A3, searching for a neighborhood within the p-pixel range of the current pixel, that is, within the p-pixel ranges above, below, left, and right, and recording the HSV value of each pixel in the neighborhood;

[0055] Step A4, count the frequency of each HSV value in the neighborhood, return the unique value and its corresponding number of occurrences; Step A5, traverse the HSV values ​​and their frequencies in the neighborhood, and find the color max_count_hsv that appears the most and exists in the first N HSV values;

[0056] Step A6: If a color that meets the conditions is found, replace the HSV value of the current pixel with max_count_hsv;

[0057] Step A7: Repeat the above steps for each pixel point, and the final image obtained uses the neighborhood information to enhance the color consistency of the image.

[0058] When step S4 is to perform region numbering on the quantized result, the method is: each region number is set to consist of three values ​​(h, s, v), and the numbering formula is: k = 0, 1, 2, where area_num(i, j, k) is the area number, image(i, j, k) is the color value of the current pixel in the kth channel, lower_range[k] is the lower bound of the kth channel, L k is the corresponding quantization parameter, which includes LH, LS or LV.

[0059] After completing the region numbering in step S4, the color quantized image and the region numbering result are tabulated, and the obtained tabular result is input into the subsequent cutting planning process for further processing.

[0060] Example:

[0061] The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0062] This example uses the following method.

[0063] (1) Counting the range of HSV three channels: Batch process all the acquired wood images, count the frequency of different pixel values ​​in the HSV three channels of all images, and obtain the pixel value distribution of the wood image in HSV space according to the size of the occurrence frequency, and then filter to obtain the limited range of each channel, such as Figure 2 As shown, the range of the H channel is [10, 30], the range of the S channel is [65, 145], and the range of the V channel is [10, 105];

[0064] (2) Image scaling: Obtain an original image of a wood image, and scale the original image of the wood with a length and width of 30000*2000, and set the scaling ratio to 10 to obtain a scaled image with a length and width of 3000*200;

[0065] (3) Color space conversion: convert the RGB space to the HSV space, the range of the H channel is (0, 180), and the range of the S and V channels is (0, 256);

[0066] (4) Remove irrelevant colors; set pixel values ​​outside the statistical HSV color range to 0, that is, convert them to black;

[0067] (5) Color quantization: Extract the height, width and number of channels of the image as H, W and C respectively. LH, LS and LV are the quantization levels of hue, saturation and brightness respectively. Loop through each pixel in the image to determine whether the HSV value of the pixel is within the specified range. If it is within the range, perform color quantization. Set LH = 7, LS = 20, LV = 7, and quantize each color channel: This process ensures that the color values ​​are quantized to the specified level, plus half a quantization level for adjustment;

[0068] (6) Count the frequency of occurrence of different colors; treat the HSV value of each pixel after quantization as a set of data, count the frequency of occurrence of each HSV value and sort them in order from large to small to help further analyze the color distribution;

[0069] (7) Quantized to the N colors that appear most frequently; the specific calculation steps are as follows:

[0070] I. Set N = 10;

[0071] II. Determine whether the HSV value of the current pixel is among the first 10 HSV values. If not, continue

[0072] Continue to process the pixel;

[0073] III. Search for the neighborhood within the 5-pixel range of the current pixel (5 pixels above, below, left and right) and record

[0074] HSV value of each pixel in the neighborhood;

[0075] IV. Count the frequency of each HSV value in the neighborhood and return the unique value and its corresponding number of occurrences;

[0076] V. Traverse the HSV values ​​and their frequencies in the neighborhood and find the color max_count_hsv that appears the most and exists in the first 10 HSV values;

[0077] VI. If a color that meets the conditions is found, replace the HSV value of the current pixel with max_count_hsv;

[0078] VII. Repeat the above steps for each pixel, and the final image uses neighborhood information to enhance the color consistency of the image.

[0079] (8) Number the regions after quantization; each region number consists of three values ​​(h, s, v), and the numbering formula is: k = 0, 1, 2, where area_num(i, j, k) is the area number, image(i, j, k) is the color value of the current pixel in the kth channel, lower_range[k] is the lower bound of the kth channel, L k is the corresponding quantization parameter (L H , L S or L V), image(1,1,0)=15, image(1,1,1)=100, image(1,1,2)=50, then the final number of area(1,1) is (1, 2, 6).

[0080] Complete the color quantization operation; input the tabular results of the color quantized image and region numbering into the subsequent cutting planning process for further processing.

Claims

1. A wood color quantification method based on HSV space is used to quantify the color of long strip wood images collected by a linear array camera at an industrial site, characterized in that: The steps include: Step S1, reducing the wood image to obtain a low-magnification wood image, and then converting the image from the RGB color space to the HSV color space; Step S2: Count the frequencies of all images appearing in the three channels H, S, and V, and determine the upper and lower limits of each channel; Step S3, processing the wood HSV image according to the upper and lower limits to remove irrelevant colors; then quantizing the image according to the quantization lengths of the three channels H, S, and V set by yourself; Step S4: Perform color statistics on the quantized image, screen out the N colors with the highest frequency, and then quantify the wood into N colors to obtain the final accurate color quantization result, and perform region numbering on the result.

2. A wood color quantification method based on HSV space according to claim 1, characterized in that: The method of reducing the wood image in step S1 is as follows: obtaining an original wood image, scaling the original wood image with a length and width size of H×W, setting the scaling ratio to r, and obtaining a length and width size of The scaled image of .

3. A wood color quantification method based on HSV space according to claim 1, characterized in that: In step S1, the range of the H channel is (0, 180), and the range of the S and V channels is (0, 256).

4. A wood color quantification method based on HSV space according to claim 3, characterized in that: After the wood image of the historical image data is converted into the HSV color space in step S1, in step S2, the occurrence frequency of the pixel values ​​of each color channel in all images is counted respectively to generate a color distribution map of the wood image in the HSV space; Then, the color range of each channel is determined according to the distribution map results, that is, [H min ,H max ],[S min ,S max ],[V min ,V max ], used for subsequent quantization processing.

5. A wood color quantification method based on HSV space according to claim 4, characterized in that: In step S3, when removing irrelevant colors of the background, the method is to set the pixel values ​​outside the statistical HSV color range to 0, that is, convert them into black.

6. The method for quantifying wood color based on HSV space according to claim 4, characterized in that: The method of quantizing the image in step S3 is color quantization, which is as follows: extract the height, width and number of channels of the image, which are H, W and C respectively, and set LH, LS and LV as the quantization levels of hue, saturation and brightness respectively, loop through each pixel in the image, and determine whether the HSV value of the pixel is within the specified range. If it is within the range, color quantization is performed. Quantize each color channel, which can be expressed as: This process ensures that color values ​​are quantized to the specified level, plus half a quantization level for adjustment.

7. The method for quantifying wood color based on HSV space according to claim 4, characterized in that: In step S4, when counting the frequencies of occurrence of different colors, the HSV value of each pixel after quantization is regarded as a set of data, and the frequency of occurrence of each HSV value is counted and sorted in order from large to small to help further analyze the color distribution.

8. The method for quantifying wood color based on HSV space according to claim 7, characterized in that: When the wood is quantified into N colors to obtain the final accurate color quantization result in step S4, the wood is quantified into the N colors that appear most frequently, and the method used includes the following specific steps: Step A1, set the N value to be selected according to the actual situation; Step A2: determine whether the HSV value of the current pixel is in the first N HSV values. If not, continue to process the pixel; Step A3, searching for a neighborhood within the p-pixel range of the current pixel, that is, within the p-pixel ranges above, below, left, and right, and recording the HSV value of each pixel in the neighborhood; Step A4: Count the frequency of each HSV value in the neighborhood and return the unique value and its corresponding number of occurrences; Step A5, traverse the HSV values ​​and their frequencies in the neighborhood, and find the color max_count_hsv that appears the most times and exists in the first N HSV values; Step A6: If a color that meets the conditions is found, replace the HSV value of the current pixel with max_count_hsv; Step A7: Repeat the above steps for each pixel point, and the final image obtained uses the neighborhood information to enhance the color consistency of the image.

9. The method for quantifying wood color based on HSV space according to claim 7, characterized in that: When step S4 is to perform region numbering on the quantized result, the method is: each region number is set to consist of three values ​​(h, s, v), and the numbering formula is: k = 0, 1, 2, where area_num(i, j, k) is the area number, image(i, j, k) is the color value of the current pixel in the kth channel, lower_range[k] is the lower bound of the kth channel, L k is the corresponding quantization parameter, which includes LH, LS or LV.

10. The method for quantifying wood color based on HSV space according to claim 9, characterized in that: After completing the region numbering in step S4, the color quantized image and the region numbering result are tabulated, and the obtained tabular result is input into the subsequent cutting planning process for further processing.

Citation Information

Patent Citations

  • Color quantization method and system

    CN104952084A

  • Color quantization system and color quantization method based on HMMD color space

    CN105574900A