A method and system for detecting a red jujube image

The jujube image detection method based on illumination-adaptive partitioning and multi-dimensional feature fusion solves the problem of false alarms and false negatives of jujube surface defects under uneven illumination conditions, and achieves high-precision defect detection and localization.

CN121095684BActive Publication Date: 2026-02-06JIANGSU MIXIN JUJUBE IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511630962.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-02-06
Estimated Expiration
2045-11-10

AI Technical Summary

Technical Problem

In automated jujube sorting production lines, existing technologies struggle to effectively distinguish between highlight and shadow areas and low-contrast defects on the jujube surface under uneven lighting conditions, resulting in high false alarm and false negative rates. Traditional global color threshold segmentation methods cannot meet the requirements for accurate detection.

Method used

An adaptive zoning method is used to extract local uniformly illuminated sub-regions. Combining color, texture, and gradient features, an adaptive classification model is used for judgment. The results of local regions are integrated to output the detection results of defects on the surface of jujubes.

Benefits of technology

It improves the detection accuracy of low-contrast defects on the surface of jujubes and the identification accuracy of light interference areas, reduces the false alarm rate and false negative rate, enhances the adaptability of the detection method to non-uniform lighting environments, and realizes the accurate location and quantitative assessment of defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121095684B_ABST
    Figure CN121095684B_ABST
Patent Text Reader

Abstract

The present application provides a kind of detection method and system of red jujube image, the present application is by utilizing the feature weight of model adaptive adjustment module, the dynamic fusion of input color feature, texture feature and gradient feature, solve the technical problem that the color feature of present technique is highly similar due to the color feature of low contrast defect of light interference and, leading traditional global color threshold segmentation or fixed weight feature fusion method cannot effectively distinguish between the two, and then produce defect false alarm and miss report, improve the detection accuracy of red jujube surface low contrast defect and the recognition accuracy of light interference area, reduce the false alarm rate and miss rate in detection process, while avoiding the tedious operation that traditional method needs to be repeated for different production line light scene Artificial adjustment feature weight or segmentation threshold, enhance the adaptability of detection method to production line non-uniform illumination environment.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image detection, in particular to a jujube image detection method and system. BACKGROUND

[0002] In the production line scene of jujube automatic sorting, due to the limited on-site environmental conditions, it is difficult to achieve absolutely uniform distribution of light. The jujube itself has a curved surface structure, and under non-uniform light, the surface will inevitably form local highlight areas and shadow areas, which brings natural challenges to the accurate detection of jujube surface defects.

[0003] Among the common defect types of jujube, slight shrinkage, superficial wormhole and other defects belong to typical low-contrast defects. The color change of such defect areas is extremely small, and the color change characteristics are highly similar to the highlight areas and shadow areas formed on the jujube surface due to uneven light.

[0004] Currently, the traditional detection method based on global color threshold segmentation is widely used in the field of jujube surface defect detection. This method can only segment the image according to a single global color threshold to distinguish between defect areas and normal areas. However, in the presence of the above highlight, shadow interference and low-contrast defects, this traditional method has obvious technical limitations: on the one hand, it is easy to misidentify normal highlight areas as defect areas, resulting in a high false positive rate; on the other hand, for low-contrast defects with similar color and shadow areas, the defect features are covered by the shadow, making it difficult to effectively detect, resulting in a serious false negative problem. In summary, the traditional detection method based on global color threshold segmentation has been difficult to meet the actual needs of accurate detection of jujube surface defects in the production line. SUMMARY

[0005] Based on the technical problems existing in the above background technology, the present application proposes a jujube image detection method and system, and the technical solutions adopted are as follows:

[0006] A jujube image detection method, the method comprising:

[0007] S1: Preprocessing the collected jujube original image to extract a region of interest containing only jujubes;

[0008] S2: Illumination adaptive partition segmentation of the region of interest to obtain a plurality of local uniform illumination sub-regions;

[0009] S3: For each local uniform illumination sub-region, simultaneously extracting color features, texture features and gradient features to form a multi-dimensional feature vector of the local uniform illumination sub-region;

[0010] S4: inputting the multi-dimension feature vector into a preset classification model to obtain a determination result of each local uniform illumination sub-region;

[0011] S5: integrating determination results of all the local uniform illumination sub-regions to output a detection result of the jujube surface defect.

[0012] Preferably, the S1 performs preprocessing on the collected jujube original image to extract a region of interest containing only jujubes, specifically including:

[0013] The foreground and background of the jujube are separated by an adaptive threshold segmentation algorithm, and the background is removed. Then, an edge detection algorithm is used to extract the jujube contour from the foreground, and the region of interest is obtained by cropping based on the minimum circumscribed rectangle of the jujube contour.

[0014] Preferably, the S2 performs light-adaptive partition segmentation on the region of interest, specifically including:

[0015] The region of interest is converted to a preset color space, the channel data reflecting the illumination brightness is extracted, and the illumination brightness distribution feature of the jujube surface is constructed. Based on the illumination brightness distribution feature, the region of interest is segmented to obtain a plurality of initial sub-regions. The initial sub-regions are screened and merged to obtain the local uniform illumination sub-region.

[0016] Preferably, the screening and merging of the initial sub-regions specifically include:

