Potato crop appearance defect detection method and system based on fluorescence imaging
By combining multi-band fluorescence imaging technology and deep learning optimization with fluorescence quenching effect and spectral gradient characteristics, we have achieved efficient and accurate detection and grading of appearance defects in potato crops, solving the problems of low efficiency and low accuracy in traditional detection methods.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-03-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional methods for detecting appearance defects in tuber crops include low efficiency, high subjectivity, and easy omissions due to manual inspection, while machine vision inspection has low accuracy in identifying defects that are similar in appearance but have different causes.
The surface of potato crops is excited by a multi-band fluorescent light source, and fluorescent and reflective images are acquired simultaneously. Defect-specific features are extracted through dark field calibration, noise suppression and image registration. The defect classification model is optimized by an adaptive weighted fusion network and transfer learning to generate a graded inspection report.
It enables accurate detection and type identification of appearance defects in potato crops, improving detection efficiency and accuracy, and solving the problems of high missed detection rate of minute defects and low accuracy of identification of similar-looking defects in traditional methods.
Smart Images

Figure CN121656205A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of appearance inspection technology for tuber crops, and in particular to a method and system for detecting appearance defects in tuber crops based on fluorescence imaging. Background Technology
[0002] Tuber crops (such as potatoes and sweet potatoes) are important food and economic crops globally, and post-harvest quality inspection is a crucial step in ensuring market circulation quality and reducing losses. Appearance defect detection, as a core component of quality inspection, mainly targets problems such as rot, sprouting, and mechanical damage that occur during the growth, harvesting, and storage of tuber crops. Traditional tuber defect detection primarily relies on manual and machine vision inspection. Machine vision inspection works by acquiring crop images using imaging equipment and combining this with image processing algorithms to capture defect-related features, thereby enabling defect identification and assessment.
[0003] Traditional methods for detecting defects in potatoes have two main problems: one is manual visual inspection, which is greatly affected by the experience and fatigue of the inspectors, resulting in a high rate of missed detection for minor defects (such as early sprouting or slight local rot), and the detection efficiency is difficult to meet the needs of large-scale production; the other is machine vision inspection, which mainly uses the color, shape and other features of defects to capture defects. This method has a low accuracy in identifying defects that look similar but have different causes (such as dry scars and slight rot). Summary of the Invention
[0004] The main objective of this invention is to provide a method and system for detecting appearance defects in potato crops based on fluorescence imaging, aiming to solve the technical problems mentioned in the background art.
[0005] This invention proposes a method for detecting appearance defects in potato crops based on fluorescence imaging, comprising:
[0006] Multi-band fluorescent light sources were used to irradiate the surface of potato crops, stimulating them to produce specific fluorescent responses, and fluorescent and reflectance images were acquired simultaneously.
[0007] Dark-field calibration, noise suppression, and image registration are performed on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair.
[0008] Based on the fluorescence quenching effect and spectral gradient characteristics, defect-specific features are extracted from the registered fluorescence and reflectance image pairs to form a high-dimensional feature vector.
[0009] The high-dimensional feature vector is input into an adaptive weighted fusion network, and the weights of different features are dynamically adjusted to output a defect probability map.
[0010] Based on the defect probability map, an improved image segmentation algorithm is used to locate surface defect regions and calculate the defect area ratio.
[0011] Obtain a historical database, optimize the defect classification model through transfer learning based on the defect sample characteristics in the historical database, identify the defect type from the high-dimensional feature vector using the defect classification model, and generate a classification result and output a detection report based on the defect type and the defect area ratio.
[0012] Preferably, the step of irradiating the surface of potato crops with a multi-band fluorescent light source to excite them to produce a specific fluorescence response, and simultaneously acquiring fluorescence images and reflectance images includes:
[0013] Obtain the light source parameters of a multi-band fluorescence excitation source, wherein the multi-band fluorescence excitation source includes a dual-band LED array of ultraviolet and blue light;
[0014] Based on the light source parameters, pulse modulation technology is used to excite the potato crop sample to be detected in a time-division excitation mode;
[0015] According to the time-division excitation mode, an optical filter group is used to simultaneously separate and acquire fluorescence images and reflection images;
[0016] Based on the fluorescence image and the reflection image, fluorescence spectral data are simultaneously acquired using a fiber optic spectrometer, and the light source parameters are dynamically optimized and adjusted based on the fluorescence spectral data.
[0017] Preferably, the step of performing dark-field calibration, noise suppression, and image registration on the fluorescence image and the reflectance image to generate a registered fluorescence and reflectance image pair includes:
[0018] Based on the fluorescence image and the reflection image, obtain a dark field image and a reference white board image;
[0019] Based on the dark field and reference whiteboard images, the fluorescence image and the reflection image are respectively subjected to dark field calibration and illumination unevenness correction;
[0020] Noise suppression is performed on the calibrated fluorescence image and the reflection image using a combination of Gaussian filtering and median filtering;
[0021] The fluorescence image after noise suppression is registered with the reflection image using a feature point-based registration algorithm to obtain a fluorescence-reflection image pair.
[0022] Preferably, the step of extracting defect-specific features from the registered fluorescence and reflectance image pairs based on fluorescence quenching effect and spectral gradient characteristics to form a high-dimensional feature vector includes:
[0023] Based on the fluorescence and reflection image pair, obtain the fluorescence intensity value of each pixel;
[0024] The fluorescence intensity attenuation coefficient of each pixel is calculated based on the fluorescence intensity value to obtain the fluorescence quenching effect index.
[0025] Acquire spectral data that matches the fluorescence and reflectance image pair, and obtain spectral gradient features based on the spectral data;
[0026] An initial feature set is constructed based on the fluorescence quenching effect index and the spectral gradient characteristics. Principal component analysis is then performed on the initial feature set to reduce its dimensionality and obtain the principal component features.
[0027] Based on the principal component features, a high-dimensional feature vector is constructed for each pixel.
[0028] Preferably, the step of inputting the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjusting the weights of different features, and outputting a defect probability map includes:
[0029] The high-dimensional feature vector is split into a fluorescence feature branch and a reflectance feature branch;
[0030] An adaptive weighted fusion network with a dual-branch structure is constructed based on the fluorescence feature branch and the reflection feature branch. Convolutional layers are used to perform depth extraction on the fluorescence feature branch and the reflection feature branch respectively to obtain dual-branch depth features.
[0031] Based on the channel attention module, the dual-branch deep features are transformed into channel descriptors through global average pooling. The first channel attention weight vector and the second channel attention weight vector are calculated through the fully connected layer. The dual-branch features are then weighted to obtain the key channel features.
[0032] Based on the key channel features, learnable first and second weight parameters are introduced to dynamically calculate the fused feature vector.
[0033] Based on the fused feature vector, the network performs classification through subsequent layers, outputting a defect probability map of the entire image.
[0034] Preferably, the step of locating the surface defect region using an improved image segmentation algorithm based on the defect probability map and calculating the defect area ratio includes:
[0035] Based on the defect probability map, a confidence threshold is set to generate a preliminary binary defect mask;
[0036] Based on the defect binary mask, morphological closing operations are used to fill the holes, and opening operations are used to remove noise points with an area smaller than a preset threshold to obtain an optimized mask.
[0037] The optimized mask is used as prior information input to improve the image segmentation algorithm for fine segmentation. The network parameters are iteratively optimized by calculating DiceLoss and outputting a high-precision defect mask.
[0038] Based on the high-precision defect mask, the area of each defect is calculated and summed to obtain the total defect area;
[0039] The sample surface area is determined based on the edge detection algorithm, and the defect area ratio is obtained based on the total defect area and the sample surface area.
[0040] Preferably, the steps of acquiring the historical database, optimizing the defect classification model through transfer learning based on the defect sample features in the historical database, identifying defect types from high-dimensional feature vectors using the defect classification model, and generating a grading result and outputting a detection report based on the defect type and the defect area ratio include:
[0041] Defect sample features of the same category as the current sample are obtained from the historical database and used as source data for transfer learning. The defect sample features include high-dimensional feature vectors, defect area ratio, and defect type.
[0042] According to the transfer learning strategy, the top classification layer of the pre-trained ResNet-50 model is replaced, and the source data is used for optimization to obtain an optimized defect classification model.
[0043] The high-dimensional feature vector and the defect area ratio are fused into a comprehensive input feature through feature concatenation, and the comprehensive input feature is input into the optimized defect classification model to output the defect type probability distribution of the current sample.
[0044] Based on the probability distribution and the preset type determination threshold, the defect type of the current sample is determined;
[0045] Based on the identified defect type and the proportion of the defect area, a classification result is generated by comparing it with a preset classification standard;
[0046] Based on the grading results, an inspection report is generated that includes the defect location, type, size, and confidence level.
[0047] This invention also discloses a fluorescence imaging-based system for detecting appearance defects in potato crops, comprising:
[0048] The excitation imaging module is used to irradiate the surface of potato crops with a multi-band fluorescent light source to excite them to produce a specific fluorescence response, and simultaneously acquire fluorescence images and reflection images.
[0049] The preprocessing module is used to perform dark field calibration, noise suppression, and image registration on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair.
[0050] The feature extraction module is used to extract defect-specific features from the registered fluorescence and reflectance image pairs based on fluorescence quenching effect and spectral gradient features, forming a high-dimensional feature vector;
[0051] The feature recognition module is used to input the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjust the weights of different features, and output a defect probability map.
[0052] The defect calculation module is used to locate surface defect regions using an improved image segmentation algorithm based on the defect probability map, and to calculate the defect area ratio.
[0053] The hierarchical output module is used to acquire a historical database, optimize the defect classification model through transfer learning based on the defect sample characteristics in the historical database, identify the defect type from the high-dimensional feature vector using the defect classification model, and generate a hierarchical result and output a detection report based on the defect type and the defect area ratio.
[0054] The present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, characterized in that the processor executes the computer program to implement the steps of a method for detecting appearance defects in potato crops based on fluorescence imaging.
[0055] The present invention also discloses a computer-readable storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the steps of a method for detecting appearance defects in potato crops based on fluorescence imaging.
[0056] The beneficial effects of this invention are as follows: This invention takes fluorescence imaging technology as its core, combines multimodal data fusion, deep learning optimization and other technologies, captures defect-specific light signals through multi-band fluorescence light sources, eliminates interference with the help of preprocessing algorithms, and mines defect-specific information through feature extraction and fusion, thus solving the problems of low efficiency, strong subjectivity and easy omission in traditional manual inspection, as well as the low accuracy of traditional machine vision inspection in identifying defects that are similar in appearance but have different causes. Attached Figure Description
[0057] Figure 1 This is a schematic diagram of a method flow according to an embodiment of this application.
[0058] Figure 2 This is a schematic diagram of the system structure according to an embodiment of this application.
[0059] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0060] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0061] like Figure 1 As shown, this application provides a method for detecting appearance defects in potato crops based on fluorescence imaging, including:
[0062] S1 uses a multi-band fluorescent light source to irradiate the surface of potato crops, exciting them to produce a specific fluorescent response, and simultaneously acquires fluorescence images and reflection images;
[0063] S2, perform dark field calibration, noise suppression and image registration on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair;
[0064] S3, based on the fluorescence quenching effect and spectral gradient characteristics, extract defect-specific features from the registered fluorescence and reflectance image pairs to form a high-dimensional feature vector;
[0065] S4, input the high-dimensional feature vector into the adaptive weighted fusion network, dynamically adjust the weights of different features, and output a defect probability map;
[0066] S5. Based on the defect probability map, an improved image segmentation algorithm is used to locate the surface defect region and calculate the defect area ratio.
[0067] S6. Obtain the historical database, optimize the defect classification model through transfer learning based on the defect sample characteristics in the historical database, identify the defect type from the high-dimensional feature vector using the defect classification model, and generate a classification result and output a detection report based on the defect type and the defect area ratio.
[0068] As described in steps S1-S6 above, this invention achieves more accurate detection, type identification, and grade determination of appearance defects (such as rot, sprouting, mechanical damage, etc.) in tuber crops (such as potatoes, sweet potatoes, etc.) through a technical solution of multi-band fluorescence excitation, image preprocessing, defect feature extraction, adaptive feature fusion, defect localization quantification, classification and grading, and report output. This provides objective and efficient technical support for post-harvest sorting and quality control of tuber crops, and solves the problems of low efficiency, strong subjectivity, and easy omissions in traditional manual inspection, as well as the low accuracy of traditional machine vision inspection in identifying defects that are similar in appearance but have different causes.
[0069] During the growth, harvesting, and storage of tuber crops, external defects can lead to changes in their internal physiological structure and chemical composition. For example, chlorophyll degradation in rotten areas weakens fluorescence response, and cell rupture in mechanically damaged areas alters light reflection characteristics. These changes are directly reflected in the crop's fluorescence emission and reflection behavior to specific wavelengths of light. Based on this physical characteristic, this invention excites the crop's specific fluorescence response using a specific light source, captures defect-related physical signals by combining image and spectral data, and then uses algorithms to process these signals into quantifiable defect features, ultimately achieving accurate defect detection and analysis. In practical detection scenarios, it is necessary to solve problems such as "how to effectively excite and capture defect-specific light signals," "how to eliminate environmental interference (such as noise and uneven lighting) to ensure signal reliability," "how to extract defect-specific features from complex light signals," "how to integrate multi-dimensional features to improve defect recognition accuracy," and "how to quantify the degree of defect and associate it with quality level." These problems collectively constitute the design guidance of the technical solution of this invention.
[0070] From the perspective of existing technologies, traditional methods for detecting defects in potatoes suffer from two main problems: one relies on manual visual inspection, which is greatly affected by the experience and fatigue of the inspectors, resulting in a high rate of missed detection for minor defects (such as early sprouting or slight localized rot), and the detection efficiency is insufficient to meet the needs of large-scale production; the other relies on machine vision inspection, which mainly captures the color and shape features of defects, but this method has low accuracy in identifying defects that look similar but have different causes (such as dry scars and slight rot). To address these problems, this invention uses "fluorescence imaging technology" as its core, combined with multimodal data fusion and deep learning optimization techniques. It captures defect-specific light signals using multi-band fluorescence light sources, eliminates interference using preprocessing algorithms, and mines defect-specific information through feature extraction and fusion, ultimately achieving defect detection that balances efficiency and accuracy.
[0071] Specifically, the first step, S1, involves irradiating the surface of potato crops with a multi-band fluorescent light source to excite a specific fluorescence response, and simultaneously acquiring fluorescence and reflectance images. The core of this step is to excite specific light signals in defective areas using a specific light source, providing reliable raw data for subsequent detection. For example, in potatoes that have experienced early rot during storage, the chlorophyll content in the rotten areas decreases. Under 365nm ultraviolet light excitation, the fluorescence intensity in the rotten areas will be significantly lower than that in healthy areas. Through the light source excitation and image acquisition in step S1, this fluorescence difference can be clearly captured, laying the foundation for subsequent identification of rot defects.
[0072] The next step, S2, involves "performing dark-field calibration, noise suppression, and image registration on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair." The purpose of this step is to eliminate various interference factors during image acquisition, ensuring the reliability and consistency of the image data. Interference is inevitably introduced during image acquisition: for example, the dark current of the imaging device generates dark-field noise, resulting in weak signals in the image even without light source illumination; uneven ambient light leads to local brightness differences in the image; subtle differences in the acquisition angle and imaging time between the fluorescence and reflection images can cause the same crop area to not overlap in the two images. These interferences can mask defect features and affect subsequent detection accuracy. Therefore, this invention addresses these issues through step S2, using a registration algorithm to avoid such problems.
[0073] Step S3, "Based on the fluorescence quenching effect and spectral gradient characteristics, extracting defect-specific features from the registered fluorescence and reflectance image pairs to form a high-dimensional feature vector," is the core feature extraction step of this invention. Defective regions in tuber crops exhibit a specific "fluorescence quenching effect." In healthy regions, chlorophyll and other substances stably emit fluorescence under fluorescence excitation, while in defective regions (such as rot), material degradation leads to a decrease in fluorescence emission intensity. This intensity attenuation is directly related to the degree of defect. Simultaneously, the spectral curve of defective regions (fluorescence intensity changes at different wavelengths) exhibits an abnormal gradient. For example, the spectral gradient of healthy regions is stable and positive in the 680-685nm range, while in rotten regions, due to reduced chlorophyll, the spectral gradient in this range may turn negative or significantly decrease. These "fluorescence quenching effects" and "spectral gradient characteristics" are core physical markers distinguishing defective from healthy regions. Therefore, this invention extracts these features through step S3 to mine specific features that accurately characterize defects from preprocessed image data, providing "feature basis" for subsequent defect identification.
[0074] The core of step S4, "inputting the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjusting the weights of different features, and outputting a defect probability map," is to fuse multi-dimensional features through a deep learning network, highlighting the contribution of key features for defect identification, and ultimately generating a probability map that reflects the probability of defects at each pixel. The high-dimensional feature vector extracted in step S3 includes fluorescence quenching-related features (from fluorescence images) and spectral gradient-related features (related to both reflectance and fluorescence properties). The contribution of different features to defect identification varies with the defect type. For example, when identifying rot defects, the contribution of fluorescence quenching features is higher; when identifying mechanical damage defects, the contribution of spectral gradient features reflecting edge features is higher. If fixed-weight fusion features are used, the identification accuracy for some defects will decrease. Therefore, this invention uses an "adaptive weighted fusion network" to dynamically adjust feature weights, ensuring that key features are highlighted for each defect type.
[0075] Step S5, "Based on the defect probability map, the improved image segmentation algorithm is used to locate the surface defect region and calculate the defect area ratio," aims to transform the defect probability map into a clear defect region mask, realizing the spatial localization and area quantification of defects, and providing a quantitative indicator of "defect severity" for subsequent grading. The defect probability map only reflects the probability of a pixel being defective; it cannot directly determine the boundary and range of the defect, and may contain "fuzzy pixels with probability values between 0.4 and 0.6" (such as the transition zone between defective and healthy areas). Additionally, the probability map may contain a small number of noise points (such as isolated pixels with a probability value of 0.6, which are actually healthy areas). Therefore, this invention extracts the true defect region through a segmentation algorithm and calculates its area ratio to quantify the severity of the defect.
[0076] Step S6, "Acquire historical database, optimize defect classification model through transfer learning based on defect sample characteristics in the historical database, identify defect types from high-dimensional feature vectors using the defect classification model, and generate grading results and output inspection reports based on the defect types and defect area proportions," is the result output stage of this invention. It achieves defect type identification by optimizing the model using historical data, completes quality grading by combining defect area proportions, and finally generates an inspection report that can be directly used in production. From a physical perspective, defect types in tuber crops (such as rot, sprouting, and mechanical damage) correspond to different degrees of quality impact. Rot leads to crop spoilage and inedibility, sprouting produces harmful substances such as solanine, and mechanical damage, while not directly producing toxins, accelerates rot. Therefore, it is necessary to first identify the defect type and then formulate grading standards based on the area proportion (reflecting the severity of the defect). However, the performance of the defect classification model depends on a large number of labeled samples. The collection and labeling costs of tuber crop defect samples are high, making it difficult to construct large-scale dedicated datasets. Therefore, this invention utilizes the general feature extraction capabilities of existing pre-trained models through transfer learning to achieve model optimization on a small number of dedicated samples.
[0077] Compared to the limitations of traditional manual visual inspection and conventional machine vision inspection in potato defect detection, this invention, with its core technology of "fluorescence imaging," achieves higher efficiency and accuracy. Regarding detection accuracy, traditional manual visual inspection is affected by experience and fatigue, resulting in a high rate of missed detections of minute defects such as early sprouting and minor localized rot. This invention, however, uses a dual-band fluorescence light source to precisely excite specific fluorescence responses in defective areas of potato crops, such as the red fluorescence attenuation caused by chlorophyll degradation in rotten areas and the green fluorescence anomaly caused by flavonoid changes in sprouting areas. Combined with fluorescence spectral data simultaneously acquired by a fiber optic spectrometer, it can capture minute defect features that are difficult to distinguish with the naked eye. Furthermore, by extracting and fusing features to mine defect-specific information, it effectively distinguishes between defects such as dry scars and minor rot that appear similar but have different causes, overcoming the limitations of conventional machine vision inspection. The problem of low recognition accuracy caused by visual recognition relying solely on color and shape features has led to the improvement of defect recognition accuracy and the reduction of the missed detection rate of minor defects. However, in terms of detection efficiency, traditional manual inspection is inefficient and cannot meet the needs of large-scale production. This invention achieves fully automated operation from light source excitation and data acquisition to defect location, classification and grading through automated processing procedures such as multi-band time-division excitation, simultaneous acquisition of fluorescence and reflectance images and adaptive weighted fusion network, and improved image segmentation algorithm. It has shorter single-sample detection time and higher detection efficiency, which can be adapted to the detection needs of large-scale potato crop post-harvest sorting production lines, balancing detection accuracy and efficiency.
[0078] In one embodiment of the present invention, the step of irradiating the surface of potato crops with a multi-band fluorescent light source to excite them to produce a specific fluorescence response, and simultaneously acquiring fluorescence images and reflectance images includes:
[0079] S11, Obtain the light source parameters of the multi-band fluorescence excitation source, wherein the multi-band fluorescence excitation source includes an ultraviolet and blue dual-band LED array;
[0080] S12, according to the light source parameters, the potato crop sample to be detected is excited in a time-division excitation mode using pulse modulation technology;
[0081] S13, according to the time-division excitation mode, use an optical filter group to simultaneously separate and acquire fluorescence images and reflection images;
[0082] S14, Based on the fluorescence image and the reflection image, fluorescence spectral data is simultaneously acquired using a fiber optic spectrometer, and the light source parameters are dynamically optimized and adjusted based on the fluorescence spectral data.
[0083] As described in steps S11-S14 above, the present invention first determines the key parameters of the multi-band fluorescence excitation source through the above steps, then excites the potato crop sample using a pulse-modulated time-division excitation mode, and simultaneously acquires fluorescence and reflection images using an optical filter group. Finally, the source parameters are dynamically optimized based on the synchronously acquired fluorescence spectral data, thereby achieving efficient and pure capture of the defect-specific fluorescence response of potato crops.
[0084] The healthy and defective regions (such as those affected by rot, sprouting, or mechanical damage) of tuber crops exhibit significant differences in molecular composition. Healthy regions contain stable chlorophyll, flavonoids, and other substances that produce stable fluorescence intensity when excited by light of specific wavelengths. Defective regions, however, experience specific differences in fluorescence emission intensity and spectral distribution due to material degradation (e.g., chlorophyll decomposition caused by rot) or structural changes (e.g., cell rupture caused by mechanical damage). This difference is the core physical basis for defect identification. Therefore, accurate defect detection requires first exciting this specific fluorescence response with a specific light source, and simultaneously acquiring fluorescence and reflectance images reflecting this response. However, in practice, it is necessary to address issues such as "how to select the light source wavelength to maximize the fluorescence difference between defective and healthy regions," "how to avoid interference from different light sources to ensure signal purity," and "how to ensure that the acquired image data accurately reflects the crop's fluorescence characteristics." Therefore, this invention effectively captures defect-specific light signals by precisely controlling the light source parameters and acquisition process.
[0085] Specifically, the process begins with step S11, "Obtaining the light source parameters of a multi-band fluorescence excitation source, which includes a dual-band LED array of ultraviolet and blue light (wavelengths 365nm±5nm and 450nm±5nm)." The core of this step is determining the light source bands and related parameters that can efficiently excite defect-specific fluorescence responses. The selection of a dual-band LED array of ultraviolet (365nm±5nm) and blue (450nm±5nm) light is based on the absorption characteristics of the main fluorescent substances in potato crops. Chlorophyll a in potato crops has a strong absorption peak for 450nm blue light, emitting fluorescence at 680-690nm after absorption; flavonoids significantly absorb 365nm ultraviolet light, emitting fluorescence at 400-500nm. Changes in the chlorophyll and flavonoid content in defect areas lead to significant differences in fluorescence intensity between these two bands. Selecting these two bands amplifies the fluorescence differences between defective and healthy areas. In addition to wavelength, light source parameters also include the power density of the LED array (usually set to 10-20 mW / cm²; too low a power will result in a weak fluorescence signal, while too high a power will easily cause damage to crop tissue) and the illumination angle of the light source (45°-60° to the crop surface to avoid direct light entering the image acquisition device). These parameters need to be determined through preliminary experiments to ensure that a stable and obvious fluorescence response can be excited without damaging the sample.
[0086] Next, step S12, "based on the light source parameters, uses pulse modulation technology to excite the potato crop sample to be tested in a time-division excitation mode." The purpose of this step is to avoid signal interference caused by simultaneous excitation from different wavelength light sources, ensuring that the fluorescence signal excited by each wavelength is independent and pure. If ultraviolet and blue light sources are excited simultaneously, the light signals from the two sources will overlap, and the crop emits fluorescence at different wavelengths with time differences. Simultaneous acquisition will lead to a mixture of the two fluorescence signals in the fluorescence image, making it difficult to distinguish which signal corresponds to which defect feature. Using a time-division excitation mode allows the two wavelength light sources to alternately excite at different time periods, with only one light source operating in each time period, ensuring that each excitation produces only the corresponding wavelength fluorescence response, thus avoiding signal interference. In terms of technical implementation, pulse modulation technology controls the switching timing of the dual-band LED array through a pulse signal generator. The excitation pulse width for each band is set to 10-20ms (ensuring sufficient excitation of the fluorescence signal without photobleaching), and the excitation interval between the two bands is 5-10ms (to avoid the afterglow of the previous band's fluorescence affecting the signal of the next band). For example, the 365nm ultraviolet LED array is turned on to excite the sample during the 0-10ms period, and the 450nm blue LED array is turned on to excite the sample during the 15-25ms period, with the 5ms interval in between used to eliminate the fluorescence residue of the previous band. This time-division excitation mode ensures that the fluorescence signal excited each time corresponds to only a single band.
[0087] Then, in step S13, "According to the time-division excitation mode, an optical filter group is used to simultaneously separate and acquire fluorescence and reflection images." The core of this step is to filter stray light through the filter group, separate fluorescence and reflection signals, and simultaneously acquire the two types of images to ensure that the acquired data can truly reflect the fluorescence and reflection characteristics of the crop. During image acquisition, in addition to the fluorescence signal emitted by the crop, there are also interference signals such as direct light from the light source and ambient stray light. These interferences increase image noise and mask the signal differences between defective and healthy areas. Furthermore, the wavelength ranges of fluorescence and reflection signals are different (e.g., the fluorescence wavelength excited by 365nm ultraviolet light is 400-500nm, while the reflected ultraviolet light wavelength is still around 365nm). Therefore, this invention uses filters to separate and acquire fluorescence and reflection images separately. The optical filter set includes two types of filters: one is a bandpass filter, used to filter stray light in the fluorescence signal. For example, for fluorescence excited by 365nm ultraviolet light, a bandpass filter with a center wavelength of 450nm and a bandwidth of 50nm is selected, allowing only fluorescence signals of 400-500nm to pass through; for fluorescence excited by 450nm blue light, a bandpass filter with a center wavelength of 685nm and a bandwidth of 30nm is selected, allowing only fluorescence signals of 670-700nm to pass through; the other is a cutoff filter, used to separate reflected signals. For example, a long-pass filter with a cutoff wavelength of 400nm is selected to filter out the direct reflected light from the 365nm ultraviolet light source, allowing only the reflected light from the crop itself (wavelength > 400nm) to pass through. In terms of acquisition timing, the optical filter group switches synchronously with the time-division excitation mode. For example, when excited by a 365nm ultraviolet LED, the system switches to the corresponding fluorescence bandpass filter to acquire fluorescence images, while simultaneously switching to the cutoff filter to acquire reflection images. Similarly, when excited by a 450nm blue LED, the system switches to the corresponding filter for acquisition, achieving synchronous and separate acquisition of fluorescence and reflection images. For instance, for mechanically damaged potato samples, under 450nm blue light excitation, the intensity of reflected light in the damaged area increases due to cell rupture. In the reflection image acquired through the cutoff filter, the damaged area appears as a bright spot, contrasting sharply with the healthy area. In the synchronously acquired fluorescence image, the damaged area appears as a dark spot due to reduced chlorophyll. The two images reflect the defect characteristics from different dimensions.
[0088] Finally, step S14, "According to the fluorescence image and the reflection image, fluorescence spectral data are simultaneously acquired using a fiber optic spectrometer, and the light source parameters are dynamically optimized and adjusted based on the fluorescence spectral data," aims to optimize the light source parameters in real time through spectral data feedback. This ensures that the defect signals of different samples are fully excited, avoiding insufficient or excessive excitation due to individual sample differences. Since the content of fluorescent substances varies among different tuber crop samples (such as different varieties of potatoes or sweet potatoes stored for different times), fixed light source parameters may not be effective for some samples. For example, samples with long storage times have low fluorescent substance content, resulting in weak fluorescence signals excited by a fixed-power light source; while fresh samples have high fluorescent substance content, and a fixed power source may lead to fluorescence signal saturation. This invention, by simultaneously acquiring fluorescence spectral data, can analyze the actual fluorescence response intensity and spectral distribution of the samples, and then dynamically adjust the light source parameters to ensure that the defect signals of each sample are effectively excited. The fiber optic probe of the fiber optic spectrometer is installed next to the image acquisition device to ensure that the acquired spectral data corresponds to the same crop region as the fluorescence and reflectance images. The spectral acquisition range is set to 400-800nm (covering the emission wavelengths of the main fluorescent substances in potato crops). The acquisition frequency is synchronized with the time-division excitation mode, meaning that the spectrometer synchronously acquires fluorescence spectral data of the corresponding band each time the light source is excited. Based on the acquired spectral data, the fluorescence intensity value at key wavelengths is calculated (e.g., fluorescence intensity at 450nm under 365nm excitation, fluorescence intensity at 685nm under 450nm excitation). If the intensity is lower than a preset threshold (e.g., lower than 50% of the average intensity of healthy samples), the power of the corresponding LED is appropriately increased (by 5% each time, with a maximum of 20mW / cm²) to enhance the fluorescence signal. If the intensity is higher than a saturation threshold (e.g., exceeding 90% of the maximum response intensity of the image sensor), the power is appropriately reduced to avoid signal saturation distortion. For example, if a sprouted sweet potato sample is excited by 365nm ultraviolet light and the fluorescence intensity at 450nm is only 40% of that of a healthy sample, which is lower than the preset threshold, then by using spectral data feedback, the power of the 365nm LED is increased from 15mW / cm² to 18mW / cm². After being excited again, the fluorescence intensity will be improved compared to the healthy sample, and the difference from the sprouted area will be significantly enhanced, making the defect features clearer in subsequent images.
[0089] Compared to traditional machine vision inspection methods, this invention comprehensively captures the specific fluorescence responses of different defect types through dual-band excitation energy, avoids inter-band interference through time-division mode, improves the image signal-to-noise ratio through optical filter group, and ensures the consistency of excitation effect for different samples through dynamic spectral optimization. The final acquired fluorescence and reflection images can more clearly and accurately reflect the defect characteristics of potato crops.
[0090] In one embodiment of the present invention, the step of performing dark-field calibration, noise suppression, and image registration on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair includes:
[0091] S21, Based on the fluorescence image and the reflection image, obtain a dark field image and a reference white board image;
[0092] S22, based on the dark field and the reference whiteboard image, perform dark field calibration and illumination unevenness correction on the fluorescence image and the reflection image respectively;
[0093] S23, noise suppression is performed on the calibrated fluorescence image and the reflection image by using Gaussian filtering combined with median filtering;
[0094] S24, using a feature point-based registration algorithm, the noise-suppressed fluorescence image and the reflection image are registered to obtain a fluorescence and reflection image pair.
[0095] As described in steps S21-S24 above, the present invention first acquires a dark field image and a reference white board image as calibration benchmarks, then performs dark field calibration and illumination unevenness correction on the fluorescence image and the reflection image respectively, then suppresses image noise by combining Gaussian filtering with median filtering, and finally uses a feature point-based registration algorithm to achieve spatial alignment of the two types of images, ultimately generating a high-quality, interference-free, and spatially consistent registered fluorescence and reflection image pair.
[0096] During the acquisition of fluorescence and reflectance images of potato crops, interference from external environmental factors and equipment inherent to the process is unavoidable. For example, the imaging equipment's sensors exhibit dark current, generating weak signals even without light source illumination, resulting in dark-field noise. Uneven distribution of ambient light sources or deviations in the light source angle can lead to localized brightness differences in the image (e.g., edge areas are brighter than the central area), i.e., uneven illumination. Dust in the air and sensor electronic noise can create isolated bright or dark spots in the image, i.e., random noise. Furthermore, subtle differences in the acquisition angle and imaging time between fluorescence and reflectance images can cause the pixel positions of the same crop area to not overlap in the two types of images. These interferences can mask the true signal differences between defective and healthy areas. For instance, dark-field noise may be misjudged as minor defects, uneven illumination may cause healthy areas to be misjudged as defects due to low brightness, and image position misalignment can lead to miscalculations when extracting fluorescence and reflectance features from the same crop area. Therefore, this invention eliminates these interferences through steps S21-S24, enabling the image data to more accurately reflect the crop's appearance and fluorescence characteristics.
[0097] Specifically, the process begins with step S21, "Acquiring a dark-field image and a reference white board image based on the fluorescence image and the reflection image." The core of this step is obtaining the baseline data required for image calibration, providing a basis for subsequent dark-field calibration and illumination unevenness correction. Dark-field images are acquired using the same imaging equipment as the fluorescence and reflectance images under conditions of "no light source illumination and no crop samples." Their pixel values reflect the noise signal generated by the dark current of the imaging equipment itself. These images can be obtained by controlling the imaging equipment to acquire 1-2 images in a darkroom environment before each batch of tests begins. Reference whiteboard images are acquired using a standard white calibration board (with known and uniform reflectivity, such as a diffuse whiteboard with 99% reflectivity) instead of the crop sample, under conditions of "light source parameters consistent with the acquired fluorescence and reflectance images." Their pixel values reflect the uniform brightness distribution under the current light source. These images can be acquired after acquiring dark-field images by placing the standard whiteboard at the crop sample detection location and acquiring reference whiteboard images of the corresponding wavelengths according to the acquisition parameters of the fluorescence and reflectance images (e.g., acquiring a reference whiteboard image of the fluorescence wavelength when acquiring a fluorescence image, and acquiring a reference whiteboard image of the reflectance wavelength when acquiring a reflectance image). For example, before acquiring fluorescence images of a batch of potatoes, all light sources are turned off, samples are removed, and dark-field images are acquired. Then, a 365nm±5nm ultraviolet light source is turned on, a standard white board is placed on the sample stage, and reference white board images in the fluorescence band are acquired to ensure that there is a clear benchmark for subsequent calibration.
[0098] Next, step S22, "Based on the dark field and reference whiteboard images, perform dark field calibration and illumination unevenness correction on the fluorescence image and the reflection image, respectively." The purpose of this step is to eliminate the influence of dark current noise from the imaging device and uneven ambient lighting on the image, ensuring that the image brightness truly reflects the fluorescence and reflection characteristics of the crop. From a technical implementation perspective, dark field calibration uses a "subtract dark field image from original image" method. This operation directly removes noise generated by the dark current of the imaging device itself. For example, if the noise value of a pixel in the original fluorescence image due to dark current is 20, the pixel value will be reduced by 20 after dark field calibration, restoring the true intensity of the crop's fluorescence signal. Illumination unevenness correction is performed based on a reference whiteboard image. First, the average pixel value of the reference whiteboard image (reflecting the uniform brightness benchmark of the current light source) is calculated. Then, the ratio of each pixel in the reference whiteboard image to the average pixel value is calculated (this ratio reflects the distribution of illumination unevenness). Finally, the dark-field calibrated image is divided by this ratio to obtain the illumination unevenness corrected image. This operation unifies the brightness of each area of the image to the average benchmark. For example, if a pixel at the edge of a reflective image has an original value of 50 due to weak illumination, and the corresponding pixel value in the reference whiteboard image is 80 (average pixel value is 100, ratio R=0.8), after illumination unevenness correction, this pixel value becomes 50 / 0.8=62.5, consistent with the brightness of the central area, avoiding the obscuring of defect features due to brightness differences. It should be noted that fluorescent and reflective images must be calibrated using their respective reference whiteboard images (e.g., a reference whiteboard image in the fluorescence band for fluorescent images, and a reference whiteboard image in the reflection band for reflective images) to ensure that the calibrated image matches the brightness benchmark of its own acquisition band.
[0099] Then, step S23, "Noise suppression is performed on the calibrated fluorescence image and the reflection image using a combination of Gaussian filtering and median filtering," is employed. The core of this step is the synergistic suppression of different types of noise in the image, reducing noise interference while preserving defect edge features. Since two main types of noise still exist in the calibrated image: one is high-frequency electronic noise (such as random noise generated by the imaging sensor), manifested as finely distributed particles in the image; the other is salt-and-pepper noise (such as isolated bright or dark spots caused by dust reflection in the air), manifested as single or a few isolated high or low grayscale pixels. A single filtering algorithm is difficult to effectively suppress both types of noise simultaneously. While Gaussian filtering can smooth high-frequency electronic noise, it blurs defect edges; while median filtering can remove salt-and-pepper noise, it has poor suppression effect on high-frequency electronic noise. Therefore, this invention employs a combination of both methods. First, Gaussian filtering is applied to the calibrated image. The kernel size for Gaussian filtering is set to 3×3 (a kernel size that is too large will cause excessive blurring of the edges), and the standard deviation is set to 0.8-1.2 (adjusted according to the noise intensity; the stronger the noise, the larger the standard deviation). The principle is to smooth high-frequency noise by weighting the pixel values within a 3×3 range around each pixel (the weights follow a Gaussian distribution, with the central pixel having the largest weight), thus obtaining a preliminary filtered image. Then, median filtering is performed. The window size for median filtering is also set to 3×3. The principle is to sort the pixel values within a 3×3 range around each pixel and take the median value to replace the original pixel value, effectively removing isolated salt-and-pepper noise, thus obtaining the final noise-suppressed image. For example, in a fluorescence image, a healthy area may contain multiple pixels with gray values of 10-15 due to electronic noise. After Gaussian filtering, these pixel values are smoothed to 12-13, eliminating the fine graininess. If there is an isolated bright spot with a gray value of 255 (salt and pepper noise) caused by dust in the same area, after median filtering, the pixel value of the bright spot will be replaced by the median value (such as 12) of the surrounding normal pixels, completely eliminating noise interference. At the same time, because the edges are smoothed by Gaussian filtering first, median filtering will not cause excessive damage to the defect edges, ensuring that the edge features of the defects can be accurately extracted subsequently.
[0100] Finally, step S24, "Using a feature-point-based registration algorithm, the noise-suppressed fluorescence image is registered with the reflectance image to obtain a fluorescence-reflectance image pair," aims to align the spatial positions of the two types of images, ensuring consistent pixel positions when extracting fluorescence and reflectance features from the same crop region. The feature-point-based registration algorithm chosen is either SIFT (Scale Invariant Feature Transform) or ORB (Oriented for Fast Feature Extraction and Description) (ORB offers faster computation speed while maintaining registration accuracy, making it more suitable for real-time detection scenarios). The specific process includes four steps: feature point detection, feature point description, feature point matching, homography matrix estimation, and image transformation. First, feature point detection is performed on both the noise-suppressed fluorescence image (the image to be registered) and the reflectance image (the reference image). The algorithm identifies scale- and rotation-invariant feature points (such as inflection points on crop edges, buds, or spots on the surface) in both types of images. The physical positions of these feature points are uniquely corresponding in both types of images (e.g., the buds at the top of the crop are uniquely located in each image). (Feature points are present in both the fluorescence and reflectance images). Next, a descriptor is generated for each feature point (e.g., a 256-bit binary descriptor generated by the ORB algorithm). The descriptor contains gray-level distribution information of the pixels surrounding the feature point, used to measure the similarity of feature points in different images. Then, using brute-force matching or FLANN matching algorithms, matching feature point pairs in the two types of images are selected based on descriptor similarity. The RANSAC (Random Sample Consensus) algorithm is used to remove mismatched feature point pairs (e.g., false feature point matches caused by noise), retaining the correct matching pairs. Finally, the homography matrix (reflecting the transformation relationship of pixel coordinates between the two types of images) is estimated based on the correct feature point pairs, and this matrix is used to perform an affine transformation on the fluorescence image to align the pixel coordinates of the fluorescence image with those of the reflectance image, ultimately obtaining the registered fluorescence and reflectance image pairs. For example, without registration, the pixel coordinates of the crop bud in the fluorescence image are (200, 300), while the pixel coordinates of the same bud in the reflectance image are (205, 303), a difference of 5 pixels. After processing with the ORB-based registration algorithm, the fluorescence image is transformed to be aligned with the reflectance image, and the pixel coordinates of the bud in both types of images are (203, 302), with a positional deviation of less than 1 pixel. This ensures that when extracting the fluorescence quenching features and reflectance features of the bud area, they can accurately correspond to the same physical area, avoiding feature misjudgment due to positional misalignment.
[0101] Compared to traditional methods, this step offers several advantages: First, dual calibration using a dark field and a reference white board eliminates the impact of equipment noise and uneven illumination on the brightness signal, ensuring a unified brightness benchmark across different samples and batches, thus improving the stability of subsequent feature extraction. Second, the combination of Gaussian and median filtering effectively suppresses both types of noise while preserving defect edge features to a greater extent, providing a clear image foundation for accurately extracting defect-specific features. Third, the feature-point-based registration algorithm overcomes the sensitivity of grayscale registration to illumination, achieving pixel-level precision registration in image pairs with large grayscale differences, such as fluorescence and reflectance images, ensuring the accuracy of subsequent multimodal feature fusion. Ultimately, this approach accurately and stably reflects the appearance and fluorescence characteristics of potato crops.
[0102] In one embodiment of the present invention, the step of extracting defect-specific features from the registered fluorescence and reflectance image pairs based on fluorescence quenching effect and spectral gradient characteristics to form a high-dimensional feature vector includes:
[0103] S31, based on the fluorescence and reflection image pair, obtain the fluorescence intensity value of each pixel;
[0104] S32, calculate the fluorescence intensity attenuation coefficient for each pixel based on the fluorescence intensity value to obtain the fluorescence quenching effect index, the formula is:
[0105]
[0106] In the formula, Indicators representing the fluorescence quenching effect of a single pixel. This represents the actual fluorescence intensity value of the current pixel. This represents the average fluorescence intensity;
[0107] S33, acquire spectral data matching the fluorescence and reflectance image pair, and obtain spectral gradient features based on the spectral data, using the following formula:
[0108]
[0109] In the formula, express Spectral gradient characteristic values in the wavelength range Indicates wavelength The fluorescence intensity value at that location, Indicates wavelength The fluorescence intensity value at that location;
[0110] S34, Construct an initial feature set based on the fluorescence quenching effect index and the spectral gradient features, and perform principal component analysis to reduce the dimensionality of the initial feature set to obtain principal component features;
[0111] S35, construct a high-dimensional feature vector for each pixel based on the principal component features.
[0112] As described in steps S31-S35 above, the present invention first extracts the fluorescence intensity value of each pixel from the registered fluorescence and reflectance image pair, then calculates the fluorescence quenching effect index based on the intensity value, simultaneously acquires the matched spectral data and extracts the spectral gradient features, then constructs an initial feature set and reduces the dimensionality through principal component analysis, and finally forms a high-dimensional feature vector for each pixel. The core objective is to accurately mine specific features that can distinguish between defective and healthy areas from multimodal image data.
[0113] External defects in tuber crops (such as rot, sprouting, and mechanical damage) directly alter their internal physiological structure and chemical composition. These changes manifest specifically at the optical signal level: chlorophyll and flavonoids in healthy areas produce stable fluorescence emission under fluorescence excitation at specific wavelengths, while defective areas exhibit fluorescence intensity attenuation (i.e., fluorescence quenching effect) due to material degradation (e.g., chlorophyll decomposition caused by rot) or structural damage (e.g., cell rupture caused by mechanical damage). Simultaneously, changes in the absorption and reflection characteristics of defective areas to different wavelengths of light cause significant differences in the trend of spectral curve changes (i.e., spectral gradient) compared to healthy areas. These fluorescence quenching effects and spectral gradient characteristics are "exclusive physical markers" of defective areas, but these features are scattered throughout the image and spectral data and cannot be directly used for defect detection. Therefore, this invention transforms these scattered physical signals into structured, computable feature vectors through steps S31-S35, achieving the transformation from "raw data" to "defect features."
[0114] Specifically, the process begins with step S31, "Acquiring the fluorescence intensity value of each pixel based on the fluorescence and reflectance image pair." The core of this step is extracting fundamental data reflecting the fluorescence characteristics of the crop from the registered image data. The fluorescence and reflectance image pair is the registered image after preprocessing steps S21-S24. The fluorescence image directly records the fluorescence emission signal of the potato crop under multi-band fluorescence light source excitation. The grayscale value (or light intensity value) of each pixel corresponds to the fluorescence intensity value at that physical location, so the fluorescence intensity value of each pixel can be directly read from the fluorescence image. The reflectance image, in this step, is mainly used to assist in screening effective pixel areas. By analyzing the grayscale distribution of the reflectance image (the reflectance of the crop area is higher than that of the background area), background pixels (such as the sample stage and environmental areas) in the fluorescence image are removed, leaving only the pixels of the crop area for subsequent processing, thus avoiding interference from invalid background pixel data in feature extraction. For example, in the registration fluorescence image of potato samples, the fluorescence intensity value of the background pixels is close to 0, while the fluorescence intensity value of the crop pixels is between 50 and 200. The pixel range of the crop area can be quickly identified by the reflection image, and only the fluorescence intensity value within this range is extracted for subsequent calculations to ensure the validity of the data.
[0115] Next is S32, "Calculate the fluorescence intensity attenuation coefficient for each pixel based on the fluorescence intensity value to obtain the fluorescence quenching effect index." The purpose of this step is to convert the fluorescence intensity value into a quantitative index that can directly reflect the degree of defect, highlighting the fluorescence difference between defective and healthy areas. Since the fluorescence quenching effect refers to the phenomenon that the fluorescence emission intensity of defective areas is lower than that of healthy areas due to changes in material composition (such as chlorophyll degradation), and the degree of intensity attenuation is positively correlated with the severity of the defect (e.g., the fluorescence attenuation degree of severely rotten areas is much higher than that of mildly rotten areas), this invention can convert the qualitative "fluorescence difference" into a quantitative "quenching index" by calculating the fluorescence intensity attenuation coefficient. The average fluorescence intensity is obtained through prior labeling or healthy area identification: if there is a clear healthy area in the sample (such as potato skin without any defects), the area can be manually labeled and its pixel fluorescence intensity average can be calculated; if the sample defects are widely distributed, healthy areas can be screened by the gray-level uniformity of the reflectance image (healthy areas have uniform reflectance and small gray-level fluctuations), and then the average fluorescence intensity of the area can be calculated. For example, the average fluorescence intensity of a healthy area in a potato sample is 180, while the actual fluorescence intensity of a pixel in a suspected rotten area is 72. Substituting these values into the calculation yields 0.6, indicating significant fluorescence quenching at this pixel, suggesting it is likely a defective area. Conversely, the actual fluorescence intensity of pixels in the healthy area is close to 180, with a fluorescence quenching effect index close to 0. The difference in the fluorescence quenching effect index clearly distinguishes the two types of areas. Furthermore, the fluorescence quenching effect index ranges from [0,1], with a higher value indicating more severe fluorescence quenching and a higher probability of defect.
[0116] Then, step S33, "acquiring spectral data matching the fluorescence and reflectance image pair, and obtaining spectral gradient features based on the spectral data," is crucial. The core of this step is extracting defect-specific features from the spectral dimension, complementing the fluorescence quenching index and enhancing the comprehensiveness of defect identification. Since the spectral data records the fluorescence emission intensity of the crop at different wavelengths, the spectral curve of a healthy region exhibits a stable trend (e.g., fluorescence intensity first increases and then decreases with increasing wavelength). However, defective regions, due to changes in material absorption characteristics, will exhibit abnormal rates of change (i.e., spectral gradients) in the spectral curve within a specific wavelength range. For example, the spectral gradient of a rotten region in the 680-685nm range (chlorophyll fluorescence characteristic band) will change from a positive value in the healthy region to a negative value. Therefore, this invention uses spectral gradient features as another key indicator for distinguishing defects. The spectral data matching the fluorescence and reflectance image pair comes from the synchronous acquisition by the fiber optic spectrometer in step S14. The field of view of the fiber optic spectrometer is aligned with the field of view of the image acquisition device to ensure that each spectral data point corresponds to a pixel (or a small area) in the fluorescence and reflectance image pair, achieving spatial matching of "image pixel - spectral data." After acquiring spectral data, the key wavelength ranges of fluorescence response in tuber crops are selected to calculate the spectral gradient. For example, ranges such as 550-555nm (flavonoid fluorescence band), 680-685nm (chlorophyll fluorescence band), and 730-735nm (secondary fluorescence band) are selected. The difference between positive and negative gradients of the spectral gradient can quickly identify rot defects, forming a dual verification with the fluorescence quenching index, thereby improving the reliability of defect characteristics.
[0117] The next step, S34, involves "constructing an initial feature set based on the fluorescence quenching effect index and the spectral gradient features, and performing principal component analysis to reduce the dimensionality of the initial feature set and obtain principal component features." The purpose of this step is to integrate multi-dimensional features and remove redundancy, reducing the computational complexity of subsequent algorithms while retaining key information. Specifically, constructing the initial feature set requires integrating the fluorescence quenching effect index of each pixel with spectral gradient features across multiple wavelength ranges into a feature vector; for example, each pixel corresponds to one feature vector. Value and 3 If the initial feature set has a value of 4, then each feature vector in the initial feature set has a dimension of 4. Since different features in the initial feature set may be correlated (e.g., the spectral gradient features of two wavelength ranges are affected by the same substance and have a high correlation), directly inputting them into the subsequent network would increase the computational load and may introduce redundant information. Therefore, dimensionality reduction is required through principal component analysis (PCA): First, the covariance matrix of the initial feature set is calculated, and the variance contribution of each feature is analyzed; then, the top principal components with a cumulative variance contribution rate ≥ 95% are selected (e.g., after PCA, the cumulative variance contribution rate of the first two principal components of the 4-dimensional initial features reaches 96%, so two principal components are retained); finally, the initial feature vectors are projected onto the selected principal component directions to obtain the principal component features.
[0118] Finally, step S35, "Constructing a high-dimensional feature vector for each pixel based on the principal component features," is crucial. The core of this step is to transform the dimensionality-reduced principal component features into a structured feature vector, preparing it for subsequent input into the adaptive weighted fusion network. From a technical implementation perspective, the principal component features of each pixel (such as the aforementioned two principal components PC1 and PC2) are arranged sequentially to form the high-dimensional feature vector for that pixel. Here, "high-dimensional" refers to the dimension relative to the initial single feature (such as only the fluorescence intensity value), and the specific dimension is determined by the number of principal components (usually 2-5 dimensions, balancing information preservation and computational efficiency). For example, if the principal component features of a pixel are PC1=0.85 and PC2=0.32, then its high-dimensional feature vector is [0.85, 0.32]. This vector condenses the core information of fluorescence quenching and spectral gradient of the pixel and has a suitable dimension, allowing it to be directly input into the adaptive weighted fusion network in step S4. It should be noted that the construction of high-dimensional feature vectors must ensure that the vector dimension of each pixel is consistent and corresponds one-to-one with the pixel position of the fluorescence and reflection images. In subsequent network processing, the specific pixel in the image can be located in reverse through the vector features.
[0119] The advantages of this step are as follows: First, by synergistically extracting fluorescence quenching effect indicators and spectral gradient features, multi-dimensional physical signals from images and spectra are comprehensively utilized, improving the accuracy of distinguishing defects with similar appearances (such as dry scars and slight rot). The spectral gradient features of dry scar areas show no obvious abnormalities, while those of slightly rotten areas are negative, and the differences between the two types of features can be effectively distinguished. Second, principal component analysis dimensionality reduction compresses the feature dimensions while retaining key information, which can reduce the computational power requirements of the subsequent adaptive weighted fusion network and improve the detection speed. Third, relying on the registered image pairs and matched spectral data, it is ensured that the feature vector of each pixel can accurately correspond to the physical location of the crop, avoiding feature misjudgment caused by data misalignment.
[0120] In one embodiment of the present invention, the step of inputting the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjusting the weights of different features therein, and outputting a defect probability map includes:
[0121] S41, the high-dimensional feature vector is split into a fluorescence feature branch and a reflectance feature branch;
[0122] S42, construct an adaptive weighted fusion network with a dual-branch structure based on the fluorescence feature branch and the reflection feature branch, and use convolutional layers to perform depth extraction on the fluorescence feature branch and the reflection feature branch respectively to obtain dual-branch depth features;
[0123] S43, based on the channel attention module, transforms the dual-branch deep features into channel descriptors through global average pooling, and calculates the first channel attention weight vector and the second channel attention weight vector through the fully connected layer. The dual-branch features are then weighted to obtain the key channel features.
[0124] S44, based on the key channel features, introduce learnable first and second weight parameters, and dynamically calculate the fused feature vector, as shown in the formula:
[0125]
[0126] In the formula, Represents the fused feature vector. This represents the first weight parameter. Indicates the second weight parameter (satisfying) + =1, dynamically adjusting the contribution of fluorescence and reflection branches; defect areas are usually... > ), This represents the first channel attention weight vector (the channel attention weight vector of the fluorescence feature branch, calculated through global average pooling + fully connected layer, highlighting the fluorescence channel that is sensitive to defects). This represents the second channel attention weight vector (the channel attention weight vector of the reflection feature branch, highlighting the reflection channel related to the defect edge). and This represents a bi-branch depth feature, where, This represents the depth extraction features of the fluorescence feature branch. This represents the depth-extracted features of the reflection feature branch;
[0127] S45, Based on the fused feature vector, the network is classified through subsequent layers to output a defect probability map of the entire image.
[0128] As described above, this invention first splits the high-dimensional feature vector into a fluorescence feature branch and a reflection feature branch, then constructs an adaptive weighted fusion network with a dual-branch structure, uses convolutional layers to extract dual-branch deep features, optimizes feature weights by combining a channel attention module, introduces learnable parameters to dynamically calculate the fused feature vector, and finally outputs a defect probability map through subsequent layers of the network. The core objective is to enhance the feature contribution to key defect identification and improve the distinction between defective and healthy regions through adaptive fusion and deep mining of multi-branch features.
[0129] The high-dimensional feature vector contains two core types of information: one is fluorescence features related to fluorescence quenching effects (reflecting differences in fluorescence signals caused by changes in the internal substances of the crop), and the other is reflection features related to light reflection properties (reflecting differences in reflection signals caused by changes in the surface structure of the crop). In the scenario of defect detection in potato crops, different defect types have different degrees of dependence on these two types of features. For example, rot defects are mainly manifested by a significant attenuation of fluorescence signals (fluorescence features contribute more), while mechanical damage is mainly manifested by abnormal changes in surface reflection signals (reflection features contribute more). If the two types of features are directly weighted and fused, the sensitivity for identifying some defect types will be reduced. At the same time, the information in different channels of the feature vector has different importance for defect identification (e.g., some fluorescence channels only reflect environmental interference and have no actual defect discrimination value), and if not filtered, redundant information will be introduced. Therefore, this invention uses a dual-branch network and attention mechanism in steps S41-S45 to dynamically adjust the feature weights, achieving "key feature enhancement and redundant feature suppression," so that each defect type can be identified with a better feature combination.
[0130] Specifically, the first step is S41, which involves "splitting the high-dimensional feature vector into fluorescence feature branches and reflectance feature branches." The core of this step is classifying the high-dimensional feature vector based on the physical origin of the features. The high-dimensional feature vector is the principal component feature vector generated through steps S31-S35. Each principal component corresponds to a specific physical signal. For example, principal components PC1 and PC2 are mainly composed of fluorescence quenching effect indices and fluorescence-related spectral gradient features (reflecting fluorescence physical signals), while principal components PC3 and PC4 are mainly composed of spectral gradient features related to reflectance characteristics (reflecting reflection physical signals). Based on this correspondence, the principal components in the high-dimensional feature vector related to fluorescence physical signals are divided into fluorescence feature branches, and the principal components related to reflection physical signals are divided into reflectance feature branches. For example, the 4-dimensional high-dimensional feature vector [PC1, PC2, PC3, PC4] can be split into a fluorescence feature branch [PC1, PC2] and a reflectance feature branch [PC3, PC4]. This splitting method ensures that subsequent networks can design extraction strategies for the different physical properties of the two types of features, avoiding information confusion caused by mixed feature processing. For example, fluorescence features need to focus on mining the intensity decay law, while reflectance features need to focus on capturing edge structure changes. After branch splitting, the extraction logic can be optimized separately.
[0131] Next is S42, "Constructing an adaptive weighted fusion network with a dual-branch structure based on the fluorescence feature branch and the reflection feature branch, and using convolutional layers to perform depth extraction on the fluorescence feature branch and the reflection feature branch respectively to obtain dual-branch depth features." The purpose of this step is to mine the deep defect information hidden in the two types of features through the dual-branch network and convolutional layers, and to transform the shallow principal component features into more discriminative depth features. The adaptive weighted fusion network features a symmetrical dual-branch structure. Each branch contains 2-3 convolutional layers (1×1 kernel size, adapted to the feature vector dimension; the number of kernels is 16-32, adjusted according to the feature dimension), a ReLU activation function, and a batch normalization layer. The 1×1 convolutional kernel can linearly combine and map features without changing the feature space dimension. For example, the 2-dimensional input of the fluorescence feature branch can be mapped to a 16-dimensional feature after 1×1 convolution, enhancing the expressive power of the features. The ReLU activation function introduces nonlinear transformations to capture complex nonlinear relationships between features (such as the nonlinear relationship between fluorescence intensity decay and decay degree). The batch normalization layer can accelerate network training convergence and avoid gradient vanishing. Taking the fluorescence feature branch as an example, the input 2D fluorescence feature branch [PC1, PC2] is processed by the first convolutional layer (1×1, 16 convolutional kernels) to output a 16D feature map. After ReLU activation and batch normalization, it is input into the second convolutional layer (1×1, 32 convolutional kernels) to finally output a 32D fluorescence branch depth feature. The reflection feature branches adopt the same structure, transforming the input 2D reflection feature branches [PC3, PC4] into 32D reflection branch depth features. This process integrates scattered defect information (such as fluorescence quenching trends in PC1 and reflection edge signals in PC3) from shallow principal component features into structured depth features, for example... One channel can specifically characterize the "fluorescence decay pattern caused by chlorophyll degradation". One channel can specifically characterize "abnormal reflection edges caused by mechanical damage".
[0132] Then, in step S43, "Based on the channel attention module, the dual-branch depth features are transformed into channel descriptors through global average pooling. The first and second channel attention weight vectors are calculated via a fully connected layer, and these are then weighted on the dual-branch features to obtain key channel features." The core of this step is to use an attention mechanism to filter key channels from two types of depth features, suppress redundant channel interference, and improve feature discriminability. Since different channels in dual-branch depth features correspond to different defect information—for example, in fluorescence branch depth features, some channels correspond to fluorescence attenuation signals in defect areas (key channels), while others correspond to ambient light interference signals (redundant channels)—this invention assigns higher weights to key channels through attention weights to enhance their contribution. The channel attention module's processing flow consists of three steps: First, it processes dual-branch depth features (such as…)… The first step involves performing global average pooling (32×H×W dimensions, where H is the image height and W is the image width) to average the H×W pixel values of each channel into a single value, resulting in a 32×1×1 channel descriptor. This descriptor reflects the global importance of each channel's features. The second step inputs the channel descriptor into a weight calculation network consisting of two fully connected layers (the first layer has 1 / 4 the number of channels, e.g., 8 neurons; the second layer has the same number of channels, e.g., 32 neurons). The first layer uses a ReLU activation function to introduce non-linearity, and the second layer uses a Sigmoid activation function to map the output to the [0,1] interval, resulting in the first channel attention weight vector. (Corresponding to the fluorescence branch, 32×1×1 dimension) and the second channel attention weight vector (Corresponding to the reflection branch, 32×1×1 dimension); The third step is to perform a channel-wise dot product between the weight vector and the depth features of the corresponding branch, i.e. and This allows us to obtain key channel features, such as channels corresponding to decay defects in fluorescence branches. The value was adjusted to 0.8 (higher than the 0.2-0.3 of other channels). After the dot product, the feature of this channel was amplified, while redundant channel features were suppressed. In the reflection branch, the channel weight corresponding to mechanical damage... The value was adjusted to 0.7, which enhanced the edge anomaly signal after dot product. This process enables the network to automatically focus on the key channel features for defect identification, reducing redundant information interference. For example, for slightly decayed samples, the signal-to-noise ratio of fluorescence attenuation signals in key channel features is improved, which can enhance the distinction between defective and healthy areas.
[0133] The next step, S44, involves "based on the key channel features, introducing learnable first and second weight parameters to dynamically calculate the fused feature vector." The purpose of this step is to dynamically adjust the contribution of fluorescence and reflection key channel features according to the defect type, achieving optimal fusion of the two types of features. Specifically, the first weight parameter... (Corresponding fluorescence key channel features) and the second weighting parameter (Corresponding to key reflection channel features) are learnable parameters during network training, initially set to 0.5, and optimized iteratively through training data: if the proportion of decay defects is high in the training samples, the network will automatically adjust. Increase (e.g., 0.7) Decreasing the value (e.g., by 0.3) makes the fluorescence feature contribute more; if the proportion of mechanically damaged samples is high, then... Reduce (e.g., 0.3) Increasing the value (e.g., by 0.7) makes the reflectance characteristics contribute more significantly. Taking a decaying sample as an example, the key fluorescence channel characteristics... It can accurately characterize the fluorescence decay mode of decayed areas and reflect key channel features. The contribution is relatively small, at this time ( =0.7), ( =0.3), fused feature vector The dominant role of fluorescence features ensures that decayed areas can be clearly identified; taking mechanically damaged samples as an example, the key reflective channels... It can highlight the signal at the edge of the damage, at this time ( =0.3), ( =0.7), the proportion of reflection features in the fused feature vector is higher, which can more accurately capture the damaged area. This dynamic fusion method avoids the problem of insufficient adaptability of fixed weights to different defect types, so that the fused feature vector has high discriminative power for all types of defects.
[0134] Finally, step S45, "Based on the fused feature vector, classification is performed through subsequent layers of the network to output a defect probability map of the entire image." The core of this step is to transform the fused feature vector into pixel-level defect probabilities, intuitively reflecting the possibility of a defect at each pixel. The subsequent layers of the network consist of a single 1×1 convolutional layer (with one kernel) and a sigmoid activation function: the 1×1 convolutional layer converts the 32-dimensional fused feature vector... The image is mapped to a 1D feature map (each pixel corresponds to one feature value). The Sigmoid activation function maps this feature value to the [0,1] interval, obtaining the defect probability value for each pixel. The closer the probability value is to 1, the higher the probability that the pixel is a defective area; the closer it is to 0, the higher the probability that it is a healthy area. For example, the pixel probability value of rotten areas is usually above 0.8, while that of healthy areas is below 0.2, showing a significant difference in probability between defective and healthy areas. The pixel probability value of mechanically damaged areas is between 0.6 and 0.9 at the edge and between 0.4 and 0.6 in the central area, clearly reflecting the range and degree of damage. The output defect probability map has the same size as the original fluorescence and reflectance images, and the probability value of each pixel can directly correspond to the physical location of the crop.
[0135] The advantages of this step are: First, the dual-branch structure and convolutional layer design allow for targeted deep extraction of different physical properties of fluorescence and reflection features, improving the ability to express defect information in shallow features and significantly enhancing the sensitivity to capture early minor defects (such as budding with an area ratio of <2%). Second, the channel attention module can filter key feature channels, suppress redundant information, reduce network computation, and decrease the misjudgment rate caused by irrelevant interference. Third, the dynamic fusion of learnable parameters enables the network to adaptively adjust the feature contribution according to the defect type, improving the average recognition accuracy of multiple types of defects such as decay, mechanical damage, and budding. Ultimately, the output defect probability map can more clearly and accurately reflect the probability of pixel-level defects.
[0136] In one embodiment of the present invention, the step of locating the surface defect region using an improved image segmentation algorithm based on the defect probability map and calculating the defect area ratio includes:
[0137] S51, Based on the defect probability map, set a confidence threshold and generate a preliminary binary defect mask;
[0138] S52, based on the defect binary mask, morphological closing operations are used to fill the holes, and opening operations are used to remove noise points with an area smaller than a preset threshold to obtain an optimized mask;
[0139] S53 uses the optimized mask as prior information input to improve the image segmentation algorithm for fine segmentation. By calculating Dice Loss, the network parameters are iteratively optimized to output a high-precision defect mask. The Dice Loss formula is:
[0140]
[0141] In the formula, express The loss function value (used to measure the similarity between the predicted mask output by the segmentation model and the ground truth labeled mask; the smaller the value, the higher the segmentation accuracy; the value range is [0,1]). This represents a mask for actual defect annotations (a binary image of the manually annotated defect area, where defect pixels are 1 and background pixels are 0). This represents the predicted defect mask output by the model (a binary image generated by an improved image segmentation algorithm, where defect pixels are 1 and background pixels are 0). express and The number of intersecting pixels (i.e., the number of defective pixels that are correctly segmented). They are respectively and The total number of pixels (i.e., the number of actual defect pixels and the number of predicted defect pixels);
[0142] S54, Calculate the area of each defect based on the high-precision defect mask, and sum them up to obtain the total defect area;
[0143] S55, determine the sample surface area based on the edge detection algorithm, and obtain the defect area ratio based on the total defect area and the sample surface area.
[0144] As described in steps S51-S55 above, the present invention first generates a preliminary binary defect mask from the defect probability map, then optimizes the mask quality through morphological operations, and then uses the optimized mask as prior information to improve the image segmentation algorithm. The network parameters are iteratively optimized through Dice Loss to output a high-precision defect mask. Finally, the total defect area and sample surface area are calculated based on the mask to obtain the defect area ratio. The core objective is to achieve accurate spatial positioning and quantitative analysis of defect areas on the surface of potato crops.
[0145] Defect probability maps reflect the likelihood of each pixel being a defective region (probability value 0-1), but cannot directly determine the specific boundaries, complete range, and actual area of the defect. For example, "fuzzy pixels" with probability values between 0.4 and 0.6 are difficult to directly identify as defects or healthy regions. Small holes (formed by low-probability pixels inside defects) or isolated noise points (high-probability pixels in healthy regions) that may exist in the probability map can also lead to misjudgments of the defect range. The core requirement for defect detection in tuber crops is not only to identify the existence of defects, but also to clarify the quantitative information of the defect's location and size. Therefore, this invention also transforms the "probability signal" into "spatial positioning and quantitative data".
[0146] Specifically, the process begins with step S51, "Based on the defect probability map, a confidence threshold is set to generate a preliminary binary defect mask." The core of this step is to convert continuous defect probability values into discrete "defect / health" binary judgments, quickly filtering out the approximate range of defects. The defect probability map is the pixel-level probability map output in step S45 (with the same size as the original image). The confidence threshold needs to be determined based on the type of defect in the potato crop and the detection requirements, typically set to 0.5 (which can be fine-tuned according to the actual scenario, such as reducing it to 0.4 to reduce missed detections when detecting minor defects). The rule for generating the preliminary binary defect mask is: pixels with a probability value ≥ the confidence threshold are marked as 1 (representing potential defect pixels), and pixels with a probability value < the confidence threshold are marked as 0 (representing potential healthy pixels). For example, in the defect probability map of a potato sample, the pixel probability values of rotten areas are mostly between 0.8 and 1.0, while those of healthy areas are mostly between 0.1 and 0.3. After setting a confidence threshold of 0.5, pixels in rotten areas are marked as 1, and pixels in healthy areas are marked as 0, quickly forming a preliminary mask. However, it should be noted that the mask generated in this step is a "preliminary result" and may have two types of problems: first, small holes may form inside defects due to probability values below the threshold (e.g., the probability value of the rotten center area is 0.48, which is mistakenly marked as 0); second, isolated high-probability noise points may exist in healthy areas (e.g., the probability value of 0.52 caused by dust reflection is mistakenly marked as 1). These problems need to be addressed in subsequent steps.
[0147] Next is S52, "Based on the aforementioned defect binary mask, morphological closing operations are used to fill the holes, and opening operations are used to remove noise points with areas smaller than a preset threshold, resulting in an optimized mask." The purpose of this step is to eliminate holes and noise in the initial mask through morphological operations, thereby optimizing the mask quality. The core of the morphological operation is to adjust the local pixels of the mask using "structural elements." The structural elements are 3×3 or 5×5 squares (adjusted according to the defect size; 3×3 structural elements are commonly used for defects in potato crops). The morphological closing operation consists of two steps: "dilation-erosion." The dilation operation first marks the neighboring pixels (within a 3×3 range) of the defect pixel (marked 1) in the mask as 1, filling small holes (such as holes of 2-3 pixels). The erosion operation then restores the edge pixels of the expanded defect area to 0, maintaining the main outline of the defect. For example, if the rotten area in the initial mask has small holes of 3 pixels, after the closing operation, the holes are filled, and the defect area forms a complete connected block. The morphological opening operation consists of two steps: erosion and dilation. The erosion operation first removes isolated noise points (such as a 1-2 pixel area marked as 1) from the mask (marking them as 0). The dilation operation then restores the edge pixels of the remaining defective areas to 1, preventing the main defect area from shrinking. For example, if a healthy area contains a 1-pixel noise point, the opening operation removes the noise point, restoring the healthy area to a complete 0-marked region. The preset threshold (used to determine whether a point is noise) is typically set to 5 pixels (i.e., connected components with an area < 5 pixels are considered noise). This value is determined by statistically analyzing the area of the smallest defect in potato crops (such as the bud in the early stages of sprouting), ensuring that valid small defects are not misclassified as noise. After morphological operations, the defective region boundaries in the optimized mask are more complete, and there is less noise.
[0148] Then, step S53, "using the optimized mask as prior information input to improve the image segmentation algorithm for fine segmentation, and iteratively optimizing network parameters by calculating Dice Loss to output a high-precision defect mask," is crucial. The core of this step is to leverage the improved image segmentation algorithm and prior information to enhance defect segmentation accuracy, particularly addressing the segmentation of small-area, blurred-edge defects. Specifically, the improved image segmentation algorithm preferentially uses an improved U-Net network (the encoder uses VGG16 pre-trained weights, and the decoder adds skip connections for optimization). Its structure is suitable for small-object segmentation scenarios such as medical images and agricultural product defects: the encoder progressively downsamples through 3×3 convolutional layers and 2×2 max-pooling layers to extract deep semantic features of defects (such as the global distribution features of rotten areas); the decoder progressively upsamples through 2×2 transposed convolutional layers to restore feature map resolution and fuses shallow features from corresponding encoder layers (such as detailed features of defect edges) through skip connections, solving the problem of blurred segmentation of small defects in traditional U-Net. The optimized mask serves as prior information and is input into the encoder-decoder fusion layer of the improved U-Net via "feature concatenation." This provides the segmentation network with approximate defect location information, guiding the network to focus on potential defect regions and reducing background interference. For example, for a sprouting defect that occupies only 2% of the area, without prior information, the network might miss it due to the high proportion of background pixels. After inputting the optimized mask, the network can quickly locate the sprouting region and segment it accurately. During network training, Dice Loss iteratively optimizes network parameters (convolutional kernel weights, biases, etc.). Compared to traditional cross-entropy loss, Dice Loss focuses more on the matching degree of defect regions and is more adaptable to scenarios with class imbalance (few defect pixels).
[0149] The next step is S54, "Calculate the area of each defect based on the high-precision defect mask, and sum them up to obtain the total defect area." The purpose of this step is to quantify the actual area of the defects using the high-precision mask, providing molecular data for subsequent calculations of the defect area ratio. The high-precision defect mask is a binary image (defect pixel 1, background pixel 0). The area calculation for each defect is achieved through "connected region analysis": using the 8-neighbor connectivity rule (i.e., pixels in the top, bottom, left, right, and four diagonal directions of a pixel are considered adjacent), all pixels in the mask are traversed, and adjacent marked 1 pixels are divided into a connected region (representing an independent defect); the number of pixels in each connected region is counted, and then multiplied by the actual physical area corresponding to a single pixel (determined by the imaging system resolution; for example, if the camera resolution is 1200×1200 pixels and the field of view is 12cm×12cm, then the actual area of a single pixel is 0.01cm²), to obtain the area of each defect; finally, the areas of all defects are summed to obtain the total defect area of the sample. For example, in a high-precision defect mask of a sweet potato sample, there are two independent connected defect regions, containing 100 pixels and 50 pixels respectively. The actual area of a single pixel is 0.01 cm², so the areas of the two defects are 1 cm² and 0.5 cm² respectively, with a total defect area of 1.5 cm². This calculation process requires ensuring that the mask is free of noise and voids. Therefore, the high-precision mask in step S53 is a prerequisite for accurate area calculation. If the mask contains 10 noise pixels, it will increase the error in the total defect area calculation by 0.1 cm², significantly affecting the quantization of small defects.
[0150] Finally, step S55, "Determine the sample surface area based on the edge detection algorithm, and obtain the defect area ratio based on the total defect area and the sample surface area," is crucial for accurately calculating the actual surface area of the sample (as the denominator of the defect area ratio) to ensure the objectivity of the quantification results. The edge detection algorithm used is the Canny algorithm (threshold set at 50-150 to adapt to the grayscale differences in potato crop images). The specific process is as follows: First, Gaussian filtering (5×5 convolution kernel, σ=1.4) is applied to the reflected image registered in step S24 (reflected images provide clearer depiction of crop edges) to smooth noise. Then, the image gradient (Sobel operator) is calculated to obtain the edge gradient magnitude and direction. Next, non-edge pixels are removed through non-maximum suppression. Finally, the complete edge contour of the crop is obtained through double threshold segmentation and edge connection. Based on the edge contour, the number of pixels within the contour is counted, and then multiplied by the actual area of a single pixel to obtain the sample surface area. For example, if the edge contour of a potato sample contains 60,000 pixels, and the actual area of a single pixel is 0.01 cm², then the sample surface area is 600 cm². Calculation of defect area percentage: For example, if the total defect area is 1.5cm² and the sample surface area is 600cm², then the defect area percentage is 0.25%. This data is directly used for quality grading in the subsequent S6 step (e.g., if the defect area percentage is ≤0.5%, it is judged as a first-class product).
[0151] The advantages of this step are: First, the morphological closing and opening operations work together to optimize the initial mask, reducing the mask noise rate and providing a high-quality prior for fine segmentation; Second, the improved U-Net combined with Dice Loss enhances the segmentation accuracy for small-area, edge-blurred defects, solving the problems of missed detection and over-detection in the algorithm; Third, the Canny edge detection algorithm ensures that the sample surface area calculation error is correct, providing an accurate benchmark for the defect area ratio.
[0152] In one embodiment of the present invention, the steps of acquiring a historical database, optimizing a defect classification model through transfer learning based on the defect sample features in the historical database, identifying defect types from high-dimensional feature vectors using the defect classification model, and generating a grading result and outputting a detection report based on the defect type and the defect area ratio include:
[0153] S61. Obtain the defect sample features of the same category as the current sample from the historical database and use them as source data for transfer learning. The defect sample features include high-dimensional feature vectors, defect area ratio, and defect type.
[0154] S62, According to the transfer learning strategy, based on the pre-trained ResNet-50 model, its top classification layer is replaced, and the source data is used for optimization to obtain an optimized defect classification model;
[0155] S63, the high-dimensional feature vector and the defect area ratio are fused into a comprehensive input feature through feature concatenation, and the comprehensive input feature is input into the optimized defect classification model to output the defect type probability distribution of the current sample;
[0156] S64, Determine the defect type of the current sample based on the probability distribution and the preset type determination threshold;
[0157] S65, Based on the identified defect type and the defect area ratio, and in accordance with the preset grading standard, generate a grading result;
[0158] S66. Based on the grading results, generate an inspection report that includes the defect location, type, size, and confidence level.
[0159] As described in steps S61-S66 above, the present invention first obtains the features of similar defect samples from the historical database as source data for transfer learning, then optimizes the defect classification model through transfer learning based on the pre-trained ResNet-50 model, then integrates the high-dimensional feature vector with the defect area ratio into a comprehensive input feature and inputs it into the model to identify the defect type, and finally combines the defect type and area ratio to generate a grading result and output a detection report, which can realize the accurate identification of defect types and quality grade determination of potato crops.
[0160] Different types of defects in tuber crops (such as rot, sprouting, and mechanical damage) have fundamentally different impacts on quality: rot leads to crop spoilage and loss of edibility; sprouting produces harmful substances such as solanine; and mechanical damage, while not directly producing toxins, accelerates rot. Therefore, this invention first clarifies the defect types, then establishes grading standards based on area proportions, classifies the physical attributes of "defect severity," and combines this with quantitative data on "defect scale" to form an objective quality evaluation basis. Meanwhile, the collection and labeling of defect samples in tuber crops is costly, making it difficult to construct large-scale dedicated datasets. Directly training a defect classification model from scratch is prone to overfitting, resulting in poor model generalization ability. Therefore, this invention utilizes the general feature extraction capabilities of pre-trained models through transfer learning to optimize the model on a small number of dedicated samples.
[0161] Specifically, step S61 involves "obtaining defect sample features of the same category as the current sample from the historical database, which serve as source data for transfer learning. The defect sample features include high-dimensional feature vectors, defect area proportions, and defect types." The core of this step is to provide high-quality, targeted training data for transfer learning, ensuring that the optimized defect classification model can adapt to the current detection task. The historical database needs to be pre-constructed, containing at least several hundred samples of tuber crops with different defect types and severity levels. These samples must be stored according to crop category (e.g., potato, sweet potato, yam, etc.) to avoid cross-category samples interfering with model training. The high-dimensional feature vectors are derived from the principal component feature vectors extracted from historical samples via steps S31-S35. The defect area proportions are derived from the quantification results calculated from historical samples via steps S51-S55. The defect types are manually labeled categories (e.g., "rot," "sprouting," "mechanical damage," "no defects"). These three elements must correspond one-to-one to ensure that the features of each historical sample are associated with the actual defect type. When acquiring source data, it is necessary to filter data from the same category as the current detection sample (e.g., potato samples). For example, if the current detection is of potatoes, source data should be extracted from the "potato" category in the historical database. This avoids using sweet potato sample data to optimize the potato detection model. If cross-category samples are mixed in, the model will learn irrelevant features, reducing classification accuracy. The amount of source data must meet the requirements of transfer learning, typically containing at least 200 labeled samples (with a balanced distribution of samples of each type of defect, such as 50 samples each of rot, sprouting, and mechanical damage, and 50 samples without defects), ensuring that the model can fully learn the defect characteristics of similar crops.
[0162] Next is S62, "Based on the transfer learning strategy, the top classification layer of the pre-trained ResNet-50 model is replaced, and the source data is used for optimization to obtain an optimized defect classification model." The purpose of this step is to adapt the general pre-trained model to a defect classification model specific to potato crops through transfer learning. The ResNet-50 model is a deep convolutional neural network pre-trained on the ImageNet large-scale image dataset (containing 1000 classes of natural images). Its bottom layer (the first 49 layers) contains 5 residual blocks and already possesses powerful general image feature extraction capabilities (such as the extraction of features like edges, textures, and shapes). These capabilities can be transferred to the defect detection scenario of potato crops without needing to train from scratch. Because the output categories of the ImageNet classification task (1000 classes) and the potato defect classification task (usually 4 classes: rot, sprouting, mechanical damage, no defect) are different, the top fully connected classification layer of ResNet-50 needs to be replaced: the fully connected layer with the original model output dimension of 1000 is replaced with a fully connected layer with the same output dimension as the number of target defect categories (e.g., 4 defect categories correspond to an output dimension of 4), and a Softmax activation function is added after this layer to output the probability distribution of each category. The model optimization adopts a "fine-tuning" strategy: the parameters of the bottom layer (first 49 layers) of ResNet-50 are fixed (preserving its general feature extraction capabilities), and only the parameters of the top layer replacement fully connected layer are trained; the high-dimensional feature vectors and defect area proportions in the source data are fused into input features through feature concatenation (e.g., if the length of the high-dimensional feature vector is 3 and the defect area proportion is 1 value, then the length of the input feature is 4), and the set is divided into training and validation sets in a 7:3 ratio; the cross-entropy loss function (measuring the difference between the predicted probability and the true label) is used in the training process, and Adam is selected as the optimizer (the learning rate is set to 1e-4 to avoid parameter oscillation caused by an excessively high learning rate). Iterative training is conducted for 50-100 rounds, and the model accuracy is evaluated using the validation set after each round of training. Training is stopped when the classification accuracy of the validation set is stable above 90%, resulting in the optimized defect classification model.
[0163] Then, step S63, "The high-dimensional feature vector and the defect area ratio are fused into a comprehensive input feature through feature concatenation, and the comprehensive input feature is input into the optimized defect classification model to output the defect type probability distribution of the current sample." The core of this step is to provide the model with more comprehensive input information through multi-feature fusion, thereby improving the accuracy of defect classification. The high-dimensional feature vector is the principal component feature vector extracted from the current sample through steps S31-S35 (e.g., a vector of length 3 [PC1, PC2, PC3]), and the defect area ratio is the quantized result calculated from the current sample through steps S51-S55 (e.g., 0.25%). Feature concatenation combines the two sequentially into a longer vector, for example, after fusion, a comprehensive input feature of length 4 [PC1, PC2, PC3, 0.25%]. This fusion approach simultaneously provides the model with both "defect-specific features" (high-dimensional feature vectors) and "defect severity features" (defect area proportions). These two types of features work synergistically to improve classification accuracy. For example, the high-dimensional feature vectors of dry scars and minor decay are similar, but the defect area proportion of dry scars is usually larger (e.g., 5%), while that of minor decay is smaller (e.g., 0.5%). By fusing the area proportion feature, the model can accurately distinguish between the two types of defects. After inputting the comprehensive input features into the optimized defect classification model, the top fully connected layer and the Softmax activation function output the probability distribution of the current sample belonging to each type of defect. For example, the output might be [0.93, 0.02, 0.04, 0.01], corresponding to the probabilities of "decay," "germination," "mechanical damage," and "no defects," respectively, with the sum of the probability values being 1.
[0164] The next step is S64, "Determine the defect type of the current sample based on the probability distribution and the preset type determination threshold." The purpose of this step is to transform the probability distribution output by the model into a clear defect type label, completing the classification decision. The preset type determination threshold can be set to 0.5 (this can be adjusted according to testing needs; for example, when food safety requirements are high, the threshold for determining rot can be lowered to 0.4 to reduce missed detections). The determination rule is: if the probability value of a certain category in the probability distribution is ≥ the determination threshold, and this probability value is the maximum among all categories, then the current sample is determined to belong to that category; if the probability values of all categories are < the determination threshold, then it is determined to be an "unknown defect," requiring manual verification. For example, if the probability distribution of a sweet potato sample is [0.01, 0.89, 0.08, 0.02], and the probability of the "sprouting" category is 0.89 ≥ 0.5 and is the maximum value, then the defect type is determined to be sprouting; if the probability distribution of a sample is [0.42, 0.38, 0.15, 0.05], and the probability of all categories is < 0.5, then it is determined to be an unknown defect. It should be noted that this step must ensure that the judgment rules are clear and unambiguous to avoid classification errors due to improper threshold settings. For example, when the judgment threshold is lowered from 0.5 to 0.4, the false negative rate of rot defects will decrease, but the false positive rate may increase. The needs of false negatives and false positives need to be balanced according to the actual detection scenario.
[0165] Next is S65, "Based on the identified defect types and the percentage of defect area, generate grading results by comparing with preset grading standards." The core of this step is to transform the defect classification and quantification results into quality grades that meet industry requirements, providing a clear basis for subsequent sorting. The preset grading standards need to be formulated in conjunction with the quality control requirements of the tuber crop industry, clearly defining the grades corresponding to different defect types and different area percentages. For example, the grading standards for potatoes can be set as: Grade 1 (no defects, or only mechanical damage with an area percentage ≤ 3%), Grade 2 (mechanical damage area percentage 3%-10%, or sprouting area percentage ≤ 1%), and Grade 3 (rotten area percentage ≥ 1%, or sprouting area percentage > 1%, or mechanical damage area percentage > 10%). When generating grading results, the defect type must first be determined, and then the corresponding grade must be matched according to the area percentage. For example, if the current sample's defect type is sprouting with an area percentage of 0.8%, it is judged as Grade 2 according to the standard; if the defect type is rot with an area percentage of 0.9%, because rot is highly detrimental to quality, it is still judged as Grade 3 even if the area percentage is small. The grading criteria must be stored in the system before testing to ensure that all samples are graded according to uniform rules and to avoid subjectivity.
[0166] Finally, step S66, "Based on the aforementioned grading results, generate an inspection report containing defect location, type, size, and confidence level," aims to integrate all inspection information and generate a complete and intuitive report, providing directly applicable data support for subsequent sorting execution modules. Specifically, the defect location in the report comes from the high-precision defect mask in step S53, determined by statistically analyzing the center coordinates of the defect's connected regions (e.g., "defect center coordinates (320, 450) pixels, corresponding to the actual location being the middle right side of the sample") or boundary coordinates; the defect type is the result determined in step S64 (e.g., sprouting); the defect size is the total defect area calculated in step S54 (e.g., 0.5 cm²); and the confidence level is the probability of the corresponding type output by the defect classification model (e.g., the probability of the sprouting category is 0.89). The test report can be in text or table format, including information such as sample number, test time, defect location, type, size, confidence level, and grading result. For example, a report might read: "Sample Number: 20010101-001; Test Time: 2001-01-01 01:01; Defect Location: Middle right side of sample; Defect Type: Sprouting; Defect Size: 0.5cm²; Confidence Level: 0.89; Grading Result: Second Grade." The generated report can be output to the subsequent sorting module via an interface. The sorting module allocates samples to corresponding channels based on the grading result (e.g., first-grade samples go to the premium channel, and substandard samples go to the rejection channel), achieving automated sorting.
[0167] Compared to traditional methods, the clear grading rules and complete report information in this step improve the consistency of grading, and the test report can directly support automated sorting, reduce manual intervention, and improve testing efficiency.
[0168] like Figure 2 As shown, this invention also discloses a fluorescence imaging-based system for detecting appearance defects in potato crops, comprising:
[0169] The excitation imaging module is used to irradiate the surface of potato crops with a multi-band fluorescent light source to excite them to produce a specific fluorescence response, and simultaneously acquire fluorescence images and reflection images.
[0170] The preprocessing module is used to perform dark field calibration, noise suppression, and image registration on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair.
[0171] The feature extraction module is used to extract defect-specific features from the registered fluorescence and reflectance image pairs based on fluorescence quenching effect and spectral gradient features, forming a high-dimensional feature vector;
[0172] The feature recognition module is used to input the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjust the weights of different features, and output a defect probability map.
[0173] The defect calculation module is used to locate surface defect regions using an improved image segmentation algorithm based on the defect probability map, and to calculate the defect area ratio.
[0174] The hierarchical output module is used to acquire a historical database, optimize the defect classification model through transfer learning based on the defect sample characteristics in the historical database, identify the defect type from the high-dimensional feature vector using the defect classification model, and generate a hierarchical result and output a detection report based on the defect type and the defect area ratio.
[0175] The present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, characterized in that the processor executes the computer program to implement the steps of a method for detecting appearance defects in potato crops based on fluorescence imaging.
[0176] The present invention also discloses a computer-readable storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the steps of a method for detecting appearance defects in potato crops based on fluorescence imaging.
[0177] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0178] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for detecting appearance defects in potato crops based on fluorescence imaging, characterized in that, include: Multi-band fluorescent light sources were used to irradiate the surface of potato crops, stimulating them to produce specific fluorescent responses, and fluorescent and reflectance images were acquired simultaneously. Dark-field calibration, noise suppression, and image registration are performed on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair. Based on the fluorescence quenching effect and spectral gradient characteristics, defect-specific features are extracted from the registered fluorescence and reflectance image pairs to form a high-dimensional feature vector. The high-dimensional feature vector is input into an adaptive weighted fusion network, and the weights of different features are dynamically adjusted to output a defect probability map. Based on the defect probability map, an improved image segmentation algorithm is used to locate surface defect regions and calculate the defect area ratio. Obtain a historical database, optimize the defect classification model through transfer learning based on the defect sample characteristics in the historical database, identify the defect type from the high-dimensional feature vector using the defect classification model, and generate a classification result and output a detection report based on the defect type and the defect area ratio.
2. The method for detecting appearance defects in potato crops based on fluorescence imaging according to claim 1, characterized in that, The steps of irradiating the surface of potato crops with a multi-band fluorescent light source to excite them to produce a specific fluorescence response, and simultaneously acquiring fluorescence and reflectance images, include: Obtain the light source parameters of a multi-band fluorescence excitation source, wherein the multi-band fluorescence excitation source includes a dual-band LED array of ultraviolet and blue light; Based on the light source parameters, pulse modulation technology is used to excite the potato crop sample to be detected in a time-division excitation mode; According to the time-division excitation mode, an optical filter group is used to simultaneously separate and acquire fluorescence images and reflection images; Based on the fluorescence image and the reflection image, fluorescence spectral data are simultaneously acquired using a fiber optic spectrometer, and the light source parameters are dynamically optimized and adjusted based on the fluorescence spectral data.
3. The method for detecting appearance defects in potato crops based on fluorescence imaging according to claim 1, characterized in that, The step of performing dark-field calibration, noise suppression, and image registration on the fluorescence image and the reflectance image to generate a registered fluorescence and reflectance image pair includes: Based on the fluorescence image and the reflection image, obtain a dark field image and a reference white board image; Based on the dark field and reference whiteboard images, the fluorescence image and the reflection image are respectively calibrated for dark field and corrected for uneven illumination. Noise suppression is performed on the calibrated fluorescence image and the reflection image using a combination of Gaussian filtering and median filtering; The fluorescence image after noise suppression is registered with the reflection image using a feature point-based registration algorithm to obtain a fluorescence-reflection image pair.
4. The method for detecting appearance defects in potato crops based on fluorescence imaging according to claim 1, characterized in that, The step of extracting defect-specific features from the registered fluorescence and reflectance image pairs based on fluorescence quenching effect and spectral gradient characteristics to form a high-dimensional feature vector includes: Based on the fluorescence and reflection image pair, obtain the fluorescence intensity value of each pixel; The fluorescence intensity attenuation coefficient of each pixel is calculated based on the fluorescence intensity value to obtain the fluorescence quenching effect index. Acquire spectral data that matches the fluorescence and reflectance image pair, and obtain spectral gradient features based on the spectral data; An initial feature set is constructed based on the fluorescence quenching effect index and the spectral gradient characteristics. Principal component analysis is then performed on the initial feature set to reduce its dimensionality and obtain the principal component features. Based on the principal component features, a high-dimensional feature vector is constructed for each pixel.
5. The method for detecting appearance defects in potato crops based on fluorescence imaging according to claim 1, characterized in that, The step of inputting the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjusting the weights of different features, and outputting a defect probability map includes: The high-dimensional feature vector is split into a fluorescence feature branch and a reflectance feature branch; An adaptive weighted fusion network with a dual-branch structure is constructed based on the fluorescence feature branch and the reflection feature branch. Convolutional layers are used to perform depth extraction on the fluorescence feature branch and the reflection feature branch respectively to obtain dual-branch depth features. Based on the channel attention module, the dual-branch deep features are transformed into channel descriptors through global average pooling. The first channel attention weight vector and the second channel attention weight vector are calculated through the fully connected layer. The dual-branch features are then weighted to obtain the key channel features. Based on the key channel features, learnable first and second weight parameters are introduced to dynamically calculate the fused feature vector. Based on the fused feature vector, the network performs classification through subsequent layers, outputting a defect probability map of the entire image.
6. The method for detecting appearance defects in potato crops based on fluorescence imaging according to claim 1, characterized in that, The step of locating surface defect regions using an improved image segmentation algorithm based on the defect probability map and calculating the defect area ratio includes: Based on the defect probability map, a confidence threshold is set to generate a preliminary binary defect mask; Based on the defect binary mask, morphological closing operations are used to fill the holes, and opening operations are used to remove noise points with an area smaller than a preset threshold to obtain an optimized mask. The optimized mask is used as prior information input to improve the image segmentation algorithm for fine segmentation. The network parameters are iteratively optimized by calculating Dice Loss to output a high-precision defect mask. Based on the high-precision defect mask, the area of each defect is calculated and summed to obtain the total defect area; The sample surface area is determined based on the edge detection algorithm, and the defect area ratio is obtained based on the total defect area and the sample surface area.
7. The method for detecting appearance defects in potato crops based on fluorescence imaging according to claim 1, characterized in that, The steps of acquiring a historical database, optimizing a defect classification model through transfer learning based on the defect sample features in the historical database, identifying defect types from high-dimensional feature vectors using the defect classification model, and generating a grading result and outputting a detection report based on the defect type and the defect area ratio include: Defect sample features of the same category as the current sample are obtained from the historical database and used as source data for transfer learning. The defect sample features include high-dimensional feature vectors, defect area ratio, and defect type. According to the transfer learning strategy, the top classification layer of the pre-trained ResNet-50 model is replaced, and the source data is used for optimization to obtain an optimized defect classification model. The high-dimensional feature vector and the defect area ratio are fused into a comprehensive input feature through feature concatenation, and the comprehensive input feature is input into the optimized defect classification model to output the defect type probability distribution of the current sample. Based on the probability distribution and the preset type determination threshold, the defect type of the current sample is determined; Based on the identified defect type and the proportion of the defect area, a classification result is generated by comparing it with a preset classification standard; Based on the grading results, an inspection report is generated that includes the defect location, type, size, and confidence level.
8. A fluorescence imaging-based system for detecting appearance defects in potato crops, characterized in that, include: The excitation imaging module is used to irradiate the surface of potato crops with a multi-band fluorescent light source to excite them to produce a specific fluorescence response, and simultaneously acquire fluorescence images and reflection images. The preprocessing module is used to perform dark field calibration, noise suppression, and image registration on the fluorescence image and the reflection image to generate a registered fluorescence and reflection image pair. The feature extraction module is used to extract defect-specific features from the registered fluorescence and reflectance image pairs based on fluorescence quenching effect and spectral gradient features, forming a high-dimensional feature vector; The feature recognition module is used to input the high-dimensional feature vector into an adaptive weighted fusion network, dynamically adjust the weights of different features, and output a defect probability map. The defect calculation module is used to locate surface defect regions using an improved image segmentation algorithm based on the defect probability map, and to calculate the defect area ratio. The hierarchical output module is used to acquire a historical database, optimize the defect classification model through transfer learning based on the defect sample characteristics in the historical database, identify the defect type from the high-dimensional feature vector using the defect classification model, and generate a hierarchical result and output a detection report based on the defect type and the defect area ratio.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.