Post-production garlic slice state detection method based on image processing

Through multi-image acquisition and synchronous alignment, dynamic fractional-order differential enhancement, multi-scale topological constrained segmentation and cascaded hybrid attention classification, the problems of low efficiency and insufficient accuracy in post-production garlic slice detection are solved, and high-precision and strong robust detection effects are achieved.

CN120635538AActive Publication Date: 2025-09-12CHIPING SHENGKANG FOODSTUFF CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510700434.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-09-12
Estimated Expiration
2045-05-28

AI Technical Summary

Technical Problem

Existing technologies for post-production garlic slice inspection suffer from low efficiency, high missed detection rates, and rising costs. Furthermore, traditional automation technologies struggle to achieve high-precision and robust detection in complex scenarios. In particular, single RGB imaging struggles to penetrate the surface to detect internal mold, and fixed threshold segmentation lacks accuracy for detecting stuck garlic slices.

Method used

Multi-image acquisition and synchronous alignment are used, combined with dynamic fractional differential enhancement and image fusion, for multi-scale topological constrained segmentation. Through cascaded hybrid attention classification, cross-modal data complementation is achieved using RGB and near-infrared images. FPGA is used to trigger camera synchronous shooting, and cascade classification is performed using the U-Net network, lightweight XGBoost model, and MobileNetV3 model.

Benefits of technology

It achieves high-precision and strong robust detection of the status of garlic slices after production, eliminates detection blind spots, improves detection accuracy and the ability to adapt to complex environments, and meets the high-precision detection needs of the food processing industry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120635538A_ABST
    Figure CN120635538A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of garlic detection application, and particularly relates to a post-production garlic slice state detection method based on image processing, which comprises the steps of multi-image acquisition and synchronous alignment, dynamic fractional order differential enhancement and image fusion, multi-scale topological constraint segmentation and cascade mixed attention classification. By collecting the RGB image reflecting the surface color and the near-infrared image reflecting the internal reflectivity, cross-modal data complementation is achieved, and a detection blind area is eliminated. Image edges and details are enhanced through dynamic fractional order differential, an enhanced area is flexibly adjusted, and adhesion garlic slices are correctly separated through multi-scale topological constraint segmentation. According to the cascade mixed attention classification design, the first layer adopts a lightweight XGBoost model for rapid filtering, and the second layer adopts a MobileNetV3 and an attention mechanism, so that the overall calculation amount is reduced while the precision is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of garlic detection applications, and in particular relates to a method for detecting the state of garlic slices after production based on image processing. Background Art

[0002] Garlic slices are a widely consumed food ingredient worldwide, and their quality after processing directly impacts food safety and commercial value. The main defects that require post-production inspection include surface defects (mold, breakage, discoloration) with a high false positive rate, internal defects such as insect infestation (undetectable by traditional methods), moisture abnormalities, and foreign contamination such as metal fragments and hair.

[0003] Currently, post-production quality inspection of garlic slices relies primarily on manual visual inspection, which faces core challenges such as low efficiency, high missed detection rates, and escalating costs. Traditional automated technologies, while partially incorporating computer vision, face multiple bottlenecks in complex scenarios: single RGB imaging struggles to penetrate the surface to detect internal mold, and fixed threshold segmentation lacks accuracy for clinging garlic slices. While technologies like multispectral imaging and dynamic morphological optimization have shown promise, existing solutions still suffer from systemic flaws such as data dimensionality fragmentation, lack of topological constraints, and model rigidity. These factors have resulted in overall accuracy rates consistently hovering below 90%, failing to meet the food processing industry's urgent need for high-precision, robust detection. Summary of the Invention

[0004] Aiming at the technical problems existing in the detection of the status of garlic slices after production, the present invention proposes a method for detecting the status of garlic slices after production based on image processing, which has a reasonable design, a simple method, strong theoretical basis and can achieve high-precision and strong robustness in the detection of the status of garlic slices after production.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is: a method for detecting the state of garlic slices after production based on image processing, comprising the following steps:

[0006] S1. Multi-image acquisition and synchronous alignment, synchronous triggering of RGB and near-infrared cameras to shoot garlic slices after production, and obtain RGB images of surface color I RGB and near-infrared image of internal reflectivity I NIR ;

[0007] S2, dynamic fractional order differential enhancement and image fusion, using dynamic fractional order differential enhancement I RGB Image edges and details, flexible adjustment of enhancement area, enhanced image The formula is:

