Method for identifying surface defects of organic momordica grosvenori based on machine vision
By constructing a virtual grayscale surface and using frequency domain filtering technology, combined with gradient operators and stitching line algorithms, a full surface map is generated and deep neural network recognition is performed. This solves the problems of light interference and complex texture in the identification of surface defects of monk fruit, and realizes accurate identification and automatic grading of surface defects of monk fruit.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUILIN SANLENG BIOTECH CO LTD
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-19
Smart Images

Figure CN122244851A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology, specifically to a machine vision-based method for identifying surface defects in organic monk fruit. Background Technology
[0002] Existing image data parsing schemes for monk fruit exhibit significant bottlenecks in image content analysis when processing target pixel streams with variable curvature topological surfaces and high-entropy texture features.
[0003] First, conventional methods struggle to construct accurate edge probability field models in image segmentation logic to address pixel gradient dispersion caused by drastic curvature changes on the target image surface. This results in edge detection programs being unable to effectively extract local singular signals through curvature frequency domain spectrum when processing virtual grayscale surface transformations, leading to severe topological connectivity breaks and spatial coordinate mapping deviations.
[0004] Secondly, given the high degree of coupling between naturally grown textures and defect signals in statistical distribution, existing technologies lack effective feature space decoupling methods. This makes it difficult to utilize optimal stitching algorithms to minimize gradient energy in full-surface image stitching, resulting in the inability to remove singular signal responses from the stem region during texture representation domain construction. Furthermore, due to the lack of deep modeling of the normal texture distribution manifold, traditional analysis methods struggle to extract nonlinear offsets of target pixels using residual vectors, limiting their ability to extract features from local tensor blocks.
[0005] Most importantly, existing geometric analysis methods typically extract only simple elementary descriptors such as area and perimeter, lacking comprehensive analysis of higher-order topological features such as Euler number, compactness, and eccentricity in anomalous regions. When processing target images with "visually similar but topologically heterogeneous" characteristics, the system cannot accurately measure heterogeneous feature vectors within the classification feature space, making it difficult to quantitatively analyze and extract the physical properties and features of the target images.
[0006] Therefore, there is a need for an image content parsing scheme that can integrate geometric topology analysis, texture manifold reconstruction, and spatial radiometry modeling.
[0007] To address this, a machine vision-based method for identifying surface defects in organic monk fruit is proposed. Summary of the Invention
[0008] The purpose of this invention is to provide a machine vision-based method for identifying surface defects in organic monk fruit. By manifold reconstruction and multidimensional feature fusion, the method improves the anti-interference ability of curved surface illumination and solves the problem of sample scarcity, thereby achieving accurate identification and automatic grading of surface defects in monk fruit.
[0009] To achieve the above objectives, the present invention provides the following technical solution: a machine vision-based method for identifying surface defects in organic monk fruit, comprising: Image data of organic monk fruit is acquired, and a curvature frequency domain spectrum is generated by transforming a virtual grayscale surface and then filtered to obtain local texture defect signals. The texture energy map is solved using a gradient operator, and a full surface map is constructed based on the optimal stitching line algorithm. Semantic segmentation is performed on the full surface map to locate the fruit stem boundary and peel region, obtain net texture data, and construct a texture representation domain based on the net texture data; The texture representation domain is mapped to a local tensor block and encoded as a feature vector; a natural texture feature distribution manifold of monk fruit is constructed, and the feature vector is mapped to the natural texture feature distribution manifold to obtain a reconstructed feature vector; the residual vector between the reconstructed feature vector and the feature vector is calculated; the residual vector is input into a deep neural network for pattern recognition to generate a defect probability map. The defect probability map is segmented by threshold to extract abnormal regions. Based on the topological features and texture gradient of the abnormal regions, a heterogeneous feature vector is constructed and mapped to a classification feature space configured with a category reference vector. The Euclidean distance is calculated, and the defect category is determined by pattern classification to complete the identification and grading of surface defects in organic monk fruit.
[0010] Preferably, constructing the full surface map includes: acquiring local image data of the spin scan of *Siraitia grosvenorii*, and establishing a spherical global coordinate system based on the spatial mapping relationship between the spin motion of *Siraitia grosvenorii* and the imaging scan; mapping the pixel plane coordinates and gray values of the local image data in the two-dimensional planar image to the three-dimensional virtual space basis coordinates and virtual height values, respectively, and constructing a virtual gray-scale surface in the virtual space; calculating the Gaussian curvature of the virtual height value; distinguishing between light spots and texture defect areas based on the Gaussian curvature characteristics, and constructing a local spatial domain Gaussian curvature field; projecting the local spatial domain Gaussian curvature field onto the orthogonal complex basis space through edge smoothing preprocessing and fast Fourier transform to obtain the local curvature frequency domain spectrum; and using a frequency domain filter to remove... After removing background illumination interference and reflection noise in the local curvature frequency domain spectrum, the local texture defect signal is generated by inverse fast Fourier transform and projected onto the spherical global coordinate system according to the spatial mapping relationship. Based on the continuous acquisition characteristics of spin scanning, the local texture defect signal in two adjacent frames is used to form a spatially overlapping region in the spherical global coordinate system. The gradient magnitude of the pixel plane coordinate points in the overlapping region is calculated as the texture energy using the gradient operator to construct a texture energy map. The nonlinear stitching boundary passing through the region with the lowest texture energy is planned in the overlapping region using the optimal stitching line algorithm. The overlapping region data is fused and stitched according to the nonlinear stitching boundary to construct the full surface map.
[0011] Preferably, the steps for constructing the texture representation domain include: inputting the full surface map into a deep fully convolutional semantic segmentation model, performing pixel-level classification prediction to resolve the segmentation boundaries of the stem-shaped strange region, the effective skin region, and the background interference region; constructing a signal suppression mask based on the segmentation boundaries, and performing edge smoothing processing on the signal suppression mask to eliminate noise at the segmentation boundaries; performing a Hadamard product operation on the signal suppression mask and the full surface map to generate mask-filtered net texture data; and based on the net texture data, removing the signal responses of the stem-shaped strange region and the background interference region at the pixel level in a spherical global coordinate system, retaining the effective skin region with continuous texture distribution characteristics, and constructing the texture representation domain.
[0012] Preferably, the process of constructing the natural texture feature distribution manifold of monk fruit includes: performing spatial sliding window processing on the texture representation domain, extracting continuous local tensor blocks, and simultaneously marking the spatial position index of the local tensor blocks in the spherical global coordinate system; taking the texture pixel data within the local tensor blocks as input; taking the natural texture distribution features of the surface in the undamaged state in the training data of defect-free monk fruit samples as normal texture; taking the natural texture distribution feature pattern as the normal texture distribution pattern; and learning the low-dimensional distribution of the normal texture in the feature space through an autoencoder network to generate the natural texture feature distribution manifold.
[0013] Preferably, the specific steps for calculating the residual vector between the feature vector and the feature vector include: encoding the texture pixel data of the local tensor block to be tested into a feature vector, mapping the feature vector to the natural texture feature distribution manifold, using manifold reconstruction decoding to obtain a reconstructed feature vector that conforms to the normal texture distribution law; performing a vector difference operation between the feature vector and the reconstructed feature vector to generate the residual vector.
[0014] Preferably, the step of generating the defect probability map includes: obtaining residual vectors of different texture attribute feature dimensions, including Euclidean distance offset and manifold deviation information; inputting the residual vectors into a deep neural network, using the embedded channel attention mechanism to identify and analyze the manifold deviation sensitivity of the feature response channels, extracting the global response statistics of the feature response channels, generating channel weighting coefficients, recalibrating the residual vectors, obtaining the defect feature channel responses, and reconstructing to generate weighted residual vectors; inputting the weighted residual vectors into the pixel-level classification decoding layer of the deep neural network, inferring and generating local defect probability values of the local tensor block anomaly degree; calling the spatial location index to map the local defect probability values corresponding to the local tensor block back to the corresponding positions in the spherical global coordinate system, and generating the defect probability map through spatial splicing and recombination.
[0015] Preferably, the step of constructing heterogeneous feature vectors includes: calculating a probability distribution histogram for the defect probability map, solving for a segmentation threshold using the maximum inter-class variance method, and segmenting the boundary between background noise and defect signals; performing binarization processing based on the segmentation threshold to generate a binarized mask, and performing connected component labeling and area filtering to filter out discrete noise points within the mask and extract abnormal regions; calculating the geometric area, Euler number, compactness, and eccentricity of the abnormal regions to generate a topological feature vector; using a gradient operator to calculate the pixel change rate of the abnormal regions, statistically analyzing the gradient magnitude and direction to generate a texture gradient feature vector; and performing the fusion of the topological feature vector and the texture gradient feature vector to construct a heterogeneous feature vector.
[0016] Preferably, the process of identifying and grading surface defects in organic monk fruit includes: constructing a classification feature space based on the feature dimensions of the heterogeneous feature vectors; statistically analyzing the category mean vector of known defect samples in the classification feature space as a category reference vector; mapping the heterogeneous feature vectors to be tested onto the classification feature space; calculating the Euclidean distance between the target vector and the category reference vector; sorting the Euclidean distances in ascending order according to the nearest neighbor principle; selecting the category corresponding to the category reference vector at the top of the sorted sequence as the defect category label of the abnormal region; extracting the geometric area value as the damaged physical quantity; constructing a comprehensive grading logic matrix containing the defect category dimension and the damaged physical quantity dimension; inputting the defect category label and the damaged physical quantity as indices into the comprehensive grading logic matrix; and outputting a grade instruction through the index mapping of the comprehensive grading logic matrix to complete the identification and grading of surface defects in organic monk fruit.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention solves the problems of strong specular reflection interference and uneven illumination caused by the smooth spherical structure of organic monk fruit by constructing a virtual grayscale surface and combining curvature frequency domain transformation and filtering. Unlike the traditional processing method that is directly based on grayscale threshold, this invention uses the difference between high-frequency reflection noise and low-frequency illumination in the curvature frequency domain to perform physical separation, effectively suppressing the "pseudo-defect" signal caused by illumination. At the same time, it solves the texture energy map based on the gradient operator and plans the optimal nonlinear stitching boundary to solve the common problems of image misalignment and texture double image in multi-view panoramic stitching of spheres, ensuring the integrity of the whole surface map and the authenticity of the texture.
[0018] 2. This invention overcomes the limitation of traditional supervised learning algorithms that require training by traversing all defect morphologies, by constructing a natural texture feature distribution manifold and an anomaly detection mechanism based on reconstructed residuals. It utilizes an autoencoder to learn the "normal texture distribution pattern" of healthy fruit peel and combines a channel attention mechanism to recalibrate the residual vector, achieving keen capture of minor anomalies that deviate from the healthy baseline data. This mechanism ensures that the anomaly detection model can effectively identify defects by reconstructing residuals without needing to pre-store defect morphologies in the training set. This significantly improves the detection rate of the model in complex industrial environments, including features of irreversible factors such as mold, cracks, insect infestation, mechanical damage, and unknown defects.
[0019] 3. This invention constructs a heterogeneous feature vector that integrates topological features (such as Euler number and compactness) and texture gradients (such as gradient magnitude), and performs Euclidean distance determination based on the nearest neighbor principle in the classification feature space. This solves the problem that single visual features are difficult to distinguish between defects that are similar in appearance but different in nature (such as dark mold spots and physical dents, cracks and mechanical scratches). This multi-dimensional heterogeneous feature verification mechanism enables accurate characterization of mold, cracks, insect infestation and mechanical damage on the surface of monk fruit, and can automatically output grading instructions in combination with the damaged physical quantity, which significantly improves the intelligence and standardization of organic monk fruit sorting. Attached Figure Description
[0020] Figure 1 This is an overall flowchart of the machine vision-based method for identifying surface defects in organic monk fruit according to the present invention. Figure 2 This is a schematic diagram illustrating the principle of noise reduction and panoramic stitching based on virtual grayscale surfaces in this invention. Figure 3 This is a schematic diagram of the deep network architecture based on spatial index mapping and anomaly detection probability closed loop of the present invention. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention.
[0022] Please see Figures 1 to 3This invention provides a machine vision-based method for identifying surface defects in organic monk fruit. The method includes acquiring image data of the organic monk fruit; constructing a curvature frequency domain spectrum based on a virtual grayscale surface and filtering it to remove reflection noise and obtain local texture defect signals; calculating the texture energy map using a gradient operator; constructing a full surface map based on the optimal stitching line algorithm; performing semantic segmentation on the full surface map to locate the fruit stem boundary and peel region, removing background interference; constructing a texture representation domain based on the net texture data; mapping the texture representation domain to a local tensor block and encoding it as a feature vector; constructing a natural texture feature distribution manifold of the monk fruit; mapping the feature vector to the natural texture feature distribution manifold to obtain a reconstructed feature vector; calculating the residual vector between the reconstructed feature vector and the feature vector; inputting the residual vector into a deep neural network for pattern recognition to generate a defect probability map; performing threshold segmentation on the defect probability map to extract abnormal regions; constructing heterogeneous feature vectors based on the topological features and texture gradients of the abnormal regions and mapping them to a classification feature space configured with a category reference vector; calculating the Euclidean distance; performing pattern classification to determine the defect category; and completing the identification and grading of surface defects in the organic monk fruit.
[0023] Example 1: In this embodiment, in the cold chain intelligent sorting line of high-altitude organic monk fruit production area, this variety has two significant visual inspection challenges: First, the epidermal cuticle is extremely thick and secretes natural fruit wax. Under the 4-degree Celsius cold chain transportation environment, the fruit surface not only exhibits strong specular highlights but also has micron-sized condensation droplets attached, generating complex mixed optical noise. Second, the characteristics of organic cultivation make "needle-tip insect damage" and "early filamentous mold" extremely concealed, and their morphology is random and unpredictable. Traditional visual systems based on grayscale thresholds and simple sample template matching are difficult to distinguish between water droplet reflections and real defects in this scenario, resulting in a very high misjudgment rate. The method of this invention is integrated into the visual inspection station of this sorting line, aiming to complete the accurate defect identification and grade determination of high-speed spinning monk fruit in milliseconds through a closed loop of artificial intelligence technology using curvature transformation of physical optics and manifold reconstruction.
[0024] Specifically, the overall execution logic of this invention is as follows: Figure 1 As shown, the system first executes step one, acquiring high-resolution image sequences during the spin process of the monk fruit, and removing interference from condensation droplets and fruit wax reflection through virtual surface transformation and frequency domain filtering to construct a seamlessly stitched full surface map; then, step two is executed, using a deep semantic segmentation network to remove the fruit stem and background, extracting a texture representation domain free from impurity interference; subsequently, steps three and four are executed, entering the manifold anomaly detection closed loop, using an autoencoder to reconstruct normal texture and calculate residuals to generate a defect probability map; finally, steps five and six are executed, extracting multidimensional heterogeneous features of the abnormal region, completing the qualitative analysis of defects and the classification of products in the classification feature space.
[0025] To address the complex noise interference caused by the coexistence of strong specular gloss and condensation droplets on the surface of monk fruit under cold chain conditions in this embodiment, this invention constructs a full surface map through physical optical transformation and energy-guided stitching technology. The specific execution process includes: geometric alignment in spatial dimensions, based on spin motion mapping, unifying discrete two-dimensional local scan data to a three-dimensional spherical global coordinate system to establish the physical position benchmark for full surface recognition; topological purification of texture features, through dimensionality increase processing of grayscale mapping height, utilizing Gaussian curvature and bidirectional frequency domain filtering to strip away light spots and high-frequency noise at the topological level, extracting pure texture defect signals unaffected by environmental interference; and seamless fusion of global information, constructing a fusion energy field centered on gradient amplitude in overlapping areas, and using an optimal stitching algorithm to find the seam path with the minimum visual cost in nonlinear space, achieving high-fidelity seamless stitching of multiple frames. Essentially, it achieves geometric alignment of physical positions on a three-dimensional sphere and seamless stitching of textures on a two-dimensional unfolded plane through energy optimization. This transforms complex surface defect identification into a full-surface defect map generated by topological feature extraction and energy-minimizing path planning under spatiotemporal consistency constraints.
[0026] Further, the construction of the full surface map includes: acquiring local image data of the organic monk fruit during the spin scanning process, and establishing a spherical global coordinate system based on the spatial mapping relationship between the spin motion of the organic monk fruit and the imaging scan; mapping the pixel plane coordinates and gray values of the local image data of the two-dimensional planar map to the three-dimensional virtual space basis coordinates and virtual height values respectively, and constructing a virtual gray-scale surface in the three-dimensional virtual space; calculating the Gaussian curvature of the virtual height value; distinguishing between light spots and texture defect areas based on the characteristics of the Gaussian curvature, and constructing a local spatial domain Gaussian curvature field; projecting the local spatial domain Gaussian curvature field onto the orthogonal complex basis space through edge smoothing preprocessing and fast Fourier transform to obtain the local curvature frequency domain spectrum; and applying a frequency domain filter to remove... In addition to low-frequency background illumination interference and high-frequency reflection noise in the local curvature frequency domain spectrum, the local texture defect signal is generated by inverse fast Fourier transform. Based on the spatial mapping relationship, the local texture defect signal is projected onto the spherical global coordinate system. Based on the continuous acquisition characteristics of spin scanning, adjacent local texture defect signals form a spatial overlap region in the spherical global coordinate system. The gradient magnitude of the pixel plane coordinate points in the overlap region is calculated using the gradient operator as the texture energy to construct a texture energy map. Then, through the optimal stitching line algorithm, a nonlinear stitching boundary passing through the region with the lowest texture energy is planned in the overlap region. The image data of the overlap region is fused and stitched according to the nonlinear stitching boundary to construct the full surface map.
[0027] Specifically, the spherical global coordinate system is established through a five-step calibration method, including: the first step is to calibrate a standard sphere: selecting a sphere with a diameter of 30.000 mm. A standard stainless steel sphere of 0.001 mm was used as a calibration object and placed at the center of the rotating stage. Images were acquired at eight uniformly selected rotation positions between 0 and 360 degrees. The coordinates of the projected center of the sphere in the images were obtained by fitting using the least squares method. and projection radius The second step involves inverse solving of the camera's intrinsic parameters: based on the physical diameter and projected radius of a standard sphere. The perspective projection geometry relationship is determined. The third step is camera extrinsic parameter calibration: combining eight sets of calibration coordinates with the angle values provided by the encoder, a nonlinear optimization algorithm is used to solve for the rotation matrix. Translation vector , Output rotation orientation, which determines the accuracy of the latitude of the pixel projection onto the sphere; The output translation displacement determines the spatial distance between the camera and the center of the monk fruit sphere. The fourth step is to perform coordinate mapping: establish a spherical global coordinate system with the center of the monk fruit sphere as the origin. .in, Distance is the radius. The spherical polar angle in the latitude direction (range) ); The azimuth longitude direction of the spherical surface (range) The pixel coordinates (u, v) are projected onto the ray equation using a projection matrix, and their intersection with the sphere is calculated to achieve precise registration between pixel features and the physical surface position. The fifth step is delay compensation and monitoring: For feedback delay during the spin process, angle correction is performed according to the formula: ,in This refers to the real-time angular velocity of the motor. The system feedback delay time; compared with the real-time angular velocity Multiplication is used to correct for longitude angular deviations caused by response lag, achieving precise registration of pixel positions with physical surfaces; if an axis offset is detected... If the distance exceeds 5 millimeters, the system will automatically trigger an alarm.
[0028] Specifically, in this embodiment, such as Figure 2 As shown, the process of mapping the pixel plane coordinates and grayscale values of the local image data in the two-dimensional planar image to the basis coordinates and virtual height values in the three-dimensional virtual space, and constructing a virtual grayscale surface in the three-dimensional virtual space, includes: establishing a coordinate system and constructing a virtual grayscale surface. Based on the average physical size of the current batch of organic monk fruit, a spherical physical coordinate system with an average radius of 30 mm as the reference is used as the global coordinate system. This is a crucial bridge for transforming local images acquired over time into spherical spatial coordinates. During the data acquisition phase, a camera with a single-frame resolution of 1024 pixels vertically and 2048 pixels wide is used to capture images, which are then projected onto a small grid of 1024 rows and 2048 columns, forming a local grayscale image matrix. The physical field of view of a single pixel in this local grayscale image matrix is approximately 30 mm in height and 60 mm in width, resulting in a physical pixel size of approximately 0.029 mm. The 2048-pixel width corresponds to the spin unfolding direction of the organic monk fruit, and the 1024-pixel vertical height corresponds to the axial direction of the imaging scan. After acquiring the local image data during the spin scanning process, as shown... Figure 2 As shown in the schematic diagram of virtual grayscale surface mapping, the program performs a mapping transformation from a two-dimensional pixel domain to a three-dimensional virtual space.
[0029] Specifically, a basis mapping is performed based on spatial mapping relationships, mapping the local image pixel coordinates (u,v) of the two-dimensional planar image to the local basis coordinates (x,y) of the three-dimensional virtual space, and then mapping the grayscale value g to the virtual height value h; where u represents the longitude angle based on spin motion, and v represents the latitude angle of the camera's field of view, ranging from 0 degrees to 360 degrees; the grayscale value g (0-255) of the two-dimensional planar image pixel is read, and the virtual height value is calculated. ;in, This is the virtual height scaling factor, determined using a standard color chart calibration method, with a value ranging from 0.4 to 0.8. For the height offset, in this embodiment, for a camera with 8-bit quantization precision in a cold chain environment, the following is selected: =0.6, =0; The value is not fixed, but is calibrated according to different light source illuminance and camera quantization accuracy: if the light source brightness increases or a 16-bit high-precision camera is used, linear recalibration is required through a standard color chart to ensure the sensitivity of the height field to defects; first, the local image pixel coordinates (u,v) are converted into three-dimensional virtual space basis coordinates (x,y).
[0030] in, The value of [value] is linearly inversely proportional to the ambient illuminance, ensuring that the virtual height field maintains optimal contrast under different brightness levels. The specific criteria are as follows: When the illuminance is high, i.e., in a strong light environment of 1500 lux or higher, the overall grayscale value of the image pixels is relatively high; in this case, [value] is selected. A coefficient between 0.4 and 0.5 is used to compress the gain in high grayscale regions, preventing the virtual surface from saturating prematurely at the light spot and preserving the microscopic undulations at defect edges; this is selected in a standard lighting environment with an illuminance of 800 to 1200 lux. A coefficient between 0.5 and 0.6 balances image brightness and texture clarity, creating a stable geometric difference between normal fruit peel and minor insect damage. In low-light environments of 500 to 800 lux, insufficient light intensity leads to pixel grayscale compression, requiring a specific coefficient to be selected. A coefficient between 0.7 and 0.8 amplifies minute grayscale fluctuations through physical gain, thereby enhancing the system's sensitivity to detecting hidden defects such as filamentous mold.
[0031] height offset The selection of the offset is entirely based on the alignment with the environmental "zero point". The system determines this by measuring the average grayscale value of the background captured by the camera in a fruitless state: Ideally, if the physical enclosed space of the visual inspection station is completely enclosed and the background grayscale value approaches zero, then the offset is... Select 0. Noise compensation: If there is constant stray light in the environment causing the background grayscale value to be non-zero, then multiply the background grayscale value by g by the virtual height scaling factor. The negative value is then used as the offset. The algorithm forces the background signal to zero to ensure that the virtual height field only reflects the characteristic energy of the monk fruit itself.
[0032] The conversion formula is: ; .
[0033] in, () represents the pixel coordinates of the camera image center. The physical size of a single pixel is 0.029 mm in this embodiment. The magnification of the optical system is 1 in this embodiment. Magnification; In this embodiment, the camera image resolution is set to a vertical height of 1024 pixels and a horizontal width of 2048 pixels, corresponding to a single pixel physical size of approximately 0.029 mm, and an optical magnification of 1. Select camera configuration =0.6, =0. This mapping aims to compress the original high-dimensional grayscale information into a topological height field that can be differentiated, which does not represent the true physical morphology of the monk fruit; the pixel coordinate point (50,50) in the two-dimensional planar image is selected. In the cold chain intelligent sorting line of this embodiment, in the organic monk fruit that has been illuminated by light reflection, the illuminated spot area is saturated with grayscale and has a smooth transition. It appears as a planar undulating line in the virtual grayscale surface as the bright fruit area (g=240). The virtual height value of the bright fruit area is then... Conversely, after light reflection, the grayscale value becomes unsaturated and fluctuates drastically, appearing as undulating lines on the virtual grayscale surface as needle-like worm-eaten or micro-crack areas (g=40). The virtual height value of these needle-like worm-eaten or micro-crack areas is then... The bright reflective points are then mapped to altitude. On high ground, the dark spots of insect eyes are mapped to altitude. The deep pit; the originally planar pixel array was transformed into a geometric mesh undulating in three-dimensional virtual space, forming a high-altitude gap between the normal surface and the defects. The geometric drop of a unit; then the three-dimensional virtual space includes three parameters (x, y, g), where (x, y) are the base coordinates of the virtual space, and g is the gray value of the pixel coordinate point of the image. The virtual gray surface is then formed by the vector (x, y, g).
[0034] The construction of the virtual grayscale surface adaptively adjusts the scaling factor and offset through an illumination-sensing mechanism. The scaling factor is linearly inversely proportional to the ambient illumination, ensuring that the virtual height field maintains optimal contrast under different light intensities: in strong light environments, the system selects a smaller virtual height scaling factor. To compress the gain in high grayscale areas and prevent premature saturation of the virtual surface at the light spot, the micro-undulations of the defect edges are preserved; in low-light environments, a larger virtual height scaling factor is selected. By amplifying minute grayscale fluctuations through physical gain, the sensitivity to detect hidden defects is improved. Simultaneously, the height offset... The selection is based on the environmental "zero point" alignment principle. The system measures the average gray value of the background in real time when there is no fruit, and then compares it with the scaling factor. The negative value after multiplication is used as the offset. At the algorithm level, the background signal and stray light are forced to zero to ensure that the generated virtual grayscale surface only objectively reflects the intrinsic characteristic energy of the monk fruit itself.
[0035] In this embodiment, the constructed three-dimensional virtual space does not refer to the physical geometric shape of the monk fruit, but rather to a virtual grayscale surface, also known as a grayscale feature energy topological surface. Two-dimensional pixel coordinates (u,v) are mapped to basis coordinates (x,y), and the pixel grayscale value g is quantized using coefficients. The mapping is represented by a virtual height h. The gray-scale feature energy topological surface, where the illuminated spot appears as a low-frequency region with uniformly diffused energy in the image space, exhibits significant isotropy in its local features, meaning that the gray-scale gradient changes smoothly and continuously in all directions. After mapping to the virtual space surface, the Hessian matrix eigenvalues of the bright spot region tend to be balanced and have small amplitudes, causing its corresponding virtual Gaussian curvature p to approach 0. Conversely, texture defects (such as decay and damage) appear as high-frequency signals in the gray-scale space, with discontinuous gradient changes at the edges. The Gaussian curvature operator is essentially equivalent to a nonlinear feature extraction operator with high-pass properties, which can suppress low-frequency components representing background and light interference, and drastically amplify the high-frequency singular features representing defect edges, causing them to produce a large absolute value of curvature on the virtual surface. Through this mapping and filtering mechanism, this invention achieves precise decoupling of illumination noise and actual defects in the feature space.
[0036] Compared to traditional linear high-pass filters (such as the Laplacian operator), this invention calculates Gaussian curvature by constructing a virtual grayscale feature energy topological surface. It can further suppress interference with unidirectional edge features (such as normal growth textures) by utilizing the product characteristics of principal curvatures, and only produces a very high response to singular point defects with bidirectional dramatic changes, significantly reducing the false alarm rate.
[0037] Specifically, the process of calculating the Gaussian curvature of the virtual height value includes: setting the Gaussian curvature to p, calculating the Gaussian curvature of the nodes on the virtual grayscale surface using the discrete Laplacian operator, and using a curvature threshold. Separate "lighting features" (low-frequency smoothness) and "texture features" (high-frequency abrupt changes); based on the principle of lighting separation, for the illuminated spot area at the coordinate point (50, 50), due to grayscale saturation and smooth transition, the virtual surface approximates a plane, and the calculated value at this time... absolute value Typically, a value of 0.001 indicates a light spot and triggers signal suppression; this is determined by a comparison formula based on a preset curvature threshold. The system performs a determination, identifying regions whose absolute value is less than the preset curvature threshold as illuminated spots, and regions whose absolute value is greater than or equal to the preset curvature threshold as illuminated spots. The area is identified as a texture defect area. For the worm-eaten pit at coordinate point (50, 50), the calculated curvature... When the value is -0.05, by adjusting the Gaussian curvature... Taking the absolute value as 0.05, at this time... The system identifies these as valid defect feature points and maps both the depressions (negative curvature) and convexities (positive curvature) of the local surface as high-amplitude positive singular energy points, unifying the expression of defect features and constructing a Gaussian curvature field in the local spatial domain. (x,y).
[0038] The preset curvature threshold The determination follows the confidence interval method based on normal distribution: 100 defect-free samples are collected from at least three different production areas with a harvesting time span exceeding two months to ensure coverage of texture variations under different environments. The Gaussian curvature field of the full surface map of each sample is calculated, and the distribution pattern of its absolute value is statistically analyzed. A normality statistical test is performed on this distribution. If the obtained statistical probability value is not lower than the significance level of 0.05, it is determined to be approximately normally distributed. The value is set to the mean plus 1.96 times the standard deviation; if the test fails, a non-parametric method is used, taking the 95th percentile of the distribution as the mean. When detecting smooth fruit peel under cold chain conditions, this threshold... The standard range is between 0.008 and 0.015. If the light source or acquisition conditions change, recalibration should be performed, and the false alarm rate of defect-free samples should not exceed five percent.
[0039] The calculation of Gaussian curvature involves mapping and transforming two-dimensional pixel grayscale values to three-dimensional virtual height. A discrete second-order partial derivative method based on pixel gradients is used to convert the grayscale value of a pixel at (x,y) in the virtual grayscale surface into the corresponding virtual height value using the function G(x,y). This is used to construct the height field to be processed; regarding the height field The Gaussian curvature is calculated using a discrete second-order partial derivative method based on pixel gradients: A discrete matrix is formed by extracting nine height values (left, right, and diagonal) within a neighborhood window centered at the pixel (x, y) with a width and height of 3 pixels. The Sobel operator is then used to perform a weighted summation operation on this neighborhood window's discrete matrix. Curvature threshold. The determination follows the reference sample method: 10 to 15 defect-free organic monk fruit samples are selected as the benchmark dataset, the Gaussian curvature distribution of their full surface map is calculated, and the absolute value of curvature of normal non-uniform regions such as light-illuminated spots is statistically analyzed.
[0040] Specifically, to eliminate misjudgments and perform frequency domain filtering and denoising (signal generation), and to eliminate the frequency domain leakage effect generated by Discrete Fourier Transform when processing finite-length signals, the system first performs edge smoothing preprocessing on the local spatial domain Gaussian curvature field. A two-dimensional window function is used to perform weighted attenuation processing on the boundary pixels of the local spatial domain Gaussian curvature field p(x,y), so that the Gaussian curvature signal smoothly transitions to zero at the local window boundary, ensuring the circumferential continuity of the signal in the spatial domain and eliminating spectral leakage generated by subsequent Fast Fourier Transform. The local window boundary refers to the outer edge pixel region of the local spatial domain Gaussian curvature field matrix in the spatial dimension. Attenuation processing is performed on the outer edge pixel region using a two-dimensional window function, so that the Gaussian curvature signal smoothly decreases from the center of the window to the edge to a reference value (such as zero), eliminating frequency domain leakage caused by signal truncation. The edge smoothing processing refers to attenuating the left and right edges to zero values, achieving a smooth edge transition and eliminating cross-shaped ghosting in the frequency domain.
[0041] In this embodiment, the smoothed Gaussian curvature field is projected onto an orthogonal complex basis space via a fast Fourier transform to obtain the local curvature frequency domain spectrum. To address the specific noise characteristics of this scenario, a specific combined frequency domain filter was designed and applied, using a high-pass filter as the cutoff spatial frequency. Period / pixel is used to remove macroscopic illumination gradients (typical wavelength approximately 100 pixels); a low-pass filter is applied as the cutoff space frequency. The period / pixel is used to suppress sensor noise and high-frequency reflections (typical wavelength approximately 10 pixels). The physical basis of this filtering parameter is that low-frequency components reflect uneven lighting, high-frequency components reflect water droplet reflections and surface roughness, and mid-frequency components (wavelengths of 10 to 100 pixels) contain substantial defect features. After inverse Fourier transform, the filtered spectrum is restored to the spatial domain. The output local texture defect signal matrix retains only mid-frequency geometric abrupt change signals related to insect damage and microcracks, completing the closed-loop transformation from the original image to a pure defect signal. The role of Gaussian curvature in virtual surface construction is clearly defined as preliminary feature separation rather than final classification. Since the highlands formed by the mapping of bright reflective points may produce local curvature jumps, the system subsequently needs to combine spatial frequency domain filtering and a manifold-based residual detection mechanism to perform secondary verification on the initially extracted singular feature points, eliminating misjudgments caused by lighting interference and natural epidermal textures (such as lenticels). In this embodiment, the pixel coordinates... u, v) refers to the discrete row and column indices in the local image array of the two-dimensional planar image; the virtual spatial local basis coordinate system (x, y) converts the pixel indices of the two-dimensional planar image into corresponding local spatial length units (such as millimeters or sub-millimeter units) according to the camera pixel size and magnification; while the spherical global coordinate system... This represents the true coordinates of the organic monk fruit in three-dimensional physical space. Through the nested transformation of the above three coordinate systems, a logical closed loop from pixel feature extraction to physical surface reconstruction is achieved.
[0042] The frequency domain filter employs a second-order Butterworth filter with linear phase characteristics and is configured for bandpass mode. Its frequency cutoff parameters are set based on the spatial frequency distribution of the surface features of the monk fruit: the low-frequency cutoff frequency is set to 0.01 cycles / pixel to filter out macroscopic illumination unevenness signals with wavelengths greater than 100 pixels; the high-frequency cutoff frequency is set to 0.1 cycles / pixel to suppress water droplet refraction and sensor noise with wavelengths less than 10 pixels. Since the geometric abrupt changes in substantial defects such as mold and insect infestation are mainly distributed within this passband, the system reconstructs pure local texture defect signals in the spatial domain through Fourier transform and its inverse transform, ensuring that the data source used for full surface image stitching has an extremely high signal-to-noise ratio.
[0043] The virtual grayscale surface construction transformation generates a curvature frequency domain spectrum, specifically including: first, mapping the local image pixel coordinates and grayscale values to the three-dimensional virtual space basis coordinates and virtual height values to construct a virtual grayscale surface; then, calculating the Gaussian curvature field on the virtual grayscale surface based on the discrete second-order partial derivative method; performing edge smoothing processing on the Gaussian curvature field and then performing a fast Fourier transform to obtain the curvature frequency domain spectrum; finally, applying a preset combined frequency domain filter to the curvature frequency domain spectrum to suppress low-frequency illumination components and high-frequency reflection noise, obtaining a local texture defect signal containing only mid-frequency defect features.
[0044] During the spin scanning of Luo Han Guo (monk fruit), the rotation step angle is controlled so that the local texture maps of two adjacent frames have a 20% field-of-view overlap in the spherical global coordinate system. In this embodiment, specifically, for every 100 pulses of rotation of the rotary table, only 80 mm is new and 20 mm is repeated. Furthermore, the local texture maps of two adjacent frames have a spatial overlap region on the spherical surface with a width of approximately 150 pixels (corresponding to a physical arc length of approximately 4.5 mm) and a height of 2048 pixels. This spatial overlap region simultaneously contains the overlapping signal data of the local texture maps of the two adjacent frames, i.e., located in the spherical global coordinate system. The overlapping signal data of the local texture maps in frames n and (n+1) provide sufficient data support for finding the optimal stitching position. The local texture maps of two adjacent frames form a three-dimensional arc-shaped overlapping area in the spherical global coordinate system as the spatial overlapping region. To facilitate texture feature analysis, the spatial overlapping region is projected and unfolded into a two-dimensional overlapping matrix. The gradient magnitude of the local texture maps of two adjacent frames (frame n and (n+1)) is calculated using the Sobel gradient operator and then fused. That is, the pixel coordinates mapped back from the spherical position in the two-dimensional overlapping matrix are calculated using the Sobel gradient operator. gradient magnitude, This represents the common sampling point position of two adjacent frames within the spherical overlap region. By traversing the two-dimensional overlap matrix space, the gradient magnitudes of corresponding positions in the two frames are linearly superimposed to construct the fusion energy, thereby generating the texture energy map that reflects the richness of local texture. The texture energy map is a weight matrix with a width of approximately 150 pixels and a height of 2048 pixels. The optimal stitching line algorithm is used to search for a path with the minimum cumulative fusion energy from the top to the bottom of the two-dimensional overlap matrix in the texture energy map, which is then used as the optimal stitching line.
[0045] The search for the optimal stitching line employs a dynamic programming algorithm to globally optimize the texture energy map, which is formed by the linear superposition of gradient magnitudes from two adjacent frames. First, the system uses the original texture energy value of the first row of the overlapping region as the initial accumulated cost for path searching. Then, it traverses the entire search space (150 pixels wide, 2048 pixels high) row by row from top to bottom. For each pixel in the desired location, the system logically compares and selects the path node with the smallest accumulated energy among its three neighboring positions in the previous row, performing numerical superposition to update the minimum accumulated cost at the current position. During this recursive calculation, the algorithm strictly adheres to the path constraint that the absolute value of the lateral movement error between adjacent rows is no greater than one pixel unit. This ensures a smooth and continuous transition of the stitching boundary at the pixel level, effectively avoiding image seam jumps caused by mechanical spin fluctuations or refraction from condensation droplets. After accumulating to the bottom of the overlapping region, the system selects the point with the smallest accumulated energy distribution in the last row as the globally optimal endpoint and performs a reverse backtracking from there, ultimately outlining a non-linear stitching boundary that minimizes the global visual difference cost. Using this boundary as a decision-making benchmark, seamless fusion and precise reorganization of overlapping area data can completely eliminate ghosting and misalignment at the splicing points, ensuring the texture authenticity of the full surface map.
[0046] In this embodiment, a path is searched that runs from the top (y=0) to the bottom (y=2047) of a spatially overlapping region on the sphere with a width of approximately 150 pixels (corresponding to a physical arc length of approximately 4.5 mm) and a height of 2048 pixels, such that the energy accumulation of all pixels traversed is maximized. To achieve the global minimum. Facing The high-energy calyx remnant region (i.e., the complex structures at both ends of the monk fruit) automatically undergoes lateral displacement to bend and bypass the suture line in order to maintain a low-energy target, preventing the suture line from severing the original key features of the pericarp. Facing Low-energy, flat pericarp regions will be preferentially traversed; a nonlinear suture boundary coordinate set L is generated, consisting of a series of coordinate points. Composition; of which represent The corresponding optimal horizontal stitching position; the local texture maps of two adjacent frames are fused and stitched according to the nonlinear stitching boundary coordinate set, and in this embodiment, the data of the nth frame and the (n+1)th frame are seamlessly fused and accurately recombined according to the coordinate set L. For pixels in the spatially overlapping area, with As the decision boundary, the left region ( When the pixel value is taken entirely from the local texture signal value of the nth frame, the original texture of the nth frame is preserved; the right region ( The pixel value at time n is taken from the local texture signal value of the (n+1)th frame. The essence of the seam processing is that the stitching line is always on the path with the least texture difference, that is, the lowest energy. The edge after splicing is visually invisible, effectively eliminating the seam feeling caused by the fluctuation of spin speed and lens distortion.
[0047] Finally, energy-directed splicing is performed to construct the full surface map, such as... Figure 2 As shown, based on the spatial mapping relationship, the processed local texture defect signal matrix is projected onto the 30 mm radius spherical global coordinate system. Based on the spatial mapping relationship, the element values and their index coordinates (u, v) in the local texture defect signal matrix are converted from latitude to longitude. Based on the camera lens field of view parameters, the pixel row index v is converted into a spherical polar angle q (latitude direction). Based on the real-time phase feedback from the rotary table encoder, the pixel column index u is converted into a spherical azimuth angle. (In the longitude direction), a local texture map with consistent physical location information is constructed on a sphere with a radius r of 30 mm.
[0048] This invention constructs a virtual grayscale surface and combines it with frequency domain filtering. By utilizing the physical differences between low-frequency illumination and high-frequency reflection, it fundamentally eliminates strong light spots and water droplet noise on the surface of the monk fruit, effectively solving the problem of misjudging reflection as a defect in high-light environments. At the same time, it uses texture energy analysis to plan nonlinear stitching boundaries that avoid complex textures in overlapping areas, eliminating image ghosting and misalignment caused by alignment errors in traditional stitching. This creates a full-surface map of the monk fruit from all angles, free from illumination and water droplet noise, and seamlessly stitched together. This serves as a data source for subsequent machine vision defect recognition, significantly improving the system's stability and anti-interference capabilities in complex industrial environments.
[0049] Further, the step of constructing the texture representation domain includes: inputting the full surface map into a deep fully convolutional semantic segmentation model, performing pixel-level classification prediction to resolve the segmentation boundaries of the stem-shaped strange region, the effective skin region, and the background interference region; constructing a signal suppression mask based on the segmentation boundaries, and performing edge smoothing processing on the signal suppression mask to eliminate noise at the segmentation boundaries; performing a Hadamard product operation on the signal suppression mask and the full surface map to generate net texture data after mask filtering; and based on the net texture data, removing the signal responses of the stem-shaped strange region and the background interference region at the pixel level in a spherical global coordinate system, retaining the effective skin region with continuous texture distribution characteristics, and constructing the texture representation domain.
[0050] Specifically, the process of converting the full surface map into a texture representation domain includes: firstly, accurately extracting the effective peel region to be detected from the full surface map, and removing interference from the fruit stem and background noise at the pixel level to prevent the natural structure of non-defects from misleading the subsequent anomaly detection network; this process includes three core steps: semantic segmentation inference, mask construction, and signal response; in the deep semantic segmentation inference step, the input data is the full surface map generated in the previous steps. The full surface map is a grayscale single-channel image with a resolution set to a vertical height of 1024 pixels and a width of 2048 pixels; where the width of 2048 pixels corresponds to the spin unfolding direction of the organic monk fruit, and the vertical height of 1024 pixels corresponds to the axial direction of the imaging scan; the black invalid pixel regions filled in the full surface map refer to the areas without image signals caused by boundary completion of the projection algorithm or the irregular shape of the fruit during the process of unfolding the spherical projection into a plane, and the pixel values of the areas without image signals are uniformly filled with 0.
[0051] In this embodiment, as Figure 3 As shown, a deep fully convolutional neural network architecture is selected as the semantic segmentation model. The semantic segmentation model is pre-trained using full surface maps of samples. This training process involves manually classifying and labeling the pixels corresponding to the pixel plane coordinates in the full surface map of the samples, logically categorizing them by type, and assigning them color training labels. The training labels include three categories: 1) unusual fruit stem areas, referring to the calyx remnants at the top and bottom of the monk fruit, which have a rough surface texture and appear dark, and are confused with mold in grayscale, belonging to unusual structures that must be removed; 2) background interference areas, i.e., the black invalid pixel areas filled in the full surface map; and 3) effective peel areas, referring to the smooth peel surface that needs to be scanned for defects.
[0052] Specifically, the deep fully convolutional semantic segmentation model adopts the U-Net architecture, and this model performs well on the full surface map test set of *Siraitia grosvenorii*. The sensitivity of the effective skin area ( To avoid erroneously removing normal fruit peel, the inference time must be controlled within 50 milliseconds per frame; training is based on at least 1000 manually labeled sample images, and the category definitions include: the unusual fruit stem area is the calyx residue area, the effective peel area is the area to be scanned, and the background interference area is the image edge and filling area.
[0053] The U-Net architecture comprises symmetrical encoder and decoder paths: the encoder contains four repeating convolutional blocks, with the number of feature map channels doubling progressively from 64 to 512 with downsampling, and all convolutional kernels are uniformly 3x3. The system utilizes 2x2 max-pooling layers for feature compression and explicitly implements skip connections through channel concatenation. Each layer integrates batch normalization layers and the LeakyReLU activation function to ensure gradient stability. Training data is based on 1000 un-augmented, manually labeled original images. To address class imbalance caused by the extremely low pixel proportions of the stem region and background, a weighted cross-entropy loss function is introduced to dynamically increase the minority class weights. The final model achieves an average intersection-over-union (IoU) of at least 95% and an effective skin sensitivity of at least 98% on an independent test set (containing heterogeneous data with different camera parameters and under cold chain temperatures).
[0054] The deep semantic segmentation model is developed based on the U-Net architecture. It extracts high-dimensional features through the encoder and combines them with skip connections to restore spatial resolution in the decoder, ensuring the accuracy of segmentation boundaries. During training, the system constructs a base dataset based on 1000 manually labeled full-surface images and introduces data augmentation techniques, including rotation transformation, brightness jitter, and random blurring, to simulate light and shadow fluctuations and condensation interference caused by sorting lines in a 4-degree Celsius cold chain environment. To address the class imbalance problem caused by the extremely low pixel proportions of unusual areas such as the fruit stem, the effective skin area, and the background, the system uses a weighted cross-entropy loss function. It dynamically adjusts the learning weights based on the pixel frequency distribution of each class, artificially increasing the model's contribution to the loss of small, unusual structures such as calyx remnants, thereby guiding the network to accurately capture complex edge features. The model training uses the Adam optimization algorithm and strictly follows the early stopping convergence criterion: if the relative decrease of the mean squared error loss of the validation set is less than one-thousandth in ten consecutive training rounds, the deep semantic segmentation model is determined to have completed the fitting of the texture distribution pattern and the training is automatically terminated. This ensures that the deep semantic segmentation model has good generalization ability and effectively prevents overfitting when it reaches a high-performance benchmark with an average intersection-union ratio of not less than 95%.
[0055] In the mask construction stage, the semantic segmentation model outputs a pixel-level classification probability distribution map with the same size as the input image. The system uses maximum indexing to convert the matching degree of pixels in the channel dimension into corresponding color training labels, parsing the classification indices of the three regions and determining the segmentation boundary coordinates. Based on the segmentation boundaries, a binary signal suppression mask is constructed (effective skin regions are 1, and the rest are 0), and edge smoothing is performed on the signal suppression mask. Addressing the spatial sampling discretization of the pixel plane coordinates and the quantization error of the category decision logic (manifested as jagged segmentation boundaries and isolated noise), morphological opening operations are used for edge smoothing. A logic of erosion followed by dilation is used to remove small burrs from the mask edges and fill tiny holes, ensuring that the generated net texture data has edge continuity.
[0056] The quantization error process includes: during the full surface map construction process, continuous image data on the spherical surface is projected onto a rectangular pixel plane coordinate system with a height of 1024 pixels and a width of 2048 pixels. The continuous coordinate system is then mapped onto a finite number of pixel grid points. At the edge positions, since pixels are the smallest discrete units, the originally smooth fruit stem edges are fitted as pixel blocks. This causes the originally continuous fruit stem edge curves to be constrained by the discrete characteristics of the pixel array, resulting in spatial aliasing during the mapping process. This causes the segmentation boundary to exhibit a stepped, jagged quantization error at the microscopic scale; in the maximum value index operation... In the calculation, the semantic segmentation model outputs continuous probability values between 0 and 1. For example, the probability of a pixel being a nutshell is 0.51, and the probability of a nut stem is 0.49. After performing the maximum value index operation, the system will forcibly quantize this uncertain pixel into an integer "1" for nutshell or "0" for nut stem. Performing the maximum value index maps continuous probabilities to discrete category labels. This nonlinear mapping is prone to inducing classification oscillations in probability-sensitive areas (boundaries). Affected by the stability of the model's edge prediction, the quantization error generated by this process manifests as outlier isolated points or discontinuous burr textures at the edges of the binarized mask.
[0057] In the signal response stage, the signal suppression mask and the full surface map are subjected to a Hadamard product operation, i.e., pixel-by-pixel multiplication, to generate the net texture data after mask filtering. Based on the net texture data, the signal responses of the stem-like singular region and the background interference region are completely removed at the pixel level in the spherical global coordinate system, retaining the effective skin region with continuous texture distribution characteristics, thus constructing the texture representation domain.
[0058] This invention utilizes a deep fully convolutional semantic segmentation model to achieve pixel-level precise localization and isolation of unusual fruit stem regions and background interference in full-surface images. By constructing a signal suppression mask with smoothed edges and performing Hadamard product operations, the interference of fruit stem textures resembling mold on subsequent anomaly detection networks is completely blocked at the physical signal level, effectively reducing the false positive rate. More importantly, the smooth mask edges avoid step noise caused by hard cutting, preventing the introduction of frequency domain artifacts. The constructed high-purity texture representation domain significantly improves the data signal-to-noise ratio, providing net texture feature data for subsequent manifold learning, ensuring extremely high sensitivity for identifying hidden and minute defects, and accurate data transmission and processing even in multidimensional and complex environments.
[0059] Furthermore, the process of constructing the natural texture feature distribution manifold of monk fruit includes: performing spatial sliding window processing on the texture representation domain, extracting continuous local tensor blocks, and simultaneously marking the spatial position index of the local tensor blocks in the spherical global coordinate system; taking the texture pixel data within the local tensor blocks as input; taking the natural texture distribution features of the surface in the undamaged state in the training data of defect-free monk fruit samples as normal texture; taking the natural texture distribution feature pattern as the normal texture distribution pattern; and learning the low-dimensional distribution of the normal texture in the feature space through an autoencoder network to generate the natural texture feature distribution manifold.
[0060] The autoencoder network is constructed as a bottleneck feature extraction structure, designed to learn the intrinsic distribution of the texture of healthy monk fruit. The network comprises an input layer, three fully connected encoding layers, and a decoding layer. The number of neurons in the encoding layers is set to 1024, 512, and 128 respectively; the decoding layer progressively reconstructs the 128-dimensional latent representation. During training, mean squared error is used as the reconstruction loss function. By minimizing the difference between the input features and the reconstructed features, the network can accurately capture the feature patterns of normal epidermis, providing a stable health benchmark for subsequent residual vector calculation.
[0061] The autoencoder network employs a deep fully convolutional network architecture with a bottleneck structure. The encoder consists of three consecutive convolutional layers, with kernel sizes set to 3 pixels in height and 3 pixels in width in the image space dimension. The sampling stride is set to 2. After each convolutional layer, a non-zero partial derivative of LeakyReLU (Leaky ReLU) with a negative slope of 0.01 is applied. The non-zero partial derivative of LeakyReLU ensures the continuity of gradient information with minor defects during backpropagation, preventing neuron inactivation. The training process uses the Adam optimization algorithm, with an initial learning rate set to... The training sample criteria are as follows: Local tensor blocks with a width of 64 pixels and a height of 64 pixels are continuously segmented from a full surface map with a resolution of 1024 pixels axial height and 2048 pixels circumferential width, thereby learning the low-dimensional distribution manifold of normal epidermis in the feature space. The exponential decay rate of the first moment estimation is set to 0.9, the exponential decay rate of the second moment estimation is set to 0.999, and the regularization constant is set to 10 to the power of -8 to ensure numerical stability when processing high-entropy texture data. The training dataset consists of 1000 defect-free samples. Each full surface map is segmented using a spatial sliding window with a stride of 32 pixels, generating 1953 local tensor blocks per image, totaling approximately 19.5 million training samples to ensure sufficient coverage of the natural texture distribution manifold. The convergence criterion is early stopping: the model is considered convergent and training is terminated when the relative decrease in the mean squared error loss of the validation set is less than one-thousandth over ten consecutive training epochs. Furthermore, the mean squared error of the reconstruction error is less than 0.05, which is the result of calculation based on the original gray values being linearly normalized to the scalar range of 0 to 1. This metric quantifies the model's fitting accuracy to the intrinsic distribution of healthy epidermis. That is, under the normalization scale, the average deviation between the reconstructed pixels and the original pixels is strictly controlled at an extremely low level, providing an accurate physical benchmark for subsequently capturing small outlier defects through residual vectors.
[0062] Specifically, the process of performing spatial sliding window processing on the texture representation domain, extracting continuous local tensor blocks and simultaneously marking the spatial position index of the local tensor blocks in the spherical global coordinate system includes: performing spatial sliding window processing on the texture representation domain based on the sliding window algorithm, first setting the sliding window size and step size, and using a sliding window with a width of 64 pixels and a height of 64 pixels, with 32 pixels as the basic displacement unit in both the horizontal and vertical dimensions. Subsequently, discrete sampling steps are performed in the texture representation domain to extract local tensor blocks. Specifically, the sliding window is controlled to perform discrete coordinate index jumps (discrete sampling steps) within the texture representation domain, which has a resolution of 1024 pixels in height and 2048 pixels in width. This ensures that the local tensor blocks of adjacent frames have a 50% overlap in both the horizontal and vertical directions, avoiding edge feature truncation due to window segmentation and ensuring that pixels can be repeatedly observed and represented in multiple adjacent frames. When the sliding window moves to the target coordinate position, the system extracts the local tensor blocks within the coverage area of the single sliding window in real time. Each pixel grayscale value is used as the current local tensor block; while extracting the current local tensor block, the system simultaneously marks the spatial position index of the local tensor block in the spherical global coordinate system.
[0063] In the construction logic of the spatial location index, the system first establishes a spherical global coordinate system with the geometric center of the monk fruit sphere as the origin. ,in The coordinate system is based on a pre-defined physical radius derived from the average diameter of the monk fruit. This coordinate system serves as a global logical benchmark, aiming to map discrete local tensor block features from a two-dimensional planar image back to the three-dimensional physical surface of the monk fruit via latitude and longitude mapping. Specifically, the system utilizes a back projection algorithm to map the center pixel coordinates (x, y) of the local tensor block extracted by the sliding window to a numerical combination of the latitudinal polar angle and the spherical azimuth angle on the corresponding sphere, serving as the unique spatial location index bound to that tensor block. Subsequently, based on the linear mapping ratio between this spherical coordinate and a probability matrix with a resolution of 1024 pixels in height and 2048 pixels in width, the system accurately calculates the corresponding row and column index coordinates (u, v). Through this spatial anchoring mechanism, the system achieves precise coupling between texture feature attributes and physical spatial location, effectively eliminating geometric distortion interference during the projection unfolding process of the sphere surface. This not only provides a foundation for subsequent global mean fusion of defect probability values acquired from different perspectives under a unified physical alignment coordinate system but also ensures a seamless conversion of defect localization accuracy from the image pixel level to the fruit's physical coordinate system.
[0064] The sliding window moves within a rectangular pixel plane with a height of 1024 pixels and a width of 2048 pixels, using a local matrix with a width of 64 pixels and a height of 64 pixels. If the pixel coordinates of the top-left corner of the sliding window in the current sampling period are... Based on the aforementioned sampling step principle of 32 pixels per unit, the coordinates of the center pixel of the sliding window are determined. By using a back projection algorithm, the coordinates of the plane center are... The values mapped to the spherical global coordinate system respectively This process achieves precise coupling between texture feature attributes and physical spatial location. The autoencoder network is trained on 1000 defect-free monk fruit samples using unsupervised learning to extract the natural texture distribution features of the surface in its undamaged state. A local tensor block composed of 4096 pixels extracted by a sliding window is input into the autoencoder network, and nonlinear dimensionality reduction is performed by the encoder to compress it into a feature vector Z containing 128 components, realizing the transformation from the original visual signal to abstract texture semantics. Within these 128 spatial components, the spatial location index of the current local tensor block is provided by a back projection algorithm. A continuous probability density function R(Z) is fitted using the kernel density estimation method. This function constitutes a mathematical representation of the distribution manifold of natural texture features. Through the high and low distribution of the values, the legitimate intervals of texture fluctuation of healthy monk fruit in different physical regions are characterized. The connected regions with higher values of the probability density function R(Z) correspond to the distribution manifold of natural texture features.
[0065] Finally, the local defect probability values are backfilled to the corresponding positions in the probability matrix, and mean fusion is performed on repeated positions; specifically, the local defect probability values (floating-point numbers between 0.0 and 1.0) inferred from the current local tensor block are written into the corresponding cells of the probability matrix. Due to the use of a 50% spatial sliding window overlap strategy, specific row and column indices in the matrix will receive multiple backfill signals. The system performs this by checking the same position... The received probability values are averaged to achieve mean fusion. This operation not only ensures the continuity of the probability distribution of defects across the entire surface in terms of physical logic, but also effectively suppresses random inference noise caused by single sliding window edge truncation through redundant observations. This process establishes the correspondence between the local tensor block of the two-dimensional pixel domain and the three-dimensional spatial position of the physical surface of the monk fruit, realizing the precise logical coupling between texture feature attributes and their physical coordinates on the monk fruit.
[0066] This invention effectively addresses the industrial challenge of decoupling natural features and pathological defects on the surface of organic monk fruit by constructing a natural texture feature distribution manifold. Utilizing a spatial sliding window combined with a back projection algorithm, local image tensor blocks are spatially anchored to a spherical global coordinate system, ensuring precise coupling between texture attributes and physical location. This provides adaptive recognition capabilities for features from different parts such as the fruit stalk and waist. A nonlinear mapping is performed on defect-free samples using an autoencoder network, achieving purification from grayscale signals to abstract semantic features. Furthermore, kernel density estimation is combined to construct a probability density manifold reflecting the characteristics of healthy fruit within the feature space. This manifold establishes a "dynamic health standard" for the detection system. By calculating the distribution probability of the sample under test relative to the manifold under a specific spatial index, interference from natural features such as lenticels, stalk imprints, and natural pigmentation can be accurately eliminated, significantly reducing the false alarm rate of traditional thresholding algorithms in complex organic backgrounds. Meanwhile, the 50% sliding window overlap strategy effectively avoids the feature truncation effect and ensures the continuity of representation; while the unsupervised learning mode gets rid of the dependence on massive defect sample annotation, significantly improves the system's ability to capture subtle unknown defects, and lays a solid algorithmic foundation for seamless recognition and sorting of full surface images.
[0067] Further, the specific steps for calculating the residual vector between the feature vector and the feature vector include: encoding the texture pixel data of the local tensor block to be tested into a feature vector, mapping the feature vector to the natural texture feature distribution manifold, using manifold reconstruction decoding to obtain a reconstructed feature vector that conforms to the normal texture distribution law; performing a vector difference operation between the feature vector and the reconstructed feature vector to generate the residual vector.
[0068] Specifically, the process of generating the residual vector includes: In this embodiment, a local tensor block with a height and width of 64 pixels is obtained as the input data stream. By calling a pre-trained convolutional neural network encoder, multiple layers of convolution and nonlinear activation processing are performed on the 4096 grayscale pixel values within the local tensor block. After passing through a feature extraction layer containing 5 layers with increasing convolutional kernels, the texture distribution state in the original image space is mapped to a feature vector Z of fixed length 128 dimensions, completing the initial encoding conversion from the high-dimensional image domain to the low-dimensional semantic feature space. Z is mapped to the natural texture feature distribution manifold. By performing a manifold reconstruction decoding operation, Z is fed into a transposed convolutional network symmetrical to the encoder structure. The transposed convolutional network, based on the probability density constraint formed by the defect-free monk fruit samples in the latent space, searches for the legal feature point with the closest Euclidean distance to the current test vector in the manifold space. The decoder then generates a reconstructed feature vector that conforms to the normal texture distribution law based on the coordinate values of the legal feature point. The reconstructed feature vector, in a 128-dimensional vector space, represents the idealized natural texture features that the corresponding position should possess in a damage-free state. The process involves applying the feature vector Z to the reconstructed feature vector... The vector difference operation performs subtraction on the components at each corresponding position in two 128-dimensional vectors. Generate a residual vector consisting of 128 deviation values. The magnitude and direction of the residual vector accurately characterize the degree of outlier between the tested local tensor block and the normal monk fruit peel in terms of texture structure, color difference fluctuation and morphological features, transforming the complex visual contrast problem into a standardized vector deviation measurement process.
[0069] Manifold reconstruction decoding performs inverse mapping restoration using the Locally Linear Embedding (LLE) algorithm. Leveraging the algorithm's property of preserving linear reconstruction weights within local neighborhoods, the 128-dimensional feature vector is mapped to a 3D intrinsic manifold space. Nearest neighbor constraints are sought within the manifold of natural texture feature distribution, decoding to generate reconstructed feature vectors that conform to normal texture distribution patterns. The residual vector is composed of Euclidean distance offset (the vector difference between the feature vector and the reconstructed feature vector, quantifying the absolute degree of deviation of the original feature from the healthy baseline) and manifold deviation information (the probability density distribution score of the feature vector in the 3D low-dimensional space, reflecting the legitimacy of the sample in the manifold distribution). Anomaly detection employs a channel attention mechanism of compressed and activated SE form to perform feature recalibration. Response statistics are aggregated through global average pooling, and two fully connected layers are used to model inter-channel dependencies and generate 8 channel weighted coefficients. Specifically, the steps for generating eight weighted coefficients across the eight channels include: inputting the description vectors representing the response intensity of the eight virtual channels into the first fully connected layer for dimensionality reduction (compression ratio typically set to 2 or 4), using the ReLU activation function to guide the nonlinear interaction between channels, and establishing the potential dependencies between them. The dimensionality-reduced feature vectors are then input into the second fully connected layer for dimensionality upscaling, restoring the dimension to eight to achieve feature activation of the original channel space. Normalization mapping output: using the Sigmoid activation function to map the output of the second fully connected layer to the (0, 1) interval, generating eight scalars representing the importance of each virtual channel as weighted coefficients. These weighted coefficients are then compared with the residual vector. Broadcast multiplication is performed with 8 channels to adaptively increase the feature weights sensitive to manifold distribution and perform channel-wise feature recalibration on the residual vector. Finally, the weighted residual vector is input into a pixel-level classification decoding layer with an embedded Sigmoid activation layer. By calculating the probability projection of feature points on the defect classification boundary, logistic regression inference is performed to generate local defect probability values between 0 and 1, achieving accurate identification of minute defects.
[0070] The system utilizes a manifold reconstruction mechanism to capture minute variations deviating from a healthy baseline. The first step involves configuring the network architecture: the autoencoder includes an encoding layer (with 1024 to 512 to 128 nodes) and a corresponding decoding layer. The input consists of local tensor blocks, each 64 pixels wide. The second step applies the LeakyReLU activation function and parameters. The encoder uses the LeakyReLU activation function with a negative slope set to 0.01 to ensure effective transmission of gradient information from minute defects during backpropagation. The loss function uses mean squared error (MSE) combined with L2 regularization (coefficients...). The third step is residual anomaly determination: the feature vector Z is mapped to the natural texture feature distribution manifold and decoded to obtain the reconstructed feature vector. Perform difference operations to generate residuals. If the proportion of abnormal dimensions exceeds 15%, it is judged as a defective area.
[0071] The channel attention mechanism responds to 128-dimensional residual features. Execution operation. During the Squeeze operation, local spatial information is compressed into a 128-dimensional channel description vector through global information aggregation. Then, activation operations are performed, using two fully connected layers to activate the vector. The system performs nonlinear modeling of the inter-channel dependencies, generating a set of channel weighting coefficients containing 128 components. During the feature recalibration phase, the system uses these channel weighting coefficients as scalar gain factors and performs channel-wise multiplication with all spatial response values of the corresponding feature channels in the original residual vector to generate a weighted residual vector. This process adaptively increases the weights of feature channels that are sensitive to deviations from the natural texture feature distribution manifold, enhancing the system's sensitivity to identifying hidden defects.
[0072] The system utilizes feature recalibration technology to improve the discrimination performance of hidden defects: the first step is to perform global response statistics: the 128-dimensional residual vector Divided into 8 virtual channels (16 dimensions per channel), the global average of the absolute values of each channel is calculated. The value represents the response strength of the feature category to anomalies. Weight generation path: Compression and activation operations are performed through two fully connected layers, and an 8-channel weighted coefficient is generated using the Sigmoid activation function, with values ranging from (0,1). Feature recalibration application: The channel weighted coefficients are broadcast to the original residual vector. This mechanism adaptively amplifies the weights of sensitive characteristics such as mold growth while suppressing weak response noise generated by natural lenticels.
[0073] After obtaining the 128-dimensional feature vector, this embodiment does not directly perform density estimation in the high-dimensional space. Instead, it utilizes the nonlinear mapping relationship inherent in the natural texture feature distribution manifold to map the 128-dimensional feature vector to a low-dimensional embedding space of dimension d, where d is much smaller than 128 and is preferably two-dimensional or three-dimensional. The intrinsic coordinates (two-dimensional or three-dimensional coordinates) of the feature vector on the low-dimensional manifold are extracted using a manifold learning operator. Specifically, a local linear embedding algorithm is employed, which maps the 128-dimensional feature vector to the three-dimensional manifold space by maintaining the linear reconstruction weights of the local neighborhood. The spatial position index is then concatenated with the low-dimensional intrinsic coordinates. Subsequently, kernel density estimation is applied to fit the probability density function R(Z) within the low-dimensional embedding space. Due to the extreme compression of the spatial dimension (reducing it from 128 dimensions to d dimensions), the sample sparsity problem in the high-dimensional space is effectively alleviated, ensuring that the kernel function can capture the distribution pattern of normal texture within a reasonable neighborhood. This allows the calculated probability density score to truly and accurately reflect the degree of deviation of the tested sample from the healthy baseline manifold. For kernel density estimation in the 3D embedding space, the system abandons the fixed Scott rule and instead adopts an adaptive bandwidth selection and cross-validation mechanism. By dynamically adjusting the kernel function bandwidth according to the local data density, it ensures that a robust probability density score can still be obtained under the statistical boundary of 1000 samples, accurately reflecting the degree of deviation of the tested texture from the healthy benchmark.
[0074] This invention, through the introduction of manifold reconstruction and residual vector computing mechanisms, effectively utilizes the statistical characteristics of normal monk fruit samples to constrain the detection benchmark. This enables the system to automatically ignore the differences in peel color caused by the natural growth environment, while maintaining extremely high sensitivity to abnormal texture mutations caused by insect infestation, mold, or mechanical collisions. This significantly enhances the online identification accuracy and system stability of minute defects on the surface of organic monk fruit.
[0075] Furthermore, the residual vector is composed of feature dimensions of different texture attributes, including Euclidean distance offset and manifold deviation information. The residual vector is input into a deep neural network, and the embedded channel attention mechanism is used to identify and analyze the manifold deviation sensitivity of the feature response channels, extract the global response statistics of the feature response channels, generate channel weighting coefficients, and perform feature recalibration on the residual vector to obtain the defect feature channel response and reconstruct the weighted residual vector. The weighted residual vector is input into the pixel-level classification decoding layer of the deep neural network to infer and generate the local defect probability value of the local tensor block anomaly degree. The spatial location index is called to map the local defect probability value corresponding to the local tensor block back to the corresponding position in the spherical global coordinate system. Through spatial splicing and recombination, the defect probability map is generated.
[0076] Specifically, the process of generating a defect probability map from the residual vector includes: acquiring a residual vector consisting of 128 dimensions as an input signal, wherein specific component sequences in the residual vector represent Euclidean distance offset and manifold deviation information, respectively; the system performs nonlinear fusion of these components through an attention mechanism, enabling the subsequent deep neural network to simultaneously capture abnormal perturbations on the surface of organic monk fruit from both the magnitude and distribution morphology dimensions. The residual vector is input into the attention analysis module of the deep neural network, and the embedded channel attention mechanism is used to automatically identify and analyze the manifold deviation sensitivity of the 128 feature response channels. The global response statistics of the feature response channels are extracted through global average pooling, and a set of channel weighting coefficients with values ranging from 0 to 1 are generated through nonlinear mapping of two fully connected layers, logically identifying the contribution of the feature channels to distinguishing between natural lenticels and diseased mold spots. The generated channel weighting coefficients are used to perform element-wise multiplication of the original residual vector for feature recalibration. By enhancing the gain of high-sensitivity channels and suppressing interference from noise channels, feature channel responses that significantly highlight defect semantics are obtained. Finally, a weighted residual vector is reconstructed, which has stronger discriminative performance in the feature space and can linearly amplify the originally weak tissue damage features in 128-dimensional space. The weighted residual vector is input into the pixel-level classification decoding layer of the deep neural network. This decoding layer adopts a logistic regression structure with a sigmoid activation function to perform deep inference on the input feature vector. By calculating the probability projection of feature points on the defect classification boundary, a local defect probability value representing the degree of anomaly in the central region of the local tensor block is generated. This value is represented in 32-bit floating-point form and its range is precisely limited to 0.0 to 1.0.
[0077] In this embodiment, the spatial location index bound to the local tensor block is invoked in real time to map the calculated local defect probability value back to the corresponding latitude and longitude coordinates of the spherical global coordinate system. A probability matrix with a width of 1024 pixels and a height of 2048 pixels, proportional to the original texture map, is dynamically maintained in memory using a preset spatial stitching and recombination algorithm. Mean fusion processing of overlapping regions is used to generate the defect probability map reflecting the overall surface quality of the fruit. Specifically, the execution logic of the spatial stitching and recombination algorithm is as follows: the probability value of the center point of the local tensor block is backfilled into the corresponding row and column indices of the probability matrix using the spatial location index; for overlapping regions generated by the 50% sampling step, the system uses mean fusion processing to accumulate and take the arithmetic mean of multiple local defect probability values falling on the same spherical coordinate point. This process not only eliminates stitching seams but also effectively suppresses inference noise through redundant observations, generating the defect probability map reflecting the overall surface quality of the fruit. In this embodiment, the deep neural network adopts a residual attention network architecture with an embedded channel attention module. Specifically, the network includes: an input layer that receives a 128-dimensional weighted residual vector. The feature extraction layer comprises three consecutive feature extraction structures, each consisting of fully connected operations, max-min normalization, and ReLU activation functions. The number of neurons is set to 256, 512, and 1024, respectively, to progressively map the low-dimensional residual signal to the high-dimensional semantic space. Skip connections are introduced between the feature extraction layers to construct a residual learning mechanism. Following the feature extraction layers is a channel attention module. This module extracts global response statistics for 1024 feature channels using global average pooling and employs two fully connected layers with a reduction ratio of 16 to perform nonlinear modeling of the correlation between channels, generating channel weighting coefficients of dimension 1024 to recalibrate features sensitive to manifold deviations. To achieve accurate mapping from feature space to physical space, the recalibrated 1024-dimensional high-level feature vector is transformed into a 3D feature tensor with a width of 16 pixels, a height of 16 pixels, and 4 channels through linear mapping and reshaping operations, thus constructing the initial spatial topology. Finally, the pixel-level classification decoding layer performs spatial upsampling through two layers of transposed convolutions with a stride of 2, restoring the spatial resolution of the feature map from a width of 16 pixels and a height of 16 pixels to a width of 64 pixels and a height of 64 pixels. The Sigmoid activation function is used to perform pixel-wise probabilistic regression, outputting the local defect probability value of pixels in the 64-pixel-wide and 64-pixel-high region belonging to the defect class, with its value strictly limited to the range [0.0, 1.0].
[0078] In this embodiment, the system first reserves a space in memory with a height of 1024 pixels and a width of 2048 pixels to form a probability matrix (at this time, all values are 0). The probability matrix serves as the logical mapping carrier of the defect probability map in memory, used to receive probability values from the backfilling of each sliding window in real time, and to perform accumulation and mean calculation. Each time a sliding window calculates a local defect probability value, it finds the corresponding slot in the matrix, i.e., the row and column index, through the spatial location index and fills in the value. Because the sliding windows overlap, some slots in the matrix will be filled multiple times. The system performs the summation and division by the number of times to perform the mean fusion calculation within the matrix. When all sliding windows have been filled with values and the mean processing has been completed, the values of the probability matrix constitute the defect probability map. The visualization after mean fusion processing generates the defect probability map. The backfilling process refers to dynamically writing the discrete local defect probability values into the storage unit corresponding to the probability matrix according to the spatial location index. After the full surface scan is completed, the global numerical distribution of the probability matrix after mean fusion processing constitutes the defect probability map.
[0079] This invention effectively enhances the algorithm's resistance to interference from complex backgrounds on the surface of monk fruit by integrating channel attention mechanism and manifold analysis technology. It solves the problem of missed detection caused by large individual differences in organic agricultural products by using feature recalibration technology. By accurately associating probability values with spatial location indices, it achieves a seamless conversion of defect localization accuracy from image pixel level to fruit physical coordinate system, providing a reliable decision basis for the backend robotic arm to perform precise removal tasks.
[0080] This invention achieves significant technical improvements in actual cold chain sorting environments, with specific quantitative indicators as follows: Light interference resistance: Under strong specular reflection interference, the signal-to-noise ratio is improved from 5dB in the traditional method to 18dB, and the false positive rate for condensation droplets is significantly reduced from 42% to 3.2%; Detection accuracy and generalization: For unseen defect morphologies, the detection rate is improved from 42% in the traditional method to 78%. The comprehensive classification accuracy for four common defect types reaches 92%; System execution efficiency: The end-to-end processing latency for a single fruit is reduced from 120ms to 85ms, and the system throughput is increased by approximately 29%, meeting the real-time requirements of a high-speed sorting line processing 11.8 fruits per second.
[0081] Further, the step of constructing heterogeneous feature vectors includes: calculating a probability distribution histogram for the defect probability map, solving for a segmentation threshold using the maximum inter-class variance method, and segmenting the boundary between background noise and defect signals; performing binarization processing based on the segmentation threshold to generate a binarized mask, and performing connected component labeling and area filtering to filter out discrete noise points within the mask and extract abnormal regions; calculating the geometric area, Euler number, compactness, and eccentricity of the abnormal regions to generate a topological feature vector; using a gradient operator to calculate the pixel change rate of the abnormal regions, statistically analyzing the gradient magnitude and direction to generate a texture gradient feature vector; and performing the fusion of the topological feature vector and the texture gradient feature vector to construct a heterogeneous feature vector.
[0082] Specifically, the process of constructing heterogeneous feature vectors based on the defect probability map includes: after obtaining the defect probability map, extracting the probability score distribution features of the internal pixels and constructing a corresponding probability distribution histogram; using the maximum inter-class variance method to traverse the probability distribution histogram for optimization, calculating the optimal segmentation threshold T that maximizes the variance between the background class pixel set representing healthy cortex and the defect class pixel set representing abnormal targets. The background class corresponds to the pixel set of low-score signal regions in the defect probability map, used to characterize healthy peel regions with minimal reconstruction residuals and conforming to the distribution manifold of natural texture features; the defect class corresponds to the pixel set of high-score signal regions in the defect probability map, used to characterize surface damaged regions that produce highly significant signal responses in the probability map due to deviation from the distribution manifold of natural texture features. The probability score corresponding to the low-score signal region approaches 0, while the probability score corresponding to the high-score signal region approaches 1. The system performs binarization processing on the defect probability map based on the optimal segmentation threshold T: pixels with a probability score greater than or equal to T are identified as target signals, and pixels with a probability score less than T are identified as background noise, generating an initial binarized mask. This process achieves accurate localization from continuous probability scores to discrete binary logic. To eliminate random interference from the imaging environment, the system performs connected component labeling on the binarized mask, identifying spatially adjacent pixels with a logic value of "1" as independent geometric regions. For each independent connected geometric region, the total number of pixels is calculated by accumulating the number of pixels contained within it; this total number of pixels represents the spatial scale of the connected geometric region in the pixel coordinate system. The extracted total number of pixels is then compared with a preset area threshold (20 pixels). Connected regions with a total number of pixels less than the preset area threshold are identified as discrete noise generated by imaging noise and removed. Regions with a total number of pixels greater than or equal to the preset area threshold are identified as abnormal regions. This binarization process purifies the noise interference signal into a true physical defect target. The preset area threshold is typically set to 10 to 50 pixels in an image with a resolution of 1024 pixels in height and 2048 pixels in width. The logic behind this value setting is to filter out non-connected signals with an area smaller than the threshold and eliminate pseudo-defect interference that does not possess physical pathological characteristics.
[0083] For the anomalous region, the process of extracting spatial morphological features and constructing a topological feature vector using analytical geometric algorithms includes: counting the total number of pixels within the anomalous region as the geometric area value; calculating the difference between the number of connected components and the number of holes within the region as the Euler number, representing the topological complexity of the defect; using the ratio of the perimeter to the area of the anomalous region as the compactness, measuring the roundness or dispersion of the defect shape; fitting an equivalent ellipse with the same second moment as the anomalous region and calculating the ratio of the major and minor axes as the eccentricity, measuring the stretchability of the defect in spatial distribution; the parameters obtained above are encapsulated into the topological feature vector after max-min normalization processing to describe the macroscopic geometric structure of the defect; while extracting the topological features, the local tensor block corresponding to the anomalous region in the full surface map is located, and the Sobel gradient operator is used to solve the pixel-level texture features. The system obtains the brightness change rate of the pixel in the horizontal and vertical directions, i.e., the horizontal derivative and the vertical partial derivative, through spatial convolution operation, and integrates them into a gradient vector representing the local intensity change trend. To eliminate polarity interference from changing directions and enhance feature recognition, the system performs energy aggregation on bidirectional guides, using the vector length in Euclidean space as the gradient magnitude of the pixel to quantify the intensity of local brightness fluctuations. Simultaneously, the gradient direction is determined by the ratio of vertical to horizontal changes, achieving a conversion from Cartesian coordinates to polar coordinates and accurately pinpointing the geometric orientation of the pixel with the most dramatic changes.
[0084] To further characterize the microscopic directionality and roughness within defects, the system discretizes and quantizes the gradient directions within abnormal regions and statistically calculates the cumulative contribution of amplitudes within each directional interval, ultimately constructing a gradient direction histogram. The statistical distribution of this histogram effectively distinguishes between physical damage and natural disturbances: for cracks and lesions with physical depth or tissue damage, the gradient amplitude exhibits dramatic and concentrated directional fluctuations, producing highly significant peaks in specific intervals of the histogram; while for natural shadows or background noise with smooth brightness transitions, the gradient amplitude is lower and the directional distribution tends to be randomly diffused. This is achieved by linearly fusing the normalized topological feature vector with the texture gradient feature vector.
[0085] Finally, the system performs feature-level fusion, linearly concatenating the extracted topological feature vector (composed of geometric area, Euler number, compactness, and eccentricity) with the texture gradient feature vector (composed of the gradient direction histogram data) to construct a heterogeneous feature vector. This heterogeneous feature vector simultaneously encompasses both macroscopic spatial topological information and microscopic local texture distribution information of defects within a unified feature space, providing multi-dimensional discriminative evidence for subsequent accurate defect classification based on the nearest neighbor principle.
[0086] Furthermore, the process of identifying and grading surface defects in organic monk fruit includes: constructing a classification feature space based on the feature dimensions of the heterogeneous feature vectors; statistically analyzing the category mean vector of known defect samples in the classification feature space as a category reference vector; mapping the heterogeneous feature vectors to be tested onto the classification feature space; calculating the Euclidean distance between the target vector and the category reference vector; sorting the Euclidean distances in ascending order according to the nearest neighbor principle; selecting the category corresponding to the category reference vector at the top of the sorted sequence as the defect category label of the abnormal region; extracting the geometric area value as the damaged physical quantity; constructing a comprehensive grading logic matrix containing the defect category dimension and the damaged physical quantity dimension; inputting the defect category label and the damaged physical quantity as indices into the comprehensive grading logic matrix; and outputting a grade instruction through the index mapping of the comprehensive grading logic matrix to complete the identification and grading of surface defects in organic monk fruit.
[0087] In the classification feature space, to overcome the problem of weakened discriminative power of Euclidean distance in high-dimensional space, the system adopts a multi-metric fusion method. In addition to calculating the Euclidean distance between the test vector and the reference vector, Mahalanobis distance is also introduced to comprehensively consider the correlation and distribution weight differences between features of different dimensions (topological features and texture gradient features), thereby improving the accuracy of defect identification.
[0088] In this embodiment, when performing defect identification and classification, the system employs a hierarchical filtering and classification strategy with a rejection mechanism to ensure compatibility with unknown defects. The first level is anomaly detection: based on the residual vector obtained from the aforementioned unsupervised manifold reconstruction and the probability density score, it determines whether the region to be tested deviates from the healthy texture benchmark. If the magnitude of the residual vector exceeds a preset healthy deviation threshold... If the physical defects are initially identified, a corresponding heterogeneous feature vector is generated. The second level is attribute classification and rejection: the heterogeneous feature vector is mapped to a classification feature space configured with category reference vectors, and the Euclidean distance between it and the reference vectors of each known defect category is calculated. The system further introduces an unknown type determination threshold. If the minimum Euclidean distance Then, based on the nearest neighbor principle, the category corresponding to the category reference vector that ranks first in the sorting sequence is selected as the defect category label for that region; if If the defective sample deviates from the healthy manifold, it indicates that it does not belong to any known baseline category in the classification space. In this case, the system will classify it as an unknown and scarce defect type and assign a specific label. Finally, the geometric area value is extracted as the damaged physical quantity, and a comprehensive hierarchical logic matrix containing both defect category and damaged physical quantity dimensions is constructed. The obtained defect category labels (including known category and unknown type labels) and damaged physical quantities are used as indices to input the comprehensive hierarchical logic matrix, and the final level instruction is output through logical mapping. This logic ensures that the system can still provide reasonable early warnings and hierarchical handling schemes when facing anomalies that have not been trained, rather than generating incorrect forced classifications.
[0089] Specifically, the process of constructing a classification feature space based on heterogeneous feature vectors, calculating Euclidean distance, constructing a comprehensive hierarchical logic matrix in conjunction with damaged physical quantities, and outputting a defect level judgment instruction through index mapping of this matrix to complete the surface defect identification of organic monk fruit includes: the construction of the classification feature space and the establishment of category benchmarks. In this embodiment, the system first constructs a high-dimensional classification feature space based on the dimensions of the aforementioned heterogeneous feature vectors (including topological feature dimension and texture gradient feature dimension). In the preprocessing stage, by statistically analyzing a large number of labeled monk fruit defect samples (such as mold, cracks, insect infestation, mechanical damage, etc.), the first moment of each type of defect in the classification feature space is calculated, i.e., the category mean vector. This category mean vector serves as the category benchmark vector for this type of defect and is stored in the system's prior knowledge base to provide a comparison reference for subsequent qualitative identification. In the process of constructing the classification feature space, the system quantifies and calculates the category mean vector of each type of defect through the following steps: normalization preprocessing of the sample feature set; firstly, it retrieves n labeled samples of the same type of defect (e.g., n mold defect samples) from the prior knowledge base to obtain the heterogeneous feature vectors corresponding to the samples. Since there are significant differences between topological features (such as the total number of pixels) and texture gradient features, the system first performs max-min normalization on each component to map it to a uniform numerical range (such as [0,1]). The objective principle of this step is to eliminate the influence of dimensions and ensure that each feature has an equal contribution weight in the subsequent spatial distance calculation, so as to avoid the identification role of features with larger values (such as area) being masked by features with smaller values (such as Euler number).
[0090] The heterogeneous feature vector is constructed by linearly cascading geometric topological descriptors and texture gradient descriptors, aiming to simultaneously encompass the macroscopic spatial topological structure and microscopic local texture orientation of defects. In the topological descriptor extraction stage, the system quantifies the macroscopic morphology of the abnormal region based on analytical geometry algorithms: first, the geometric area is obtained by counting the total number of pixels contained within the abnormal region; second, the algebraic difference between the number of connected components and the number of holes within the abnormal region is calculated as the Euler number to quantitatively characterize the connectivity complexity of the defect's topological structure; subsequently, the compactness is calculated using the ratio of the square of the perimeter of the abnormal region to its area, thereby measuring the degree of fragmentation or roundness of the defect edges; simultaneously, the eccentricity is obtained by calculating the ratio of the major axis to the minor axis of the equivalent ellipse, characterizing the stretching characteristics of the defect in physical space.
[0091] Simultaneously, the texture gradient descriptor enhances feature discriminativeness by statistically quantifying the microscopic details of the abnormal region. During the texture feature calculation stage, the system applies directional gradient histogram statistical logic to perform microscopic texture modeling on the abnormal region based on the pixel-level gradient vectors obtained through spatial convolution. Specifically, the system maps the gradient vectors from a Cartesian coordinate system to a polar coordinate space, discretizing and projecting the continuously distributed gradient directions into 12 equally divided directional intervals. Subsequently, using the gradient magnitude represented by the vector length in Euclidean space as a statistical weight, the system accumulates and calculates the magnitude energy distribution within each directional interval, constructing a directional gradient histogram that accurately characterizes the directionality and roughness of the defect's microscopic texture. This descriptor effectively captures the directional and roughness features of the texture within the defect. Finally, the system performs linear concatenation of the vector dimensions of the descriptor, which covers both the macroscopic geometric topology and the directionality of the microscopic texture, to construct a heterogeneous feature vector with multidimensional discriminative evidence. This scheme, through deep fusion of heterogeneous features, provides comprehensive data support for subsequent accurate defect category determination in the classification feature space.
[0092] The category mean vector generation assumes that the heterogeneous feature vector contains *s* feature dimensions (e.g., the first dimension is area, the second dimension is Euler number, and so on, the *s*th dimension is gradient magnitude in a specific direction). For all *n* sample vectors under this category, the system calculates the arithmetic mean for each dimension. The system then arranges the calculated *s* arithmetic means according to the original dimensional order and combines them to generate the final category mean vector. The calculated category mean vector is stored in the system as the category benchmark vector for this type of defect, providing a corresponding comparison benchmark for subsequent Euclidean distance calculation and nearest neighbor discrimination of the test vectors.
[0093] Based on Euclidean distance-based nearest neighbor classification and recognition, in the real-time detection stage, the currently generated heterogeneous feature vector to be tested is mapped to the classification feature space. Specifically, the system performs logical mapping and attribute determination of the heterogeneous feature vector to be tested to the classification feature space. First, the system retrieves the test vector jointly generated by the topological descriptor and the texture gradient descriptor. Given that the components within the vector, such as geometric area and gradient magnitude, have significant differences in dimensions and numerical magnitudes, the system performs max-min normalization processing on each dimension component of the test vector according to the preset feature weights and distribution intervals, mapping it to a unified numerical magnitude space. Subsequently, the system projects the standardized test vector to the classification feature space defined by the feature dimensions, ensuring that its spatial coordinate system is physically aligned with the reference vectors of each defect category stored in the space. Within this unified feature space, the system calculates the Euclidean distance between the test vector and the category benchmark vector using a metric algorithm to quantify the similarity between the test sample and various standard defects. Based on the nearest neighbor principle, the system sorts all calculated Euclidean distances in ascending order, selecting the defect category corresponding to the smallest Euclidean distance (i.e., the one at the top of the sort sequence). It then determines the attribute of the abnormal region and outputs the corresponding defect category label (e.g., mold or mechanical scratch). This process achieves a precise mapping from multi-dimensional feature extraction to discrete logical labels. Simultaneously with defect characterization, geometric area values are extracted from the aforementioned topological feature vectors as a physical quantity to measure the degree of fruit damage. To achieve intelligent grading, a comprehensive grading logic matrix is pre-constructed, which includes both defect category and physical quantity value dimensions in its logical dimension. The system inputs the defect category label and the physical quantity as a two-dimensional index into the comprehensive grading logic matrix. Through the mapping logic within the matrix, the system automatically matches the quality level corresponding to the index and outputs grade instructions such as premium, first-grade, second-grade, or defective / rejected.
[0094] Specifically, for different defect categories, the comprehensive hierarchical logic matrix pre-sets a quantitative area determination criterion: if the defect category label is mold or insect infestation, when the damaged physical quantity (geometric area value) is... When the pixel is in the range, output a "defective rejection" command; when... When the pixel is specified, output a "Level 2" instruction. If the defect category label is "Mechanical Damage" or "Crack", when... When the pixel is displayed, output the "secondary" instruction; when... When the pixel is in the range, output the "Level 1" instruction; when... When the pixel value is reached, the "Special Grade" instruction is output. This matrix achieves scientific sorting of monk fruit by applying a zero-tolerance standard to irreversible diseases (such as mold) and a flexible tolerance standard to physical damage. (Comprehensive Grading Logic Matrix) Defined as The matrix, where Defect categories (such as mold, insect infestation, mechanical damage, cracks). The number of quantification levels for damaged area is typically 4, and the matrix elements are... Mapping to the final product level, the initial matrix is constructed based on 100 labeled samples and includes a dynamic expansion mechanism. When a new type of defect is encountered, the system records its heterogeneous feature vectors. After accumulating 10 to 20 samples, the matrix is updated, automatically adding new row vectors. The row index represents the defect category. For example, when =1 corresponds to mold. =2 corresponds to the crack type, and so on. Each defect category label corresponds to a matrix index. This matrix index is derived from the defect category labels identified by the system. The column index represents the quantification level of the damaged area. It is usually divided into 4 quantification levels, representing the range of the damaged physical quantity, such as the geometric area value.
[0095] The comprehensive hierarchical logical matrix has an incremental update mechanism. When a heterogeneous feature vector to be tested is mapped to the classification feature space, and its minimum Euclidean distance with all known category centroids (reference vectors) exceeds a preset deviation threshold, the system classifies it as an unknown type. When the number of such unknown samples accumulates to a certain threshold (e.g., 20), the system triggers the K-means clustering algorithm to recalculate the feature space distribution and uses the newly formed cluster centroids as the reference vectors for the new categories, dynamically adding category row vectors to the matrix. When handling decision conflicts, the system enforces a biosafety priority strategy, ensuring that the judgment priority of high-risk defects (such as mold) is always higher than that of general physical damage, making the sorting results stricter than food safety standards.
[0096] This invention effectively solves the detection challenge of strong reflectivity and condensation interference on the surface of organic monk fruit in high-altitude cold chain environments by constructing a physical optical surface model and a recognition closed loop based on heterogeneous feature manifolds. First, by utilizing virtual height field mapping and Gaussian curvature calculation, low-frequency illumination spots and high-frequency reflection noise are accurately separated at the topological level, achieving high signal-to-noise ratio purification of texture defect signals. Second, a manifold reconstruction and residual vector computation mechanism based on an autoencoder is introduced, combined with a channel attention mechanism to recalibrate and nonlinearly fuse residual features, solving the problem of false detection caused by individual growth differences in organic agricultural products. A spatially sensitive dynamic health standard is constructed. Finally, by fusing macroscopic topological geometric features and microscopic texture gradient information to construct heterogeneous feature vectors, and using the nearest neighbor principle in the classification feature space to achieve defect characterization, combined with a comprehensive hierarchical logic matrix, the damaged physical quantity is accurately converted into hierarchical decision instructions. The entire process achieves seamless mapping and logical reorganization from original visual pixels to physical coordinates, enhancing the anti-interference capability and robustness of the detection system in complex industrial environments, providing reliable technical support for intelligent and precise quality inspection of organic agricultural products.
[0097] Example 2: This embodiment, based on the system architecture described in Embodiment 1, further describes the specific implementation of the deep processing algorithm and logical judgment mechanism involved in the grading process. For parts not described in detail in this embodiment, please refer to the relevant content in Embodiment 1. In this embodiment, in the cold chain intelligent sorting line of high-altitude organic monk fruit production areas, this variety has two significant visual detection challenges: First, the epidermal cuticle is extremely thick and secretes natural fruit wax. Under the 4-degree Celsius cold chain transportation environment, the fruit surface not only exhibits strong specular highlights but also has micron-sized condensation droplets, generating complex mixed optical noise; Second, the characteristics of organic cultivation make "needle-tip insect damage" and "early filamentous mold" extremely concealed, and their morphology is random and unpredictable. Traditional visual systems based on grayscale thresholds and simple sample template matching struggle to distinguish between water droplet reflections and real defects in this scenario, resulting in a very high misjudgment rate. Embodiment 2 fully describes the positive and negative physical meanings of curvature. Building upon Embodiment 1's use of discrete differential operators to obtain second-order partial derivatives, Embodiment 2 further constructs a Hessian matrix capable of describing the local undulations of the surface. The system distinguishes between bright convexities and concave edges from a physical dimension by solving two core eigenvalues of the matrix, performing illumination spot recognition logic: illumination spots appear as smooth, isotropic convexities on a virtual curved surface. When both eigenvalues are negative, representing local maxima with a ratio close to 1:1, the system determines that the region possesses strong directional consistency, classifying it as a pseudo-defect spot formed by fruit wax reflection, and performs signal suppression. Then, it performs substantive defect extraction logic: pinpoint insect damage or early mold exhibits asymmetrical, peculiar characteristics. At this point, the absolute values of the eigenvalues differ significantly (representing dramatic changes in the degree of curvature in different directions) or have opposite signs. Based on this, the system captures hidden physical damage signals, achieving physical separation of defects from background noise.
[0098] The second step introduces directional gradient denoising using the structure tensor. To further eliminate high-frequency point noise caused by condensation droplets, the system simultaneously uses multi-order differential operators to solve the local structure tensor and analyze the directional gradient distribution of the local texture. First, isotropic suppression is performed: for regions that meet the curvature threshold, the system calculates the eigenvalue ratio. If the ratio is close to 1 (representing that the gradient change at that point is equal in all directions), and the average gray value of the original pixel is higher than the preset illumination benchmark, it is determined to be a light spot or symmetrical water droplet reflection, and smoothing repair is performed. Then, directional feature preservation is performed: if a local area exhibits obvious anisotropy and the eigenvalue ratio is much greater than 1, it indicates that the texture has a specific extension growth direction, such as cracks or filamentous mold. The system retains this signal and extracts its topological features.
[0099] This second embodiment accurately removes interference from strong light spots and condensation droplets through topological morphology verification and directional gradient denoising, solving the problem of decoupling minor defects in organic monk fruit under complex cold chain environments, significantly reducing the misjudgment rate and improving sorting stability. In this embodiment, the specific construction and mapping rules of the comprehensive grading logic matrix in the grading process are further elaborated. To achieve scientific sorting of organic monk fruit quality, the system extracts the geometric area values of abnormal regions as damaged physical quantities and constructs a two-dimensional discrimination matrix containing defect category dimensions and damaged physical quantity dimensions. The specific implementation is as follows: the comprehensive grading logic matrix is constructed and mapped according to the following rules: the matrix is based on the defect category dimension and the damaged physical quantity dimension, where the defect category dimension is quantified by preset risk weight values, specifically divided into: mold (weight 2.5) as category index 1, cracks (weight 1.8) as category index 2, insect infestation (weight 1.5) as category index 3, and mechanical damage (weight 1.0) as category index 4. The physical quantity of damage is divided into four levels based on the projected area of the defect, each with an index: a projected area less than 2 square millimeters is considered minor damage (index 1); 2 to 10 square millimeters is minor damage (index 2); 10 to 30 square millimeters is moderate damage (index 3); and greater than 30 square millimeters is severe damage (index 4). In the judgment logic, the system uses the product of the identified category weight and the area interval index as the judgment score. The comprehensive grading logic matrix automatically indexes and outputs the final handling instruction level based on the score range: specifically, when the judgment score is greater than or equal to 5, the instruction level output is rejection; when the judgment score is between 2 and 5, the instruction level output is second-class; and when the judgment score is less than 2, the instruction level output is top-class.
[0100] The comprehensive classification logic matrix is built based on 2000 samples labeled by professionals according to industry standards. The system quantitatively optimizes risk weights through logistic regression. In this embodiment, leave-one-out verification is used to search all weight combinations, aiming to maximize the weighted average of classification accuracy, sensitivity, and specificity. The final weights are determined as follows: mold 2.5 (absolutely unacceptable, extremely high risk of infection), cracks 1.8 (affecting appearance and storage), insect infestation 1.5 (food safety hazard), and mechanical damage 1.0 (visual defect but does not affect safety). The classification thresholds are optimized using the working characteristic curve, setting values greater than or equal to 5 for rejection, 2 to 5 for level two, and less than 2 for special level. The dynamic update mechanism is set so that when the test vector deviates from the existing benchmark by more than three standard deviations, it is judged as a new type. After accumulating 20 samples, a new category is added using the K-means clustering algorithm, and the classification accuracy is verified to decrease by no more than 2% to ensure stability. For cases with multiple defects, the "worst defect first" principle is strictly followed, and the final risk weight of the fruit is set as the maximum value of the weights of all detected defect types, rather than taking the average.
[0101] Based on the above logical mapping, for moldy defects with infectious risks, since their base weight is set at 2.5, even if the damaged area is in the smallest micro-damage range (index one), its judgment score will be forcibly corrected to be greater than or equal to 5 in the logical judgment. This correction logic ensures that all moldy fruits can be stably marked as rejected fruits, completely eliminating food safety risks. In contrast, for mechanical damage defects, since their base weight is lower, downgrading or rejection instructions are only triggered when the damaged area enters the upper limit of the severe or moderate range. This matrix mapping mechanism based on the coupling of physical quantification values and risk weights abandons the limitations of traditional single area threshold judgment. By transforming features of different dimensions into a unified judgment score, the sorting system can optimize the yield of healthy organic monk fruit while strictly adhering to food safety standards (such as for mold), achieving a balance between economic benefits and product quality.
[0102] The autoencoder network described in this invention employs a bottleneck feature extraction structure composed of convolutional layers and fully connected layers connected in series, aiming to learn the intrinsic manifold distribution of the texture of healthy monk fruit. This embodiment, based on the network architecture described in Embodiment 1, further refines the engineering implementation details and performance benchmarks of model training: First, it enhances data preprocessing: before inputting local tensor blocks into the encoder, the system performs a linear normalization operation, mapping the original grayscale values to a scalar range of zero to one, thereby improving the convergence stability of the model in the early stages of training. Second, it implements a convergence control mechanism: during model training, in addition to executing the optimization algorithm described in Embodiment 1, this Embodiment 2 introduces an early stopping convergence criterion. Specifically, it monitors the mean squared error loss of the validation set in real time. If this loss value does not decrease significantly for ten consecutive training epochs, the model is determined to have entered a convergence saturation state, automatically terminating training and saving the optimal weight values. Using the above training strategy and the 128-dimensional bottleneck layer structure, it can ensure that the mean squared error of the reconstruction error of healthy fruit peel samples is consistently below 0.05. This quantitative indicator proves that the model can completely and accurately capture the intrinsic distribution law of the natural texture on the surface of organic monk fruit, providing reliable data support for the subsequent accurate capture of outlier defect residuals.
[0103] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for identifying surface defects of organic monk fruit based on machine vision, characterized in that, include: Image data of organic monk fruit is acquired, and a curvature frequency domain spectrum is generated by transforming a virtual grayscale surface and then filtered to obtain local texture defect signals. The texture energy map is solved using a gradient operator, and a full surface map is constructed based on the optimal stitching line algorithm. Semantic segmentation is performed on the full surface map to locate the fruit stem boundary and peel region, and net texture data is obtained. Based on the net texture data, a texture representation domain is constructed; The texture representation domain is mapped to a local tensor block and encoded as a feature vector; a model of monk fruit is constructed. A natural texture feature distribution manifold is used to map feature vectors to obtain reconstructed feature vectors. The residual vector between the reconstructed feature vectors and the feature vectors is calculated. The residual vector is then input into a deep neural network for pattern recognition to generate a defect probability map. The defect probability map is segmented using a threshold to extract abnormal regions, and the topology is then built upon these abnormal regions. By combining surface features and texture gradients, heterogeneous feature vectors are constructed and mapped to a classification feature space configured with category reference vectors. Euclidean distance is calculated, and pattern classification is performed to determine the defect category, thus completing the identification and grading of surface defects in organic monk fruit.
2. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 1, characterized in that Constructing the full surface map includes: acquiring local image data of the spin scan of *Siraitia grosvenorii* fruit, and establishing a spherical global coordinate system based on the spatial mapping relationship between the spin motion of *Siraitia grosvenorii* fruit and the imaging scan; mapping the pixel plane coordinates and gray values of the local image data in the two-dimensional planar image to the basis coordinates and virtual height values in the three-dimensional virtual space, respectively, and constructing a virtual gray-scale surface in the virtual space; calculating the Gaussian curvature of the virtual height values; distinguishing between light spots and texture defect areas based on the Gaussian curvature characteristics, and constructing a local spatial domain Gaussian curvature field; projecting the local spatial domain Gaussian curvature field onto the orthogonal complex basis space through edge smoothing preprocessing and fast Fourier transform to obtain the local curvature frequency domain spectrum; and removing local curvature using a frequency domain filter. Background illumination interference and reflection noise in the curvature frequency domain spectrum are converted into local texture defect signals by inverse fast Fourier transform and projected onto the spherical global coordinate system according to the spatial mapping relationship. Based on the continuous acquisition characteristics of spin scanning, the local texture defect signals in two adjacent frames are used to form a spatial overlapping region in the spherical global coordinate system. The gradient magnitude of the pixel plane coordinate points in the overlapping region is calculated as the texture energy using the gradient operator to construct a texture energy map. The nonlinear stitching boundary passing through the region with the lowest texture energy is planned in the overlapping region using the optimal stitching line algorithm. The overlapping region data is fused and stitched according to the nonlinear stitching boundary to construct the full surface map.
3. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 1. characterized in that The steps for constructing the texture representation domain include: inputting the full surface map into a deep fully convolutional semantic segmentation model, performing pixel-level classification prediction to resolve the segmentation boundaries of the stem-shaped strange region, the effective skin region, and the background interference region; constructing a signal suppression mask based on the segmentation boundaries, and performing edge smoothing processing on the signal suppression mask to eliminate noise at the segmentation boundaries; performing a Hadamard product operation on the signal suppression mask and the full surface map to generate mask-filtered net texture data; and based on the net texture data, removing the signal responses of the stem-shaped strange region and the background interference region at the pixel level in a spherical global coordinate system, retaining the effective skin region with continuous texture distribution characteristics, and constructing the texture representation domain.
4. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 3. characterized in that The process of constructing the natural texture feature distribution manifold of monk fruit includes: performing spatial sliding window processing on the texture representation domain, extracting continuous local tensor blocks, and simultaneously marking the spatial position index of the local tensor blocks in the spherical global coordinate system; taking the texture pixel data in the local tensor blocks as input; taking the natural texture distribution features of the surface in the undamaged state in the training data of defect-free monk fruit samples as normal texture; taking the natural texture distribution feature pattern as the normal texture distribution pattern; and learning the low-dimensional distribution of the normal texture in the feature space through an autoencoder network to generate the natural texture feature distribution manifold.
5. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 4. characterized in that The specific steps for calculating the residual vector between the feature vector and the feature vector include: encoding the texture pixel data of the local tensor block to be tested into a feature vector, mapping the feature vector to the natural texture feature distribution manifold, using manifold reconstruction decoding to obtain a reconstructed feature vector that conforms to the normal texture distribution law; performing a vector difference operation between the feature vector and the reconstructed feature vector to generate the residual vector.
6. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 5, characterized in that The steps for generating a defect probability map include: obtaining residual vectors with different texture attribute feature dimensions, including Euclidean distance offset and manifold deviation information; inputting the residual vectors into a deep neural network, using an embedded channel attention mechanism to identify and analyze the manifold deviation sensitivity of the feature response channels, extracting global response statistics of the feature response channels, generating channel weighting coefficients, recalibrating the residual vectors, obtaining defect feature channel responses, and reconstructing and generating weighted residual vectors; inputting the weighted residual vectors into the pixel-level classification decoding layer of the deep neural network, inferring and generating local defect probability values of the local tensor block anomaly degree; calling the spatial location index to map the local defect probability values corresponding to the local tensor block back to the corresponding positions in the spherical global coordinate system, and generating the defect probability map through spatial splicing and recombination.
7. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 6, characterized in that The steps for constructing heterogeneous feature vectors include: calculating a probability distribution histogram for the defect probability map, solving for a segmentation threshold using the maximum inter-class variance method, and segmenting the boundary between background noise and defect signals; performing binarization processing based on the segmentation threshold to generate a binarized mask, and performing connected component labeling and area filtering to filter out discrete noise points within the mask and extract abnormal regions; calculating the geometric area, Euler number, compactness, and eccentricity of the abnormal regions to generate a topological feature vector; using a gradient operator to calculate the pixel change rate of the abnormal regions, statistically analyzing the gradient magnitude and direction to generate a texture gradient feature vector; and fusing the topological feature vector and the texture gradient feature vector to construct a heterogeneous feature vector.
8. The machine vision-based method for identifying surface defects in organic monk fruit according to claim 7, characterized in that The process of identifying and grading surface defects in organic monk fruit includes: constructing a classification feature space based on the feature dimensions of the heterogeneous feature vectors; statistically analyzing the category mean vector of known defect samples in the classification feature space as a category baseline vector; mapping the heterogeneous feature vectors as test vectors to the classification feature space; calculating the Euclidean distance between the test vectors and the category baseline vectors; sorting the Euclidean distances in ascending order according to the nearest neighbor principle; selecting the category corresponding to the category baseline vector at the top of the sorted sequence as the defect category label of the abnormal region; extracting the geometric area value as the damaged physical quantity; constructing a comprehensive grading logic matrix containing the defect category dimension and the damaged physical quantity dimension; inputting the defect category label and the damaged physical quantity as indices into the comprehensive grading logic matrix; and outputting grade instructions through the index mapping of the comprehensive grading logic matrix to complete the identification and grading of surface defects in organic monk fruit.