[0017] A screening determination basis is determined, which includes the area feature of the initial sub-region and the distribution uniformity feature of the illumination brightness in the initial sub-region;

[0018] Based on the area feature, preliminary screening is performed to remove small initial sub-regions whose area ratio to the total area of the region of interest meets a preset area ratio threshold;

[0019] Based on the illumination brightness distribution uniformity feature, secondary screening is performed. The distribution dispersion parameter of the channel data of the illumination brightness in each initial sub-region is calculated, and the initial sub-region whose distribution dispersion parameter exceeds a preset dispersion range is removed.

[0020] The initial sub-regions remaining after the two screenings are merged to obtain the local uniform illumination sub-region.

[0021] Preferably, the S3 extracts color features, specifically including:

[0022] For the local uniform illumination sub-region, a preset color space is converted, statistical distribution parameters of the local uniform illumination sub-region on each channel of the color space are calculated, the statistical distribution parameters include parameters reflecting color central tendency and parameters reflecting color dispersion degree, and the statistical distribution parameters are combined to form the color feature.

[0023] Preferably, the process of the texture feature and gradient feature of S3 includes:

[0024] The texture feature of the local uniform illumination sub-region is extracted by a local texture description algorithm;

[0025] A gradient operation operator performs gradient calculation on the local uniform illumination sub-region to obtain a horizontal direction gradient map and a vertical direction gradient map, and statistical feature parameters are extracted based on the gradient map to form the gradient feature;

[0026] The color feature, the texture feature, and the gradient feature are integrated to form a multi-dimensional feature vector of the local uniform illumination sub-region.

[0027] Preferably, the process of constructing the classification model of S4 includes:

[0028] Red jujube sample images under different illumination conditions are collected, multi-dimensional feature vectors of each local uniform illumination sub-region in the samples are extracted, and a class label of each sub-region is labeled, the class label including a normal region, an illumination interference region, and a defect region;

[0029] The multi-dimensional feature vectors are standardized to construct a training sample set;

[0030] Based on the training sample set, a classification model is trained;

[0031] The trained classification model is optimized by a verification sample set to obtain the preset classification model.

[0032] Preferably, the process of obtaining the determination result of the local uniform illumination sub-region in S4 includes:

[0033] The multi-dimensional feature vector is input into the preset classification model, and the input color feature, texture feature, and gradient feature are fused by a feature weight self-adaptive adjustment module of the model;

[0034] Based on the fused feature vector, a probability value of the local uniform illumination sub-region belonging to each class label is output;

[0035] The class label with the highest probability value is taken as the determination result of the local uniform illumination sub-region, and the determination result includes a normal region, an illumination interference region, and a defect region.

[0036] Preferably, characterized in that, the S5 comprises:

[0037] A spatial mapping relationship between the local uniform illumination sub-regions and the jujube region of interest is established, and the determination result of each local uniform illumination sub-region is corresponded to the original spatial position of the jujube region of interest, to form an associated data set;

[0038] The associated data set is subjected to consistency verification of the determination result, if the determination results of adjacent local uniform illumination sub-regions are the same defect type, then they are merged into a continuous defect region;

[0039] If the determination results of adjacent sub-regions are contradictory, the determination result of the contradictory region is corrected in combination with the multi-dimensional feature vector similarity of the two local uniform illumination sub-regions, and the determination result matched with the feature similarity is retained;

[0040] Key information of all defect regions is extracted, the key information including position coordinates of the defect region in the jujube region of interest, defect type and defect region area;

[0041] The key information of all defect regions is outputted and serves as the detection result of the jujube surface defect.

[0042] A jujube image detection system, the system comprising:

[0043] A jujube image preprocessing and region of interest extraction system: the collected jujube original image is preprocessed, and a region of interest containing only jujubes is extracted;

[0044] An illumination adaptive sub-region segmentation system: the region of interest is subjected to illumination adaptive partition segmentation, to obtain a plurality of local uniform illumination sub-regions;

[0045] A multi-dimensional feature extraction and vector generation system: for each local uniform illumination sub-region, color features, texture features and gradient features are synchronously extracted, to form a multi-dimensional feature vector of the local uniform illumination sub-region;

[0046] A feature vector classification and sub-region determination system: the multi-dimensional feature vector is inputted into a preset classification model, to obtain the determination result of each local uniform illumination sub-region;

[0047] A sub-region determination result integration and defect detection output system: the determination results of all local uniform illumination sub-regions are integrated, and the detection result of the jujube surface defect is outputted.

[0048] The present application has the beneficial effects that: the present application solves the technical problems that the traditional global color threshold segmentation or fixed weight feature fusion method cannot effectively distinguish the color features with high similarity caused by the illumination interference and low contrast defects, and further produces defect false positives and omissions, improves the detection accuracy of low contrast defects on the surface of red dates and the recognition accuracy of the illumination interference area, reduces the false positive rate and omission rate in the detection process, avoids the tedious operation of manually adjusting the feature weight or segmentation threshold repeatedly for different production line illumination scenes in the traditional method, and enhances the adaptability of the detection method to the non-uniform illumination environment of the production line. BRIEF DESCRIPTION OF DRAWINGS

[0049] Figure 1 The present application relates to a kind of red date image detection method. DETAILED DESCRIPTION

[0050] The preferred embodiments of the present application will be described below with reference to the accompanying drawings, and it should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and not to limit the present application.