[0008]

[0009] Among them, x represents the horizontal position of the pixel in the RGB image, y represents the vertical position of the pixel in the RGB image, and IRGB (x, y) represents the pixel value of the RGB image at the (x, y) position, α(x, y) represents the differential order dynamically adjusted at the (x, y) position of the RGB image, K represents the maximum neighborhood radius, and k represents the neighborhood pixel offset. Indicates the differential operation in the x direction with the order of α(x, y), I RGB (xk, y) represents the pixel value at the position (xk, y) of the RGB image, represents the gradient-based adaptive weight, represents the neighborhood weight distribution coefficient, and The formula is:

[0010]

[0011] in, Represents the (xk, y) position gradient, k represents the neighborhood pixel offset, α(x, y) represents the differential order dynamically adjusted at the (x, y) position of the RGB image, and I NIR Upsampled to 2448×2048 resolution with I RGB By enhancing the image R channel, enhanced image G channel and I NIR Construct a fused image F;

[0012] S3. Multi-scale topological constraint segmentation and construction of topological loss function:

[0013]

[0014] Among them, S represents the number of multi-scale levels, 1≤S≤5, s represents the scale level, λ s represents the loss weight of the s-th scale level, represents the number of connected regions at the s-th scale level, represents the number of target connected regions at the s-th scale level, represents the holes at the s-th scale level, represents the target hole at the s-th scale level, λ s The formula is:

[0015] λ s =2 -(s-1)

[0016] Among them, s represents the scale level, and the topological loss function L MT Adding the cross entropy loss function of the U-Net network gives the total loss function L:

[0017] L=0.5L MT +0.5L CE

[0018] Among them, L MT is the topological loss function, L CE is the cross entropy loss function, and the U-Net network based on the total loss function segments the fused image F and outputs the segmented garlic slice regions;

[0019] S4, cascade hybrid attention classification, extracts the 4-dimensional texture features of each segmented garlic slice area, the average value of spectral information, the color mean of the R channel, and the color mean of the G channel to form a 7-dimensional feature vector. The first-level XGBoost model outputs the four classification probabilities of the sample. If one classification probability is greater than 0.98, the classification is directly output. Otherwise, it enters the second-level MobileNetV3 model based on channel and spatial hybrid attention to output the classification result.

[0020] As a preference, the step S1 triggers the dual cameras to shoot synchronously via FPGA, L RGB The resolution is 2560×2048, 8-bit color depth, I NIR The wavelength is 850nm and the resolution is 1280×1024.

[0021] Preferably, the four-dimensional texture features in step S5 are GLCM contrast, energy, entropy and correlation, and the four categories are normal, moldy, damaged and impurities.

[0022] Compared with existing technologies, the advantages and positive effects of the present invention are as follows: The present invention implements an image processing-based method for detecting the state of post-production garlic slices through multi-image acquisition and synchronous alignment, dynamic fractional-order differential enhancement and image fusion, multi-scale topologically constrained segmentation, and cascaded hybrid attention classification. By acquiring RGB images reflecting surface color and near-infrared images reflecting internal reflectivity, cross-modal data complementation is achieved, eliminating detection blind spots. Dynamic fractional-order differentials are used to enhance image edges and details, allowing for flexible adjustment of the enhancement area. Multi-scale topologically constrained segmentation ensures the correct separation of stuck garlic slices. The cascaded hybrid attention classification design uses a lightweight XGBoost model for fast filtering in the first layer, and MobileNetV3 and the attention mechanism are used in the second layer to reduce overall computational complexity while ensuring accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0024] Figure 1This is a flow chart of a method for detecting the status of garlic slices after production based on image processing provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described below in conjunction with the accompanying drawings and embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features therein can be combined with each other.

