An image processing-based post-production garlic slice state detection method

By employing multi-image acquisition and synchronous alignment, dynamic fractional derivative enhancement, multi-scale topological constraint segmentation, and cascaded hybrid attention classification, the problems of low efficiency and high false negative rate in traditional detection methods are solved, achieving high-precision and robust post-production garlic slice state detection, adaptable to complex industrial environments.

CN120635538BActive Publication Date: 2026-01-27CHIPING SHENGKANG FOODSTUFF CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing technologies for detecting garlic slices after production suffer from low efficiency, high false negative rates, and rising costs. Furthermore, traditional automated technologies struggle to achieve high-precision and robust detection in complex scenarios. In particular, single RGB imaging is insufficient to penetrate the surface and detect internal mold growth, and fixed threshold segmentation is not accurate enough for sticky garlic slices.

Method used

Multi-image acquisition and synchronous alignment are employed, combined with dynamic fractional derivative enhancement and image fusion, to perform multi-scale topological constraint segmentation. Cascaded hybrid attention classification is used to detect surface color using RGB images and internal reflectivity using near-infrared images, and high-precision classification is achieved by combining XGBoost and MobileNetV3 models.

Benefits of technology

It achieves high-precision and robust post-production garlic slice condition detection, eliminates detection blind spots, improves detection efficiency and accuracy, reduces computational load, and adapts to complex industrial environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120635538B_ABST
    Figure CN120635538B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of garlic detection application, and particularly relates to a production post garlic slice state detection method based on image processing, which comprises 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 acquiring RGB images reflecting surface color and near-infrared images reflecting internal reflectivity, cross-modal data complementation is realized, and detection blind spots are eliminated. The image edges and details are enhanced by dynamic fractional order differential, the enhanced area is flexibly adjusted, and the multi-scale topological constraint segmentation makes the adhered garlic slices correctly separated. The cascade mixed attention classification design adopts a lightweight XGBoost model for rapid filtering in the first layer, and the MobileNetV3 and attention mechanism are enabled in the second layer to reduce the overall calculation amount while ensuring the accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of garlic detection application technology, and in particular relates to a method for detecting the state of garlic slices after production based on image processing. Background Technology

[0002] As a widely consumed food ingredient globally, the quality of garlic slices after processing directly impacts food safety and commercial value. The main defects that need to be detected in garlic slices after production include: surface defects (mold, damage, discoloration) with a high false detection rate; internal defects such as insect infestation (which cannot be detected by traditional methods) and abnormal moisture content; and foreign matter contamination such as metal fragments and hair.

[0003] Currently, quality inspection of garlic slices after production mainly relies on manual visual inspection, which faces core problems such as low efficiency, high false negative rate, and rising costs. Although traditional automation technology partially utilizes computer vision, it faces multiple bottlenecks in complex scenarios: single RGB imaging is insufficient to penetrate the surface to detect internal mold, and fixed threshold segmentation is not accurate enough for sticky garlic slices. Although technologies such as multispectral imaging and dynamic morphological optimization have shown potential, existing solutions still suffer from systemic defects such as fragmented data dimensions, lack of topological constraints, and rigid models, resulting in an overall accuracy rate that has long hovered below 90%, failing to meet the urgent needs of the food processing industry for high-precision and robust inspection. Summary of the Invention

[0004] This invention addresses the technical problems existing in the detection of the state of garlic slices after production by proposing an image processing-based method for detecting the state of garlic slices after production. This method is reasonably designed, simple, theoretically sound, and can achieve high precision and strong robustness in detecting the state of garlic slices after production.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: 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: Simultaneously trigger RGB and near-infrared cameras to capture images of garlic slices after production, obtaining RGB images of the surface color. RGB Near-infrared image of internal reflectivity I NIR ;

[0007] S2. Dynamic fractional-order differential enhancement and image fusion, utilizing dynamic fractional-order differential enhancement I RGB Image edges and details, flexible adjustment of enhancement areas to enhance the image. The formula is:

[0008]

[0009] Where x represents the horizontal position of a pixel in the RGB image, y represents the vertical position of a pixel in the RGB image, and IRGB (x, y) represents the pixel value at position (x, y) in the RGB image, α(x, y) represents the derivative order of the dynamic adjustment at position (x, y) in the RGB image, K represents the maximum neighborhood radius, and k represents the neighborhood pixel offset. I represents the differential operation of order α(x, y) in the x-direction. RGB (xk, y) represents the pixel value at position (xk, y) in the RGB image. This represents gradient-based adaptive weights. Represents the neighborhood weight allocation coefficient. and The formula is:

[0010]