[0051] One embodiment of the present application is a red date image detection method, the method comprises:

[0052] S1: the collected red date original image is preprocessed, and the region of interest containing only red dates is extracted;

[0053] S2: the region of interest is adaptively segmented by light, and a plurality of local uniform illumination sub-regions are obtained;

[0054] S3: for each local uniform illumination sub-region, color features, texture features and gradient features are extracted synchronously to form a multi-dimensional feature vector of the local uniform illumination sub-region;

[0055] S4: the multi-dimensional feature vector is input into a pre-set classification model to obtain the determination result of each local uniform illumination sub-region;

[0056] S5: integrate the determination results of all local uniform illumination sub-regions, and output the detection result of red date surface defects.

[0057] The working principle and effects of the above technical solution are as follows: first, the collected raw jujube image is preprocessed, the foreground and background of the jujube are separated by an adaptive threshold segmentation algorithm, and the background is removed, then an edge detection algorithm is used to extract the contour of the jujube foreground, and a minimum circumscribed rectangle based on the contour is used to crop the region of interest containing only jujube, thereby excluding background interference such as the conveying track and environmental debris, and laying a foundation for subsequent accurate detection; then, the region of interest is adaptively partitioned and segmented according to the light, the region of interest is first converted to a preset color space and the channel data reflecting the light intensity is extracted, the light intensity distribution feature of the jujube surface is constructed, and then the region of interest is segmented based on the light intensity distribution feature to obtain multiple initial sub-regions, then the small initial sub-regions with no detection value are removed by area feature screening, the initial sub-regions with internal light fluctuation are removed by combining the light intensity distribution uniformity feature, and the adjacent initial sub-regions with similar light properties after screening are merged, and finally multiple local uniform light sub-regions are obtained, thereby eliminating the interference of highlights and shadows under non-uniform light on detection; then, color features, texture features and gradient features are extracted for each local uniform light sub-region, wherein the color features are formed by calculating the statistical distribution parameters of each channel in the preset color space, the texture features are extracted by a local texture description algorithm, and the gradient features are formed by calculating the horizontal and vertical gradient maps by a gradient operator and extracting statistical feature parameters, and the three types of features are integrated into a multi-dimensional feature vector of the sub-region to fully capture the differentiated properties of normal areas, light interference areas and defect areas on the jujube surface; then, the multi-dimensional feature vector is input into a preset classification model, the classification model first calculates the consistency deviation of the feature vector of the to-be-detected sub-region and the typical features of each category based on the sample feature library of each category constructed in the training stage, excludes false high probability misjudgment caused by local feature similarity, and finally selects the category with the highest corrected probability as the determination result of the local uniform light sub-region; finally, the determination results of all sub-regions are integrated, the spatial mapping relationship between the sub-regions and the region of interest is established, the determination results are mapped to the original spatial position, the contradictory determination results of adjacent sub-regions are corrected in combination with the feature similarity, the continuous defect areas of the same type are merged, the position coordinates, defect type and area of each defect area are extracted, and the detection results of the jujube surface defects are output in the form of a heat map.

[0058] The application solves the technical problem that the traditional global color threshold segmentation or fixed weight feature fusion method cannot effectively distinguish the color features with high similarity caused by illumination interference and low contrast defects, thereby producing defect false positives and omissions, improves the detection accuracy of low-contrast defects on the surface of red dates and the recognition accuracy of the illumination interference area, reduces the false positive rate and omission rate in the detection process, avoids the tedious operation of manually adjusting the feature weight or segmentation threshold repeatedly for different production line illumination scenes in the traditional method, and enhances the adaptability of the detection method to the non-uniform illumination environment of the production line.

[0059] In an embodiment of the application, the S1 pre-processes the collected red date original image, extracts a region of interest containing only red dates, specifically including:

[0060] The foreground and background of the red dates are separated by the adaptive threshold segmentation algorithm, and the background is removed, and then the red date contour is extracted from the foreground by using the edge detection algorithm, and the region of interest is obtained based on the minimum bounding rectangle of the red date contour.

[0061] The working principle and effects of the above technical solution are as follows: first, the collected red date original image is converted into a gray image, the Otsu adaptive threshold segmentation algorithm is used to process the gray image, the optimal segmentation threshold (120-160) is automatically determined by calculating the inter-class variance maximum value of the image gray histogram, the threshold is used to divide the gray image into red date foreground and background, and the background area is removed to retain the red date foreground; then, the Canny edge detection algorithm is used to extract the contour of the retained red date foreground area, the low threshold of the Canny algorithm is set to 50, and the high threshold is set to 150, the edge pixel points of the red date foreground area are captured by the algorithm and connected to form a complete red date contour; finally, based on the extracted red date contour, the minimum bounding rectangle is determined by calculating the minimum horizontal coordinate, maximum horizontal coordinate, minimum vertical coordinate and maximum vertical coordinate of the contour boundary pixels, the original image is cropped according to the coordinate range of the rectangle, the redundant background area outside the rectangle is removed, and finally the region of interest containing only red dates is obtained.