[0026] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways than those described herein. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0027] Examples, such as Figure 1 As shown, current post-production quality inspection of garlic slices relies primarily on manual visual inspection, which faces core challenges such as low efficiency, high missed detection rates, and escalating costs. While traditional automated technologies partially utilize computer vision, they face multiple bottlenecks in complex scenarios: single RGB imaging struggles to penetrate the surface to detect internal mold, and fixed threshold segmentation lacks accuracy for clinging garlic slices. While technologies such as multispectral imaging and dynamic morphological optimization have shown promise, existing solutions still suffer from systemic flaws such as data dimensionality fragmentation, lack of topological constraints, and model rigidity. These results have resulted in overall accuracy rates consistently hovering below 90%, failing to meet the food processing industry's urgent need for high-precision, robust inspection. Considering that near-infrared light can penetrate the epidermis to detect internal mold, RGB can detect surface damage, and near-infrared can detect internal defects, RGB cameras (capturing surface color and texture) and near-infrared cameras (detecting internal reflectivity differences) enable comprehensive inspection from the outside in. Therefore, the present invention proposes a method for detecting the status of garlic slices after production based on image processing. The FPGA (field programmable gate array) directly generates a trigger signal through a hardware circuit, which can achieve nanosecond synchronization error (usually <100ns), ensuring that the RGB and near-infrared cameras are strictly synchronized for shooting. Compared with software triggering (delay of about 1-10ms) or microcontrollers (delay of about 1μs-1ms), the hardware parallelism of the FPGA completely eliminates the uncertainty brought by the operating system scheduling and software stack. First, multiple images are collected and synchronized, and the RGB and near-infrared cameras are synchronously triggered to shoot the garlic slices after production to obtain the RGB image of the surface color. RGB and near-infrared image of internal reflectivity I NIR Specifically, FPGA is used to trigger the dual cameras to shoot synchronously. RGB The resolution is 2560×2048, 8-bit color depth, I NIR The wavelength is 850nm and the resolution is 1280×1024.

[0028] Fractional differentials are a special form of calculus that can handle non-integer derivatives and integrals. They are widely used in fields such as signal processing and image processing. In image enhancement, fractional differentials can be used to capture detailed information within an image. Mathematical methods are used to highlight edges and details in garlic slice processing. For example, adjusting parameters can make moldy areas in a photo more visible. While conventional methods can only enhance fixed areas, fractional differentials allow for flexible adjustment of the enhanced area (for example, focusing on dark moldy spots). Dynamic fractional differential enhancement, by adaptively adjusting the differential order, can more flexibly capture local signal details, suppress noise, and improve the accuracy and robustness of complex system modeling.

[0029] Considering that surface color changes in garlic slices (such as mold, oxidation, or drying) are most pronounced in the R channel (red band), moldy areas typically appear brown or black, with stronger absorption in the red band, making the reflectance difference in the R channel more pronounced. Yellowing or darkening due to drying or oxidation creates a higher contrast between the R and G channels. The G channel (green band) is sensitive to changes in chlorophyll and plant tissue, reflecting the freshness or physiological state of the garlic slices. The B channel (blue band) contributes less to garlic slice surface detection. The blue band is susceptible to interference from ambient light (such as uneven lighting or shadows) and is subject to high noise. The reflectance difference in the blue band is smaller, resulting in high information redundancy. Near-infrared images already contain information related to moisture and internal structure (such as cell rupture or mold penetration), which may overlap some of the functionality of the B channel, avoiding redundant enhancement. RGB images directly reflect surface defects such as mold, discoloration, and damage, making them suitable for detail localization (such as edge detection). The internal structure information of near-infrared images can penetrate the surface to detect internal moisture distribution, cell damage or mildew penetration, and is not affected by surface reflections or slight contamination, making it more robust.

[0030] Therefore, dynamic fractional order differential enhancement and image fusion are used to enhance the image quality. RGB (x,y) image edges and details, flexible adjustment of enhancement area, enhanced image The formula is:

[0031]

[0032] Among them, x represents the horizontal position of the pixel in the RGB image, y represents the vertical position of the pixel in the RGB image, and I RGB (x, y) represents the pixel value of the RGB image at the (x, y) position, α(x, y) represents the differential order dynamically adjusted at the (x, y) position of the RGB image, K represents the maximum neighborhood radius, and k represents the neighborhood pixel offset. Indicates the differential operation in the x direction with the order of α(x, y), I RGB (xk, y) represents the pixel value at the position (xk, y) of the RGB image, represents the gradient-based adaptive weight, represents the neighborhood weight distribution coefficient, and The formula is:

[0033]

[0034] in, Represents the (xk, y) position gradient, k represents the neighborhood pixel offset, α(x, y) represents the differential order dynamically adjusted at the (x, y) position of the RGB image, and I NIR Upsampled to 2448×2048 resolution with I RGB By enhancing the image R channel, enhanced image G channel and I NIR Construct the fused image F.

