A tea quality grading system and method based on image detection
Through the tea quality grading method based on image detection, combined with illumination uniformity and color temperature compensation, and dynamic modulation of tea feature extraction and grading thresholds, the subjectivity and ambient light interference problems of traditional tea grading are solved, and efficient and accurate tea quality grading is achieved.
Patent Information
- Application Number
- CN202511007236.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-07-22
AI Technical Summary
Traditional tea quality grading relies on manual sensory evaluation, which is highly subjective and inefficient. Existing image analysis-based technologies have difficulty solving feature extraction errors caused by uneven lighting and color temperature shift under ambient light interference, and lack overall calibration, resulting in insufficient grading accuracy.
By obtaining the category identification and original RGB image of tea, calculating the illumination uniformity factor and color temperature offset, and combining the preset tea benchmark parameter mapping table, the environment-adapted spatial feature set and chromaticity coefficient are generated, and the illumination robust features are extracted by channel. The pre-trained quality scoring model is used and compensation correction is performed through dynamic grading thresholds to achieve tea quality grading.
It significantly suppresses the interference of uneven lighting and color temperature deviation in extreme environments, improves the accuracy and efficiency of tea grading, reduces the misjudgment rate, and achieves efficient and accurate grading of tea quality.
Smart Images

Figure CN120510460B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a tea quality grading system and method based on image detection. Background Art
[0002] Traditional tea quality grading mainly relies on manual sensory evaluation, which is highly subjective, inefficient, and has inconsistent standards. Although existing image analysis-based technologies can improve objectivity, they face multiple problems under the interference of ambient light. First, in terms of ambient light interference processing, existing methods find it difficult to simultaneously solve the uneven illumination intensity, resulting in the combined interference of contour distortion and color temperature offset when extracting morphological features. Most schemes only use general image enhancement methods such as histogram equalization, and are unable to adaptively compensate for special optical properties such as wrinkles and hairs on the surface of tea leaves; secondly, at the feature extraction level, mainstream technologies ignore the morphological differences of tea leaves and use the same processing strategy for the wrinkle highlight area of curled tea leaves and the vein texture area of flat tea leaves, resulting in insufficient detection rate of curled tea texture and excessively high false detection rate of flat tea morphology; finally, in the grading decision-making link, existing systems generally rely on fixed grading thresholds and lack a coupling compensation mechanism for ambient color temperature and feature discreteness, resulting in an increased misjudgment rate in extreme environments. The deeper problem lies in the fact that the three major links of environmental parameter calibration, feature extraction, and grading decision-making are in a state of separation. For example, color temperature compensation only acts on color correction but is not linked to the adjustment of grading thresholds. Morphological feature extraction has no dynamic correlation with the light uniformity factor, which ultimately leads to a lack of integrity in tea grading and reduces grading efficiency.
[0003] Therefore, it is necessary to provide a tea quality grading system and method based on image detection to solve the above technical problems. Summary of the Invention
[0004] In order to solve the above technical problems, the present invention provides a tea quality grading system and method based on image detection, which achieves the beneficial effect of efficient and accurate tea quality grading.
[0005] The present invention provides a tea quality grading method based on image detection, comprising:
[0006] S1: Obtain the category identification and original RGB image of the tea to be tested, and extract the illumination uniformity factor and color temperature offset of the original RGB image;
[0007] S2: Query the preset tea benchmark parameter mapping table through the category identifier to obtain the spatial feature benchmark coefficient set, spectral feature benchmark coefficient and benchmark decision weight matrix;
[0008] S3: Modulate the spatial feature reference coefficient set according to the illumination uniformity factor to generate the environment adaptation spatial feature set, perform color temperature compensation on the spectral feature reference coefficient and the reference decision weight matrix according to the color temperature offset, and generate the environment adaptation chromaticity coefficient and the environment adaptation decision matrix;
[0009] S4: Based on the environment adaptation spatial feature set and the environment adaptation chromaticity coefficient, and according to the tea morphology type determined by the category identification, feature extraction is performed on the original RGB image channel to obtain the illumination robust feature vector;
[0010] S5: Input the illumination robust feature vector into the pre-trained quality scoring model to obtain the original score, and compensate and correct the original score through the environment adaptation decision matrix to obtain the quality score of the tea to be tested;
[0011] S6: Based on the baseline grading threshold vector in the environmental adaptation decision matrix and combined with the discrete characteristics of the illumination robust feature vector, the dynamic grading threshold vector is calculated, and the quality score is converted into the quality grade of the tea to be tested according to the dynamic grading threshold vector.
[0012] Preferably, in step S1, the step of calculating the illumination uniformity factor includes:
[0013] Divide the original image into multiple grid areas;
[0014] Calculate the average brightness value of each grid area;
[0015] Calculate the brightness standard deviation of all grid areas and use the brightness standard deviation as the lighting uniformity factor.
[0016] Preferably, in step S1, the step of calculating the color temperature offset includes:
[0017] Segment the original RGB image of the tea leaves to be detected, and take the continuous tea area with the largest area as the main area;
[0018] Convert the main area into HSV color space and extract the median hue angle of H channel;
[0019] Based on the category identification of the tea to be tested, a preset tea benchmark parameter mapping table is searched to obtain the standard hue angle median and color temperature sensitivity coefficient of the tea to be tested;
[0020] The hue angle deviation is obtained by subtracting the median of the standard hue angle from the median of the H channel hue angle, and the color temperature offset is obtained by multiplying the hue angle deviation by the color temperature sensitivity coefficient of the tea to be tested.
[0021] Preferably, in step S2, the spatial feature reference coefficient set includes morphology enhancement reference coefficients and texture sensitivity reference coefficients.
[0022] Preferably, in step S3, modulating the spatial feature reference coefficient set according to the illumination uniformity factor to generate the environment adaptation spatial feature set includes the following steps:
[0023] The illumination uniformity factor is used to linearly amplify the morphology enhancement benchmark coefficient;
[0024] The illumination uniformity factor is used to perform exponential decay processing on the texture sensitivity benchmark coefficient;
[0025] The morphological enhancement benchmark coefficients after linear scaling and the texture sensitivity benchmark coefficients after exponential decay processing are combined into an environment adaptation space feature set.
[0026] Preferably, in step S3, performing color temperature compensation on the spectral characteristic reference coefficient according to the color temperature offset comprises the following steps:
[0027] The compensation direction is determined by the sign of the color temperature offset. A positive value performs blue-yellow enhancement compensation, while a negative value performs red enhancement compensation.
[0028] The absolute value of the color temperature offset is multiplied by a preset fixed proportional factor to obtain a compensation value;
[0029] When the color temperature offset is positive, the spectral characteristic base coefficient is added with the compensation value to obtain the environment adaptation chromaticity coefficient. When the color temperature offset is negative, the spectral characteristic base coefficient is subtracted with the compensation value to obtain the environment adaptation chromaticity coefficient.
[0030] Preferably, in step S3, the environment adaptation decision matrix includes a level weight vector, a feature weight matrix and a grading threshold vector.
[0031] Preferably, in step S4, the tea leaves include flat and curled types.
[0032] Preferably, in step S4, the step of performing feature extraction by channel includes:
[0033] The original RGB image is converted into a Lab color space image. When the tea morphology type is curly, the morphological gradient features are extracted from the L channel. When the tea morphology type is flat, the texture skeleton features are extracted from the a channel.
[0034] The present invention provides a tea quality grading system based on image detection, which is applied to a tea quality grading method based on image detection, comprising:
[0035] An environmental perception module is used to obtain the category identification and original RGB image of the tea to be detected, and to extract the illumination uniformity factor and color temperature offset of the original RGB image;
[0036] A parameter query module is used to query the preset tea benchmark parameter mapping table through the category identifier to obtain the spatial feature benchmark coefficient set, spectral feature benchmark coefficient and benchmark decision weight matrix;
[0037] The environmental adaptation modulation module is used to modulate the spatial feature reference coefficient set according to the illumination uniformity factor to generate the environmental adaptation spatial feature set, and perform color temperature compensation on the spectral feature reference coefficient and the reference decision weight matrix according to the color temperature offset to generate the environmental adaptation chromaticity coefficient and the environmental adaptation decision matrix;
[0038] The robust feature extraction module is used to extract features from the original RGB image channels based on the environment adaptation spatial feature set and the environment adaptation chromaticity coefficient, and according to the tea morphology type determined by the category identification, to obtain the illumination robust feature vector;
[0039] The quality scoring module is used to input the illumination robust feature vector into the pre-trained quality scoring model to obtain the original score, and then compensate and correct the original score through the environmental adaptation decision matrix to obtain the quality score of the tea to be tested;
[0040] The quality grading module is used to calculate the dynamic grading threshold vector based on the baseline grading threshold vector in the environmental adaptation decision matrix and the discrete characteristics of the illumination robust feature vector, and convert the quality score into the quality grade of the tea to be tested according to the dynamic grading threshold vector.
[0041] Compared with related technologies, the tea quality grading system and method based on image detection provided by the present invention has the following beneficial effects:
[0042] The present invention constructs a dual environmental compensation system by fusing the illumination uniformity factor and the color temperature offset, and implements dynamic modulation in the feature extraction stage: the spatial feature reference coefficient set is linearly amplified by the morphological enhancement coefficient and exponentially attenuated by the texture sensitivity coefficient in response to the uneven illumination, which significantly suppresses the contour distortion under the interference of shadows and highlights; directional compensation is performed on the spectral feature reference coefficient in response to the color temperature offset, and at the same time, features are extracted in the Lab color space based on the tea morphology type, which solves the false detection rate caused by the interference of heterogeneous tea features; in the decision-making stage, third-order collaborative optimization is achieved through the environmental adaptation decision matrix, the feature weight matrix dynamically screens the core features to improve the robustness of the model, the graded threshold vector fuses the discrete characteristics of the features to generate a dynamic threshold, and the grade weight vector performs confidence weighted correction, ultimately ensuring the stability of the grading accuracy in extreme environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a flow chart of a tea quality grading method based on image detection according to the present invention;
[0044] Figure 2This is a module structure diagram of a tea quality grading system based on image detection according to the present invention. DETAILED DESCRIPTION
[0045] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all of the structures. Furthermore, the embodiments of the present invention and the features of the embodiments may be combined with one another unless there is a conflict.
[0046] It should also be noted that, for ease of description, only portions relevant to the present invention are shown in the accompanying drawings, rather than all of the contents. Before discussing the exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the various operations (or steps) as being processed sequentially, many of the operations can be performed in parallel, concurrently, or simultaneously. In addition, the order of the various operations can be rearranged. The process can be terminated when its operations are completed, but may also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0047] Example 1
[0048] A tea quality grading method based on image detection, in the specific implementation process, such as Figure 1 As shown, it shows a flow chart of a tea quality grading method based on image detection, including:
[0049] Step S1: Obtain the category identification and original RGB image of the tea to be tested, and extract the illumination uniformity factor and color temperature offset of the original RGB image.
[0050] Specifically, in step S1, the calculation step of the illumination uniformity factor includes:
[0051] Divide the original image into multiple grid areas;
[0052] Calculate the average brightness value of each grid area;
[0053] Calculate the brightness standard deviation of all grid areas and use the brightness standard deviation as the lighting uniformity factor.
[0054] Specifically, in step S1, the step of calculating the color temperature offset includes:
[0055] Segment the original RGB image of the tea leaves to be detected, and take the continuous tea area with the largest area as the main area;
[0056] Convert the main area into HSV color space and extract the median hue angle of H channel;
[0057] Based on the category identification of the tea to be tested, a preset tea benchmark parameter mapping table is searched to obtain the standard hue angle median and color temperature sensitivity coefficient of the tea to be tested;
[0058] The hue angle deviation is obtained by subtracting the median of the standard hue angle from the median of the H channel hue angle, and the color temperature offset is obtained by multiplying the hue angle deviation by the color temperature sensitivity coefficient of the tea to be tested.
[0059] In the specific implementation process, the original RGB image of the tea to be inspected is first collected by an industrial camera, and the tea category identification code entered by the user is obtained at the same time; for example, to quantify the light distribution, the entire image is divided into 8×8 rectangular grids of equal area, and the arithmetic mean of the pixel brightness in each grid is calculated respectively. Then, the standard deviation of these 64 brightness values is taken as the light uniformity factor. The larger the value, the more uneven the light. For the calculation of color temperature offset, the region segmentation algorithm based on superpixel segmentation is first performed on the tea image, and the tea main body region with the largest and most continuous area is selected. Specifically, a continuous area covering more than 40% of the area must be included. After converting the RGB values of the subject area to the HSV color space, all pixel values in the H channel are extracted and the median is calculated as the detected hue angle. The pre-set tea benchmark parameter mapping table is queried using the category identifier to obtain the median of the standard hue angle and color temperature sensitivity coefficient for that category under the D65 standard light source. The standard value is subtracted from the detected hue angle to obtain the hue angle deviation. A positive result indicates that the actual hue is yellower than the standard, meaning the light source is warmer. A negative result indicates that the hue is bluish, meaning the light source is cooler. Finally, this deviation is multiplied by the color temperature sensitivity coefficient to obtain the color temperature offset. This provides a quantitative basis for subsequent environmental compensation.
[0060] Step S2: query the preset tea benchmark parameter mapping table through the category identification to obtain the spatial feature benchmark coefficient set, spectral feature benchmark coefficient and benchmark decision weight matrix.
[0061] Specifically, in step S2, the spatial feature reference coefficient set includes morphology enhancement reference coefficients and texture sensitivity reference coefficients.
[0062] During the specific implementation process, the preset tea benchmark parameter mapping table is queried through the category identification. The mapping table is an embedded relational database, and the core structure includes three major data modules: the spatial feature benchmark coefficient set consists of a morphological enhancement benchmark coefficient and a texture sensitivity benchmark coefficient. The morphological enhancement coefficient has a value range of 0.5-1.2, which is used to control the sensitivity of contour curvature detection. For example, Biluochun curly tea is set to 0.85 to enhance wrinkle recognition. The texture sensitivity coefficient has a value range of 0.6-1.5, which is used to adjust the amplitude of vein texture enhancement. For example, Longjing flat tea is set to 1.1 to enhance vein development; the spectral feature benchmark coefficient stores the chromaticity compensation intensity under the standard light source, which is calibrated by the CIEDE2000 color difference model; the benchmark decision weight matrix includes the grade weight vector, the feature weight matrix and the grading threshold vector, which together constitute the basis for quality decision-making. The construction of a benchmark parameter mapping table for tea categories requires collecting thousands of samples in a D65 standard light box. Using gradient backpropagation optimization, the method first extracts contour curvature features from high-resolution images, then linearly regresses the curvature change rate with the sensory scores to determine the morphological coefficient. Next, the vein regions are segmented to calculate skeleton density, and the texture coefficient is determined using a density threshold mapping table. Finally, the decision weight allocation is optimized based on the confusion matrix of historical grading data. For example, a B+ tree index is established with the category identifier as the primary key, achieving query response times within 3ms, providing a benchmark for subsequent environmental adjustments.
[0063] Step S3: Modulate the spatial feature reference coefficient set according to the illumination uniformity factor to generate an environment adaptation spatial feature set, perform color temperature compensation on the spectral feature reference coefficient and the reference decision weight matrix according to the color temperature offset, and generate an environment adaptation chromaticity coefficient and an environment adaptation decision matrix.
[0064] Specifically, in step S3, the spatial feature reference coefficient set is modulated according to the illumination uniformity factor to generate the environment adaptation spatial feature set, which includes the following steps:
[0065] The illumination uniformity factor is used to linearly amplify the morphology enhancement benchmark coefficient;
[0066] The illumination uniformity factor is used to perform exponential decay processing on the texture sensitivity benchmark coefficient;
[0067] The morphological enhancement benchmark coefficients after linear scaling and the texture sensitivity benchmark coefficients after exponential decay processing are combined into an environment adaptation space feature set.
[0068] Specifically, in step S3, performing color temperature compensation on the spectral characteristic reference coefficient according to the color temperature offset includes the following steps:
[0069] The compensation direction is determined by the sign of the color temperature offset. A positive value performs blue-yellow enhancement compensation, while a negative value performs red enhancement compensation.
[0070] The absolute value of the color temperature offset is multiplied by a preset fixed proportional factor to obtain a compensation value;
[0071] When the color temperature offset is positive, the spectral characteristic base coefficient is added with the compensation value to obtain the environment adaptation chromaticity coefficient. When the color temperature offset is negative, the spectral characteristic base coefficient is subtracted with the compensation value to obtain the environment adaptation chromaticity coefficient.
[0072] Specifically, in step S3, the environment adaptation decision matrix includes a level weight vector, a feature weight matrix and a classification threshold vector.
[0073] During the specific implementation process, after querying the tea benchmark parameter mapping table through category identification to obtain the spatial feature benchmark coefficient set, the spatial feature benchmark coefficient set includes the morphological enhancement benchmark coefficient and the texture sensitivity benchmark coefficient, the spectral feature benchmark coefficient and the benchmark decision weight matrix, and the benchmark decision weight matrix includes the grade weight vector, the feature weight matrix and the grading threshold vector. First, spatial feature modulation is performed based on the illumination uniformity factor, and the factor is used to directly linearly amplify the morphological enhancement benchmark coefficient. The amplification ratio is dynamically controlled by the illumination uniformity factor, and the degree of amplification is inversely proportional to the value of the factor. The specific amplification can be determined by the experimental process. To the greatest extent, at the same time, the texture sensitivity benchmark coefficient is directly exponentially attenuated, and the attenuation degree is proportional to the value of the illumination uniformity factor, generating an environment adaptation space feature set that only contains the modulated morphological enhancement coefficient and the texture sensitivity coefficient; secondly, spectral compensation based on the color temperature offset is performed, and the compensation direction is directly determined according to the positive and negative signs of the color temperature offset. For positive values, blue-yellow enhancement compensation is performed, and for negative values, red enhancement compensation is performed. The absolute value of the color temperature offset is multiplied by a preset fixed proportional factor to obtain a compensation value. Addition or subtraction operations are directly performed on the spectral feature benchmark coefficient to generate the environment adaptation chromaticity coefficient. When the color temperature offset is positive, The spectral feature base coefficient is added with the compensation value to obtain the environmental adaptation chromaticity coefficient. When the color temperature offset is a negative value, the spectral feature base coefficient is subtracted with the compensation value to obtain the environmental adaptation chromaticity coefficient. Finally, the three components of the benchmark decision weight matrix are collaboratively compensated, and the grade weight vector, the feature weight matrix and the grade threshold vector are synchronously adjusted according to the same color temperature offset. For the adjustment of the grade weight matrix, for example, when the offset is a positive value, the weight of the quality grade of special grade is increased and the weight of the quality grade of secondary grade is reduced. When it is a negative value, the weight of the quality grade of special grade is reduced and the weight of the quality grade of secondary grade is increased. For the feature weight matrix For adjustment of the array, for example, when the color temperature offset is a positive value, the spectral feature weight is increased and the morphological feature weight is reduced; when it is a negative value, the morphological feature weight is increased and the spectral feature weight is reduced; for adjustment of the grading threshold vector, for example, when the offset is a positive value, the special grading threshold of the quality grade of special grade is lowered and the secondary grading threshold of the quality grade of secondary grade is increased; when it is a negative value, the special grading threshold of the quality grade of special grade is increased and the secondary grading threshold of the quality grade of secondary grade is lowered, and finally, an environmental adaptation decision matrix consisting of the three components after compensation is generated, so as to realize full-process adaptive correction under the combined interference of uneven illumination and color temperature offset.
[0074] Step S4: Based on the environment adaptation space feature set and the environment adaptation chromaticity coefficient, and according to the tea morphology type determined by the category identification, feature extraction is performed on the original RGB image channel to obtain a lighting robust feature vector.
[0075] Specifically, in step S4, the tea leaf morphology types include flat type and curled type.
[0076] Specifically, in step S4, the step of performing feature extraction by channel includes:
[0077] The original RGB image is converted into a Lab color space image. When the tea morphology type is curly, the morphological gradient features are extracted from the L channel. When the tea morphology type is flat, the texture skeleton features are extracted from the a channel.
[0078] During the specific implementation process, the morphological type of tea is first determined based on the category identification. For example, the morphological type of tea can be obtained by querying and constructing a tea type mapping table, such as "West Lake Longjing" corresponds to a flat type and "Dongting Biluochun" corresponds to a curly type. Then, the original RGB image is converted into the Lab color space, and differentiated channel feature extraction is performed for different morphological types. If it is a curly type of tea, only the morphological gradient features are extracted from the L channel of the Lab image. Specifically, the convolution kernel is constructed using the modulated morphological enhancement coefficient in the environmental adaptation space feature set to perform edge enhancement operations, while disabling texture-related operations. If it is a flat type of tea, only the texture skeleton features are extracted from the a channel of the Lab image. The texture-sensitive reference coefficient after spatial feature modulation is used to set the skeletonization threshold for vein recognition, and morphological processing is disabled at the same time. In the process of extracting single channel features, the environmental adaptation chromaticity coefficient is simultaneously applied for spectral calibration. Curly-type tea needs to enhance the spectral consistency of the brightness feature, and flat-type tea needs to ensure the color fidelity of the chromaticity channel. Finally, the morphological or texture features optimized by environmental parameters are quantized into a fixed-dimensional illumination robust feature vector. For example, the curly type outputs a 128-dimensional morphological feature vector, and the flat type outputs a 96-dimensional texture feature vector. The whole process strictly follows the principle of channel isolation. Texture extraction is disabled for the curly type, and morphological extraction is disabled for the flat type, providing data basis for subsequent steps.
[0079] Step S5: Input the illumination robust feature vector into the pre-trained quality scoring model to obtain the original score, and compensate and correct the original score through the environment adaptation decision matrix to obtain the quality score of the tea to be tested.
[0080] In the specific implementation process, the illumination robust feature vector is first input into the pre-trained quality scoring model with a three-layer convolutional neural network. The construction and training process of the quality scoring model is as follows: RGB images of thousand-level tea samples are collected under the D65 standard light source environment, including curly and flat tea types. National tea evaluation experts annotate the quality scores according to the national standard GB / T23776-2018 to form a training data set. After data enhancement by image rotation, cropping, and brightness fine-tuning, the input is a network structure consisting of two convolutional layers, a convolution kernel size of 3×3, a step size of 1, ReLU activation, a maximum pooling layer, a pooling window of 2×2, and a fully connected layer with 128 neurons. The final output layer uses a linear activation function to generate an original score of 0-100 points, which is calculated by the mean square error loss function and A The dam optimizer with a learning rate of 0.001 is iteratively trained until convergence. After the model converges, the network parameters are fixed for industrial deployment. In the model application stage, the light robust feature vector of the tea to be tested is input into the network to obtain the original score, and then the third-order correction driven by the environment adaptation decision matrix is performed: in the first stage, the feature weight matrix in the decision matrix is used to screen the dominant features, and according to the temporary level corresponding to the original score, for example, if the original score is 85 points, it corresponds to level 1, and the feature weight row of the level is selected, and the feature vector is multiplied element by element by the weight row to generate a weighted feature vector; in the second stage, the weighted feature vector is used to re-enter the quality scoring model to calculate the baseline score; in the third stage, the final level is determined based on the grading threshold vector of the decision matrix, and the level weight value corresponding to the final level in the decision matrix is extracted, according to the formula Confidence weighting is performed, where It is a gain coefficient preset based on the category identification of tea. For example, the gain coefficient of Longjing tea is set to 0.1, and the quality score of the tea to be tested after correction is finally output.
[0081] Step S6: Based on the reference grading threshold vector in the environmental adaptation decision matrix and in combination with the discrete characteristics of the illumination robust feature vector, a dynamic grading threshold vector is calculated, and the quality score is converted into the quality grade of the tea to be tested according to the dynamic grading threshold vector.
[0082] During the specific implementation process, after obtaining the quality score of the tea to be tested, the pre-stored benchmark grading threshold vector is first extracted from the environmental adaptation decision matrix, including benchmark thresholds for special grade, first grade, and second grade. Then, the discrete characteristics of the illumination robust feature vector are analyzed. For example, the degree of discreteness is quantified by calculating the standard deviation of the illumination robust feature vector. A dynamic grading threshold vector is generated based on the standard deviation and the benchmark grading threshold vector. Specifically, the standard deviation is added to the benchmark special grade threshold and multiplied by a preset adjustment coefficient to obtain a dynamic special grade threshold. The standard deviation is reduced from the benchmark second grade threshold and multiplied by a preset adjustment coefficient to obtain a dynamic second grade threshold. The first grade threshold remains unchanged at the benchmark value, wherein the adjustment coefficient is pre-stored based on the category identification of the tea. Finally, the compensated and corrected quality score is compared with the dynamic grading threshold vector. When the quality score is greater than or equal to the dynamic special grade threshold, it is judged as special grade. When the quality score is greater than or equal to the dynamic first grade threshold and less than the dynamic special grade threshold, it is judged as first grade. When the quality score is greater than or equal to the dynamic second grade threshold and less than the dynamic first grade threshold, it is judged as second grade. When the quality score is less than the dynamic second grade threshold, it is judged as unqualified, and the final quality grade of the tea to be tested is output.
[0083] The working principle of the tea quality grading method based on image detection provided by the present invention is as follows:
[0084] First, the original image and category identification of the tea to be inspected are collected in real time, and the illumination uniformity factor is calculated through grid analysis. The color temperature offset is calculated based on the deviation between the median of the HSV space hue angle and the pre-stored standard value in the segmented main tea area; then the tea benchmark parameter mapping table is queried to obtain the spatial feature benchmark coefficient set, the spectral feature benchmark coefficient and the benchmark decision weight matrix, wherein the morphological enhancement coefficient and texture sensitivity coefficient contained in the spatial feature set are subjected to linear proportional amplification and exponential attenuation processing of the illumination uniformity factor respectively to generate an environment-adapted spatial feature set; at the same time, the spectral feature benchmark coefficient performs positive and negative compensation operations according to the sign direction of the color temperature offset. When the color temperature offset is positive, the base value is increased to enhance the blue-yellow compensation ability, and when it is negative, the base value is reduced to enhance the redness compensation ability, and the environment-adapted chromaticity coefficient is output; the three types of components of the decision weight matrix are synchronously adjusted under the drive of the color temperature offset, and the grade weight vector is adjusted according to the cold Light or warm light environment increases or decreases the weight of special grade and secondary grade, the feature weight matrix reallocates the weight ratio of spectral and morphological features, and the grading threshold vector moves up or down the threshold boundary of special grade and secondary grade according to the environmental characteristics, and finally generates an environmental adaptation decision matrix; based on the above environmental adaptation parameters and the tea morphological type determined by the category identification, the original image is converted to Lab space and then the features are extracted channel by channel. For curly tea, only the morphological gradient features of the L channel are extracted, and for flat tea, only the texture skeleton features of the a channel are extracted to form a lighting robust feature vector that is resistant to environmental interference; after the vector is input into the pre-trained scoring model to obtain the original score, it is subjected to multi-dimensional compensation correction through the weights and threshold parameters in the decision matrix to obtain the final quality score; finally, combined with the discrete distribution characteristics of the lighting robust feature vector, the upper limit of the special grade and the lower limit of the secondary grade are dynamically offset on the basis of the benchmark grading threshold vector to form an adaptive dynamic threshold system to achieve quality grade conversion.
[0085] Example 2
[0086] A tea quality grading system based on image detection is applied to a tea quality grading method based on image detection. In the specific implementation process, Figure 2 As shown, it shows a module structure diagram of a tea quality grading system based on image detection, including:
[0087] The environmental perception module 100 is used to obtain the category identification and original RGB image of the tea to be detected, and extract the illumination uniformity factor and color temperature offset of the original RGB image;
[0088] Parameter query module 200, for querying a preset tea benchmark parameter mapping table by category identification to obtain a spatial feature benchmark coefficient set, a spectral feature benchmark coefficient, and a benchmark decision weight matrix;
[0089] The environment adaptation modulation module 300 is used to modulate the spatial feature reference coefficient set according to the illumination uniformity factor to generate the environment adaptation spatial feature set, and perform color temperature compensation on the spectral feature reference coefficient and the reference decision weight matrix according to the color temperature offset to generate the environment adaptation chromaticity coefficient and the environment adaptation decision matrix;
[0090] Robust feature extraction module 400, for extracting features from the original RGB image by channel based on the environment adaptation spatial feature set and the environment adaptation chromaticity coefficient, and according to the tea morphological type determined by the category identifier, to obtain a lighting robust feature vector;
[0091] The quality scoring module 500 is used to input the illumination robust feature vector into the pre-trained quality scoring model to obtain the original score, and to compensate and correct the original score through the environment adaptation decision matrix to obtain the quality score of the tea to be tested;
[0092] The quality grading module 600 is used to calculate the dynamic grading threshold vector based on the baseline grading threshold vector in the environmental adaptation decision matrix and the discrete characteristics of the illumination robust feature vector, and convert the quality score into the quality grade of the tea to be tested according to the dynamic grading threshold vector.
[0093] The working principle of the tea quality grading system based on image detection provided by the present invention is as follows:
[0094] First, the environmental perception module 100 captures the tea image and quantifies the degree of illumination non-uniformity and color temperature offset; the parameter query module 200 calls the pre-stored tea benchmark parameter mapping table to obtain the original spatial feature coefficient, spectral benchmark coefficient and decision weight matrix; the environmental adaptation modulation module 300 uses the illumination uniformity factor to perform linear proportional amplification and exponential attenuation dual-path processing on the spatial feature, and at the same time performs positive and negative compensation operations on the spectral coefficient according to the sign direction of the color temperature offset, and synchronously adjusts the three types of components within the decision weight matrix, dynamically corrects the grade weight distribution according to the cold light or warm light environment, reorganizes the feature weight ratio, and offsets the classification threshold boundary. Generate an environmental adaptation parameter set; the robust feature extraction module 400 converts the Lab space according to the tea morphological type, selectively extracts the morphological features of the lightness channel of curled tea or the texture features of the chromaticity channel of flat tea, and forms an anti-interference feature vector; the quality scoring module 500 inputs the vector into the neural network model to obtain the initial score, and then outputs the corrected quality score through the multi-dimensional compensation mechanism of the environmental adaptation decision matrix; the final quality grading module 600 combines the discrete characteristics of the feature vector, and dynamically floats the special grade upper limit and the secondary grade lower limit based on the benchmark threshold provided by the decision matrix to form an adaptive grading threshold, so as to achieve accurate grade determination that is immune to optical interference.
[0095] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0096] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium, including a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disc storage, magnetic disk storage, or magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0097] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
Claims
1. A tea quality grading method based on image detection, characterized in that: The tea quality grading method comprises the following steps: S1: Obtain the category identification and original RGB image of the tea to be tested, and extract the illumination uniformity factor and color temperature offset of the original RGB image; S2: Query the preset tea benchmark parameter mapping table through the category identifier to obtain the spatial feature benchmark coefficient set, spectral feature benchmark coefficient and benchmark decision weight matrix; S3: Modulate the spatial feature reference coefficient set according to the illumination uniformity factor to generate the environment adaptation spatial feature set, perform color temperature compensation on the spectral feature reference coefficient and the reference decision weight matrix according to the color temperature offset, and generate the environment adaptation chromaticity coefficient and the environment adaptation decision matrix; S4: Based on the environment adaptation spatial feature set and the environment adaptation chromaticity coefficient, and according to the tea morphology type determined by the category identification, feature extraction is performed on the original RGB image channel to obtain the illumination robust feature vector; S5: Input the illumination robust feature vector into the pre-trained quality scoring model to obtain the original score, and compensate and correct the original score through the environment adaptation decision matrix to obtain the quality score of the tea to be tested; S6: Based on the baseline grading threshold vector in the environmental adaptation decision matrix and in combination with the discrete characteristics of the illumination robust feature vector, a dynamic grading threshold vector is calculated, and the quality score is converted into the quality grade of the tea to be tested according to the dynamic grading threshold vector; In step S3, the spatial feature reference coefficient set is modulated according to the illumination uniformity factor to generate the environment adaptation spatial feature set, which includes the following steps: The illumination uniformity factor is used to linearly amplify the morphology enhancement benchmark coefficient; The illumination uniformity factor is used to perform exponential decay processing on the texture sensitivity benchmark coefficient; The morphological enhancement benchmark coefficient after linear scaling and the texture sensitivity benchmark coefficient after exponential decay processing are combined into an environment adaptation space feature set; In step S4, the step of performing feature extraction by channel includes: The original RGB image is converted into a Lab color space image. When the tea morphology type is curly, the morphological gradient features are extracted from the L channel. When the tea morphology type is flat, the texture skeleton features are extracted from the a channel.
2. The tea quality grading method based on image detection according to claim 1, characterized in that: In step S1, the step of calculating the illumination uniformity factor includes: Divide the original image into multiple grid areas; Calculate the average brightness value of each grid area; Calculate the brightness standard deviation of all grid areas and use the brightness standard deviation as the lighting uniformity factor.
3. The tea quality grading method based on image detection according to claim 2, characterized in that: In step S1, the step of calculating the color temperature offset includes: Segment the original RGB image of the tea leaves to be detected, and take the continuous tea area with the largest area as the main area; Convert the subject area into HSV color space and extract the median hue angle of the H channel; Based on the category identification of the tea to be tested, a preset tea benchmark parameter mapping table is searched to obtain the standard hue angle median and color temperature sensitivity coefficient of the tea to be tested; The hue angle deviation is obtained by subtracting the median of the standard hue angle from the median of the H channel hue angle, and the color temperature offset is obtained by multiplying the hue angle deviation by the color temperature sensitivity coefficient of the tea to be tested.
4. The method for tea quality grading based on image detection according to claim 3, characterized in that: In step S2, the spatial feature reference coefficient set includes morphology enhancement reference coefficients and texture sensitivity reference coefficients.
5. The method for tea quality grading based on image detection according to claim 4, characterized in that: In step S3, performing color temperature compensation on the spectral characteristic reference coefficient according to the color temperature offset includes the following steps: The compensation direction is determined by the sign of the color temperature offset. A positive value performs blue-yellow enhancement compensation, while a negative value performs red enhancement compensation. The absolute value of the color temperature offset is multiplied by a preset fixed proportional factor to obtain a compensation value; When the color temperature offset is positive, the spectral characteristic base coefficient is added with the compensation value to obtain the environment adaptation chromaticity coefficient. When the color temperature offset is negative, the spectral characteristic base coefficient is subtracted with the compensation value to obtain the environment adaptation chromaticity coefficient.
6. The method for tea quality grading based on image detection according to claim 5, characterized in that: In step S3, the environment adaptation decision matrix includes a level weight vector, a feature weight matrix and a classification threshold vector.
7. The method for tea quality grading based on image detection according to claim 6, characterized in that: In step S4, the tea leaves have a morphological type including a flat type and a curled type.
8. A tea quality grading system based on image detection, characterized in that: Applied to a tea quality grading method based on image detection as claimed in any one of claims 1 to 7, the tea quality grading system comprises: An environmental perception module is used to obtain the category identification and original RGB image of the tea to be detected, and to extract the illumination uniformity factor and color temperature offset of the original RGB image; A parameter query module is used to query the preset tea benchmark parameter mapping table through the category identifier to obtain the spatial feature benchmark coefficient set, spectral feature benchmark coefficient and benchmark decision weight matrix; The environmental adaptation modulation module is used to modulate the spatial feature reference coefficient set according to the illumination uniformity factor to generate the environmental adaptation spatial feature set, and perform color temperature compensation on the spectral feature reference coefficient and the reference decision weight matrix according to the color temperature offset to generate the environmental adaptation chromaticity coefficient and the environmental adaptation decision matrix; The robust feature extraction module is used to extract features from the original RGB image channels based on the environment adaptation spatial feature set and the environment adaptation chromaticity coefficient, and according to the tea morphology type determined by the category identification, to obtain the illumination robust feature vector; The quality scoring module is used to input the illumination robust feature vector into the pre-trained quality scoring model to obtain the original score, and then compensate and correct the original score through the environmental adaptation decision matrix to obtain the quality score of the tea to be tested; The quality grading module is used to calculate the dynamic grading threshold vector based on the baseline grading threshold vector in the environmental adaptation decision matrix and the discrete characteristics of the illumination robust feature vector, and convert the quality score into the quality grade of the tea to be tested according to the dynamic grading threshold vector.
Citation Information
Patent Citations
FPGA (field programmable gate array)-based automatic tobacco leaf grading system
CN106446968A
Finished tea type and grade identification method based on image color and texture features
CN112418161A