[0062] The fixed threshold value is prone to incomplete foreground and background separation when the light of the production line fluctuates, and the jujube foreground region is ensured to be completely reserved; meanwhile, the jujube contour is extracted through a Canny edge detection algorithm, and double thresholds are used to effectively reduce the generation of false edges and edge breakage, thereby avoiding the problems of incomplete jujube contour or containing background miscellaneous edges caused by a single threshold value, and improving the completeness and accuracy of the jujube contour; and then, based on the complete and accurate contour, a minimum bounding rectangle is cropped to obtain a region of interest, so that the redundant background such as a conveying track and environmental sundries is completely removed, the interference problem of background residues on subsequent light partition segmentation, feature extraction and defect detection is solved, the data amount of subsequent processing is reduced, and the calculation load is reduced.

[0063] In an embodiment of the present application, the S2 performs light self-adaptive partition segmentation on the region of interest, specifically comprising:

[0064] The region of interest is converted to a preset color space, channel data reflecting light brightness is extracted, and light brightness distribution features of the jujube surface are constructed; based on the light brightness distribution features, the region of interest is segmented to obtain a plurality of initial sub-regions; and the initial sub-regions are screened and merged to obtain the local uniform light sub-region.

[0065] The working principle and effects of the above technical solution are as follows: first, the extracted jujube region of interest is converted from a gray color space to a preset HSV color space, V channel data reflecting light brightness in the HSV color space is extracted, the brightness value of each pixel in the V channel is calculated, a two-dimensional brightness matrix is constructed, and light brightness distribution features of the jujube surface are formed; based on the light brightness distribution features, the region of interest is segmented by using a region growing method, each local extreme point in the brightness matrix is taken as a seed point, the adjacent pixel brightness difference threshold is set to 5-8, the adjacent pixels with a brightness difference less than the threshold from the seed point are aggregated to the same region, the process is repeated until all pixels are assigned, and a plurality of initial sub-regions are obtained; then, the initial sub-regions are screened and merged, first, the initial sub-regions with an area ratio less than 0.5% of the total area of the region of interest are removed based on the area characteristics, then, the initial sub-regions with a standard deviation greater than 20 are removed based on the uniformity of light brightness distribution, and finally, the screened initial sub-regions adjacent to each other and with a light brightness difference less than 3 are merged, and the initial sub-regions adjacent to each other and with a light brightness difference greater than 8 are retained, thereby obtaining a plurality of local uniform light sub-regions.

[0066] This method solves the problem that traditional methods struggle to effectively capture uneven lighting distribution, such as highlights and shadows, on the surface of jujubes. It uses a region growing method to segment initial sub-regions, ensuring the continuity of lighting attributes between adjacent pixels and avoiding interference in subsequent feature extraction caused by the conflation of highlight and shadow areas in traditional global segmentation. Through filtering and merging operations, it eliminates meaningless fragmented regions resulting from over-segmentation while retaining independent regions with significantly different lighting attributes, ultimately obtaining multiple locally uniformly illuminated sub-regions. This solves the problem of feature extraction distortion caused by uneven lighting in existing technologies.

[0067] In one embodiment of the present invention, the filtering and merging of the initial sub-regions specifically includes:

[0068] The selection criteria are determined, including the area characteristics of the initial sub-region and the uniformity of the illumination distribution within the initial sub-region.

[0069] Based on the area characteristics, a preliminary screening is performed to eliminate small initial sub-regions whose area ratio to the total area of ​​the region of interest meets a preset ratio threshold.

[0070] A secondary screening is performed based on the uniformity characteristics of the illumination distribution. The distribution dispersion parameter of the channel data of illumination in each initial sub-region is calculated, and the initial sub-regions whose distribution dispersion parameter exceeds the preset dispersion range are eliminated.

[0071] The initial sub-regions retained after two rounds of screening are merged to obtain the locally uniformly illuminated sub-region.

[0072] The working principle and effect of the above technical solution are as follows: First, the area characteristics of the initial sub-region and the uniformity of the illumination distribution within the region are clearly defined as the core criteria for screening. Then, preliminary screening is conducted based on the area characteristics, setting a preset percentage threshold (0.5% of the total area of ​​the region of interest). The percentage of each initial sub-region's area to the total area of ​​the region of interest is calculated, and small initial sub-regions whose percentage reaches the preset threshold are removed. Subsequently, a second screening is conducted based on the uniformity of the illumination distribution, selecting a distribution dispersion parameter (standard deviation), and calculating the illumination within each initial sub-region retained after the preliminary screening. The distribution dispersion parameter of the brightness channel data is set with a preset dispersion range (standard deviation ≤ 20). Initial sub-regions with distribution dispersion parameters exceeding this range are removed. Finally, the initial sub-regions retained after two rounds of filtering are merged. The illumination similarity judgment condition is set (the difference in the standard deviation of illumination of adjacent sub-regions is ≤ 3). Adjacent initial sub-regions that meet the illumination similarity condition are merged into a continuous region. Adjacent initial sub-regions that do not meet the illumination similarity condition are kept independent. Finally, multiple locally uniform illumination sub-regions with uniform internal illumination, area with detection value, and clear illumination attributes are obtained.

[0073] The problems of increased calculation load and subsequent feature extraction noise interference caused by retaining the fine area without detection value in the prior art are solved, and the influence of invalid area on detection efficiency and accuracy is avoided;Through the uniformity feature screening of light intensity distribution, the initial sub-area with distribution dispersion parameter exceeding the preset range is removed, so that the internal light of the retained sub-area is stable, and the technical difficulties that the traditional method does not strictly control the uniformity of the light in the area, resulting in the mixed light interference of the subsequently extracted features and the inability to truly reflect the surface properties of red dates are solved.