[0035] Topological data analysis guides segmentation to handle stacked garlic slices and unclear boundaries, ensuring each slice is completely separated. The system calculates the number of garlic slices in the photo and automatically adjusts segmentation parameters if too many or too few are found. This ensures that the segmented garlic slices are free of holes and have the same number as the actual slices. This ensures that stuck garlic slices are correctly separated. By matching the number of holes, the correct internal structure (such as surface defects or moldy areas) is ensured. Topological constraints significantly improve the legibility of segmentation results in scenarios where garlic slices are stuck together, have blurred edges, or have internal damage.

[0036] Therefore, multi-scale topological constraint segmentation is performed to construct a topological loss function:

[0037]

[0038] Among them, S represents the number of multi-scale levels, 1≤S≤5, s represents the scale level, λ s represents the loss weight of the s-th scale level, represents the number of connected regions at the s-th scale level, represents the number of target connected regions at the s-th scale level, Holes at the s-th scale level, represents the target hole at the s-th scale level, λ s The formula is:

[0039] λ s =2 -(s-1)

[0040] Among them, s represents the scale level, and the topological loss function L MT Adding the cross entropy loss function of the U-Net network gives the total loss function L:

[0041] L=0.5L MT +0.5L CE

[0042] Among them, L MT is the topological loss function, L CE is the cross entropy loss function, and the U-Net network based on the total loss function segments the fused image F and outputs the segmented garlic slice regions.

[0043] Given XGBoost's sensitivity to explicit patterns (such as color thresholds and texture statistics), it is suitable for high-confidence samples. MobileNetV3 uses convolution to learn implicit features (such as the microtexture of moldy edges and the irregular shapes of damaged parts) to address fuzzy boundaries. The two-stage model makes independent decisions, allowing XGBoost misclassifications (such as misclassifying impurities as damage) to be corrected by the second-stage model, reducing the overall error rate. Multi-scale topological constraints in the segmentation stage ensure complete segmentation of the garlic slice region, avoiding feature extraction bias caused by region truncation (such as segmenting only half a garlic slice) during the classification stage. Cascaded hybrid attention classification achieves high-speed response in garlic slice status detection through efficiency-accuracy hierarchical decision-making and multimodal feature complementarity: XGBoost quickly filters simple samples to meet production line cycle requirements. MobileNetV3 and attention use fine-grained discrimination to overcome complex cases and improve classification accuracy. The dual-model synergy reduces the risk of single-model failure and adapts to industrial environmental disturbances.

[0044] The channel attention mechanism dynamically enhances key feature channels and suppresses noise, while the spatial attention mechanism precisely locates the target area and reduces background interference. The two mechanisms work together to optimize feature representation, balancing efficiency and accuracy. In the garlic slice state classification task, the hybrid attention mechanism significantly improves the model's sensitivity to subtle defects, adaptability to complex environments, and real-time processing efficiency through dual-dimensional "channel-space" optimization. It is the core technical foundation for the cascade classification system to achieve high accuracy and low latency. Channel attention dynamically learns channel weights through global average pooling and fully connected layers, prioritizing feature channels related to defects. For example, in mold detection, the R channel (reduced reflectivity in moldy areas) and near-infrared spectral features are given higher weights. Spatial attention, through convolution, generates a two-dimensional spatial weight map to precisely locate defect areas (such as mold spot centers and damaged edges) while avoiding interference from intact areas or background noise. The synergistic effect of the two enables the model to adaptively focus on key information and improve sensitivity to subtle defects (such as early mold growth and fine cracks). MobileNetV3 itself uses Neural Architecture Search (NAS) to optimize its network structure, introducing efficient inverted residual blocks and h-swish activation functions. This allows it to maintain high inference speed with only 1 / 10 the number of parameters of traditional CNNs. The hybrid attention module significantly improves feature expression capabilities while adding only a small amount of computation. The hybrid attention mechanism effectively addresses industrial environment challenges such as uneven lighting and partial occlusion by dynamically calibrating feature responses. For example, in highly reflective scenes, spatial attention can suppress invalid features in overexposed areas, while channel attention enhances near-infrared spectral information to compensate for distortion in the visible light channel. For clinging garlic slices, the attention mechanism can separate the target area from adjacent interference, ensuring the independence of feature extraction.

