Method and system for automatic evaluation of tea color based on machine vision
By constructing a stable optical measurement environment and using multi-band polarization imaging technology, the reflective components on the surface of tea leaves are separated and spectral consistency is corrected. This solves the problems of subjectivity and environmental interference in tea color assessment, and realizes automated, standardized and high-precision assessment of tea color.
Patent Information
- Application Number
- CN202511747678.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-11-26
AI Technical Summary
Traditional manual methods for assessing tea color rely on the assessor's experience, resulting in strong subjectivity, poor consistency, and susceptibility to interference from ambient light. Existing machine vision technology lacks accuracy and robustness in tea color detection.
A stable optical measurement environment is constructed, and the mirror and diffuse reflection components are separated by multi-band polarization sequence imaging. Spectral consistency correction is performed by combining radiation baseline parameters, mapping to the CIE Lab color space, extracting multi-dimensional color feature vectors, and constructing a quantitative evaluation and grade determination model, comprehensively considering moisture content changes and anomaly detection.
It has enabled automated and standardized determination of tea color, improved detection efficiency and the reliability and comparability of results, and ensured the consistency and traceability of evaluation results between different batches.
Smart Images

Figure CN121207890B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of machine vision and optical inspection technology, specifically to a method and system for automatic evaluation of tea color based on machine vision. Background Technology
[0002] As a key sensory indicator for judging the quality and grade of tea, the objective and accurate quantitative evaluation of tea color has always been an important direction for the development of tea quality control technology. Traditional manual evaluation methods rely heavily on the professional experience of the evaluators and have accumulated a valuable sensory evaluation knowledge system. With the advancement of machine vision and spectral analysis technology, tea color detection has gradually shifted from subjective judgment to objective measurement. Existing technologies can achieve a certain degree of color analysis through color imaging and simple spectral feature extraction.
[0003] Chinese invention patent CN120635597B discloses a machine vision-based tea variety identification method and system. This system uses a multi-band image acquisition device to capture surface and partial internal structure information of the tea leaves, obtaining raw image data. By real-time detection of ambient light and exposure features in the acquired images, it automatically adjusts the light source intensity and distribution, calibrates camera parameters, extracts the complete outline of the tea leaves and the foreground image region, and fuses them into a unified hybrid feature vector, providing the core data representation for variety identification. A lightweight neural network model identifies and judges the multidimensional features of the tea leaf images, outputting the specific variety category and confidence level, and generating corresponding sorting control instructions. Based on the system's decision, it controls the sorting device, including a robotic arm and a pneumatic sorter, to place the tea leaves into the corresponding packaging channel and provides feedback on the track status, forming a closed-loop control.
[0004] However, the complex optical properties of tea surface and the holistic nature of color perception place higher demands on the accuracy and robustness of the technology. To further improve the scientific rigor and repeatability of the evaluation results, in-depth research is needed in areas such as imaging environment standardization, fine analysis of reflectance characteristics, and multi-dimensional feature fusion, thereby promoting the continuous development of tea quality testing technology towards automation, high precision, and intelligence. Summary of the Invention
[0005] The purpose of this invention is to address the problems existing in the background technology by proposing an automatic evaluation method and system for tea color based on machine vision.
[0006] The technical solution of this invention: an automatic tea color evaluation method based on machine vision, comprising the following specific implementation steps:
[0007] S1. Construct a stable and repeatable optical measurement environment and calculate the system's radiation baseline parameters;
[0008] S2. Perform multi-band polarization sequence imaging on tea samples under optical measurement conditions to obtain raw image data;
[0009] S3. Use multi-band polarization sequence imaging data to separate the specular and diffuse reflection components of the tea surface, and combine the radiation baseline parameters to perform spectral consistency correction to obtain the corrected diffuse reflection image.
[0010] S4. Based on the corrected diffuse reflection image, perform multi-band spectral reconstruction and normalization processing, map to the CIE Lab color space, and extract pixel-level brightness, chromaticity and color distribution statistical indicators. Then, combine with the spatial weighting matrix for optimization to generate the final color feature vector.
[0011] S5. Construct a quantitative evaluation and grading model based on color feature vectors, comprehensively calculate perceived color score, drying calibration color score and penalty term, and thus obtain the final score and output the color grade result of the tea.
[0012] Preferably, step S1 includes:
[0013] The tea sample to be tested is evenly laid on a neutral non-reflective substrate with a surface reflectivity of less than 0.05, and the substrate is kept at a fixed distance from the camera optical axis by a positioning groove. The attitude matrix of the sample is established in a plane coordinate system.
[0014] The sample posture is automatically adjusted through visual feedback so that the absolute value of the angle between the sample principal plane normal and the camera optical axis is no greater than 1 degree.
[0015] A semi-enclosed microenvironment was set up above the sample, and the temperature and relative humidity were kept constant through a temperature and humidity control mechanism. The environmental stability was then calculated.
[0016] A calibrated neutral reflective reference plate was placed at the edge of the sample base plate, and a micro sample tray containing the same batch of tea leaves was placed simultaneously.
[0017] The radiation baseline parameters are calculated based on the attitude matrix, environmental stability, and normalized reflectance.
[0018] Preferably, step S2 specifically includes:
[0019] The built-in multi-channel programmable LED array generates narrowband illumination covering the 400nm~900nm wavelength band, and sets the emission sequence and exposure energy according to the adaptive coding sequence;
[0020] Under each band of illumination, the polarization modulation unit is controlled to acquire images in two polarization angle states of zero degrees and ninety degrees in sequence to form polarization frame pairs, and the phase difference between the polarizer angle switching and the camera shutter signal is less than 1 millisecond.
[0021] Assign a composite code containing spectral and polarization states to each frame of acquired image, write it into the image metadata, and generate a timestamp and associate it with the global acquisition log.
[0022] The system monitors the average brightness and standard deviation of each frame in real time and dynamically adjusts the exposure time of subsequent frames according to the brightness control rules. If the brightness deviation exceeds the threshold for several consecutive frames, the system automatically executes the brightness correction procedure.
[0023] Preferably, step S3 specifically includes:
[0024] The polarization difference matrix for each band is calculated based on the two sets of polarization images obtained from polarization sequence imaging to initially separate specular reflection and diffuse reflection components.
[0025] A pixel-level specular reflection weight matrix is established based on the polarization difference matrix, and low-pass filtering and neighborhood smoothing are applied to the weight matrix to ensure its spatial continuity and spectral consistency.
[0026] The diffuse reflectance components that were initially separated were normalized using the radiation baseline parameters to obtain the corrected diffuse reflectance image matrix.
[0027] The spectral mean and standard deviation of each frame of diffuse reflection image are calculated, and the correction effect is judged based on the set threshold. If the requirements are not met, the specular reflection weight matrix is updated through an iterative algorithm.
[0028] Preferably, step S4 specifically includes:
[0029] The corrected diffuse reflectance image sequence is integrated into a three-dimensional spectral matrix by band, and a continuous approximate spectral curve is generated using a local weighted spectral interpolation method.
[0030] The continuous spectral matrix is normalized by combining radiation baseline parameters and energy balance information to eliminate band response differences and environmental biases.
[0031] The normalized spectral matrix is mapped to the CIE Lab color space to obtain the lightness value, red-green value and yellow-blue value of each pixel, and the mean, standard deviation and skewness of each channel in the sample area are calculated as basic statistical indicators.
[0032] A spatial weighted matrix is constructed based on local brightness gradient, texture roughness, and local reflection consistency. This matrix is then used to weight and aggregate basic statistical indicators to generate the final weighted color feature vector.
[0033] Preferably, step S5, which involves constructing a quantitative assessment and rating model, specifically includes:
[0034] The weighted color feature vector is mapped to the discriminative feature space through a linear transformation, and its Mahalanobis distance with the preset centers of each level is calculated. The distance is then converted into a perceptual color score through an exponential mapping.
[0035] By utilizing the moisture absorption peak characteristics in the near-infrared band of the multi-band reconstructed spectral information, the moisture content factor of the tea sample is calculated, and then the perceived color score is corrected for humidity to generate a dry calibration color score.
[0036] Anomaly masks are constructed based on pixel-level color differences. The proportion of abnormal pixels and the average deviation are statistically analyzed to calculate the severity of the anomaly. At the same time, a comprehensive penalty term is calculated by combining pixel-level reconstruction confidence and environmental stability indicators.
[0037] The final comprehensive score is calculated by combining the perceived color score, the drying calibration color score, and the comprehensive penalty item, and the color grade of the sample is determined according to the preset grade threshold and abnormal limit.
[0038] Preferably, calculating the moisture content factor of the tea sample and then performing humidity correction on the perceived color score specifically includes:
[0039] Using the near-infrared band in the range of 900nm to 1700nm, the characteristics of moisture absorption peaks are analyzed, and the estimated water content of each pixel is calculated.
[0040] The water content factor, representing the overall water content of the sample, is obtained by weighted averaging of the estimated water content of all pixels in the entire sample.
[0041] The water content offset is calculated based on the water content factor, and the offset is used to correct the sensory feature vector of the sample to obtain the sensory feature vector under dry conditions.
[0042] The Mahalanobis distance between the perceived feature vector under the dry state and the center of each level is calculated, and the dry calibration color score is obtained through exponential mapping.
[0043] Preferably, the calculation of the comprehensive penalty term includes:
[0044] The color uniformity index is defined based on the standard deviation of each color channel of the tea sample.
[0045] By comparing the difference between pixel-level perceptual feature vectors and their local window mean, and constructing an anomaly mask based on dynamically adjusted anomaly thresholds, the proportion of anomaly pixels is statistically analyzed.
[0046] The reconstruction error of each pixel is calculated and mapped to the reconstruction confidence score. At the same time, the environmental stability index is obtained by comparing the real-time observation value of the reference standard point with the standard value.
[0047] The comprehensive penalty term is calculated based on the global average of the reconstruction confidence level, the severity of the anomaly, and the environmental stability index.
[0048] Preferably, step S5 further includes an online adaptive update mechanism, specifically:
[0049] After determining the level, the central mean of the corresponding level is dynamically updated using the feature vector of the new sample with high confidence.
[0050] The weighting coefficients of perceived color and dry calibration color, the water content sensitivity coefficient, and the scaling coefficient of Mahalanobis distance are periodically recalibrated.
[0051] Through the continuous accumulation of micro-samples and manually verified samples, the adaptive learning and optimization of model parameters are achieved.
[0052] The technical solution of this invention: A machine vision-based automatic tea color evaluation system, used to execute the above-mentioned machine vision-based automatic tea color evaluation method, comprising:
[0053] The sample positioning and microenvironment control module is used to automatically and accurately place tea samples and maintain a stable imaging environment.
[0054] The image acquisition and multi-angle feature capture module is used to acquire multi-band polarization image data of the tea sample surface;
[0055] The color standardization and multi-feature fusion module is used to process the raw data obtained by the image acquisition module, separate the specular and diffuse reflection components, and perform spectral consistency correction.
[0056] The multi-band spectral reconstruction and color feature extraction module is used to reconstruct the continuous spectrum based on the corrected diffuse reflection image, map it to the standard color space, and extract the weighted multi-dimensional color feature vector.
[0057] The color quantification assessment and grading module is used to calculate the perceived color score and the drying calibration color score based on the color feature vector, combine the penalty items to make a comprehensive score, and finally output the color grading result of the tea and a traceable quality report.
[0058] Compared with the prior art, the above-mentioned technical solution of the present invention has the following beneficial technical effects:
[0059] This invention designs an automatic tea color evaluation method and system based on machine vision. By constructing a stable and controllable optical imaging environment and an automated acquisition process, it effectively overcomes the drawbacks of traditional manual visual evaluation of tea color, such as strong subjectivity, poor consistency, and susceptibility to ambient light interference. The introduced multi-band polarization imaging technology and specular diffuse reflection separation method can accurately remove high-gloss interference from the tea surface and obtain diffuse reflectance spectral information that faithfully reflects the tea's intrinsic color, significantly improving the accuracy and reliability of color data. Furthermore, through high-fidelity spectral reconstruction and CIE... Lab color space mapping enables refined quantitative extraction of multi-dimensional color characteristics of tea leaves, such as brightness, hue, and saturation, resulting in more comprehensive and objective evaluation results. The system comprehensively considers and corrects the impact of moisture content changes on color, while introducing uniformity indicators and anomaly detection mechanisms to enhance the robustness and practicality of the evaluation results. Finally, through an intelligent judgment model that integrates perceived color score, drying calibration color score, and comprehensive penalty items, the system achieves automated and standardized judgment of tea color grades, which not only significantly improves detection efficiency but also ensures the comparability and traceability of evaluation results between different batches. Attached Figure Description
[0060] Figure 1 This is a flowchart of a machine vision-based automatic tea color evaluation method proposed in this invention.
[0061] Figure 2 This is a system architecture diagram of an automatic tea color evaluation system based on machine vision proposed in this invention. Detailed Implementation
[0062] Example 1, as Figure 1 As shown, the present invention proposes an automatic tea color evaluation method based on machine vision, which includes the following specific implementation steps:
[0063] S1. Establish stable and repeatable optical measurement conditions before imaging acquisition to provide a unified geometric and radiometric reference for subsequent multi-band polarization sequence acquisition. The specific implementation process is as follows:
[0064] S11. Perform sample spatial positioning and attitude correction. Evenly lay the tea sample to be tested on a neutral, non-reflective substrate with a surface reflectivity of less than 0.05. The substrate maintains a fixed distance d0 from the camera's optical axis via a positioning groove. The sample is positioned in the plane coordinate system O. s Establish the attitude matrix :
[0065] ;
[0066] in, This represents the rotation matrix of the sample relative to the camera; Indicates the tilt angle of the sample in three axes; Represents the translation matrix; Represents the spatial coordinates of the sample's center point;
[0067] The sample posture is automatically adjusted by visual feedback so that the angle α between the sample principal plane normal and the camera optical axis satisfies |α|≤1°, thereby reducing the reflection error caused by the angle.
[0068] S12. To establish a stable microenvironment, a semi-enclosed microenvironment cover is placed above the sample to reduce interference from external light and humidity fluctuations. Temperature is maintained through a temperature and humidity control mechanism. and relative humidity The environmental stability function is defined as follows: ;
[0069] Where T0 and H0 represent ideal environmental parameters; and These represent the maximum allowable deviation ranges, respectively.
[0070] Environmental stability The closer the value is to 1, the higher the environmental stability. Closed-loop control can then be used to achieve this. ≥0.95, to ensure that the brightness and color of subsequent images are minimally affected by environmental fluctuations;
[0071] S13. Set up the reference plate and micro-sample tray, that is, place a calibrated neutral reflectance reference plate on the edge of the sample base plate, the reflectance of which is denoted as . The angle β between the reference plate and the center of the camera's field of view remains constant; trays containing 3-5 micro-samples of the same batch of tea leaves are placed simultaneously, and their spectral mean is used for subsequent micro-calibration, while the normalized reflectance is calculated during initialization. :
[0072] ;
[0073] Among them, I s Indicates the average gray value of the sample; I ref Indicates the grayscale value of the reference panel; I d Indicates dark current response;
[0074] By normalizing reflectance The dynamic adjustment enables automatic normalization of the measurement baseline;
[0075] S14. Based on the attitude matrix Environmental stability and normalized reflectance Calculate radiation baseline parameter B:
[0076] ;
[0077] Where k1 and k2 represent system calibration coefficients; α represents the angle between the sample normal and the optical axis;
[0078] If the radiation baseline parameter B exceeds the empirical range [0.8, 1.2], the light source brightness will be automatically reset and the reference frame will be reacquired to maintain the stability of the radiation baseline.
[0079] S2. Under the stable microenvironment and radiation baseline conditions established in step S1, multi-band polarization sequence imaging is performed on the tea sample to obtain raw image data that combines spectral and structural characteristics. The specific implementation process is as follows:
[0080] S21. Execute the narrowband illumination sequence generation and encoding control program: A built-in multi-channel programmable LED array covers the visible to near-infrared band from 400nm to 900nm, with the center wavelength of each band denoted as... Corresponding to half bandwidth and according to the adaptive coding sequence Set the light emission sequence:
[0081] ;
[0082] Encoded sequence Based on the radiation baseline parameter B generated in step S1, the exposure energy is adaptively adjusted to ensure that the exposure energy is... satisfy: ;
[0083] Where k represents the illumination constant; P i This indicates the driving power for the corresponding frequency band; t i Indicates the exposure time; n represents the corresponding band number;
[0084] S22. Execute the polarization state switching and inter-frame synchronization control program. Under each band of illumination, the polarization modulation unit sequentially adjusts the polarization angle. and Images are acquired under two states to form polarization-matched frames; the polarizer angle switching is driven by a high-speed electronically controlled rotation module, and its synchronization signal and the camera shutter signal are locked in phase difference of less than 1ms by the FPGA controller to ensure illumination stability between images; polarization difference is used for subsequent separation of the specular and diffuse reflection components, and the differential signal... The calculation formula is:
[0085] ;
[0086] in, Indicates band Down polarization angle The image grayscale matrix;
[0087] S23. Perform spectral-polarization composite coding and frame-level timestamp annotation. After each frame is acquired, assign a composite code to that frame: ;
[0088] in, This represents a hash encoding function that outputs a 128-bit frame identifier.
[0089] Will Write image metadata and generate timestamps It is associated with the global collection log to form a traceable collection sequence;
[0090] S24. Execute the dynamic exposure self-adjustment and sequence verification procedure, and monitor the average brightness of each frame in real time during the acquisition process. and standard deviation According to brightness control rules Make minor adjustments to the exposure time;
[0091] Among them, L t Indicates the target brightness threshold; L i Indicates the current target brightness; t i+1 This indicates the adjusted exposure time;
[0092] If the brightness deviation is three consecutive frames It automatically executes a brightness correction procedure, adjusting... and Rebalancing energy;
[0093] Based on this, a complete multi-band polarization sequence dataset D is obtained. raw :
[0094] .
[0095] S3. Using the multi-band polarization sequence obtained in step S2, specular and diffuse reflection components on the tea surface are separated. Combined with the radiation baseline parameter B from step S1, spectral brightness consistency correction is achieved, providing a high-fidelity optical foundation for subsequent color quantification evaluation. The specific implementation process is as follows:
[0096] S31. Perform polarization difference calculation and preliminary separation based on the polarization pair frame data from step 2. and Calculate the polarization difference matrix, i.e., the difference signal D. i : ;
[0097] Among them, D i Indicates band The initial estimate of the specular reflection intensity is obtained, and the remaining part corresponds to the diffuse reflection component. Through this difference matrix, the initial separation of specular and diffuse reflection is achieved at the pixel level.
[0098] S32, For each polarization difference matrix Establish a pixel-level specular reflection weight matrix W m :
[0099] ;
[0100] Where (x,y) represents pixel coordinates; ε represents a small constant to prevent division by zero;
[0101] It should be noted that the pixel-level specular reflection weight matrix W m The value range is [0,1], with high values indicating a high proportion of specular reflection and low values indicating a high proportion of diffuse reflection. The weight matrix is processed by low-pass filtering and neighborhood smoothing between different bands to ensure spectral consistency and spatial continuity.
[0102] S33. Normalize the diffuse reflection portion according to the radiation baseline B in step S1:
[0103] ;
[0104] in, This represents the corrected diffuse reflection image matrix;
[0105] S34. Execute the spectral consistency check and iterative optimization procedure to calculate the spectral mean S of each frame of diffuse reflectance image. mean With standard deviation S std According to the set threshold Determine whether the correction effect meets the requirements:
[0106] like Then the weight matrix W is updated iteratively. m ;
[0107] That is, if the threshold is exceeded, the weight matrix W is fine-tuned using gradient descent. m In this embodiment, the number of iterations N max Set the number of iterations to three or less to balance accuracy and computational efficiency.
[0108] S4. Based on the diffuse reflectance corrected image output in step S3, high-precision quantitative feature extraction of tea color is achieved through multi-band spectral reconstruction, normalization correction, color mapping, and spatial weighted optimization. This provides a scientific and reliable multi-dimensional indicator for color grade determination, taking into account spectral integrity, cross-batch consistency, and visual perception authenticity. The specific implementation process is as follows:
[0109] S41. The corrected image sequence output in step S3 is integrated into a three-dimensional spectral matrix by band, and a continuous spectral curve is generated by local weighted interpolation to complete the high-fidelity spectral reconstruction under finite bands. Specifically:
[0110] The corrected image sequence obtained in step S3 is divided into bands. Integrated into a three-dimensional spectral matrix:
[0111] ;
[0112] To address the issue of spectral sparsity across bands, a locally weighted spectral interpolation method is employed to generate continuous spectra.
[0113] ;
[0114] ;
[0115] in, This indicates the diffuse reflection image output from step S3, after specular components have been removed and radiometric normalization correction has been applied, at pixel (x,y) and in the band [band missing]. Gray / radiance readings (numerical matrix) are obtained below. This represents the discrete sampled values in the original multi-band spectral matrix, i.e., the pixel (x,y) in the sampling band. The diffuse reflectance value below; This represents the interpolation weights, i.e., the discrete bands at the target wavelength λ. The weight of contribution to the interpolation result; Indicates discrete bands The continuous approximate spectral value obtained after interpolation is the estimated reflectance value at any wavelength λ.
[0116] S42. Normalize the continuous spectral matrix, and combine it with the radiation baseline parameters and micro-sample references to eliminate differences in band response and deviations caused by light sources or environment, thereby achieving spectral consistency among different batches of tea samples and providing reliable input for color mapping.
[0117] Based on the radiation baseline B from step S1 and the energy balance information from step S2, the spectral matrix for each band is normalized: ;
[0118] in, This indicates the interpolated spectrum. The normalization process is used to eliminate band response differences and light source / environment biases, giving different bands a unified dimension; S max (λ) represents the maximum reference gray value at wavelength λ; S min (λ) represents the minimum reference gray value at wavelength λ;
[0119] S43. Map the normalized spectral matrix to the CIE Lab color space, calculate pixel-level brightness, chromaticity, and color distribution statistics to obtain the overall color and uniformity information of the sample, i.e.:
[0120] The normalized spectral matrix S norm (x,y,λ) mapped to the CIE Lab color space yields pixel-level CIE Lab color space coordinates: , , ;
[0121] Then, pixel-level statistical metrics for the samples were calculated, including mean, standard deviation, and skewness:
[0122] ;
[0123] in, Indicates brightness; Represents the chromaticity components from green to red; F represents the chromaticity components from blue to yellow. color This represents an unweighted pixel statistical feature vector; , and These represent the arithmetic mean of the corresponding channels within the sample area, and respectively represent the overall brightness and the main hue tendency; , and These represent the sample standard deviations of the corresponding channels, reflecting the spatial uniformity of color (the larger the value, the less uniform the color). , and These represent skewness, a statistical measure describing the degree of skewness in the distribution of pixel values, reflecting whether there is a local color shift (e.g., local color spots causing distribution shift);
[0124] S44. Construct a spatial weighted matrix based on local texture and brightness gradients to optimize pixel-level color features, reducing the influence of local highlights and texture unevenness, and generating the final weighted color feature vector, i.e.:
[0125] Apply a texture weighting matrix W to pixel-level color features s (x, y), calculate the weighted color feature vector:
[0126] ;
[0127] Among them, W s (x,y) represents the spatial weighting matrix, i.e., the set pixel-level weighting coefficients used to adjust the contribution of each pixel to the overall feature when constructing the final feature vector; F weighted Indicates spatial weighting W s The final color feature vector after aggregation;
[0128] It should be noted that the weight W s(x,y) is constructed based on local brightness gradient, texture roughness (local Gabor energy) and local reflectance consistency (inverse ratio of spectral variance in the neighborhood). High gradient or local highlight regions are assigned low weights, while flat diffuse reflectance regions are assigned high weights.
[0129] S5. Based on the output data of the aforementioned multi-band spectral reconstruction, a quantitative evaluation and grading model for tea color is constructed. Through multi-dimensional color parameter mapping, perceptual consistency calibration, grading interval division, and intelligent adaptive judgment, a high-precision conversion from objective spectral characteristics to subjective aesthetic evaluation is achieved, forming a standardized color quantification system. The specific implementation process is as follows:
[0130] S51. By performing CIE Lab color gamut mapping and normalization transformation on multi-band reflectance data, multi-dimensional features are extracted and a color feature vector is formed. Simultaneously, by combining saturation difference and hue shift correction factors, the model ensures that it can accurately express the comprehensive characteristics of tea surface brightness, hue, and saturation, providing a unified feature basis for subsequent perceptual evaluation. Specifically:
[0131] The weighted color feature vector F output in step S4 weighted Perform a linear transformation to map it to the discriminative feature space, denoted as vector v: ;
[0132] Subsequently, during the training phase, the distribution center in the perceptual space is established for each level g. With covariance matrix These parameters are generated from standard samples or high-confidence samples accumulated online, and are used to characterize the statistical features of color distribution at different levels.
[0133] Where v represents the feature vector of the perceptual discrimination space; M f Represents the color gamut conversion matrix; b f This represents the offset term, used to offset systematic biases in different imaging batches, so that the mapped features are stable across different batches in the perceptual space;
[0134] During the online detection phase, the Mahalanobis distance (i.e., Mahalanobis distance) between the current sample and the centers of each level is calculated: ;
[0135] The distance value is further converted into a perceived color score through an exponential mapping:
[0136] ;
[0137] Where, d g S represents the Mahalanobis distance between the sample vector and the center of grade g, used to measure the degree of deviation of the sample color from each grade; perc,gThe perceived color score is represented by an exponential mapping that transforms the Mahalanobis distance into an easily understandable score, with the closer to 1 indicating that the color is closer to the center of the rank. Indicates the scaling factor;
[0138] Output the initial perceived color score S based on the level corresponding to the highest score. perc ;
[0139] S52. Obtain the moisture content factor, perform linear humidity correction on the perceived color characteristics, and generate a dryness-calibrated color score to eliminate the influence of moisture content changes on color assessment. Execute dual-track output of the perceived color score and the standard color score to improve the comparability of the assessment. Specifically:
[0140] Using the multi-band reconstructed spectral information from step S4, particularly the near-infrared band in the 900–1700 nm range, the characteristics of the water absorption peaks are analyzed. For each pixel or local region, the difference in absorption intensity of reflectance R(λ) in the water absorption band is calculated. ;
[0141] And obtain the water content factor of the whole sample: ;
[0142] Among them, MC pixel represents the estimated water content of a single pixel or local region, used to construct the water content factor of the entire sample; k1 represents an empirical coefficient used to map the reflectance difference to the water content factor; R ref This represents the reference reflectance of a dry standard sample in the same wavelength band. The wavelength corresponding to the moisture absorption peak is based on the near-infrared absorption characteristics of moisture in tea leaves. Indicates the sample at wavelength The spectral reflectance is denoted by MC; MC represents the overall moisture content factor of the tea sample, that is, the degree to which the moisture content of the sample affects the optical color. The weights of pixels or local regions are used to calculate the weighted average water content factor, emphasizing the influence of high-confidence pixels.
[0143] Define water content offset: ;
[0144] The sensory characteristics of the sample are corrected based on the above offset: ;
[0145] Then calculate its drying distance from the center of each grade:
[0146] ;
[0147] And from this, the drying calibration color score S is obtained. dry : ;
[0148] in, This represents the sensing feature drift vector caused by water content, used to correct sample features; This represents the water content sensitivity coefficient vector, i.e., the magnitude of the effect of a unit change in water content on color features in different perceptual dimensions, obtained through fitting experimental samples; v dry This represents the perceived feature vector in a dry state, and the color features after moisture content correction. This represents the Mahalanobis distance between the sample in its dry state and the center of grade g; The drying calibration score indicates how close the sample is to the grade center under standard drying conditions.
[0149] S53. Introducing a color uniformity index and local abnormal pixel detection, combined with a comprehensive penalty term calculated based on reconstruction confidence and environmental stability, the score is corrected to reflect the consistency and anomalies in the sample color distribution, thereby enhancing the reliability and robustness of the score. Specifically:
[0150] Define color uniformity index: ;
[0151] Secondly, anomaly masks are constructed based on pixel-level color differences:
[0152] ;
[0153] The proportion of abnormal pixels (A) frac And calculate the severity of the anomaly: ;
[0154] in, , and T represents the standard deviation of each color channel of the tea sample; u represents the normalization constant, which converts the color difference standard deviation into a uniformity index range [0,1]; U represents the color uniformity index, and the closer it is to 1, the more uniform the color distribution. This represents a pixel-level perceptual feature vector used to detect local color difference anomalies. T represents the feature mean of a local window, used to calculate local anomalies; a This represents the abnormal threshold, which is dynamically adjusted based on the local variance and used to determine whether a pixel is abnormal. Represents a pixel-level anomaly mask, marking abnormal regions; A frac This indicates the proportion of abnormal pixels, representing the degree to which overall color consistency is affected; This represents the average deviation of abnormal pixels, used to comprehensively assess the severity of the anomaly; and This represents an empirical weight used to balance the contributions of the number of outlier pixels and the magnitude of outliers;
[0155] For each pixel, calculate its reconstruction error E. rec (x,y) maps the error to the confidence level C. rec (x,y):
[0156] ;
[0157] ;
[0158] Select a reference standard point (such as a reference board) in the sampling area and obtain the difference between the real-time observed value R(x,y) and the standard value R0(x,y). : ;
[0159] Calculate the average difference over the entire reference area: ;
[0160] Mapping the average difference to a stability index: ;
[0161] Among them, F pixel (x,y) represents the actual feature vector of pixel (x,y); F pred (x,y) represents the predicted feature vector of pixel (x,y) (generated in this embodiment by a neighborhood interpolation algorithm); Represents the reconstruction error of pixel (x,y), used to quantify the deviation between the actual reconstructed value and the predicted value; C rec (x,y) represents the reconstruction confidence value of pixel (x,y), which reflects the credibility or reliability of the multi-band color reconstruction result of the pixel. This represents the confidence decay coefficient, used to adjust the degree of influence of error on the confidence level. This represents an environmental stability index, used to reflect the stability of the sampling environment on the measurement of tea color; This represents the environmental sensitivity coefficient, used to control the attenuation of stability indicators by average environmental differences. The reference area represents the average color difference, quantifying the overall deviation between the current acquisition environment and standard reference conditions; N represents the total number of pixels in the reference area; L * a * and b * This represents the actual color characteristics of the sampled pixel; , and Indicates the color values of the standard reference panel;
[0162] Define the global confidence level C: ;
[0163] Define the comprehensive penalty term P: ;
[0164] Where C represents the global confidence level, which reflects the overall reliability of the current sample color determination; the closer the value is to 1, the more reliable the sample color measurement and reconstruction; N pix This represents the total number of pixels in the sample image, used to calculate the average pixel-level reconstruction confidence score. This represents the penalty attenuation coefficient, which controls the suppression of outlier regions on the global confidence level. The larger the value, the stronger the penalty for outlier regions.
[0165] S54. The final comprehensive score is calculated by integrating the perceived color score, the drying calibration color score, and the penalty item. The sample grade is determined based on the grade threshold and the abnormal limit. At the same time, the grade center and weight parameters are adaptively adjusted through a small sample online update mechanism. Specifically:
[0166] Define the overall score and generate the final report score:
[0167] ; ;
[0168] Among them, S overall Indicates the overall score; w p and w d These represent the weights of the perceived color and the drying calibration color, respectively, and can be dynamically adjusted according to the type of tea or lighting conditions; S report Indicates the final report score;
[0169] Based on the threshold T defined in the rating library g and abnormal limits Perform a level assessment:
[0170] when , and When the sample is classified as grade g, it is determined to be of grade g.
[0171] like or If so, it will be marked as requiring manual review and downgraded one level from the output;
[0172] In addition, to avoid grading errors caused by batch offset, a small-sample online update mechanism is established to dynamically correct the grading center parameters: ;
[0173] Among them, T g The scoring threshold for grade g is used to determine the grade to which a sample belongs. This represents the maximum anomaly ratio threshold for level g, used to control the impact of abnormal regions on level determination; C min This represents the minimum confidence threshold; samples below this value are marked as requiring manual review. This represents the mean after the rank center is updated, used for online adaptive adjustment of the rank center; ng The cumulative sample size for rank g is used to calculate the mean update; v new This represents the feature vector of the new sample, used to update the mean of the rank center;
[0174] For weight w p w d Moisture content coefficient K and distance scale Periodic recalibration is performed, and adaptive learning of parameters is achieved through the accumulation of micro-samples or manually reviewed samples.
[0175] The final output report includes perceived score, dryness score, uniformity, anomaly rate, confidence level, and grade label, and generates a traceable quality report containing spectral curves and anomaly distribution maps.
[0176] Example 2, as Figure 2 As shown, the present invention proposes an automatic tea color evaluation system based on machine vision, which is used to execute the automatic tea color evaluation method based on machine vision proposed in Embodiment 1. It includes: a sample positioning and microenvironment control module, an image acquisition and multi-angle feature capture module, a color standardization and multi-feature fusion module, a multi-band spectral reconstruction and color feature extraction module, and a color quantification evaluation and grade determination module.
[0177] The sample positioning and microenvironment control module is used to automatically and accurately place tea samples and regulate environmental conditions. The tea sample is fixed in the center of the imaging field of view by the tray positioning device. At the same time, the micro climate control unit adjusts the temperature and humidity in real time to maintain the stability of the imaging environment. The reference standard plate provides color and light intensity reference. The environmental sensor collects temperature and humidity information in real time and feeds it back to the controller to ensure the repeatability and accuracy of subsequent optical acquisition.
[0178] The image acquisition and multi-angle feature capture module is used to acquire surface images and micro-texture information of tea samples. It is equipped with a multi-band adjustable light source, a machine vision camera array, and a micro-moving support, which can perform multi-angle and multi-spectral imaging of the sample surface and capture leaf color, gloss, texture, and micro-structure features. The camera array and light source are coordinated by the controller to achieve rapid and continuous acquisition, generating raw color image data and spectral response maps, providing rich information for subsequent feature extraction.
[0179] The color standardization and multi-feature fusion module is used to preprocess the acquired images and construct feature vectors. Through image denoising, color correction, transmission and reflection compensation, and reference standard plate data, it standardizes images from different batches. At the same time, it uses multi-angle and multi-band image information to extract multi-dimensional features such as leaf brightness, hue, saturation and texture consistency, and fuses the features into a weighted vector to comprehensively reflect the color attributes of tea samples.
[0180] The multi-band spectral reconstruction and color feature extraction module is used to reconstruct the multi-band spectrum of tea samples based on the fused feature vector and calculate key color parameters. Based on multi-angle and multi-band acquired data, a weighted reconstruction algorithm is used to restore the reflectance characteristics of tea in different spectral bands, and further extract the distribution of brightness, hue, saturation and local color difference information. At the same time, it generates uniformity index and anomaly distribution map, and can output spectral data with high resolution and multi-dimensional color features, providing an accurate basis for color quantitative evaluation.
[0181] The color quantification assessment and grading module converts spectral feature vectors into quantifiable scores and automatically outputs grading results. First, perceptual color mapping is performed, mapping the feature vectors to a space conforming to human visual perception, and a dry standard color score is calculated by combining sample moisture correction. Then, a comprehensive penalty adjustment is applied based on uniformity indicators and abnormal region information, and a final comprehensive score is generated by combining reconstructed confidence. Finally, the sample color grade is determined through a grading threshold, and a complete quality report including color score, uniformity, abnormality rate, confidence, and grading label is generated. Furthermore, dynamic updates and adaptive parameter adjustments to the grading center ensure the system maintains stability and traceability during long-term operation.
[0182] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited thereto. Various changes can be made within the scope of knowledge possessed by those skilled in the art without departing from the spirit of the present invention.
Claims
1. A method for automatically evaluating the color of tea leaves based on machine vision, characterized in that, The specific implementation steps include the following: S1. Establish a stable and repeatable optical measurement environment and calculate the system's radiation baseline parameters, including: The tea sample to be tested is evenly laid on a neutral non-reflective substrate with a surface reflectivity of less than 0.05, and the substrate is kept at a fixed distance from the camera optical axis by a positioning groove. The attitude matrix of the sample is established in a plane coordinate system. The sample posture is automatically adjusted through visual feedback so that the absolute value of the angle between the sample principal plane normal and the camera optical axis is no greater than 1 degree. A semi-enclosed microenvironment was set up above the sample, and the temperature and relative humidity were kept constant through a temperature and humidity control mechanism. The environmental stability was then calculated. A calibrated neutral reflective reference plate was placed at the edge of the sample base plate, and a micro sample tray containing the same batch of tea leaves was placed simultaneously. The radiation baseline parameters are calculated based on the attitude matrix, environmental stability, and normalized reflectance. S2. Perform multi-band polarization sequence imaging on tea samples under optical measurement conditions to obtain raw image data; S3. Use multi-band polarization sequence imaging data to separate the specular and diffuse reflection components of the tea surface, and combine the radiation baseline parameters to perform spectral consistency correction to obtain the corrected diffuse reflection image. S4. Based on the corrected diffuse reflection image, perform multi-band spectral reconstruction and normalization processing, map to the CIE Lab color space, and extract pixel-level brightness, chromaticity and color distribution statistical indicators. Then, combine with the spatial weighting matrix for optimization to generate the final color feature vector. S5. Based on the color feature vector, a quantitative evaluation and grading model is constructed. This model comprehensively calculates the perceived color score, the drying calibration color score, and the penalty term to obtain the final score and output the tea's color grade result, including: The weighted color feature vector is mapped to the discriminative feature space through a linear transformation, and its Mahalanobis distance with the preset centers of each level is calculated. The distance is then converted into a perceptual color score through an exponential mapping. By utilizing the moisture absorption peak characteristics in the near-infrared band of the multi-band reconstructed spectral information, the moisture content factor of the tea sample is calculated, and then the perceived color score is corrected for humidity to generate a dry calibration color score. Anomaly masks are constructed based on pixel-level color differences. The proportion of abnormal pixels and the average deviation are statistically analyzed to calculate the severity of the anomaly. At the same time, a comprehensive penalty term is calculated by combining pixel-level reconstruction confidence and environmental stability indicators. The final comprehensive score is calculated by combining the perceived color score, the drying calibration color score, and the comprehensive penalty item, and the color grade of the sample is determined according to the preset grade threshold and abnormal limit.
2. The automatic tea color evaluation method based on machine vision according to claim 1, characterized in that, Step S2 specifically includes: The built-in multi-channel programmable LED array generates narrowband illumination covering the 400nm~900nm wavelength band, and sets the emission sequence and exposure energy according to the adaptive coding sequence; Under each band of illumination, the polarization modulation unit is controlled to acquire images in two polarization angle states of zero degrees and ninety degrees in sequence to form polarization frame pairs, and the phase difference between the polarizer angle switching and the camera shutter signal is less than 1 millisecond. Assign a composite code containing spectral and polarization states to each frame of acquired image, write it into the image metadata, and generate a timestamp and associate it with the global acquisition log. The system monitors the average brightness and standard deviation of each frame in real time and dynamically adjusts the exposure time of subsequent frames according to the brightness control rules. If the brightness deviation exceeds the threshold for several consecutive frames, the system automatically executes the brightness correction procedure.
3. The automatic tea color evaluation method based on machine vision according to claim 2, characterized in that, Step S3 specifically includes: The polarization difference matrix for each band is calculated based on the two sets of polarization images obtained from polarization sequence imaging to initially separate specular reflection and diffuse reflection components. A pixel-level specular reflection weight matrix is established based on the polarization difference matrix, and low-pass filtering and neighborhood smoothing are applied to the weight matrix to ensure its spatial continuity and spectral consistency. The diffuse reflectance components that were initially separated were normalized using the radiation baseline parameters to obtain the corrected diffuse reflectance image matrix. The spectral mean and standard deviation of each frame of diffuse reflection image are calculated, and the correction effect is judged based on the set threshold. If the requirements are not met, the specular reflection weight matrix is updated through an iterative algorithm.
4. The automatic tea color evaluation method based on machine vision according to claim 3, characterized in that, Step S4 specifically includes: The corrected diffuse reflectance image sequence is integrated into a three-dimensional spectral matrix by band, and a continuous approximate spectral curve is generated using a local weighted spectral interpolation method. The continuous spectral matrix is normalized by combining radiation baseline parameters and energy balance information to eliminate band response differences and environmental biases. The normalized spectral matrix is mapped to the CIE Lab color space to obtain the lightness value, red-green value and yellow-blue value of each pixel, and the mean, standard deviation and skewness of each channel in the sample area are calculated as basic statistical indicators. A spatial weighted matrix is constructed based on local brightness gradient, texture roughness, and local reflection consistency. This matrix is then used to weight and aggregate basic statistical indicators to generate the final weighted color feature vector.
5. The automatic tea color evaluation method based on machine vision according to claim 4, characterized in that, Calculating the moisture content factor of tea samples and then performing humidity correction on the perceived color score specifically includes: Using the near-infrared band in the range of 900nm to 1700nm, the characteristics of moisture absorption peaks are analyzed, and the estimated water content of each pixel is calculated. The water content factor, representing the overall water content of the sample, is obtained by weighted averaging of the estimated water content of all pixels in the entire sample. The water content offset is calculated based on the water content factor, and the offset is used to correct the sensory feature vector of the sample to obtain the sensory feature vector under dry conditions. The Mahalanobis distance between the perceived feature vector under the dry state and the center of each level is calculated, and the dry calibration color score is obtained through exponential mapping.
6. The automatic tea color evaluation method based on machine vision according to claim 5, characterized in that, The calculation of the comprehensive penalty includes: The color uniformity index is defined based on the standard deviation of each color channel of the tea sample. By comparing the difference between pixel-level perceptual feature vectors and their local window mean, and constructing an anomaly mask based on dynamically adjusted anomaly thresholds, the proportion of anomaly pixels is statistically analyzed. The reconstruction error of each pixel is calculated and mapped to the reconstruction confidence score. At the same time, the environmental stability index is obtained by comparing the real-time observation value of the reference standard point with the standard value. The comprehensive penalty term is calculated based on the global average of the reconstruction confidence level, the severity of the anomaly, and the environmental stability index.
7. The automatic tea color evaluation method based on machine vision according to claim 6, characterized in that, Step S5 also includes an online adaptive update mechanism, specifically: After determining the level, the central mean of the corresponding level is dynamically updated using the feature vector of the new sample with high confidence. The weighting coefficients of perceived color and dry calibration color, the water content sensitivity coefficient, and the scaling coefficient of Mahalanobis distance are periodically recalibrated. Through the continuous accumulation of micro-samples and manually verified samples, the adaptive learning and optimization of model parameters are achieved.
8. A machine vision-based automatic tea color evaluation system, used to execute the machine vision-based automatic tea color evaluation method according to any one of claims 1 to 7, characterized in that, include: The sample positioning and microenvironment control module is used to automatically and accurately place tea samples and maintain a stable imaging environment. The image acquisition and multi-angle feature capture module is used to acquire multi-band polarization image data of the tea sample surface; The color standardization and multi-feature fusion module is used to process the raw data obtained by the image acquisition module, separate the specular and diffuse reflection components, and perform spectral consistency correction. The multi-band spectral reconstruction and color feature extraction module is used to reconstruct the continuous spectrum based on the corrected diffuse reflection image, map it to the standard color space, and extract the weighted multi-dimensional color feature vector. The color quantification assessment and grading module is used to calculate the perceived color score and the drying calibration color score based on the color feature vector, combine the penalty items to make a comprehensive score, and finally output the color grading result of the tea and a traceable quality report.
Citation Information
Patent Citations
Tea variety identification method and system based on machine vision
CN120635597B
Six-channel multispectral measurement system and method based on cross polarization
CN111896489A
System and method for detecting optical performance of camouflage material
CN120404611A