[0074] In an embodiment of the present application, the color feature of S3 is extracted, specifically comprising:

[0075] For the local uniform light sub-area, the statistical distribution parameters of the local uniform light sub-area on each channel of the color space are calculated, the statistical distribution parameters include parameters reflecting color concentration trend and parameters reflecting color dispersion degree, and the statistical distribution parameters are combined to form the color feature.

[0076] The working principle and effect of the above technical solution are: for each local uniform light sub-area, it is converted from the current color space to the preset Lab color space, and the pixel value data of the L channel, a channel (red-green color) and b channel (yellow-blue color) in the space are extracted respectively, the parameters reflecting color concentration trend (mean value) and the parameters reflecting color dispersion degree (standard deviation) on each channel are calculated, and all channels are arranged and combined in a preset order to form a color feature that can fully represent the color properties of the local uniform light sub-area.

[0077] The technical problems that the color information in the RGB space is easily disturbed by light and it is difficult to accurately distinguish the color difference between the normal area and the low-contrast defect area of red dates are solved, wherein the concentration trend parameter can accurately represent the overall color tone of the sub-area, the dispersion degree parameter can capture local subtle color fluctuations, and the color feature formed by the combination of the two can fully and accurately reflect the color properties of the surface of red dates, avoiding the defect of single parameter that cannot completely describe color information leading to defect misjudgment or misjudgment.

[0078] In an embodiment of the present application, the process of the texture feature and gradient feature of S3 comprises:

[0079] The texture feature of the local uniform light sub-area is extracted by a local texture description algorithm;

[0080] The gradient calculation operator performs gradient calculation on the local uniform light sub-area to obtain the gradient graph in the horizontal direction and the vertical direction, and extracts statistical feature parameters based on the gradient graph to form the gradient feature;

[0081] Integrate the color feature, the texture feature and the gradient feature to form a multi-dimension feature vector of the local uniform illumination sub-region.

[0082] The working principle and effect of the technical solution are as follows: for each local uniform illumination sub-region, a local binary pattern (LBP) algorithm is used to extract a texture feature, a sub-region is divided into a plurality of 3*3 pixel neighborhoods, each center pixel value is used as a threshold to mark the neighborhood pixels as 0 or 1 to form a binary number and convert it into a decimal LBP value, and the LBP value histogram of the entire sub-region is counted as the texture feature; at the same time, a Sobel operator is used to calculate the gradient of the local uniform illumination sub-region, a horizontal direction convolution kernel ([-1, 0, 1; -2, 0, 2; -1, 0, 1]) and a vertical direction convolution kernel ([-1, -2, -1; 0, 0, 0; 1, 2, 1]) are respectively convolved with the sub-region image to obtain the horizontal direction and vertical direction gradient maps, and the gradient statistical feature parameters are extracted based on the gradient maps to form the gradient feature; finally, the color feature, the texture feature and the gradient feature extracted in the early stage are integrated in a preset dimension order to form a multi-dimension feature vector which can comprehensively depict the surface properties of the sub-region from three dimensions of color, texture and edge intensity.

[0083] The problem that the traditional texture extraction method is not sensitive to subtle texture changes and leads to missed defects is solved; the horizontal and vertical direction gradient maps are calculated by the Sobel operator and the gradient statistical feature parameters are extracted, which represent the gray scale change intensity and direction of the defect edge, avoiding the incomplete edge feature caused by the loss of single direction gradient information; the color feature, the texture feature and the gradient feature are integrated into a multi-dimension feature vector, which realizes the comprehensive depiction of the sub-region properties from three complementary dimensions of color tone, surface texture and edge morphology, and solves the technical pain point that the existing technology cannot distinguish the illumination interference and the real defect which are similar in color but different in texture / edge.

[0084] In one embodiment of the present application, the process of obtaining the determination result of the local uniform illumination sub-region in S4 includes:

[0085] The multi-dimension feature vector is input into the preset classification model, and the color feature, the texture feature and the gradient feature input are fused by a feature weight self-adaptive adjustment module of the model;

[0086] Based on the fused feature vector, a probability value of the local uniform illumination sub-region belonging to each category label is output;

[0087] The category label with the highest probability value is taken as the determination result of the local uniform illumination sub-region, the determination result includes a normal region, an illumination interference region and a defect region, and the determination result is obtained by the following formula:

[0088]

[0089] wherein, denotes a probability value of a locally uniform-illuminated sub-region belonging to a normal region, denotes a probability value of a locally uniform-illuminated sub-region belonging to a light interference region, denotes a probability value of a locally uniform-illuminated sub-region belonging to a defect region, and the probability value is obtained by the following formula:

[0090]

[0091] wherein, i∈(1, 2, 3), denotes a probability value of a locally uniform-illuminated sub-region belonging to the i-th region in the original output of the classification model; denotes an adjustment coefficient (a=0.5); denotes a consistency deviation of the feature vector for the i-th region, and the consistency deviation of the feature vector for the i-th region is obtained by the following formula:

[0092]