[0011] in, Let I represent the gradient at position (xk, y), where k represents the offset of neighboring pixels, and α(x, y) represents the derivative order of the dynamic adjustment at position (x, y) in the RGB image. NIR Upsampled to 2448×2048 resolution and I RGB To address this, by enhancing the image R channel, enhanced image G channel and I NIR Construct the fused image F;

[0012] S3. Multi-scale topological constraint segmentation, constructing the topological loss function:

[0013]

[0014] Where S represents the number of multi-scale levels, 1≤S≤5, s represents the scale level, and λ s This represents the loss weight at the s-th scale level. This represents the number of connected regions at the s-th scale level. This represents the number of target connected regions at the s-th scale level. This represents the hole 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] Where s represents the scale level, and the topological loss function L... MT Adding the cross-entropy loss function to the U-Net network yields the total loss function L:

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

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

[0019] S4. Cascaded hybrid attention classification: Extract the 4D texture features, average spectral information, average R-channel color value, and average G-channel color value of each segmented garlic slice region to form a 7D feature vector. The first-level XGBoost model outputs the four classification probabilities of the sample. If any 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] Preferably, step S1 triggers simultaneous shooting by dual cameras via FPGA. RGB The resolution is 2560×2048, with 8-bit color depth. NIR The wavelength is 850nm and the resolution is 1280×1024.

[0021] Preferably, the 4D 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 this invention are as follows: This invention implements a post-production garlic slice state detection method based on image processing through multi-image acquisition and synchronous alignment, dynamic fractional-order differential enhancement and image fusion, multi-scale topological constraint segmentation, and cascaded hybrid attention classification. By acquiring RGB images reflecting surface color and near-infrared images reflecting internal reflectivity, cross-modal data complementarity is achieved, eliminating detection blind spots. Dynamic fractional-order differential enhancement is used to enhance image edges and details, flexibly adjusting the enhancement area, and multi-scale topological constraint segmentation ensures the correct separation of adhered garlic slices. The cascaded hybrid attention classification design uses a lightweight XGBoost model for fast filtering in the first layer, and enables MobileNetV3 and attention mechanisms in the second layer to reduce the overall computational load while maintaining accuracy. Attached Figure Description

[0023] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1A flowchart of a post-production garlic slice status detection method based on image processing provided in an embodiment of the present invention. Detailed Implementation

[0025] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.

[0026] Numerous specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways than those described herein, and therefore the invention is not limited to the specific embodiments disclosed in the following specification.

[0027] Examples, such as Figure 1 As shown, current quality inspection of garlic slices after production mainly relies on manual visual inspection, facing core problems such as low efficiency, high false negative rate, and rising costs. While traditional automation 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 adhered garlic slices. Although multispectral imaging and dynamic morphological optimization technologies have shown potential, existing solutions still suffer from systemic defects such as fragmented data dimensions, lack of topological constraints, and rigid models, resulting in overall accuracy 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 skin to detect internal mold, RGB can detect surface damage, and near-infrared can detect internal defects, an RGB camera (capturing surface color and texture) and a near-infrared camera (detecting internal reflectivity differences) achieve comprehensive inspection "from the surface inwards." Therefore, this invention proposes a post-production garlic slice state detection method based on image processing. An FPGA (Field-Programmable Gate Array) directly generates trigger signals through hardware circuitry, achieving nanosecond-level synchronization error (typically <100ns), ensuring strict synchronization between RGB and near-infrared cameras. Compared to software triggering (delay approximately 1-10ms) or microcontrollers (delay approximately 1μs-1ms), the hardware parallelism of the FPGA completely eliminates the uncertainties introduced by operating system scheduling and software stacks. Firstly, multiple images are acquired and synchronized, synchronously triggering RGB and near-infrared cameras to capture images of post-production garlic slices, obtaining the RGB image of the surface color. RGB Near-infrared image of internal reflectivity I NIR Specifically, it uses an FPGA to trigger simultaneous shooting by dual cameras. RGB The resolution is 2560×2048, with 8-bit color depth. NIR The wavelength is 850nm and the resolution is 1280×1024.

[0028] Fractional derivatives, a special form of calculus, can handle derivatives and integrals of non-integer order and are widely used in signal processing, image processing, and other fields. In image enhancement, fractional derivatives can be used to capture detailed information in an image. For example, in garlic slice processing, mathematical methods are used to highlight edges and details. Ordinary methods can only enhance fixed areas, while fractional derivatives can flexibly adjust the enhancement area (e.g., focusing on dark spots of mold). Dynamic fractional derivative enhancement, by adaptively adjusting the derivative order, can more flexibly capture local signal details, suppress noise, and improve the accuracy and robustness of complex system modeling.

