A digital representation method for uniformity based on the cluster similarity of the main color of a single tobacco leaf in RGB.
By using a digital representation method based on the cluster similarity of the main color of a single tobacco leaf in RGB, the problem of difficulty in representing the color uniformity of tobacco leaves in existing technologies has been solved, and the fine classification of tobacco leaf grades and the improvement of usability have been achieved.
Patent Information
- Application Number
- CN202310159366.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-02-23
AI Technical Summary
Existing technologies cannot effectively characterize the color uniformity of tobacco leaves, especially in terms of visual representation of the main color tone, resulting in low pass rates and poor usability of tobacco leaf grades.
A digital representation method for uniformity based on the cluster similarity of the main color tone of a single tobacco leaf is adopted. Through image preprocessing, K-means clustering and Calinski-Harabasz index analysis, the Euclidean distance between clusters is calculated, the color tone with the lowest similarity is excluded, and the main color tone with the highest similarity is retained.
A novel method for expressing tobacco leaf uniformity is provided, which can statistically analyze the dominant color tone of tobacco leaves at the visual level, thereby improving the accuracy and usability of tobacco leaf grading.
Smart Images

Figure CN116229115B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition technology, specifically relating to a method for digitally representing uniformity based on the cluster similarity of the main color tone of a single tobacco leaf in RGB. Background Technology
[0002] Tobacco industry products require meticulous manufacturing and precise classification. Due to varying levels of grading skills among tobacco farmers and differing purchasing expertise, the acquired tobacco leaves often exhibit mixed grades, parts of tobacco, by-products, and colors, resulting in low grade qualification rates, poor purity, and limited usability. Therefore, based on the selection procedures for high-end cigarette tobacco leaves, this study explores scientific research into the precise selection of tobacco leaves, seeking a new digital representation method for tobacco leaf quality.
[0003] Patent application CN102749140A discloses a method for judging the uniformity of color on the surface of flue-cured tobacco leaves. Based on the calculation of the mean and coefficient of variation of three characteristic parameters of tobacco leaf color brightness (L*), redness (a*) and yellowness (b*), the method uses an established tobacco leaf color uniformity comparison table to judge the uniformity of tobacco leaf color brightness, redness and yellowness.
[0004] Patent application CN101762583A discloses a method for characterizing the appearance color of tobacco leaves with regional characteristics. It calculates the fractal dimension corresponding to different threshold parameters of each component of tobacco leaf color (red, green, blue, and brightness), and uses it as an indicator to quantitatively describe the surface distribution state of tobacco leaf color. It plots the fractal dimension variation curve of each color component, which can comprehensively reflect the surface distribution state of tobacco leaf color. The fractal dimension variation curve can effectively characterize the appearance color of tobacco leaves with regional characteristics.
[0005] Existing technologies mostly employ color space conversion followed by statistical analysis of each color component. This method is classic but not well-suited for image recognition technology, and it cannot represent the dominant color tone at the visual level.
[0006] The present invention is proposed to solve the above problems. Summary of the Invention
[0007] In view of this, the purpose of this invention is to provide a method for digitally representing uniformity based on the cluster similarity of the main color tones of a single tobacco leaf in RGB (Red, Green, Blue).
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] A method for digitally representing the uniformity of tobacco leaf uniformity based on the cluster similarity of dominant color tones in RGB single leaves includes the following steps:
[0010] S1: Acquire tobacco leaf images and perform preprocessing to generate preprocessed tobacco leaf images;
[0011] S2: Analyze the preprocessed tobacco leaf image, extract the histogram data of the RGB color components, perform Gaussian fitting on it to achieve image denoising, and obtain the distribution range of the Gaussian model of R, G, and B components, and then combine them into a Gaussian fitted RGB tobacco leaf image.
[0012] S3: First, perform pixel clustering using the K-means clustering algorithm on the Gaussian-fitted RGB tobacco leaf image in S2, and then use the Calinski-Harabasz exponent to compare each cluster to find the best cluster.
[0013] S4: Find the best cluster after clustering, calculate the Euclidean distance between clusters, eliminate the hue with the lowest similarity, and obtain the main hue with the highest similarity.
[0014] S5: Retain the main color with the highest similarity and use the proportion of the main color value as the uniformity of the main color of the tobacco leaf.
[0015] Preferably, the preprocessing in step S1 includes image background removal, image contour extraction, and image leaf surface extraction.
[0016] Preferably, the image background removal step is as follows: first, the background image of the tobacco leaf is converted into a background frame and cached; then, the image background is removed using the frame difference method. Specifically, each frame of the captured image is compared with the background frame; pixels with the same color information as the background are identified as background, and those without are identified as foreground. Let the background frame be B, and the RGB vector of a pixel in the background frame be B. i,j The acquired material image is S, and the RGB vector of a certain pixel in the material image is S. i,j Δ is a fixed RGB vector, and the frame difference method is shown in the following formula:
[0017] S i,j =0if|S i,j -B i,j |≤|Δ|
[0018] In the formula, 0 is the RGB zero vector, i.e. (0,0,0).
[0019] Preferably, the image contour extraction uses the Canny operator to extract the image contour; Let I[i, j] represent the image, and using a separable filtering process, calculate the convolution integral of the image with the Gaussian smoothing filter to obtain the smoothed data matrix:
[0020] S[i,j]=G[i,j;σ]*I[i,j]
[0021] Where σ is the scattering parameter of the Gaussian function, the gradient of the smoothed data matrix S[i,j] is calculated using a 2×2 first-order finite difference approximation to calculate the partial derivatives of X and Y, and the two matrices P[i,j] and Q[i,j] are:
[0022]
[0023]
[0024] Calculate the amplitude and azimuth using the coordinate transformation formula from rectangular to polar coordinates:
[0025]
[0026] θ[i,j]=arcten(Q[i,j] / P[i,j])
[0027] Where M[i,j] is the amplitude and θ[i,j] is the azimuth angle.
[0028] Preferably, step S2 specifically includes the following steps: performing Gaussian fitting on the histogram statistics of the RGB color components of the tobacco leaves to obtain the parameters (μ, σ) of the Gaussian model for each component, where μ is the mean of the Gaussian distribution and σ is the standard deviation; determining the threshold range of a certain component based on [μ-kσ, μ+kσ], where k is a coefficient, as follows:
[0029] R min =μ R -kσ R
[0030] R max =μ R +kσ R
[0031] G min =μ G -kσ G
[0032] G max =μ G +kσ G
[0033] B min =μ B -kσ B
[0034] B max =μ B +kσ B
[0035] Among them, R min R max These are the minimum and maximum thresholds for the red component, μ. RLet σ be the mean of the Gaussian distribution of the red component. R G represents the standard deviation of the Gaussian distribution of the red component. min G max These are the minimum and maximum thresholds for the green component, μ G Let σ be the mean of the Gaussian distribution of the green component. G B is the standard deviation of the Gaussian distribution of the green component; min B max These are the minimum and maximum thresholds for the blue component, μ. B The mean of the Gaussian distribution of the blue component is σ. B The standard deviation of the Gaussian distribution for the blue component;
[0036] Based on the above parameters, the distribution range of the Gaussian model for the red component is [μ]. R -kσ R +kσ R The distribution range of the Gaussian model for the green component is [μ]. G -kσ G ,μ G +kσ G The distribution range of the blue component Gaussian model is [μ]. B -kσ B ,μ B +kσ B The distribution ranges of the three color component Gaussian models are combined and integrated into a Gaussian-fitted RGB tobacco leaf image.
[0037] Preferably, step S3 specifically includes the following steps:
[0038] S31: The pixel intensity of the RGB tobacco leaf image is clustered using the K-means clustering algorithm and Gaussian fitting. Given an image of size M×N with a total of M×N pixels, each pixel is composed of three components: RGB. The M×N pixels are clustered using K-means, resulting in multiple clusters. Each cluster has a cluster center and multiple sample points. The variance is calculated using an unbiased estimate of the variance and multiplied by the total number of samples corresponding to each cluster.
[0039] S32: The formula for calculating the Calinski-Harabasz index is:
[0040]
[0041] Among them B k For class spacing, W k The formula for calculating the class margin is as follows;
[0042]
[0043]
[0044] Where C q Indicate the class q, c of the current point. q C is the cluster center of the current class q. E n represents the center of class E. q Indicates the number of points contained in q;
[0045] A larger S-value indicates a better clustering effect and a greater difference between clusters. In this case, the distance between clusters is much greater than the distance within clusters, meaning that the clusters are farther apart and the clustering results are better. Conversely, if the S-value is smaller, it indicates that the clusters are closer together and the clustering effect is worse.
[0046] S33: Using the Calinski-Harabasz index evaluation system for clustering, the best clustering was found to be 5 clusters after comparing 3-, 4-, 5-, and 6-cluster tests.
[0047] Preferably, step S4 specifically includes the following steps:
[0048] S41: After finding the best cluster in S3, find its corresponding cluster class, and then compare the correlation factors between the cluster classes, including the wrinkles, holes, and stems on the surface of the tobacco leaf. First, extract the RGB values of the pixels of the stems, wrinkles, and holes. Then, through the cluster analysis of the entire leaf surface, compare the RGB values of the color block with the smallest cluster proportion and the Euclidean distance of the interference pixel. Under the RGB domain, compare the Euclidean distance in the color space. The smaller the Euclidean distance, the more similar the colors are.
[0049] S42: Extract and compare 5 clusters by the RGB values of pigments from different tobacco leaves and different interference parts, and remove the cluster with the closest RGB Euclidean distance and the smallest spatial distance of interference terms. Compare the RGB Euclidean distance between the centers of the remaining 4 color blocks. The smaller the Euclidean distance, the more similar the two color blocks are. Merge the similar color blocks together as the main color of the tobacco leaf. Finally, 3 color blocks with high similarity are merged into the main color.
[0050] Preferably, the Euclidean distance is calculated using the Euclidean Distance of Raw RGB method, with the specific formula as follows: Where C1 and C2 represent color 1 and color 2 respectively, C 1,R C represents the red channel of color 1. 1,G C represents the green channel of color 1. 1,B This represents the blue channel of color 1.
[0051] The beneficial effects of this invention are:
[0052] The method of this invention can serve as a novel method for expressing the uniformity of a single tobacco leaf, and can also be used for statistical analysis of the uniformity of tobacco leaves across multiple groups (such as grade, region, etc.). It provides a reference method for extracting the dominant color tone of tobacco leaves at the visual level. Attached Figure Description
[0053] Figure 1 This is a flowchart of the method for digitally representing the uniformity of a tobacco leaf based on the similarity of the main color clusters of RGB single leaves, according to the present invention.
[0054] Figure 2 (a) is the Gaussian fitting plot of the R component, (b) is the Gaussian fitting plot of the G component, and (c) is the Gaussian fitting plot of the B component.
[0055] Figure 3 This is a flowchart of the Gaussian fitting process.
[0056] Figure 4 Comparison chart of Calinski-Harabasz evaluation for different cluster types.
[0057] Figure 5 A color block diagram with a primary color tone.
[0058] Figure 6 This is a comparison chart of cluster factor similarity. Detailed Implementation
[0059] The present invention will be further described below with reference to the accompanying drawings and embodiments. However, the accompanying drawings and embodiments are not intended to limit the technical solutions of the present invention. Any modifications or improvements made based on the teachings of the present invention shall fall within the protection scope of the present invention.
[0060] like Figure 1 As shown, the method for digitally representing uniformity based on the cluster similarity of the main color tone of a single tobacco leaf according to the present invention includes the following steps:
[0061] S1: Acquire tobacco leaf images and perform preprocessing to generate preprocessed tobacco leaf images;
[0062] S2: Analyze the preprocessed tobacco leaf image, extract the histogram data of the RGB color components, perform Gaussian fitting on it to achieve image denoising, and obtain the distribution range of the Gaussian model of R, G, and B components, and then combine them into a Gaussian fitted RGB tobacco leaf image.
[0063] S3: First, perform pixel clustering using the K-means clustering algorithm on the Gaussian-fitted RGB tobacco leaf image in S2, and then use the Calinski-Harabasz exponent to compare each cluster to find the best cluster.
[0064] S4: Find the best cluster after clustering, calculate the Euclidean distance between clusters, eliminate the hue with the lowest similarity, and obtain the main hue with the highest similarity.
[0065] S5: Retain the main color with the highest similarity and use the proportion of the main color value as the uniformity of the main color of the tobacco leaf.
[0066] Specifically as follows:
[0067] Image acquisition and preprocessing of industrial tobacco leaves is a crucial step, directly impacting the success of subsequent image processing. Image preprocessing includes background removal, contour extraction, and leaf surface extraction. Images acquired by the acquisition device consist of a monochrome background (background panel) and foreground (i.e., tobacco leaves). To analyze the material's color characteristics, the material must first be distinguished from the background—that is, the background must be removed, and the foreground extracted to facilitate analysis of each tobacco leaf.
[0068] Background removal is a crucial step in image processing, directly impacting the success of subsequent image processing operations. This invention employs a frame difference method for background removal. This involves pre-storing background frames, first converting the tobacco leaf image into a background frame for buffering, and then using the frame difference method for background removal. Specifically, each captured image frame is compared with the background frame; pixels matching the background color are identified as background, while those differing are identified as foreground. Let the background frame be B, and the RGB vector of a pixel within the background frame be B0. i,j The acquired material image is S, and the RGB vector of a certain pixel in the material image is S. i,j Δ is a fixed RGB vector, and the frame difference method is shown in the following formula:
[0069] S i,j =0if|S i,j -B i,j |≤|Δ|
[0070] In the formula, 0 is the RGB zero vector, i.e. (0,0,0).
[0071] In this invention, the image contour extraction employs the Canny operator; I[i, j] represents the image, and using a separable filtering process, the convolution integral of the image with the Gaussian smoothing filter is calculated to obtain the smoothed data matrix.
[0072] S[i,j]=G[i,j;σ]*I[i,j]
[0073] Where σ is the scattering parameter of the Gaussian function, the gradient of the smoothed data matrix S[i,j] is calculated using a 2×2 first-order finite difference approximation to calculate the partial derivatives of X and Y, and the two matrices P[i,j] and Q[i,j] are:
[0074]
[0075]
[0076] Calculate the amplitude and azimuth using the coordinate transformation formula from rectangular to polar coordinates:
[0077]
[0078] θ[i,j]=arcten(Q[i,j] / P[i,j])
[0079] Where M[i,j] is the amplitude and θ[i,j] is the azimuth angle. The Canny operator is the first derivative of the Gaussian function. It can better preserve the edge information of the image contour, has low sensitivity to contour noise, and its parameters can be adjusted according to different requirements to identify different edge characteristics, thus making it suitable for different occasions.
[0080] Leaf surface extraction can reduce data disturbance caused by background color. Its advantage lies in its ability to intuitively reflect leaf surface details that are imperceptible to the naked eye. It is one of the important expression methods for leaf surface representation extraction, and also one of the important methods for image feature extraction in image classification neural network models.
[0081] The process involves analyzing preprocessed tobacco leaf images, extracting histogram data of the RGB color components, performing Gaussian fitting on them to denoise the images, and determining the distribution range of the Gaussian models for the R, G, and B components. These are then combined to form a Gaussian-fitted RGB tobacco leaf image. Specifically, this includes the following steps: performing Gaussian fitting on the histogram statistics of the RGB color components of the tobacco leaf to obtain the parameters (μ, σ) of the Gaussian model for each component, where μ is the mean of the Gaussian distribution and σ is the standard deviation. The threshold range for a certain component is determined based on [μ-kσ, μ+kσ], where k is a coefficient, as detailed below:
[0082] R min =μ R -kσ R
[0083] R max =μ R +kσ R
[0084] G min =μ G -kσ G
[0085] G max =μ G +kσ G
[0086] B min =μ B -kσ B
[0087] B max =μ B +kσ B
[0088] Among them, R min R max These are the minimum and maximum thresholds for the red component, μ. R Let σ be the mean of the Gaussian distribution of the red component. R G represents the standard deviation of the Gaussian distribution of the red component. min G max These are the minimum and maximum thresholds for the green component, μ G Let σ be the mean of the Gaussian distribution of the green component. G B is the standard deviation of the Gaussian distribution of the green component; min B max These are the minimum and maximum thresholds for the blue component, μ. B The mean of the Gaussian distribution of the blue component is σ. B The standard deviation of the Gaussian distribution for the blue component;
[0089] Based on the above parameters, the distribution range of the Gaussian model for the red component is [μ]. R -kσ R +kσ R The distribution range of the Gaussian model for the green component is [μ]. G -kσ G ,μ G +kσ G The distribution range of the blue component Gaussian model is [μ]. B -kσ B ,μ B +kσ B The distribution ranges of the three color component Gaussian models are combined and integrated into a Gaussian-fitted RGB tobacco leaf image.
[0090] A histogram, also called a bar chart, displays the exposure accuracy of a photograph as a waveform on a coordinate axis. The horizontal axis represents brightness levels, ranging from 0 (dark tones) on the left to 255 (light tones) on the right, dividing the photograph's brightness into 256 levels. The vertical axis represents the number of pixels at each brightness level; a higher peak indicates a larger number of pixels for that brightness value, and thus a larger area occupied in the image. Connecting these pixel values on the vertical axis forms a continuous histogram waveform. We can rationally judge the distribution and proportion of pixels using the horizontal and vertical axes of the histogram. Selecting a tobacco leaf, we analyze its color characteristics to obtain its color distribution characteristics, specifically the range of RGB components, i.e., the threshold range of the tobacco leaf's color components. We extract the histogram data of the tobacco leaf's color components, perform Gaussian fitting on it, obtain the parameters of the Gaussian distribution function, and plot the fitted Gaussian distribution graph, as shown below. Figure 2 As shown in (a)-(c). After verifying the Gaussian fitting of the histogram statistics of each component, it was found that the Gaussian fitting curves of the R, G, and B components of the material can basically cover the entire range of their true values.
[0091] Gaussian model method: Gaussian fitting is performed on the histogram statistics of a certain component of the selected material to obtain the parameters (μ, σ) of the Gaussian model for each component, where μ is the mean of the Gaussian distribution and σ is the standard deviation. Then, the threshold range of a certain component can be determined based on [μ-kσ, μ+kσ], where k is a coefficient. The algorithm flowchart of the parameter extraction method based on the Gaussian model is shown below. Figure 3 As shown.
[0092] K-means clustering, originating from a vector quantization method in signal processing, is now more widely used as a clustering analysis method in data mining. The goal of K-means is to divide n data points into k clusters. Each of the n data points is assigned to the cluster closest to the mean. The mean of each cluster is called the "centroid" or "center". For example, clustering the pixel intensity of an RGB image. Given an M×N image with M×N pixels, each pixel consists of three components: red, green, and blue. We treat these M×N pixels as data points and cluster them using K-means. Since the distance from each cluster center to the global cluster center is only calculated once, the variance ratio is multiplied by the total number of samples corresponding to each cluster to eliminate differences in intra-cluster distances; simultaneously, an unbiased estimate of the variance is used when calculating the variance. This invention employs the K-means clustering algorithm to cluster the pixel intensity of an RGB tobacco leaf image using Gaussian fitting. Given an image of size M×N with a total of M×N pixels, each pixel is composed of three components: RGB. K-means is used to cluster the M×N pixels, resulting in multiple clusters. Each cluster has a cluster center and multiple sample points. The variance is calculated using an unbiased estimate of the variance and multiplied by the total number of samples corresponding to each cluster.
[0093] Clustering can be divided into n clusters. The Calinski-Harabasz index is used for comparison to determine the appropriate number of clusters. The Calinski-Harabasz index is essentially the ratio of inter-cluster distance to intra-cluster distance, and its overall calculation process is similar to variance calculation, hence it is also called the variance ratio criterion. The Calinski-Harabasz index measures intra-cluster density by calculating the sum of squared distances between each point in a cluster and the cluster center, and measures dataset separation by calculating the sum of squared distances between each cluster centroid and the dataset centroid. The Calinski-Harabasz index is derived from the ratio of separation (inter-cluster distance) to density (intra-cluster distance). Therefore, a larger Calinski-Harabasz index indicates more compact clusters and greater dispersion between clusters, resulting in a better clustering outcome.
[0094] The formula for calculating the Calinski-Harabasz index is:
[0095] Among them B k W represents the between-clusters dispersion mean (inter-class distance). k The formula for within-clusterdispersion (distance within a class) is as follows;
[0096]
[0097]
[0098] W k Chinese: C q Indicates the class q to which the current point belongs; c q It is the cluster center of the current class q;
[0099] B k Chinese: C E Indicates the center of class E; n q This indicates the number of points contained in category q;
[0100] A larger S-value indicates better clustering results, with greater differences between clusters. In this case, the inter-cluster distance is much greater than the intra-cluster distance, meaning that clusters that are farther apart have better clustering results. Conversely, a smaller S-value indicates that clusters that are closer together have poorer clustering results. Figure 4 As shown, this embodiment uses the Calinski-Harabasz index evaluation system for clustering to analyze and compare 3-, 4-, 5-, and 6-cluster tests, and finds that the optimal clustering is 5-cluster, meaning that the intra-cluster distances are close and the inter-cluster distances are farthest. Figure 4 As shown, based on the analysis of various experimental data, the optimal clustering category is 5. Therefore, this method uses 5 categories as the color extraction clusters. The 5-category CSA color chart obtained by the algorithm then represents the RGB main color tone of the tobacco leaf (values are percentages).
[0101] The dominant color tone refers to the overall color tendency of a painting, representing the overall color effect. Algorithms are used to extract the dominant color tone of tobacco leaves as the basis for representation. Color quantization involves an RGB image of a tobacco leaf, where each pixel has three components: R, G, and B. Each component is represented by one byte, resulting in a color space of 256^3. Obviously, the human eye cannot distinguish colors with such fine detail. Therefore, in computer processing, to save space or to index the color dimensions of the image, it is often necessary to extract the dominant color. This extraction process may involve merging similar colors, ultimately obtaining the main RGB values as the dominant color tone of the image.
[0102] After finding the best cluster, find its corresponding cluster class, and then compare the correlation factors between the cluster classes, including the wrinkles, holes, and stems on the surface of the tobacco leaf. First, extract the RGB values of the pixels of the stems, wrinkles, and holes. Then, through the cluster analysis of the entire leaf surface, compare the RGB values of the color block with the smallest cluster proportion and the Euclidean distance of the interference pixel. Under the RGB domain, compare the Euclidean distance in the color space. The smaller the Euclidean distance, the more similar the colors are.
[0103] Five clusters were extracted and compared based on the RGB values of pigments from different tobacco leaves and different interference parts. Clusters with the smallest RGB Euclidean distance and the smallest spatial distance between interference terms were removed. The RGB Euclidean distances between the centers of the remaining four color patches were compared; smaller distances indicated greater similarity, and similar patches were merged together as the dominant color of the tobacco leaf. Ultimately, three highly similar color patches were merged as the dominant color. The dominant color with the highest similarity was retained, and its color value percentage was used as the dominant color uniformity of the tobacco leaf.
[0104] Specifically, the Euclidean distance is calculated using the raw RGB Euclidean distance method, and the specific formula is as follows: Where C1 and C2 represent color 1 and color 2 respectively, C 1,R C represents the red channel of color 1. 1,G C represents the green channel of color 1. 1,B This represents the blue channel of color 1.
[0105] like Figure 5 After identifying the optimal cluster, find its corresponding 5 clusters, which are then referred to as the color blocks of the dominant color.
[0106] The proportions of the five color patches are as follows: C0 = 40.3%, C1 = 28.49%, C2 = 17.9%, C3 = 11.0%, and C4 = 2%, which together represent the main color tone of the entire tobacco leaf, 100. However, it is still necessary to compare the color patches between clusters, remove color patches with little influence and low similarity, and retain color patches with high similarity to obtain the optimal uniformity representation method.
[0107] Many factors affect color uniformity, such as wrinkles, holes, and stems on the surface of tobacco leaves. To make the results more accurate, a color clustering algorithm is used to identify these influencing factors. First, the RGB values of the pixels in the stems, wrinkles, and holes are extracted. Then, after clustering analysis of the entire leaf surface, the color space distance between the color block with the smallest cluster percentage and the RGB values of the interference pixels is compared.
[0108] Current research on dominant color sampling in images is mostly focused on image matching, restoration, and recognition. When comparing the similarity of colors in two images, the color space distance is typically compared within the RGB domain; the smaller the value, the closer the color distance and the more similar the colors.
[0109] like Figure 6As shown, by extracting and comparing the RGB values of pigments from different tobacco leaves and different interference parts, five main color tones were obtained. This also reflects that the classification color block C4 is closest to the RGB distance of these influencing factors (stalks, wrinkles, spots, and holes), and has the smallest spatial distance of interference items, indicating a high degree of similarity. Therefore, color block C4 can represent the interference factor class and has generalization ability, so it can be removed before calculating the evenness value.
[0110] Next, we compare the center RGB values of C0, C1, C2, and C3 to determine their similarity. We then compare the Euclidean distance between each pair of vectors. The smaller the distance, the more similar the two color patches are. Therefore, we can merge similar color patches together as the main color tone of the tobacco leaf. After determining the number of main color tone patches, we calculate the proportion of the main color tone, which is the uniformity metric.
[0111] Specific embodiments are shown below:
[0112] Table 1 shows the color space distances of C0, C1, C2, and C3. It reveals that C3 has the largest spatial distance from each color block. The spatial distances between the first three color blocks (C0, C1, and C2) are small, indicating high similarity. C3 has a relatively large distance from C0, C1, and C2, indicating very low similarity. Therefore, C0, C1, and C2 are spatially similar color blocks and can be merged as the primary color tone.
[0113] Table 1
[0114]
[0115] Ultimately, the tobacco leaf uniformity value E can be expressed as E = C0 + C1 + C2. Figure 5 For example: its tobacco leaf uniformity value E=(40.3+28.49+17.9=)=86.69.
[0116] The above description is only used to detail the specific embodiments of the present invention, but the technical solutions proposed by the present invention are not limited to the above methods. All equivalent modifications and variations made by those skilled in the art to the technology proposed by the present invention without departing from the basic principles of the present invention should be covered within the scope of the claims of the present invention.
Claims
1. A method for digital characterization of uniformity based on similarity of RGB single-leaf tobacco dominant color clusters, characterized by, The method comprises the following steps: S1: collecting tobacco leaf images and pre-processing to generate pre-processed tobacco leaf images; S2: analyzing the pre-processed tobacco leaf images, extracting the histogram data of the RGB color components, performing Gaussian fitting, realizing image denoising, and obtaining the distribution range of the R, G and B component Gaussian models, thereby combining to form a Gaussian fitting RGB tobacco leaf image; S3: first performing pixel clustering on the Gaussian fitting RGB tobacco leaf image in S2 using a K-means clustering algorithm, then comparing the Calinski-Harabasz index of each cluster to find the best cluster; S4: finding the best cluster, calculating the Euclidean distance between the clusters, and excluding the color tone with the lowest similarity to obtain the main color tone with the highest similarity; S5: retaining the main color tone with the highest similarity, and taking the color value proportion of the main color tone as the main color tone uniformity of the tobacco leaf; Step S4 specifically comprises the following steps: S41: after finding the best cluster in S3, find the corresponding cluster, then compare the related factors between the clusters including the wrinkles, holes and stems on the surface of the tobacco leaf, first extract the pixel point RGB value of the stem, wrinkles and holes, then compare the RGB value color space Euclidean distance between the smallest color block and the interference item pixel point through cluster analysis of the entire leaf surface, and compare the color space Euclidean distance in the RGB domain, the smaller the Euclidean distance, the more similar the colors; S42: compare the RGB values of the pigments of different tobacco leaves and different interference parts, eliminate the cluster with the closest RGB Euclidean distance and the smallest interference item space distance; compare the RGB Euclidean distances of the remaining four color blocks, the smaller the Euclidean distance, the more similar the two color blocks, combine the similar color blocks together as the main color tone of the tobacco leaf, and finally obtain three color blocks with high similarity, which are combined as the main color tone.
2. The method according to claim 1, wherein, The pre-processing in step S1 comprises image background removal, image contour extraction and image leaf surface extraction.
3. The method according to claim 2, wherein, The image background removing step is: firstly, converting the tobacco leaf collecting background image into a background frame for caching, and then using frame difference method to remove the image background, and the specific operation is: comparing each collected frame image with the background frame, and judging the pixel points with the same background color information as the background, and otherwise as the foreground; setting the background frame as X, the RGB vector of a certain pixel point in the background frame as X i,j , the collected material image as S, the RGB vector of a certain pixel point in the material image as S i,j , and Δ as a fixed RGB vector, and the frame difference method is shown in the following formula: S i,j = 0 if |S i,j -X ,j |≤|Δ| 0 is an RGB zero vector, i.e. (0, 0, 0).
4. The method according to claim 2, wherein, The image contour extraction uses a Canny operator to extract the image contour; I[i, j] represents the image, and a separable filter is used to calculate the convolution integral of the image and a Gaussian smoothing filter to obtain a smoothing data matrix: S[i,j]=Y[i,j;σ]*I[i,j] Wherein sigma is the dispersion parameter of the Gaussian function, the gradient of the smoothing data matrix S[i,j] is calculated using a 2x2 first-order finite difference approximation formula to calculate the partial derivatives of X and Y, and two matrices P[i,j] and Q[i,j] are: The amplitude and azimuth are calculated using the coordinate transformation formula from rectangular coordinates to polar coordinates: Theta[i,j]=arctan(Q[i,j] / P[i,j]) Wherein M[i,j] is the amplitude, and theta[i,j] is the azimuth.
5. The method according to claim 1, wherein, The step S2 specifically comprises the following steps: Gaussian fitting is performed on the tobacco RGB color component histogram statistics to obtain parameters (μ, σ) of each component Gaussian model, wherein μ is the mean of the Gaussian distribution, σ is the standard deviation, a threshold range of a certain component is determined according to [μ-k, μ+kσ], wherein k is a coefficient, and the specific process is as follows: R min = μ R -k σ R R max = μ R + kσ R G min = μ G -k σ G G max = μ G + kσ G B min = μ B -k σ B B max = μ B + kσ B wherein R min , R max are the minimum and maximum threshold values of the red component, μ R is the mean of the Gaussian distribution of the red component, and σ R is the standard deviation of the Gaussian distribution of the red component; G min , G max are the minimum and maximum threshold values of the green component, μ G is the mean of the Gaussian distribution of the green component, and σ G is the standard deviation of the Gaussian distribution of the green component; B min , B max are the minimum and maximum threshold values of the blue component, μ B is the mean of the Gaussian distribution of the blue component, and σ B is the standard deviation of the Gaussian distribution of the blue component. Based on the above parameters, the distribution range of the Gaussian model for the red component is [μ]. R -kσ R +kσ R The distribution range of the Gaussian model for the green component is [μ]. G -kσ G ,μ G +kσ G The distribution range of the blue component Gaussian model is [μ]. B -kσ B ,μ B +kσ B The distribution ranges of the three color component Gaussian models are combined and integrated into a Gaussian-fitted RGB tobacco leaf image.
6. The method according to claim 1, wherein, The step S3 specifically comprises the following steps: S31: The K-means clustering algorithm is used to cluster the pixel intensity of the Gaussian fitting RGB tobacco image, a M*N size image is given, there are M*N pixels in total, each pixel is composed of three components of RGB, K-means is used to cluster M*N pixels, and a plurality of cluster clusters are included, each cluster has a cluster center and a plurality of sample points; the unbiased estimation of variance is used to calculate the variance, and the total number of samples corresponding to each cluster is multiplied; The calculation formula of the Calinski-Harabasz index is as follows: where B k is the inter-class distance, W k is the intra-class distance, calculated as follows; where C q represents the class q in which the current point is located, c q is the cluster center point of the current class q, C E represents the center of the class E, n q represents the number of points included in the class q; The larger the S value is, the better the clustering effect is, and the larger the difference is, at this time, the inter-cluster distance is larger than the intra-cluster distance, that is, the farther the distance between clusters is, the better the clustering result is; on the contrary, if it is smaller, it indicates that the distance between clusters is closer, and the clustering effect is poorer; S33: Through the clustering Calinski-Harabasz index evaluation system, the best clustering is obtained by analyzing 3 types, 4 types, 5 types, 6 types of test comparison.
7. The method according to claim 1, wherein, The Euclidean distance is calculated by using the original RGB Euclidean distance method, and a specific formula is as follows: Wherein, C1 and C2 represent color 1 and color 2 respectively, C 1,R represents the red channel of color 1, C 1,G represents the green channel of color 1, C 1,B represents the blue channel of color 1.
Citation Information
Patent Citations
Method for characterizing color of characteristic tobacco by place of origin
CN101762583A
Tobacco leaf surface color uniformity judging method of flue-cured tobacco
CN102749140A
Method and device for judging color uniformity of flue-cured tobacco leaves based on machine vision
CN113838081A
Tobacco leaf grading method and system based on computer vision
CN115049865A