[0093] wherein, M denotes a total dimension number of a multi-dimensional feature vector; denotes a standardized value of the j-th feature vector of the locally uniform-illuminated sub-region to be tested (j∈(color feature, texture feature and gradient feature)), denotes a standardized value of the vector of the i-th region in the model training stage, and the standardized value of the vector of the i-th region in the model training stage is obtained by the following formula:

[0094]

[0095] wherein, denotes the j-th feature vector of the locally uniform-illuminated sub-region to be tested, denotes a global mean value of each feature dimension j on the entire training set in the classification model training stage; denotes a global standard deviation of each feature dimension j on the entire training set in the classification model training stage;

[0096] the consistency deviation of the feature vector for the i-th region is obtained by the following formula:

[0097]

[0098] wherein, denotes a mean value of each feature dimension j under each region i in the model training stage.

[0099] ​​​The working principle and effect of the above technical solution are as follows: In jujube detection, the numerical ranges of color features, texture features, and gradient features vary greatly. If feature deviation is calculated directly, features with large numerical ranges will dominate the deviation results, masking features with small numerical ranges but crucial for defect judgment. This formula, however, brings different types of features to the same scale, ensuring that color, texture, and gradient features contribute equally to consistency deviation, and avoiding judgment bias caused by differences in dimensions. It is the feature vector of the sub-region to be tested and the typical feature vector of region i. The mean absolute deviation, specifically, represents the degree to which sample characteristics conform to the typical patterns of region i. When the value approaches 0, it indicates that the features (color, texture, gradient) of the tested sub-region are highly consistent with the typical features of region i (the average features of all samples of this category in the training set). When the value approaches a large value, it indicates that the characteristics of the sub-region under test deviate significantly from the typical characteristics of region i. α, as a fixed adjustment coefficient, is set to control the magnitude of the impact of feature inconsistency on probability, thus avoiding... Excessive suppression of reliable probabilities also increases the suppression rate of false high probabilities.

[0100] In the field of jujube defect detection, traditional methods all employ a single logic of directly determining the model's output probability, focusing only on the matching degree between features and model parameters without verifying the consistency between features and typical category patterns. This leads to the model outputting a high probability value when local features (such as color) in areas of illumination interference are similar to defects, resulting in false positives; conversely, low-contrast defects in shadows have low probability values ​​due to insignificant local features, leading to missed detections. This formula introduces a feature consistency verification step into jujube defect detection, going beyond simply optimizing the model training process to verify the posterior reliability of the model's output probability. Quantifying whether features conform to category patterns solves the fundamental flaw of existing technologies that "only believe in probability and do not ask about patterns," and reduces the probability of false positives and false negatives.

[0101] In one embodiment of the present invention, S5 includes:

[0102] Establish a spatial mapping relationship between the locally uniformly illuminated sub-region and the region of interest of jujube, and map the judgment result of each locally uniformly illuminated sub-region to its original spatial position in the region of interest of jujube, forming an associated dataset;

[0103] The consistency of the judgment results is checked on the associated dataset. If the judgment results of adjacent local uniform illumination sub-regions are of the same defect type, they are merged into a continuous defect region.

[0104] If the determination results of adjacent sub-regions are contradictory, the determination result of the contradictory region is corrected in combination with the multi-dimensional feature vector similarity of the two local uniform illumination sub-regions, and the determination result matched with the feature similarity is retained;

[0105] Key information of all defect regions is extracted, including position coordinates of the defect regions in the jujube region of interest, defect types, and defect region areas;

[0106] The key information of all defect regions is output and serves as the detection result of the jujube surface defects.

[0107] The working principle and effects of the above technical solution are as follows: firstly, the spatial mapping relationship of each local uniform illumination sub-region and the jujube region of interest is established, the determination results of the sub-regions are one-to-one corresponding to the original spatial positions by recording the pixel coordinate range of the sub-regions in the region of interest, and the associated data set of "sub-region - position coordinates - determination result" is formed; then the consistency of the determination results of the associated data set is checked, for adjacent local uniform illumination sub-regions, if the determination results of the two sub-regions are the same defect class, the spatial coordinate ranges are combined to form a continuous defect region; if the determination results of adjacent sub-regions are contradictory, the cosine similarity of the multi-dimensional feature vectors of the two sub-regions is calculated, the determination result of the contradictory region is corrected according to the similarity, and the determination result matched with the feature similarity is retained to eliminate misjudgment; subsequently, the key information of all defect regions is extracted from the checked associated data set, including the minimum bounding rectangle coordinates of each defect region in the region of interest, the specific defect type, and the pixel area; finally, these key information is output in a preset format as the final detection result of the jujube surface defects, realizing complete recording and presentation of the jujube surface defects.

[0108] The problem that only sub-region determination results are outputted but the specific position of defects on the surface of red dates cannot be located in the prior art is solved, and accurate spatial anchoring of defects is realized; through consistency checking on the associated data set, adjacent defects of the same type are merged into continuous defect regions, thereby avoiding the drawbacks that the same defect is split into multiple independent regions due to sub-region segmentation, and the actual range of the defect cannot be completely reflected; in the case of contradictory sub-region determination results, the determination results are corrected in combination with the similarity of multi-dimensional feature vectors, thereby solving the technical pain point that the traditional method directly retains single sub-region determination results, which is prone to cause overall detection deviation due to local misjudgment, and the reliability of the determination results is improved; by extracting the position coordinates, type and area of the defect region and outputting the key information, the deficiency that the detection results of the prior art can only determine whether there is a defect or not but cannot provide specific details of the defect is solved, the actual needs of the red date automatic sorting production line for accurate positioning, quantitative evaluation and grading processing of defects are met, and complete defect information also provides data support for subsequent red date quality tracing, thereby further improving the practicality and industrial adaptability of the detection method.

