Fruit and vegetable quality grading processing method and system based on machine vision
By acquiring polarization component images of fruits and vegetables at different incident angles, calculating the brightness profile and polarization retention rate, and combining equivalent motion broadening compensation and coupling index, the problem of judgment drift in the fruit and vegetable quality grading system under different batches and working conditions was solved, achieving stable grading results and reliability.
Patent Information
- Application Number
- CN202511472873.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2026-01-09
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In existing technologies, fruit and vegetable quality grading systems suffer from systematic drift across different batches and operating conditions, resulting in unstable judgment results, a lack of long-term consistency, and difficulty in ensuring the traceability and reliability of grading standards.
A machine vision-based fruit and vegetable quality grading method is adopted. Parallel polarization component images and vertical polarization component images are acquired at the first and second incident angles. The brightness profile and polarization retention rate are calculated. Combined with equivalent motion broadening compensation and coupling index, a sliding reference set is constructed to dynamically adjust the grading criteria.
This method enables multi-angle joint characterization of the optical state of fruit and vegetable skins, eliminating the influence of changes in light source intensity and geometric angles, ensuring the stability and accuracy of grading results, and improving long-term consistency and reliability.
Smart Images

Figure CN121305192A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of fruit and vegetable quality grading technology, and in particular to a method and system for fruit and vegetable quality grading based on machine vision. Background Technology
[0002] Modern fruit and vegetable grading production lines generally employ directional lighting and camera arrays to assess the appearance quality of individual fruits and vegetables during high-speed transport. Post-harvest waxing and subsequent storage alter the microstructure of the epidermal cuticle and wax film, causing variations in specular reflection intensity, bright spot morphology, and polarization retention over time and with different processes. Simultaneously, fluctuations in conveyor speed and adjustments to exposure time during online operations result in slight drifts in the relative angle between the light source and camera. These factors combined cause changes in the spatial broadening, saturation, and trailing of specular bright spots across shifts and batches, directly impacting the pixel quantization results upon which appearance quality assessment relies.
[0003] Current technologies primarily use brightness thresholds under single-angle imaging, color channel ratios, simple polarization ratios, or statistics based on bright spot masks as criteria for appearance quality, supplemented by periodic whiteboard correction. While these methods can maintain a certain level of consistency in the short term, changes in wax formulation, storage time, environmental humidity, and temperature alter surface micro-roughness and orientation, causing a shift in the relative proportions of specular and diffuse components. These changes, coupled with adjustments to conveyor speed and exposure time, result in equivalent motion broadening and brightness compression. These variations cannot be offset by a single gain or white balance adjustment. Systematic drift in single-angle statistics across different shifts and batches leads to systematic biases in judgment results, resulting in misclassification and omissions in quality grades. This makes it difficult to guarantee the traceability and reliability of grading standards in long-term operation. Summary of the Invention
[0004] The purpose of this invention is to address the shortcomings of existing technologies, such as the systematic drift of single-angle statistics under different batches and working conditions leading to the failure of grading criteria, unstable quality grades, and lack of long-term consistency. The invention proposes a machine vision-based method and system for fruit and vegetable quality grading.
[0005] To address the problems existing in the prior art, the present invention adopts the following technical solution:
[0006] Machine vision-based methods for grading fruit and vegetable quality include:
[0007] S1. Collect parallel polarization component images and vertical polarization component images of fruits and vegetables at the first and second incident angles, respectively.
[0008] S2. Extract the brightness profile from the parallel polarization component image to obtain the brightness profile, and determine the millimeter half-peak width based on the maximum brightness of the brightness profile; specifically as follows, determine the mirror direction according to the camera geometric calibration parameters; extract the brightness profile from the parallel polarization component images at the first incident angle and the second incident angle respectively along the mirror direction to obtain the brightness profile at the first incident angle and the brightness profile at the second incident angle.
[0009] Half the maximum brightness value of the brightness profile is taken as the half-peak threshold; two intersection points on the brightness profile that are equal to the half-peak threshold are found on the left and right sides, and the pixel coordinates of the two intersection points are subtracted to obtain the half-peak width; the pixel units of the half-peak widths of the first and second incident angles are converted to millimeters to obtain the millimeter half-peak widths of the first and second incident angles.
[0010] S3. The corrected half-peak width is obtained by performing equivalent motion broadening compensation on the millimeter half-peak width. The polarization retention rate is obtained based on the grayscale ratio of the parallel polarization component image and the vertical polarization component image. Specifically, the equivalent motion broadening amount is calculated by multiplying the camera's exposure time and transport speed. Based on the equivalent motion broadening amount, equivalent motion broadening compensation is performed on the millimeter half-peak width at the first incident angle and the millimeter half-peak width at the second incident angle to obtain the corrected half-peak widths at the first and second incident angles. Continuous images in the brightness profile that are not lower than the half-peak threshold are... The set of element positions is taken as a half-peak band; the gray-level ratio of the parallel polarization component image and the vertical polarization component image at the first incident angle is calculated within the half-peak band along the mirror direction to obtain the gray-level ratio sequence of the first incident angle; the gray-level ratio of the parallel polarization component image and the vertical polarization component image at the second incident angle is calculated within the half-peak band along the mirror direction to obtain the gray-level ratio sequence of the second incident angle; the mean values of the gray-level ratio sequences of the first and second incident angles are calculated to obtain the polarization retention rate of the first and second incident angles respectively.
[0011] S4. Calculate the ratio of the corrected half-peak width of the second incident angle to the corrected half-peak width of the first incident angle to obtain the width ratio; perform a difference operation on the polarization retention rate of the second incident angle and the polarization retention rate of the first incident angle to obtain the polarization difference; calculate the ratio of the polarization difference to the width ratio to obtain the coupling index.
[0012] S5. Construct a sliding reference set based on the historical coupling index, and determine the lower and upper bound thresholds of the coupling index based on the median of the sliding reference set.
[0013] S6. Grading of fruit and vegetable quality is performed based on the lower and upper bound thresholds of the coupling index, and the sliding reference set is updated according to the grading results and the coupling index.
[0014] Preferably, the parallel polarization component images and vertical polarization component images of the fruits and vegetables are acquired at the first incident angle and the second incident angle, respectively, including:
[0015] Set the first angle of incidence to be smaller than the second angle of incidence;
[0016] Images of the parallel polarization component and the vertical polarization component of fruits and vegetables were collected at the first and second incident angles, respectively.
[0017] When acquiring parallel polarization component images and vertical polarization component images, the camera's exposure time and transport speed through the imaging area are recorded.
[0018] Preferably, a sliding reference set is constructed based on historical coupling indices, and the lower and upper bound thresholds of the coupling index are determined based on the median of the sliding reference set, including:
[0019] A predetermined number of coupling indices are selected from the historical coupling indices to form a sliding reference set;
[0020] Calculate the absolute value of the deviation of each element of the sliding reference set from the median of the sliding reference set to obtain the absolute deviation set, and use the median of the absolute deviation set as the absolute median difference;
[0021] The absolute median is converted to an approximate standard deviation by using a fixed robust conversion factor.
[0022] The lower bound threshold is obtained by subtracting the product of the approximate standard deviation and the prior device coefficients from the median of the sliding reference set.
[0023] The upper bound threshold is obtained by adding the approximate standard deviation to the median of the sliding reference set and the product of the prior device coefficients.
[0024] Preferably, the quality of fruits and vegetables is graded based on the lower and upper bound thresholds of the coupling index, and the sliding reference set is updated according to the grading results and the coupling index, including:
[0025] When the coupling index is less than or equal to the lower threshold, the quality level is set to Level 1; when the coupling index is greater than the lower threshold and less than or equal to the upper threshold, the quality level is set to Level 2; when the coupling index is greater than the upper threshold, the quality level is set to Level 3.
[0026] Record the timestamp of the grading event and write the coupling index and timestamp into the sliding reference set;
[0027] If the length of the sliding reference set exceeds the set capacity, the oldest element in the set is deleted, and the updated sliding reference set state is persisted.
[0028] To address the above problems, the present invention also provides a machine vision-based fruit and vegetable quality grading system, the system comprising:
[0029] The image acquisition module is used to acquire parallel polarization component images and vertical polarization component images of fruits and vegetables at the first incident angle and the second incident angle, respectively.
[0030] The profile extraction module is used to extract the brightness profile from the parallel polarization component image to obtain the brightness profile, and the millimeter half-peak width is determined based on the maximum brightness of the brightness profile.
[0031] The broadening compensation module is used to perform equivalent motion broadening compensation on the millimeter half-peak width to obtain the corrected half-peak width. Based on the grayscale ratio of the parallel polarization component image and the vertical polarization component image, the polarization retention rate is obtained.
[0032] The index calculation module is used to calculate the coupling index based on the corrected half-width and polarization retention rate.
[0033] The threshold generation module is used to construct a sliding reference set based on historical coupling indices, and to determine the lower and upper bound thresholds of the coupling index based on the median of the sliding reference set.
[0034] The quality grading module is used to grade the quality of fruits and vegetables based on the lower and upper bound thresholds of the coupling index, and to update the sliding reference set according to the grading results and the coupling index.
[0035] Compared with the prior art, the beneficial effects of the present invention are:
[0036] 1. This invention achieves multi-angle joint characterization of the optical state of fruit and vegetable skin by simultaneously acquiring parallel polarization component images and vertical polarization component images at the first and second incident angles, and calculating the millimeter half-peak width and polarization retention rate in the brightness profile. It can comprehensively reflect the dynamic changes in the ratio of specular reflection to diffuse reflection caused by waxing, storage and environmental changes, thereby effectively avoiding misjudgment of surface state caused by single-angle distortion.
[0037] 2. This invention introduces equivalent motion broadening compensation, using the product of transport speed and exposure time as the motion blur amount, and corrects the millimeter half-width, ensuring image stability under high-speed transport and varying imaging conditions. Simultaneously, it constructs a polarization retention rate based on the grayscale ratio of parallel and vertical polarization channels, further eliminating the influence of light source intensity fluctuations and minute geometric angle drifts. This ensures stable and comparable optical parameters under different shifts and batches, improving the long-term consistency of grading results.
[0038] 3. This invention constructs a sliding reference set of historical coupling indices and generates upper and lower bound thresholds based on robust statistical methods, thereby realizing a dynamic and adaptive grading criterion. It can automatically adjust the judgment boundary as production conditions fluctuate, avoiding the problem of fixed thresholds failing under environmental and process changes. This improves the accuracy and robustness of fruit and vegetable quality grading and ensures the traceability and reliability of the grading standard in long-term continuous operation. Attached Figure Description
[0039] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0040] Figure 1 This is a flowchart illustrating a machine vision-based fruit and vegetable quality grading method according to an embodiment of the present invention.
[0041] Figure 2 A functional block diagram of a machine vision-based fruit and vegetable quality grading system provided in an embodiment of the present invention;
[0042] Figure 3 This is a schematic flowchart of a profile extraction method provided in an embodiment of the present invention;
[0043] Figure 4 This is a schematic flowchart of a broadening compensation method provided in an embodiment of the present invention;
[0044] Figure 5 This is a flowchart illustrating a method for calculating an index according to an embodiment of the present invention;
[0045] Figure 6 This is a flowchart illustrating a threshold generation method provided in an embodiment of the present invention; Detailed Implementation
[0046] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0047] Example: This example provides a machine vision-based method for grading the quality of fruits and vegetables. See [link to example]. Figure 1 Specifically, including:
[0048] Images of the parallel polarization component and the vertical polarization component of fruits and vegetables were collected at the first and second incident angles, respectively.
[0049] In an embodiment of the present invention, the acquisition of parallel polarization component images and vertical polarization component images of fruits and vegetables at a first incident angle and a second incident angle, respectively, includes:
[0050] Set the first angle of incidence to be smaller than the second angle of incidence;
[0051] Images of the parallel polarization component and the vertical polarization component of fruits and vegetables were collected at the first and second incident angles, respectively.
[0052] When acquiring parallel polarization component images and vertical polarization component images, record the camera's exposure time and the transport speed when passing through the imaging area.
[0053] Specifically, the first incident angle refers to the smaller incident angle of the light source relative to the normal of the fruit and vegetable surface in the optical illumination device. This angle is set smaller than the second incident angle to generate a relatively concentrated and strong specular reflection component. Data collected through the first incident angle more easily reveals the reflective characteristics of the fine wax layer and smooth areas of the fruit and vegetable skin. The second incident angle refers to the larger incident angle of the light source relative to the normal of the fruit and vegetable surface in the optical illumination device. Compared with the first incident angle, this angle tends to enhance the diffuse reflection component, thus more comprehensively reflecting the roughness or minor defects of the fruit and vegetable surface. The difference between the first and second incident angles provides the physical premise for subsequent ratio and difference operations. The parallel polarization component image refers to the grayscale or color image captured by the camera when the polarization direction of the detected light is parallel to the direction of the incident plane at a specific incident angle. This type of image is more sensitive to the specular reflection component and can reflect the smoothness of the fruit and vegetable skin and the uniformity of the wax film layer. Vertical polarization component images are grayscale or color images captured by a camera when the polarization direction of the detected light is perpendicular to the plane of incidence at a specific incident angle. These images reduce the contribution of specular reflection to some extent and retain more diffuse reflection information, thereby enhancing the ability to identify surface roughness and microcracks in fruits and vegetables.
[0054] Specifically, the illumination setting using a first incident angle smaller than the second incident angle is based on the combined effects of the angle dependence of specular and diffuse reflection and Fresnel's law of reflection. A smaller incident angle concentrates the specular component, facilitating the characterization of epidermal smoothness, while a larger incident angle enhances sensitivity to near-specular scattering and broadening caused by roughness. Thus, sampling at both angles yields complementary information about the same target surface. Setting the detection polarization direction parallel and perpendicular to the incident plane, respectively, allows for the separation of specular and diffuse components. The parallel polarization channel is sensitive to specular reflection, while the perpendicular polarization channel effectively suppresses specular components and retains more volume scattering information. Therefore, the combined use of these two channels can stably reflect the differences in the state of the stratum corneum and the wax film. Simultaneously, recording the exposure time and transport speed within the same scanning cycle of acquiring the parallel and perpendicular polarization component images compensates for motion blur. According to the imaging integral model, the length of the motion blur is proportional to the product of the transport speed and the exposure time. If this is not recorded and used for subsequent correction, motion stretching errors will be misjudged as changes in surface roughness. By setting the angles, separating polarization components, and measuring time and velocity synchronously, the disturbances of device gain and kinematic factors can be separated from the surface state measurement, improving the stability and comparability of subsequent calculations of brightness profile, full width at half maximum, and polarization retention rate, thus providing a reliable basis for classification based on these equivalent quantities.
[0055] Specifically, during the acquisition process, the first incident angle is set to be smaller than the second incident angle to create two different lighting conditions. Then, the fruits and vegetables are placed sequentially within the imaging area, and the parallel polarization component images and vertical polarization component images of the fruits and vegetables are acquired at the first incident angle and the second incident angle, respectively, ensuring that four corresponding images are obtained within the same scanning cycle. While completing the above image acquisition, the control module of the imaging device synchronously records the exposure time used for this image acquisition, and the speed sensing unit of the conveying device records the conveying speed of the fruits and vegetables as they pass through the imaging area. Through the above operations, it can be ensured that the data unit corresponding to each fruit position simultaneously contains dual-angle dual-polarization component images and their exposure time and conveying speed parameters, thereby realizing the correction of motion blur and the stable analysis of surface condition in subsequent steps, providing reliable basic data for the entire quality grading.
[0056] Brightness profiles are extracted from the parallel polarization component images to obtain the brightness profiles, and the half-width at half maximum (WHM) in millimeters is determined based on the maximum brightness of the brightness profiles.
[0057] In an embodiment of the present invention, see Figure 3 Brightness profiles are extracted from the parallel polarization component images to obtain a brightness profile. The half-width at half maximum (FWHM) in millimeters is determined based on the maximum brightness of the brightness profile, including:
[0058] Determine the mirror orientation based on the camera's geometric calibration parameters;
[0059] Brightness profiles are extracted from the parallel polarization component images of the first and second incident angles along the mirror surface direction to obtain the brightness profiles of the first and second incident angles.
[0060] Specifically, the specular direction refers to the propagation direction of the main specular reflection energy generated on the surface of fruits and vegetables under illumination at a specific incident angle. It is determined by the camera's geometric calibration parameters, that is, the theoretical path of specular reflection is derived from the spatial relationship between the light source, the normal to the surface of the fruits and vegetables, and the camera's imaging axis; the brightness profile refers to the one-dimensional grayscale value sequence extracted from the image along the specular direction.
[0061] Specifically, determining the mirror direction based on the camera's geometric calibration parameters ensures that the reference direction for extracting the bright spot profile is consistent with the actual optical path. When light undergoes specular reflection on a smooth surface, it follows the rule that the angle of incidence equals the angle of reflection. Once the spatial geometric relationship between the camera and the light source is determined, the main energy of specular reflection is concentrated in the direction calculated by the geometric calibration. Extracting the profile along this direction ensures that the brightness distribution curve passes through the center of the bright spot, thus accurately representing the concentration of reflected energy and reflecting the smoothness of the fruit and vegetable skin and the continuity of the wax film. If the profile direction deviates from the mirror direction, the brightness distribution in the profile will be broadened or weakened, leading to deviations in the calculation of the half-peak width. Therefore, limiting the profile extraction path by the mirror direction can minimize geometric errors, improve the comparability of brightness profiles under two incident angles, and provide stable and reliable input for subsequent half-peak width calculations and coupling index construction.
[0062] Specifically, first, the camera's geometric calibration parameters are read, and the spatial relationship between the surface normal of the light source position and the camera's imaging axis is calculated accordingly. The mirror direction, consistent with the incident angle equal to the reflection angle, is determined. Then, in the parallel polarization component image at the first incident angle, a straight line passing through the center of the bright spot is selected as the profile path, using the mirror direction as a reference. If saturated pixels exist on the profile path, the path is moved along the mirror direction within the nearest neighbor range to the position of the nearest unsaturated peak to avoid errors caused by peak suppression. Next, grayscale readings are performed on consecutive pixels along this profile path at a fixed step size, and linear interpolation is used to obtain a sub-pixel grayscale sequence. The obtained grayscale sequence is then arranged according to the sampling order. The brightness profile at the first incident angle is obtained. Then, in the parallel polarization component image at the second incident angle, the same mirror direction and the same profile path construction method are reused. The grayscale of continuous pixels is extracted with the same step size and interpolation strategy to generate the brightness profile at the second incident angle. In the above process, the starting point coordinates, ending point coordinates and step size parameters of the profile are uniformly saved and associated with the timestamp and incident angle identifier. This ensures that the brightness profiles at the two incident angles are generated based on the same geometric reference, the same sampling rule and the same pixel-to-physical length conversion coefficient. This provides complete and reproducible data input for subsequently defining the half-peak threshold at half the maximum brightness and calculating the millimeter half-peak width.
[0063] Use half the maximum brightness value of the brightness profile as the half-peak threshold.
[0064] Find the two intersection points on the brightness profile that are equal to the half-peak threshold, and subtract the pixel coordinates of the two intersection points to obtain the half-peak width.
[0065] Convert the pixel units of the half-peak widths of the first and second incident angles to millimeters to obtain the millimeter half-peak widths of the first and second incident angles.
[0066] Specifically, when processing the brightness profile, half of the maximum brightness in the profile is taken as the half-peak threshold. This is based on the concept of full width at half-peak (FWHM) commonly used in optical measurements. The FWHM position can stably characterize the concentration and broadening of bright spot energy. Then, two intersection points on the brightness profile curve that are equal to the FWHM threshold are found, and the pixel coordinates of these two intersection points are differentially calculated. The difference obtained is the FWHM, which represents the effective width of the energy concentration area in the brightness distribution. This method can avoid interference from low-intensity noise at the edges. Finally, the FWHM is converted from pixel units to millimeters. This conversion is completed based on the geometric calibration parameters of the imaging system. This process ensures that the FWHM at different incident angles can directly correspond to the actual geometric scale of the fruit and vegetable surface, thus obtaining the millimeter FWHM at the first incident angle and the millimeter FWHM at the second incident angle. This processing method can convert the image brightness distribution into a physical quantity for comparison and analysis during subsequent quality grading.
[0067] Specifically, when processing the brightness profile, the maximum gray value is first found in the extracted brightness profile sequence, and half of this maximum gray value is used as the half-peak threshold. Then, the gray value and the half-peak threshold are compared point by point along the sampling sequence of the brightness profile. The left intersection point where the gray value first drops from above the threshold to equal to the threshold and the right intersection point where the gray value first drops from above the threshold to equal to the threshold are found. By recording the pixel coordinates of these two intersection points in the profile and performing difference calculation, the half-peak width corresponding to the profile is obtained. The half-peak width reflects the effective expansion range of the bright spot energy concentration area. In order to convert this width into the actual scale of the fruit and vegetable surface, the pixel unit of the half-peak width is converted into the millimeter unit using the correspondence between pixel size and physical length contained in the camera geometric calibration parameters. Finally, the millimeter half-peak width at the first incident angle and the millimeter half-peak width at the second incident angle are obtained.
[0068] The corrected half-peak width is obtained by performing equivalent motion broadening compensation on the millimeter half-peak width. The polarization retention rate is obtained based on the grayscale ratio of the parallel polarization component image and the vertical polarization component image.
[0069] In an embodiment of the present invention, see Figure 4The corrected half-peak width is obtained by performing equivalent motion broadening compensation on the millimeter half-peak width. Based on the grayscale ratio of the parallel polarization component image and the perpendicular polarization component image, the polarization retention rate is obtained, including:
[0070] The equivalent motion broadening is calculated by multiplying the camera's exposure time and transport speed.
[0071] Based on the equivalent motion broadening, the millimeter half-peak width and the millimeter half-peak width of the first incident angle are compensated for by equivalent motion broadening, respectively, to obtain the corrected half-peak width of the first incident angle and the corrected half-peak width of the second incident angle.
[0072] Specifically, when fruits and vegetables pass through the imaging area, motion blur occurs due to the combined effects of transport speed and exposure time. According to the principle of image integration, the blur broadening is proportional to the distance the object moves during exposure, and this distance is equal to the product of transport speed and exposure time. Therefore, the equivalent motion broadening can be obtained by multiplying the exposure time by the transport speed. If the uncorrected half-width is used directly, it will inevitably include additional broadening introduced by motion blur, thus masking the true distribution characteristics of optical scattering on the fruit and vegetable surface. Therefore, the equivalent motion broadening needs to be applied to the millimeter half-widths of the first and second incident angles respectively. The equivalent motion broadening compensation is completed by subtracting this broadening. The half-widths after correction for the first and second incident angles obtained in this way can more accurately reflect the true brightness distribution of the fruit and vegetable surface at different incident angles. This method eliminates the interference caused by kinematic factors, so that the parameters calculated subsequently can maintain a stable correspondence with the differences in fruit and vegetable quality.
[0073] Specifically, when fruits and vegetables pass through the imaging area, the control module first calls the exposure time recording unit inside the camera to obtain the exposure time of this imaging, and the speed sensor of the conveying device obtains the instantaneous conveying speed of the fruits and vegetables when they pass through the imaging area. Then, the exposure time and the conveying speed are multiplied to obtain the equivalent motion broadening, which represents the length of the lateral trailing of the bright spot caused by the movement of the fruits and vegetables during the exposure process. Then, the equivalent motion broadening is applied to the millimeter half-peak width at the first incident angle and the millimeter half-peak width at the second incident angle, respectively. During the compensation process, the equivalent motion broadening is subtracted from the half-peak width, thereby obtaining the corrected half-peak width at the first incident angle and the corrected half-peak width at the second incident angle, respectively. The entire implementation process ensures that the influence of motion blur is quantitatively eliminated, so that the obtained corrected half-peak width can truly reflect the optical scattering and reflection characteristics of the fruit and vegetable skin without being interfered with by kinematic factors such as conveying speed and exposure time, providing accurate and reliable input data for the subsequent calculation of polarization retention rate and coupling index.
[0074] The set of consecutive pixel positions in the brightness profile that are not lower than the half-peak threshold is taken as the half-peak band;
[0075] The grayscale ratio of the parallel polarization component image and the vertical polarization component image at the first incident angle is calculated within the half-peak zone along the mirror direction to obtain the grayscale ratio sequence of the first incident angle.
[0076] The grayscale ratio of the parallel polarization component image and the vertical polarization component image at the second incident angle is calculated within the half-peak zone along the mirror direction to obtain the grayscale ratio sequence of the second incident angle.
[0077] The mean values of the first incident angle grayscale ratio sequence and the second incident angle grayscale ratio sequence are calculated to obtain the polarization retention rate of the first incident angle and the polarization retention rate of the second incident angle.
[0078] Specifically, the set of continuous pixel positions in the brightness profile that are not lower than the half-peak threshold is defined as the half-peak band. This is to ensure that the selected area only covers the main range of bright spot energy concentration, avoiding interference from low-energy noise at the edges on the calculation results. Calculating the grayscale ratio simultaneously using both parallel polarization component images and perpendicular polarization component images within the half-peak band is based on the laws of polarization optics. Incident light has different reflection components on smooth and rough surfaces; the parallel component is more sensitive to specular reflection, while the perpendicular component is more sensitive to volume scattering. The ratio calculation can weaken the influence of light source intensity and geometric changes, thus directly reflecting the microstructure of the fruit and vegetable peel. The ability to retain polarization states is assessed by generating grayscale ratio sequences for the first and second incident angles, and then averaging these sequences. This process is equivalent to statistically extracting the overall polarization retention level of the region. The resulting polarization retention rates at the first and second incident angles comprehensively characterize the ability of fruits and vegetables to retain polarized light under different incident conditions. Therefore, comparing the polarization retention rates at the two angles can effectively reflect the epidermal optical anisotropy and quality differences. This step ensures the stability and comparability of the extracted parameters, providing a solid foundation for the subsequent construction of coupling indices and the completion of quality grading.
[0079] Specifically, a set of continuous pixel locations is found in the extracted brightness profile, and all pixels with gray values not lower than the half-peak threshold are grouped into a half-peak band. Then, using the half-peak band as a spatial constraint interval, the gray-level ratio is calculated on the corresponding pixels of the parallel polarization component image and the vertical polarization component image at the first incident angle. The parallel polarization gray value is divided by the vertical polarization gray value, and the calculation is performed point by point and arranged in order to obtain the gray-level ratio sequence at the first incident angle. Subsequently, the same half-peak band range and the same ratio calculation method are used at the second incident angle, with the corresponding pixels of the parallel polarization component image and the vertical polarization component image as input. The grayscale ratio sequence for the second incident angle is obtained. After obtaining the grayscale ratio sequences for the two incident angles, the mean operation is performed on each sequence. The sum of all elements in the sequence is divided by the sequence length, thereby obtaining the polarization retention rate for the first incident angle and the polarization retention rate for the second incident angle. In this process, the limitation of the half-peak band ensures that the calculation area only covers the main body of the light spot, effectively eliminating the influence of background noise and edge attenuation. The calculation of the grayscale ratio ensures that the changes in light source intensity and geometric conditions are weakened, and the mean operation further stabilizes the statistical performance of the parameters. The final polarization retention rate can be used as a reliable input for subsequent quality grading analysis.
[0080] The coupling index is calculated based on the corrected half-width and polarization retention rate.
[0081] In an embodiment of the present invention, see Figure 5 The coupling index is calculated based on the corrected half-width and polarization retention rate, including:
[0082] The ratio of the corrected half-peak width at the second incident angle to the corrected half-peak width at the first incident angle is calculated to obtain the width ratio.
[0083] The polarization difference is obtained by performing a difference operation between the polarization retention rate at the second incident angle and the polarization retention rate at the first incident angle;
[0084] The coupling index is obtained by calculating the ratio of polarization difference to width ratio.
[0085] Specifically, the ratio of the corrected half-peak width at the second incident angle to that at the first incident angle is calculated to measure the degree to which the bright spot broadening varies with the angle at different incident angles. According to the laws of optical reflection and scattering theory, the roughness of the fruit and vegetable peel and the thickness of the wax film layer cause the bright spot expansion to exhibit a non-linear change with increasing angle. This ratio can eliminate the influence of a single scale factor and retain the relative differences caused by the angle change. The difference between the polarization retention rate at the second incident angle and that at the first incident angle is calculated to characterize the ability to retain polarization information with changing angle. This is based on Malus's law and... Based on the Brewster angle principle, the polarization retention rate varies significantly at different angles. Difference operations can directly reflect the differences in surface microstructure and moisture state. Finally, the ratio of polarization difference to width ratio is calculated, and the resulting coupling index combines the comprehensive information of bright spot broadening and polarization retention rate changes. It can directly reflect the overall influence of fruit and vegetable skin roughness, wax film state, and micro-scattering structure in a dimensionless expression. The resulting coupling index serves as a key criterion for subsequent quality grading, possessing stability and discriminative power, and ensuring that the differences in optical response among different fruits and vegetables can be accurately quantified.
[0086] A sliding reference set is constructed based on the historical coupling index, and the lower and upper bound thresholds of the coupling index are determined based on the median of the sliding reference set.
[0087] In an embodiment of the present invention, see Figure 6 A sliding reference set is constructed based on historical coupling indices. The lower and upper bound thresholds of the coupling index are determined based on the median of the sliding reference set, including:
[0088] A predetermined number of coupling indices are selected from the historical coupling indices to form a sliding reference set;
[0089] Calculate the absolute value of the deviation of each element of the sliding reference set from the median of the sliding reference set to obtain the absolute deviation set, and use the median of the absolute deviation set as the absolute median difference;
[0090] Specifically, when processing historical coupling indices, a sliding reference set is constructed by extracting a preset number of coupling indices from the time series. This ensures that the calculation reflects short-term fluctuations while maintaining statistical stability. In this sliding reference set, the absolute value of the deviation between each element and the median of the set is first calculated. This operation originates from the definition of absolute median difference in robust statistics. By avoiding reliance on the mean, it reduces the impact of extreme values on the overall distribution, thus more accurately reflecting the central tendency. After forming an absolute deviation set from these absolute deviation values, the median of the absolute deviation set is taken as the absolute median difference. This is equivalent to a robust estimation of the overall data fluctuation range, which can more accurately characterize the stable fluctuation of the coupling index within the normal range, thereby ensuring that the subsequent determination of the threshold is more consistent with the true distribution pattern of fruit and vegetable quality grading.
[0091] Specifically, data is read from historical coupling indices in reverse chronological order, and the current coupling index is removed. A preset number of samples is then used to form a sliding reference set. This preset number is typically set based on the batch size of fruits and vegetables processed on the conveyor line, the camera sampling frequency, and the desired time window. For example, on a continuous production line, a sampling range covering several seconds to tens of seconds can be selected to ensure both the robustness of the statistical results and real-time response to dynamic fluctuations. If the number of historical samples is less than the preset number, all existing historical samples are used to form the sliding reference set. The start and end times of the set and the number of samples are recorded for traceability. The sliding reference set is then arranged in ascending order of values to obtain an ordered sequence. The median of the sliding reference set is determined by the median position of this ordered sequence. When the number of samples is odd... The median is calculated by taking the value at the middle position of the sequence. When the number of samples is even, the median is calculated by taking the arithmetic mean of the two middle numbers in the sequence. After obtaining the median, the absolute value of the difference between each element in the sliding reference set and the median is taken. All absolute values are combined into an absolute deviation set in the original sample order. The absolute deviation set is then sorted in ascending order of value. The absolute median difference is determined by the value at the middle position. When the number of elements in the absolute deviation set is odd, the absolute median difference is taken as the value at the middle position. When the number of elements is even, the absolute median difference is taken as the arithmetic mean of the two middle numbers. Finally, the median of the sliding reference set, the absolute deviation set, and the absolute median difference are stored together and associated with the corresponding time information to provide directly callable data input for subsequent threshold calculations.
[0092] The absolute median is converted to an approximate standard deviation by using a fixed robust conversion factor.
[0093] The lower bound threshold is obtained by subtracting the product of the approximate standard deviation and the prior device coefficients from the median of the sliding reference set.
[0094] The upper bound threshold is obtained by adding the approximate standard deviation to the median of the sliding reference set and the product of the prior device coefficients.
[0095] Specifically, in statistical analysis, the absolute median is used as a robust estimator of data dispersion. Since its dimensions are the same as the data itself, it needs to be approximated to the standard deviation by using a fixed robust conversion factor. This allows for a characterization capability equivalent to the variance of a normal distribution without the interference of outliers. When setting thresholds, the median of the sliding reference set is used as a representative of central tendency. The lower and upper bound thresholds are constructed by subtracting or adding the product of the approximate standard deviation and the prior device coefficient, which is equivalent to defining a symmetrical interval for the data distribution. The prior device coefficient acts as a scaling factor, allowing the threshold range to be adjusted for sensitivity and robustness according to specific applications. This ensures the suppression of abnormal fluctuations and dynamically adapts to the actual distribution patterns of the coupling index in fruit and vegetable quality grading, thus providing scientific and reasonable boundary conditions for subsequent grading.
[0096] Specifically, the system first calls a preset fixed robust conversion factor, then multiplies the absolute median by this conversion factor to obtain an approximate standard deviation. This operation ensures that the system can still achieve a fluctuation characterization equivalent to the variance under different distribution conditions. Under a normal distribution, there is a fixed proportional relationship between the expected value of the absolute median and the standard deviation. According to probability and statistics, the standard deviation is approximately equal to the absolute median multiplied by a constant. This constant is the fixed robust conversion factor, which takes a value of approximately 1.4826 under the common normal distribution. The lower bound threshold for the median of the sliding reference set is calculated by subtracting the product of the approximate standard deviation and the prior device coefficient from the median. The upper bound threshold is then calculated by adding the approximate standard deviation and the prior device coefficient to the median. The device coefficient is pre-obtained through experimental calibration. Before the fruit and vegetable quality grading equipment is put into use, a batch of standard samples with known grades are selected, and their coupling index distribution ranges are calculated. By comparing the coverage between the actual distribution and the statistical interval, the coefficient is adjusted so that the upper and lower bound thresholds just cover the expected proportion of normal samples while excluding obviously abnormal samples. The absolute median deviation provides a robust fluctuation estimate, the fixed robust conversion coefficient achieves a standard deviation approximation, and the prior device coefficient is used as a regulating factor to control the threshold bandwidth. The resulting upper and lower bound thresholds constitute the judgment boundaries for fruit and vegetable quality grading, avoiding misjudgments caused by individual abnormal data and ensuring a sensitive response of the thresholds to actual quality fluctuations.
[0097] Fruit and vegetable quality is graded based on the lower and upper bound thresholds of the coupling index, and the sliding reference set is updated according to the grading results and the coupling index.
[0098] In embodiments of the present invention, the quality of fruits and vegetables is graded based on a lower and upper bound threshold of the coupling index, and the sliding reference set is updated according to the grading results and the coupling index, including:
[0099] When the coupling index is less than or equal to the lower threshold, the quality level is set to Level 1; when the coupling index is greater than the lower threshold and less than or equal to the upper threshold, the quality level is set to Level 2; when the coupling index is greater than the upper threshold, the quality level is set to Level 3.
[0100] Record the timestamp of the grading event and write the coupling index and timestamp into the sliding reference set;
[0101] If the length of the sliding reference set exceeds the set capacity, the oldest element in the set is deleted, and the updated sliding reference set state is persisted.
[0102] Specifically, the coupling index is compared with upper and lower thresholds to determine the quality grade of fruits and vegetables. The lower threshold represents the lower range in the historical distribution. When the coupling index is less than or equal to the lower threshold, it indicates that the scattering broadening of the fruit and vegetable surface is small, the polarization retention rate is significantly different, the fruit and vegetable skin is intact and smooth, and the wax film continuity is high. This is a high-quality sample and is set as Grade 1. The middle range corresponds to the coupling index falling between the upper and lower thresholds. Its physical state is characterized by moderate scattering broadening and polarization change, and slight roughness or moisture state difference of the fruit and vegetable skin. This is a medium-quality sample and is set as Grade 2. Above the upper threshold, it indicates large scattering broadening, insufficient polarization retention rate difference, and damage or severe roughness of the wax film on the fruit and vegetable skin. This is a low-quality sample and is set as Grade 3. By setting a symmetrical threshold range around the median, the continuous quantity of the coupling index is mapped to a discrete grade, ensuring the stability and interpretability of the quality grading process and accurately reflecting the optical and structural differences of the fruit and vegetable skin.
[0103] Specifically, in the process of fruit and vegetable quality grading, in order to ensure the continuity and traceability of data judgment results, the coupling index and timestamp corresponding to each grading need to be written into the sliding reference set simultaneously. The timestamp records provide the chronological order of grading, thus enabling the differentiation of data states in different time periods during subsequent analysis. When the length of the sliding reference set exceeds the set capacity, deleting the oldest element is equivalent to the finite memory sliding window mechanism in signal processing, ensuring that the set only retains recent data to reflect the state trend of the current batch of fruits and vegetables, avoiding the computational complexity caused by the unbounded growth of the set length. At the same time, through rolling updates of the time series, adaptive tracking of dynamic distribution is achieved, ensuring that the upper and lower bound thresholds are always consistent with the latest data. In this way, the contribution of historical data to threshold estimation is ensured, while avoiding interference from outdated data to the current grading, ultimately achieving the persistence of the sliding reference set state and the stability of grading judgment.
[0104] like Figure 2 The diagram shown is a functional block diagram of a machine vision-based fruit and vegetable quality grading system provided in an embodiment of the present invention.
[0105] In this embodiment, the functions of each module / unit are as follows:
[0106] The image acquisition module is used to acquire parallel polarization component images and vertical polarization component images of fruits and vegetables at the first incident angle and the second incident angle, respectively.
[0107] The profile extraction module is used to extract the brightness profile from the parallel polarization component image to obtain the brightness profile, and the millimeter half-peak width is determined based on the maximum brightness of the brightness profile.
[0108] The broadening compensation module is used to perform equivalent motion broadening compensation on the millimeter half-peak width to obtain the corrected half-peak width. Based on the grayscale ratio of the parallel polarization component image and the vertical polarization component image, the polarization retention rate is obtained.
[0109] The index calculation module is used to calculate the coupling index based on the corrected half-width and polarization retention rate.
[0110] The threshold generation module is used to construct a sliding reference set based on historical coupling indices, and to determine the lower and upper bound thresholds of the coupling index based on the median of the sliding reference set.
[0111] The quality grading module is used to grade the quality of fruits and vegetables based on the lower and upper bound thresholds of the coupling index, and to update the sliding reference set according to the grading results and the coupling index.
[0112] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for grading fruit and vegetable quality based on machine vision, characterized in that, include: S1. Collect parallel polarization component images and vertical polarization component images of fruits and vegetables at the first and second incident angles, respectively. S2. Extract the brightness profile from the parallel polarization component image to obtain the brightness profile, and determine the millimeter half-peak width based on the maximum brightness of the brightness profile; specifically as follows, determine the mirror direction according to the camera geometric calibration parameters; extract the brightness profile from the parallel polarization component images at the first incident angle and the second incident angle respectively along the mirror direction to obtain the brightness profile at the first incident angle and the brightness profile at the second incident angle. Half the maximum brightness value of the brightness profile is taken as the half-peak threshold; two intersection points on the brightness profile that are equal to the half-peak threshold are found on the left and right sides, and the pixel coordinates of the two intersection points are subtracted to obtain the half-peak width; the pixel units of the half-peak widths of the first and second incident angles are converted to millimeters to obtain the millimeter half-peak widths of the first and second incident angles. S3. The corrected half-peak width is obtained by performing equivalent motion broadening compensation on the millimeter half-peak width. The polarization retention rate is obtained based on the grayscale ratio of the parallel polarization component image and the vertical polarization component image. Specifically, the equivalent motion broadening amount is calculated by multiplying the camera's exposure time and transport speed. Based on the equivalent motion broadening amount, equivalent motion broadening compensation is performed on the millimeter half-peak width at the first incident angle and the millimeter half-peak width at the second incident angle to obtain the corrected half-peak widths at the first and second incident angles. Continuous images in the brightness profile that are not lower than the half-peak threshold are... The set of element positions is taken as a half-peak band; the gray-level ratio of the parallel polarization component image and the vertical polarization component image at the first incident angle is calculated within the half-peak band along the mirror direction to obtain the gray-level ratio sequence of the first incident angle; the gray-level ratio of the parallel polarization component image and the vertical polarization component image at the second incident angle is calculated within the half-peak band along the mirror direction to obtain the gray-level ratio sequence of the second incident angle; the mean values of the gray-level ratio sequences of the first and second incident angles are calculated to obtain the polarization retention rate of the first and second incident angles respectively. S4. Calculate the ratio of the corrected half-peak width of the second incident angle to the corrected half-peak width of the first incident angle to obtain the width ratio; perform a difference operation on the polarization retention rate of the second incident angle and the polarization retention rate of the first incident angle to obtain the polarization difference; calculate the ratio of the polarization difference to the width ratio to obtain the coupling index. S5. Construct a sliding reference set based on the historical coupling index, and determine the lower and upper bound thresholds of the coupling index based on the median of the sliding reference set. S6. Grading of fruit and vegetable quality is performed based on the lower and upper bound thresholds of the coupling index, and the sliding reference set is updated according to the grading results and the coupling index.
2. The method for grading fruit and vegetable quality based on machine vision according to claim 1, characterized in that, Images of the parallel polarization components and vertical polarization components of fruits and vegetables were collected at the first and second incident angles, respectively, including: Set the first angle of incidence to be smaller than the second angle of incidence; Images of the parallel polarization component and the vertical polarization component of fruits and vegetables were collected at the first and second incident angles, respectively. When acquiring parallel polarization component images and vertical polarization component images, the camera's exposure time and transport speed through the imaging area are recorded.
3. The method for grading fruit and vegetable quality based on machine vision according to claim 1, characterized in that, A sliding reference set is constructed based on historical coupling indices. The lower and upper bound thresholds of the coupling index are determined based on the median of the sliding reference set, including: A predetermined number of coupling indices are selected from the historical coupling indices to form a sliding reference set; Calculate the absolute value of the deviation of each element of the sliding reference set from the median of the sliding reference set to obtain the absolute deviation set, and use the median of the absolute deviation set as the absolute median difference; The absolute median is converted to an approximate standard deviation by using a fixed robust conversion factor. The lower bound threshold is obtained by subtracting the product of the approximate standard deviation and the prior device coefficients from the median of the sliding reference set. The upper bound threshold is obtained by adding the approximate standard deviation to the median of the sliding reference set and the product of the prior device coefficients.
4. The method for grading fruit and vegetable quality based on machine vision according to claim 1, characterized in that, Fruit and vegetable quality is graded based on lower and upper bound thresholds of the coupling index. The sliding reference set is updated according to the grading results and the coupling index, including: When the coupling index is less than or equal to the lower threshold, the quality level is set to Level 1; when the coupling index is greater than the lower threshold and less than or equal to the upper threshold, the quality level is set to Level 2; when the coupling index is greater than the upper threshold, the quality level is set to Level 3. Record the timestamp of the grading event and write the coupling index and timestamp into the sliding reference set; If the length of the sliding reference set exceeds the set capacity, the oldest element in the set is deleted, and the updated sliding reference set state is persisted.
5. A machine vision-based fruit and vegetable quality grading system, characterized in that, The system includes: The image acquisition module is used to acquire parallel polarization component images and vertical polarization component images of fruits and vegetables at the first incident angle and the second incident angle, respectively. The profile extraction module is used to extract the brightness profile from the parallel polarization component image to obtain the brightness profile, and the millimeter half-peak width is determined based on the maximum brightness of the brightness profile. The broadening compensation module is used to perform equivalent motion broadening compensation on the millimeter half-peak width to obtain the corrected half-peak width. Based on the grayscale ratio of the parallel polarization component image and the vertical polarization component image, the polarization retention rate is obtained. The index calculation module is used to calculate the coupling index based on the corrected half-width and polarization retention rate. The threshold generation module is used to construct a sliding reference set based on historical coupling indices, and to determine the lower and upper bound thresholds of the coupling index based on the median of the sliding reference set. The quality grading module is used to grade the quality of fruits and vegetables based on the lower and upper bound thresholds of the coupling index, and to update the sliding reference set according to the grading results and the coupling index.