[0045] Therefore, a cascaded hybrid attention classification is performed. The 4-dimensional texture features, spectral average, R channel color mean, and G channel color mean of each segmented garlic slice are extracted to form a 7-dimensional feature vector. The first-level XGBoost model outputs four classification probabilities for the sample. If a classification probability is greater than 0.98, that classification is directly output. Otherwise, the second-level MobileNetV3 model, based on channel- and spatial-hybrid attention, outputs the classification result. Specifically, the 4-dimensional texture features are GLCM contrast, energy, entropy, and correlation, and the four classifications are normal, moldy, damaged, and impurities.

[0046] The above description is merely a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any person skilled in the art may utilize the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes for application in other fields. However, any simple modification, equivalent change, and modification of the above embodiments made in accordance with the technical essence of the present invention without departing from the technical solution of the present invention shall still fall within the scope of protection of the technical solution of the present invention.

Claims

1. A method for detecting the state of garlic slices after production based on image processing, characterized in that: The steps include: S1. Multi-image acquisition and synchronous alignment, synchronous triggering of RGB and near-infrared cameras to shoot garlic slices after production, and obtain RGB images of surface color I RGB and near-infrared image of internal reflectivity I NIR ; S2, dynamic fractional order differential enhancement and image fusion, using dynamic fractional order differential enhancement I RGB Image edges and details, flexible adjustment of enhancement area, enhanced image The formula is: Among them, x represents the horizontal position of the pixel in the RGB image, y represents the vertical position of the pixel in the RGB image, and I RGB (x,y) represents the pixel value of the RGB image at the (x,y) position, α(x,y) represents the differential order dynamically adjusted at the (x,y) position of the RGB image, K represents the maximum neighborhood radius, and k represents the neighborhood pixel offset. Indicates the differential operation in the x direction with the order of α(x,y), I RGB (xk,y) represents the pixel value at the (xk,y) position of the RGB image, represents the gradient-based adaptive weight, represents the neighborhood weight distribution coefficient, and The formula is: in, Represents the (xk, y) position gradient, k represents the neighborhood pixel offset, α(x, y) represents the differential order dynamically adjusted at the (x, y) position of the RGB image, and I NIR Upsampled to 2448×2048 resolution with I RGB By enhancing the image R channel, enhanced image G channel and I NIR Construct a fused image F; S3. Multi-scale topological constraint segmentation and construction of topological loss function: Among them, S represents the number of multi-scale levels, 1≤S≤5, s represents the scale level, λ s represents the loss weight of the s-th scale level, represents the number of connected regions at the s-th scale level, represents the number of target connected regions at the s-th scale level, represents the holes at the s-th scale level, represents the target hole at the s-th scale level, λ s The formula is: l s =2 -(s-1) Among them, s represents the scale level, and the topological loss function L MT Adding the cross entropy loss function of the U-Net network gives the total loss function L: L=0.5L MT +0.5L CE Among them, L MT is the topological loss function, L CE is the cross entropy loss function, and the U-Net network based on the total loss function segments the fused image F and outputs the segmented garlic slice regions; S4, cascade hybrid attention classification, extracts the 4-dimensional texture features of each segmented garlic slice area, the average value of spectral information, the color mean of the R channel, and the color mean of the G channel to form a 7-dimensional feature vector. The first-level XGBoost model outputs the four classification probabilities of the sample. If one classification probability is greater than 0.98, the classification is directly output. Otherwise, it enters the second-level MobileNetV3 model based on channel and spatial hybrid attention to output the classification result.

2. The method for detecting the state of garlic slices after production based on image processing according to claim 1, wherein: The S1 step triggers the dual cameras to shoot synchronously through FPGA, I RGB The resolution is 2560×2048, 8-bit color depth, I NIR The wavelength is 850nm and the resolution is 1280×1024.

3. The method for detecting the state of garlic slices after production based on image processing according to claim 1, wherein: The four-dimensional texture features in step S5 are GLCM contrast, energy, entropy, and correlation, and the four categories are normal, moldy, damaged, and impurities.

Citation Information

Patent Citations

  • Foggy weather image enhancement method based on fractional differential and dark channel prior

    CN107358585A

  • Wheat growth period nutrient information detection method

    CN114252406A

  • Image processing method and black garlic production quality online detection system applying same

    CN116824586A

  • Arterial aneurysm 3D point cloud automatic segmentation method combined with geometric topology analysis

    CN119379721A

  • Kernal approximation on fractional differential operator for edge detection

    US20180315198A1