[0109] In one embodiment of the present application, a red date image detection system comprises:

[0110] A red date image preprocessing and region of interest extraction system: the collected red date original image is preprocessed, and a region of interest containing only red dates is extracted;

[0111] An illumination adaptive sub-region segmentation system: the region of interest is subjected to illumination adaptive partition segmentation, and a plurality of local uniform illumination sub-regions are obtained;

[0112] A multi-dimensional feature extraction and vector generation system: for each local uniform illumination sub-region, color features, texture features and gradient features are simultaneously extracted, and a multi-dimensional feature vector of the local uniform illumination sub-region is formed;

[0113] A feature vector classification and sub-region determination system: the multi-dimensional feature vector is input into a preset classification model, and a determination result of each local uniform illumination sub-region is obtained;

[0114] A sub-region determination result integration and defect detection output system: the determination results of all local uniform illumination sub-regions are integrated, and a detection result of the surface defects of red dates is outputted.

[0115] The working principle and effects of the above technical solution are as follows: first, the collected raw jujube image is preprocessed, the foreground and background of the jujube are separated by an adaptive threshold segmentation algorithm, and the background is removed, then an edge detection algorithm is used to extract the contour of the jujube foreground, and a minimum circumscribed rectangle based on the contour is used to crop the region of interest containing only jujube, thereby excluding background interference such as the conveying track and environmental debris, and laying a foundation for subsequent accurate detection; then, the region of interest is adaptively partitioned and segmented according to the light, the region of interest is first converted to a preset color space and the channel data reflecting the light intensity is extracted, the light intensity distribution feature of the jujube surface is constructed, and then the region of interest is segmented based on the light intensity distribution feature to obtain multiple initial sub-regions, then the small initial sub-regions with no detection value are removed by area feature screening, the initial sub-regions with internal light fluctuation are removed by combining the light intensity distribution uniformity feature, and the adjacent initial sub-regions with similar light properties after screening are merged, and finally multiple local uniform light sub-regions are obtained, thereby eliminating the interference of highlights and shadows under non-uniform light on detection; then, color features, texture features and gradient features are extracted for each local uniform light sub-region, wherein the color features are formed by calculating the statistical distribution parameters of each channel in the preset color space, the texture features are extracted by a local texture description algorithm, and the gradient features are formed by calculating the horizontal and vertical gradient maps by a gradient operator and extracting statistical feature parameters, and the three types of features are integrated into a multi-dimensional feature vector of the sub-region to fully capture the differentiated properties of normal areas, light interference areas and defect areas on the jujube surface; then, the multi-dimensional feature vector is input into a preset classification model, the classification model first calculates the consistency deviation of the feature vector of the to-be-detected sub-region and the typical features of each category based on the sample feature library of each category constructed in the training stage, excludes false high probability misjudgment caused by local feature similarity, and finally selects the category with the highest corrected probability as the determination result of the local uniform light sub-region; finally, the determination results of all sub-regions are integrated, the spatial mapping relationship between the sub-regions and the region of interest is established, the determination results are mapped to the original spatial position, the contradictory determination results of adjacent sub-regions are corrected in combination with the feature similarity, the continuous defect areas of the same type are merged, the position coordinates, defect type and area of each defect area are extracted, and the detection result of the jujube surface defects is output in the form of a heat map.

[0116] The application solves the technical problem that the traditional global color threshold segmentation or fixed weight feature fusion method cannot effectively distinguish the two due to the high similarity of color features caused by illumination interference and low contrast defects, and further produces defect false positives and omissions, improves the detection accuracy of low contrast defects on the surface of red dates and the recognition accuracy of the illumination interference area, reduces the false positive rate and the omission rate in the detection process, avoids the tedious operation of manually adjusting the feature weight or segmentation threshold repeatedly for different production line illumination scenes in the traditional method, and enhances the adaptability of the detection method to the non-uniform illumination environment of the production line.

[0117] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application belong to the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these modifications and variations.

Claims

1. A method for detecting jujube images, characterized in that, The method includes: S1: Preprocess the original images of jujubes to extract regions of interest containing only jujubes; S2: Perform illumination-adaptive partitioning on the region of interest to obtain multiple locally uniformly illuminated sub-regions; S3: For each of the local uniform illumination sub-regions, simultaneously extract color features, texture features and gradient features to form a multi-dimensional feature vector of the local uniform illumination sub-region. S4: Input the multi-dimensional feature vector into a preset classification model to obtain the determination result of each of the local uniform illumination sub-regions; S5: Integrate the judgment results of all the local uniform illumination sub-regions and output the detection results of jujube surface defects; S5 includes: Establish a spatial mapping relationship between the locally uniformly illuminated sub-region and the region of interest of jujube, and map the judgment result of each locally uniformly illuminated sub-region to its original spatial position in the region of interest of jujube, forming an associated dataset; The consistency of the judgment results is checked on the associated dataset. If the judgment results of adjacent local uniform illumination sub-regions are of the same defect type, they are merged into a continuous defect region. If there are contradictions in the determination results of adjacent sub-regions, the determination results of contradictory regions are corrected by combining the multi-dimensional feature vector similarity of two locally uniformly illuminated sub-regions, and the determination results that match the feature similarity are retained. Extract key information from all defective regions, including the location coordinates of the defective region within the region of interest of the jujube, the defect type, and the area of ​​the defective region. Output key information for all defective areas and use it as the detection result for defects on the surface of jujubes.