[0029] Considering that color changes on garlic slices (such as mold, oxidation, or drying) are significantly reflected in the R channel (red band): moldy areas are usually brown or black, with strong absorption in the red band, making the reflectance difference in the R channel more obvious; drying or oxidation causes yellowing or darkening, resulting in 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 garlic slices; the B channel (blue band) contributes less to garlic slice surface detection; the blue band is easily affected by ambient light interference (such as uneven lighting or shadows), resulting in significant noise. The reflectance difference of garlic slice surface color in the blue band is relatively small, leading to high information redundancy. Near-infrared images already contain information related to moisture and internal structure (such as cell rupture or mold penetration), which may cover some functions of the B channel, thus avoiding redundant enhancement. RGB images: directly reflect apparent defects such as mold spots, discoloration, and damage, suitable for detailed localization (such as edge detection). Near-infrared imaging can penetrate the surface to detect internal moisture distribution, cell damage, or mold penetration, and is not affected by surface reflection or slight contamination, making it more robust.

[0030] Therefore, dynamic fractional-order differential enhancement and image fusion utilize dynamic fractional-order differential enhancement I. RGB (x,y) Image edges and details, flexibly adjust the enhancement area to enhance the image. The formula is:

[0031]

[0032] Where x represents the horizontal position of a pixel in the RGB image, y represents the vertical position of a pixel in the RGB image, and I RGB (x, y) represents the pixel value at position (x, y) in the RGB image, α(x, y) represents the derivative order of the dynamic adjustment at position (x, y) in the RGB image, K represents the maximum neighborhood radius, and k represents the neighborhood pixel offset. I represents the differential operation of order α(x, y) in the x-direction. RGB (xk, y) represents the pixel value at position (xk, y) in the RGB image. This represents gradient-based adaptive weights. Represents the neighborhood weight allocation coefficient. and The formula is:

[0033]

[0034] in, Let I represent the gradient at position (xk, y), where k represents the offset of neighboring pixels, and α(x, y) represents the derivative order of the dynamic adjustment at position (x, y) in the RGB image. NIR Upsampled to 2448×2048 resolution and I RGB To address this, by enhancing the image R channel, enhanced image G channel and I NIR Construct the fused image F.

[0035] Topological data analysis guides the segmentation of stacked garlic slices where boundaries are indistinguishable. It ensures each slice is completely separated, calculates the number of slices in the image, and automatically adjusts segmentation parameters if too many or too few are found. The segmented slices must be free of holes, and the number must match the actual number. This ensures the correct separation of adhered garlic slices. By matching the number of holes, it ensures the accuracy of the internal structure (such as surface defects or internal mold areas). In scenarios where garlic slices are adhered, have blurred edges, or contain internal damage, topological constraints significantly improve the reasonableness of the segmentation results.

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

[0037]

[0038] Where S represents the number of multi-scale levels, 1≤S≤5, s represents the scale level, and λ s This represents the loss weight at the s-th scale level. This represents the number of connected regions at the s-th scale level. This 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] Where s represents the scale level, and the topological loss function L... MT Adding the cross-entropy loss function to the U-Net network yields the total loss function L:

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

[0042] Among them, L MT Let L be the topological loss function. CE Using the cross-entropy loss function, the U-Net network based on the total loss function segments the fused image F, outputting the segmented garlic-shaped regions.

[0043] Considering XGBoost's sensitivity to explicit patterns (such as color thresholds and texture statistics), it is suitable for high-confidence samples. MobileNetV3 learns implicit features through convolution (such as the microscopic texture of moldy edges and the irregular shape of damaged areas) to handle ambiguous boundary problems. The two-level models make independent decisions; misclassifications by XGBoost (such as misclassifying impurities as damaged areas) can be corrected by the second-level 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 of the garlic slice) in the classification stage. Cascaded hybrid attention classification achieves high-speed response in garlic slice state detection through efficiency-accuracy hierarchical decision-making and multimodal feature complementarity: XGBoost quickly filters simple samples, meeting production line cycle requirements. Fine discrimination by MobileNetV3 and attention tackles complex cases, improving classification accuracy. The system is robust; the dual-model collaboration reduces the risk of single-model failure and adapts to industrial environmental disturbances.

[0044] Channel attention dynamically enhances key feature channels and suppresses noise, while spatial attention accurately locates target regions and reduces background interference. The combination of these two mechanisms synergistically optimizes feature representation, balancing efficiency and accuracy. In garlic slice state classification tasks, the hybrid attention mechanism, through dual-dimensional optimization of "channel-space," significantly improves the model's sensitivity to subtle defects, adaptability to complex environments, and real-time processing efficiency. It is a core technological guarantee for achieving high accuracy and low latency in cascaded classification systems. Channel attention dynamically learns the weights of each channel through global average pooling and fully connected layers, prioritizing the enhancement of feature channels related to defects. For example, in mold detection, the R channel (reflectivity decreases in moldy areas) and near-infrared spectral features are given higher weights. Spatial attention generates a two-dimensional spatial weight map through convolution, accurately locating defect regions (such as mold centers or damaged edges) and avoiding interference from intact regions or background. The synergistic effect of both mechanisms enables the model to adaptively focus on key information, improving sensitivity to minor defects (such as early mold growth or fine cracks). MobileNetV3 employs Neural Architecture Search (NAS) to optimize its network structure, introducing efficient inverted residual blocks and the h-swish activation function, maintaining high inference speed while having only one-tenth the number of parameters of traditional CNNs. The hybrid attention module adds only a small amount of computation but significantly improves feature representation capabilities. The hybrid attention mechanism effectively addresses challenges in industrial environments such as uneven lighting and local 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 adhered garlic slices, the attention mechanism can separate the target region from adjacent interference, ensuring the independence of feature extraction.

[0045] Therefore, a cascaded hybrid attention classification process is performed to extract the 4D texture features, average spectral information, average R-channel color value, and average G-channel color value of each segmented garlic slice region, forming a 7D feature vector. The first-stage XGBoost model outputs the four classification probabilities of the sample. If any classification probability is greater than 0.98, that classification is directly output; otherwise, the second-stage MobileNetV3 model based on channel and spatial hybrid attention outputs the classification result. Specifically, the 4D texture features are GLCM contrast, energy, entropy, and correlation; the four classifications are normal, moldy, damaged, and impurities.

[0046] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments for application in other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A method for detecting the state of garlic slices after production based on image processing, characterized in that, Includes the following steps: S1. Multi-image acquisition and synchronous alignment: Simultaneously trigger RGB and near-infrared cameras to capture images of garlic slices after production, obtaining RGB images of the surface color. RGB Near-infrared image of internal reflectivity I NIR ; S2. Dynamic fractional-order differential enhancement and image fusion, utilizing dynamic fractional-order differential enhancement I RGB Image edges and details, flexible adjustment of enhancement areas to enhance the image. The formula is: Where x represents the horizontal position of a pixel in the RGB image, y represents the vertical position of a pixel in the RGB image, and I RGB (x,y) represents the pixel value at position (x,y) in the RGB image, α(x,y) represents the derivative order of the dynamic adjustment at position (x,y) in the RGB image, K represents the maximum neighborhood radius, and k represents the neighborhood pixel offset. I represents the differential operation of order α(x,y) in the x-direction. RGB (xk,y) represents the pixel value at position (xk,y) in the RGB image. This represents gradient-based adaptive weights. Represents the neighborhood weight allocation coefficient. and The formula is: in, Let I represent the gradient at position (xk,y), where k represents the offset of neighboring pixels, and α(x,y) represents the derivative order of the dynamic adjustment at position (x,y) in the RGB image. NIR Upsampled to 2448×2048 resolution and I RGB To address this, by enhancing the image R channel, enhanced image G channel and I NIR Construct the fused image F; S3. Multi-scale topological constraint segmentation, constructing the topological loss function: Where S represents the number of multi-scale levels, 1≤S≤5, s represents the scale level, and λ s This represents the loss weight at the s-th scale level. This represents the number of connected regions at the s-th scale level. This represents the number of target connected regions at the s-th scale level. This represents the hole 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) Where s represents the scale level, and the topological loss function L... MT Adding the cross-entropy loss function to the U-Net network yields the total loss function L: L=0.5L MT +0.5L CE Among them, L MT Let L be the topological loss function. CE Using the cross-entropy loss function, the U-Net network based on the total loss function segments the fused image F and outputs the segmented garlic-shaped regions; S4. Cascaded hybrid attention classification: Extract the 4D texture features, average spectral information, average R-channel color value, and average G-channel color value of each segmented garlic slice region to form a 7D feature vector. The first-level XGBoost model outputs the four classification probabilities of the sample. If any 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, characterized in that, Step S1 triggers simultaneous dual-camera shooting via FPGA. RGB The resolution is 2560×2048, with 8-bit color depth. 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, characterized in that, The four-dimensional texture features mentioned in step S5 are GLCM contrast, energy, entropy, and correlation, and the four categories are normal, moldy, damaged, and impurities.

Citation Information

Patent Citations

  • 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