2. The method for detecting jujube images according to claim 1, characterized in that, S1 preprocesses the acquired original image of jujubes, extracting the region of interest containing only jujubes, specifically including: An adaptive threshold segmentation algorithm is used to separate the foreground and background of the jujube, and the background is removed. Then, an edge detection algorithm is used to extract the outline of the jujube in the foreground. The region of interest is obtained by cropping the minimum bounding rectangle of the jujube outline.

3. The method for detecting jujube images according to claim 1, characterized in that, The illumination-adaptive partitioning of the region of interest in step S2 specifically includes: The region of interest is converted to a preset color space, and channel data reflecting illumination intensity is extracted to construct the illumination intensity distribution characteristics of the jujube surface. Based on the illumination intensity distribution characteristics, the region of interest is segmented to obtain multiple initial sub-regions. The initial sub-regions are then filtered and merged to obtain the locally uniform illumination sub-region.

4. The method for detecting jujube images according to claim 3, characterized in that, The filtering and merging of the initial sub-regions specifically includes: The selection criteria are determined, including the area characteristics of the initial sub-region and the uniformity of the illumination distribution within the initial sub-region. Based on the area characteristics, a preliminary screening is performed to eliminate small initial sub-regions whose area of ​​each initial sub-region and the total area of ​​the region of interest meet a preset percentage threshold. A secondary screening is performed based on the uniformity characteristics of the illumination distribution. The distribution dispersion parameter of the channel data of illumination in each initial sub-region is calculated, and the initial sub-regions whose distribution dispersion parameter exceeds the preset dispersion range are eliminated. The initial sub-regions retained after two rounds of screening are merged to obtain the locally uniformly illuminated sub-region.

5. The method for detecting jujube images according to claim 1, characterized in that, The extracted color features in S3 specifically include: For the local uniform illumination sub-region, it is converted to a preset color space, and the statistical distribution parameters of the local uniform illumination sub-region on each channel of the color space are calculated. The statistical distribution parameters include parameters reflecting the color concentration trend and parameters reflecting the color dispersion. The statistical distribution parameters are combined to form the color feature.

6. The method for detecting jujube images according to claim 1, characterized in that, The process of defining the texture features and gradient features of S3 includes: Texture features of the locally uniformly illuminated sub-region are extracted using a local texture description algorithm; The gradient operation operator performs gradient calculation on the local uniform illumination sub-region to obtain gradient maps in the horizontal and vertical directions. Statistical feature parameters are extracted based on the gradient maps to form the gradient features. The color features, texture features, and gradient features are integrated to form a multi-dimensional feature vector of the locally uniformly illuminated sub-region.

7. The method for detecting jujube images according to claim 1, characterized in that, The process of constructing the classification model of S4 includes: Images of jujube samples under different lighting conditions were collected, and multi-dimensional feature vectors of each local uniformly illuminated sub-region in the samples were extracted. Each sub-region was labeled with a category label, which includes normal regions, light interference regions, and defective regions. The multi-dimensional feature vectors are standardized to construct a training sample set; Based on the training sample set, train the classification model; The trained classification model is optimized by validating the sample set to obtain the preset classification model.

8. The method for detecting jujube images according to claim 1, characterized in that, The process of obtaining the determination result of the locally uniformly illuminated sub-region in S4 includes: The multi-dimensional feature vector is input into the preset classification model, and the input color features, texture features and gradient features are fused by the model's feature weight adaptive adjustment module. Based on the fused feature vector, the probability values ​​of local uniform illumination sub-regions belonging to each category label are output; The category label with the highest probability value is used as the determination result of the local uniform illumination sub-region, and the determination result includes normal region, illumination interference region and defect region.

9. A system for implementing the jujube image detection method as described in claim 1, characterized in that, The system includes: Red Date Image Preprocessing and Region of Interest Extraction System: This system preprocesses the acquired original red date images and extracts regions of interest containing only red dates. Illumination-adaptive sub-region segmentation system: The region of interest is segmented into multiple locally uniformly illuminated sub-regions by performing illumination-adaptive partitioning; Multi-dimensional feature extraction and vector generation system: For each of the local uniform illumination sub-regions, color features, texture features and gradient features are extracted simultaneously to form a multi-dimensional feature vector of the local uniform illumination sub-region; Feature vector classification and sub-region determination system: The multi-dimensional feature vectors are input into a preset classification model to obtain the determination result of each local uniform illumination sub-region; Sub-region judgment result integration and defect detection output system: integrates the judgment results of all the local uniform illumination sub-regions and outputs the detection results of defects on the surface of jujubes.

Citation Information

Patent Citations

  • Red date defect identification and classification method and device based on image processing

    CN113516193A

  • Agricultural product skin defect detection system based on image detection

    CN118747735A