Impurity identification method and system for fruit and vegetable powder
By calculating the dark channel index and gradient features, generating impurity confidence, and constructing a weighted histogram, the problem of distinguishing shadows from impurities in fruit and vegetable powder images using the CLAHE algorithm is solved, achieving high-precision impurity identification.
Patent Information
- Application Number
- CN202511902729.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2045-12-17
AI Technical Summary
The traditional CLAHE algorithm cannot distinguish between accumulated shadows and real impurities when processing images of piled fruit and vegetable powders. This results in the shadow areas being indiscriminately enhanced, producing artifacts and leading to false detections of impurities, thus affecting the detection accuracy.
By calculating the dark channel index, gradient magnitude dispersion, and gradient direction information entropy, impurity confidence is generated. Weighted enhancement is used when constructing the local histogram. Combined with threshold segmentation and connected component analysis, high signal-to-noise ratio identification of impurities is achieved.
It effectively avoids the erroneous stretching of the shadow area, improves the accuracy and stability of impurity identification, reduces the false detection rate, and provides a high-precision foreign object detection solution.
Smart Images

Figure CN121353318A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for identifying impurities in fruit and vegetable powder. Background Technology
[0002] With the increasing demand of modern consumers for natural and healthy foods, fruit and vegetable powder products are widely favored by the market due to their rich content of vitamins and anthocyanins. Ensuring that no foreign matter such as metal particles or plastic fragments is mixed into the product during the industrial production and automated packaging of fruit and vegetable powder is a crucial step in guaranteeing food safety and product quality.
[0003] Existing fruit and vegetable powder production lines typically use machine vision systems in conjunction with the Limit Contrast Adaptive Histogram Equalization (CLAHE) algorithm for impurity detection. This algorithm suppresses noise by limiting the height of local histograms, while enhancing the contrast of local areas to improve detection difficulties caused by uneven lighting or indistinct impurity features.
[0004] However, the traditional CLAHE algorithm has significant limitations when processing images of fruit and vegetable powders distributed in a piled-up manner. Because the powder particles are extremely fine and easily absorb moisture and clump together, they often present a rolling, hilly shape on the conveyor belt. Under illumination, the low-lying areas of the powder accumulation create numerous shadows with low grayscale values. These shadows are very similar in grayscale characteristics to dark impurities. Since the CLAHE algorithm only performs equalization based on the grayscale statistics of local pixels, it cannot distinguish whether low-grayscale pixels belong to a dark background or a dark target, resulting in indiscriminately increasing the contrast of shadow areas. This forcibly brightens and sharpens the natural undulating shadows on the powder surface, producing numerous high-contrast artifact edges. These artifacts are easily misidentified as impurity outlines in subsequent detection, affecting the detection accuracy. Summary of the Invention
[0005] To address the technical problem that the traditional CLAHE algorithm cannot distinguish between accumulated shadows and real impurities when processing images of accumulated fruit and vegetable powders, resulting in indiscriminate enhancement of shadow areas and the generation of artifacts, which in turn leads to false detection of impurities, this invention provides solutions in the following aspects.
[0006] In a first aspect, the present invention provides a method for identifying impurities in fruit and vegetable powders, the method comprising the steps of: The original image of fruit and vegetable powder on a conveyor belt is acquired and preprocessed to obtain a grayscale image. Based on the grayscale distribution characteristics of all pixels within the neighborhood window of each pixel in the grayscale image, the dark channel index of each pixel is obtained. The dispersion of the gradient magnitude and the information entropy of the gradient direction within the neighborhood window of each pixel are statistically analyzed. The dark channel index is corrected using the dispersion and the information entropy to obtain the impurity confidence of each pixel. The grayscale image is subjected to adaptive histogram equalization based on the impurity confidence to obtain an enhanced image, wherein the count value of each pixel is determined by its impurity confidence when constructing the local histogram. Threshold segmentation and connected component analysis are performed on the enhanced image to identify impurities.
[0007] This invention first obtains a grayscale image through preprocessing and calculates the dark channel index, initially screening out all significantly darkened areas from a photometric perspective to cover all potential impurity targets. Subsequently, texture feature analysis is introduced, statistically analyzing the dispersion of gradient magnitudes and the information entropy of gradient directions within the pixel neighborhood. Utilizing the physical difference between sharp impurity edges and irregular surface morphology, and smooth, ordered transitions in stacked shadows, the dark channel index is corrected to generate an impurity confidence score that accurately characterizes the probability of impurities. Furthermore, based on the impurity confidence score, the counting weights when constructing the local histogram are determined, ensuring that the enhancement process is directed towards high-confidence impurity regions while suppressing low-confidence shadows and the background. This process of first screening and then enhancing effectively avoids artifacts caused by erroneous stretching of shadow regions. Finally, combined with threshold segmentation and connected component analysis, it achieves high signal-to-noise ratio identification of minute impurities in complex stacked backgrounds.
[0008] Preferably, the step of obtaining the dark channel index of each pixel based on the grayscale distribution characteristics of all pixels within the neighborhood window of each pixel in the grayscale image includes: taking any pixel in the grayscale image as the current pixel, calculating the difference between the mean grayscale value within its neighborhood window and the grayscale value of the current pixel, dividing the difference by the grayscale value of the current pixel to obtain a grayscale difference ratio; constructing a background suppression term by combining the ratio of the minimum grayscale value within the neighborhood window to the global mean grayscale value; and multiplying the grayscale difference ratio by the background suppression term to obtain the dark channel index of each pixel.
[0009] This invention calculates the dark channel index from two dimensions: local abruptness and global darkness, by constructing a grayscale difference ratio and a background suppression term. Specifically, calculating the difference ratio between the mean of the neighborhood window and the center pixel can keenly capture abrupt changes in brightness within a local area, effectively detecting tiny dark spots. Simultaneously, a background suppression term is constructed by combining the ratio of the neighborhood minimum to the global mean, used to measure the relative brightness level of that area in the entire image. The multiplication mechanism ensures that only pixels that exhibit both abrupt dark features locally and belong to the dark area globally are assigned a high index, effectively eliminating false target interference from locally dark but overall bright areas, providing high-quality basic data for subsequent processing.
[0010] Preferably, the dark channel index satisfies the following relationship: ; in, It is the first Dark channel index of each pixel; It is the first The grayscale value of each pixel; It is the first The average gray level within the neighborhood window of each pixel; It is the first The minimum gray value within the neighborhood window of a pixel; It is the global grayscale mean of the grayscale image; It is a natural exponential function; It is the preset first minute value.
[0011] This invention quantifies the dark channel index using a specific mathematical formula. The formula uses a difference ratio term to reflect the contrast difference of a pixel relative to its neighboring background. A natural exponential function is used to map the global darkness ratio, resulting in a non-linear, smooth decay of the background suppression factor. This mathematical model adaptively balances the relationship between local detail extraction and global background suppression, accurately mapping potential impurity regions to high numerical responses, thus achieving initial digital screening of dark targets.
[0012] Preferably, obtaining the dispersion of the gradient magnitude within the neighborhood window of each pixel includes: calculating the variance of the gradient magnitude within the neighborhood window of each pixel as the dispersion of the gradient magnitude.
[0013] Preferably, the impurity confidence level satisfies the following relationship: ; in, It is the first Impurity confidence level of each pixel; It is the first Dark channel index of each pixel; It is the first The standard deviation of the gradient magnitude within the neighborhood window of each pixel; It is the first The average gradient magnitude within the neighborhood window of each pixel; It is the first Information entropy of gradient direction within the neighborhood window of each pixel; It is a natural exponential function; It is the preset second minute value.
[0014] This invention constructs an exponential correction function that includes gradient magnitude variance and gradient direction information entropy to calculate impurity confidence. This function utilizes the decaying characteristic of the natural exponential function: when a region is detected to have large gradient magnitude fluctuations and chaotic directions, the exponential term approaches zero, causing the correction coefficient to approach 1, thus preserving the original dark channel exponent; conversely, if the region is smooth and orderly, the exponential term increases, leading to a significant suppression of confidence. This nonlinear fusion mechanism eliminates shadow interference from a texture mechanism perspective, transforming the feature recognition result into probability values in the [0,1] interval, providing accurate control parameters for subsequent weighted enhancement.
[0015] Preferably, obtaining the information entropy of the gradient direction within the neighborhood window of the pixel includes: calculating the horizontal and vertical gradients of each pixel using an edge detection operator, and calculating the gradient direction angle based on the ratio of the horizontal and vertical gradients; dividing the range of the gradient direction angle into several discrete direction intervals, and calculating the probability that the gradient direction angle enters each direction interval within the neighborhood window; calculating the product of the logarithm of the probability and the probability, accumulating the product of all direction intervals and taking the negative value to obtain the information entropy of the gradient direction.
[0016] Preferably, the step of performing adaptive histogram equalization processing based on impurity confidence in the grayscale image to obtain the enhanced image includes: using a power function to nonlinearly stretch the impurity confidence of each pixel, and rounding it down using a preset amplification factor to obtain the weighted contribution value of each pixel; dividing the grayscale image into several non-overlapping image blocks, calculating the sum of the weighted contribution values corresponding to each grayscale level within each image block, and constructing a local histogram; performing grayscale mapping on the pixels within the image blocks based on the local histogram, and fusing the image blocks using interpolation operations to obtain the enhanced image.
[0017] This invention amplifies the weight of high-confidence impurity pixels in histogram statistics through nonlinear stretching and rounding operations, while compressing the weight of background pixels. When constructing the local histogram, this differentiated counting method ensures that the histogram distribution is primarily determined by impurity features, thereby enabling the generated grayscale mapping function to directionally expand the dynamic range of the impurity region. Through image patch interpolation fusion, it achieves strong enhancement of weak impurity signals while maintaining the overall smoothness of the enhanced image, avoiding block artifacts.
[0018] Preferably, the weighted contribution values satisfy the following relationship: ; in, It is the first The weighted contribution value when constructing a local histogram from individual pixels; Therefore, the first Impurity confidence level per pixel The base is used to adjust the index. The term is a power function of the exponent; It is the magnification factor; It is a floor function.
[0019] Preferably, the step of performing threshold segmentation and connected component analysis on the enhanced image to identify impurities includes: calculating a global threshold for the enhanced image using the maximum inter-class variance method; segmenting the enhanced image into binary images based on the global threshold; marking connected components in the binary images to obtain several connected components; calculating the pixel area of each connected component; and determining that the connected component is an impurity if the area of the connected component is greater than a preset minimum impurity area threshold.
[0020] In a second aspect, the present invention provides an impurity identification system for fruit and vegetable powders. The impurity identification system for fruit and vegetable powders includes a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the impurity identification method for fruit and vegetable powders according to the first aspect of the present invention is implemented.
[0021] By adopting the above technical solution, a computer program for identifying impurities in fruit and vegetable powder according to the first aspect of the present invention is generated and stored in a memory so that it can be loaded and executed by a processor, thereby creating a terminal device based on the memory and the processor for convenient use.
[0022] The beneficial effects of this invention are as follows: First, this invention calculates the dark channel index based on photometric features to achieve preliminary localization of dark regions. Then, it introduces the discreteness of gradient magnitude and the information entropy of gradient direction as texture descriptors. Utilizing the essential difference between smooth and ordered gradients in shadow regions and sharp and disordered gradients in impurity regions, a nonlinear correction model is constructed to generate impurity confidence, effectively eliminating shadow false targets. Based on this, this invention uses a weighted histogram equalization technique based on impurity confidence to change the uniform statistical mode of traditional algorithms, achieving targeted enhancement of impurity details and suppression of background noise, thus improving the contrast between impurities and the background in the image. Finally, combined with adaptive threshold segmentation and morphological screening, this invention can reduce the false detection rate while preserving the characteristics of minute impurities, providing a high-precision and high-stability technical solution for foreign object detection in fruit and vegetable powder production lines. Attached Figure Description
[0023] Figure 1 A flowchart of a method for identifying impurities in fruit and vegetable powder provided in an embodiment of the present invention; Figure 2 This is a schematic diagram comparing grayscale distribution histograms provided in an embodiment of the present invention; Figure 3 This is a structural block diagram of an impurity identification system for fruit and vegetable powder provided in an embodiment of the present invention. Detailed Implementation
[0024] The first aspect of this invention provides a method for identifying impurities in fruit and vegetable powders, such as... Figure 1 As shown, the method includes steps S100-S400: Step S100: Collect the original image of the fruit and vegetable powder on the conveyor belt and preprocess it to obtain a grayscale image.
[0025] It should be noted that fruit and vegetable powders are usually transported in a pile on the conveyor belt on the production line. In order to detect any tiny impurities that may be mixed in, such as metal particles or plastic fragments, high-quality image data is first required as the basis for analysis.
[0026] Specifically, a high-resolution industrial line scan camera is installed above the conveyor belt of the automatic fruit and vegetable powder packaging line to collect RGB color images of the conveyor belt surface in real time. Since the difference between impurities and fruit and vegetable powder is mainly reflected in brightness and texture features, color information does not contribute significantly to impurity identification. Moreover, the large amount of RGB color image data can easily increase the computational complexity of subsequent algorithms. Therefore, the collected RGB color images are converted into grayscale images to obtain grayscale images to be processed.
[0027] At this point, the grayscale image of the fruit and vegetable powder has been obtained.
[0028] Step S200: Based on the grayscale distribution characteristics of all pixels within the neighborhood window of each pixel in the grayscale image, obtain the dark channel index of each pixel.
[0029] It should be noted that the traditional CLAHE algorithm uses a uniform statistical approach, which can easily lead to the incorrect enhancement of shadows. Therefore, this invention optimizes the histogram construction process with weighted methods, introducing differentiated weights to suppress shadows. As the first step in the optimization, this invention first utilizes the optical physical property that the absorbance of impurities is usually higher than that of fruit and vegetable powders to initially screen out all obviously darkened areas from the complex background, and calculates the dark channel index to provide basic data for the subsequent construction of confidence weights that can accurately distinguish between shadows and impurities.
[0030] First, define the neighborhood window for each pixel. It should be noted that the size of the neighborhood window determines the statistical range of the background mean, which in turn affects the sensitivity of dark channel feature extraction.
[0031] As a preferred implementation, the neighborhood window size can be set to... Pixels, considering that common impurities such as metal particles or plastic fragments typically result in image sizes within the field of view of industrial cameras, are generally considered to be... Pixels around A neighborhood window for a pixel can both completely cover potential obfuscation targets and retain enough surrounding background pixels to calculate a reliable local grayscale mean, thus ensuring that the contrast difference between the foreground and background is correctly captured; if the window is too small, such as Larger impurities may fill the entire window, causing contrast calculations to fail; if the window is too large, such as... This could introduce excessive powder buildup, creating a gradual change in illumination at the far end, interfering with the judgment of abrupt changes in the current point. Operators can adjust the magnification of the conveyor belt camera based on the expected minimum impurity diameter to be detected.
[0032] Next, the dark channel index of each pixel is calculated. It should be noted that, based on optical properties, the absorbance of impurities such as metal particles is usually significantly higher than that of the fruit and vegetable powder background, appearing as local minima in the image. To distinguish impurities from the normal background, it is necessary to consider not only the abruptness of the pixel relative to its neighboring window, but also its global brightness level to eliminate false targets that are locally dark but globally bright.
[0033] Based on the above logic, the first Dark channel index per pixel Satisfying the relation: ; in, It is the first The grayscale value of each pixel; It is the first The average gray level within the neighborhood window of each pixel; It is the first The minimum gray value within the neighborhood window of a pixel; It is the global grayscale mean of the grayscale image; It is a natural exponential function; It is a preset first tiny value used to prevent the denominator from being 0, and can be set to 0.001.
[0034] In this relation, Used to measure local contrast, the higher the value of this item, the better. The gray value of a pixel is significantly lower than the average level of its surrounding neighborhood, meaning that the pixel is a striking dark spot relative to the local background. Used to measure global darkness, when the minimum value of the neighborhood window is reached. Relative to the global mean The lower the value, the closer the independent variable of the natural exponential function is to 0, and the larger the function value, indicating that the region is generally a dark region. The product of the two makes... A high value is only output when a pixel satisfies both the condition of local abrupt darkening and the condition of being in the dark area overall, thereby effectively filtering out potential dark impurity areas.
[0035] At this point, the dark channel index of each pixel has been obtained.
[0036] Step S300: Calculate the dispersion of gradient magnitude and the information entropy of gradient direction within the neighborhood window of each pixel; use the dispersion and the information entropy to correct the dark channel index to obtain the impurity confidence of each pixel.
[0037] It should be noted that while the dark channel index calculated solely based on grayscale features can filter out dark areas, it is easily affected by deep pit shadows in complex scenarios involving fruit and vegetable powder accumulation. This is because such shadow areas also exhibit extremely low grayscale responses, causing their dark channel index to produce artificially high response values, thus being misjudged as real impurities. However, there is a fundamental difference between the two in terms of texture gradient: shadows originate from the natural accumulation of powder, and their edge transitions have spatial continuity, with relatively ordered gradient directions; while real impurities typically have sharp physical edges and irregular surface morphologies, exhibiting drastic fluctuations in gradient amplitude and chaotic, disordered directions.
[0038] Based on this, the present invention introduces gradient direction and gradient magnitude to construct a nonlinear suppression term to correct the dark channel index: when the target region is detected to have low grayscale features but smooth texture, it is determined to be a shadow and suppressed; otherwise, it is confirmed as an impurity and high confidence is retained.
[0039] Based on the above logic, the first Impurity confidence level per pixel Satisfying the relation: ; in, It is the first Dark channel index of each pixel; It is the first The standard deviation of the gradient magnitude within the neighborhood window of each pixel; It is the first The average gradient magnitude within the neighborhood window of each pixel; It is the first The information entropy of the gradient direction within the neighborhood window of each pixel is calculated using operators such as Sobel, and the information entropy is calculated using Shannon entropy. This is existing technology and will not be elaborated on here. It is a natural exponential function; It is a preset second tiny value used to prevent the denominator from being 0, and can be set to 0.001.
[0040] In this relation, It is the coefficient of variation of the gradient magnitude. The larger the value, the more violent the fluctuation of the local gradient magnitude relative to the mean, which characterizes the sharp edge features of the impurities. It is the first Information entropy of gradient direction within the neighborhood window of each pixel The larger the value, the higher the disorder of the gradient direction distribution, characterizing the irregularity of the impurity surface. When a pixel is located in an impurity region, the gradient amplitude fluctuates greatly and its direction is disordered, causing the independent variable of the natural exponential function to tend to a large negative value, making... Approaching 0, thus making Approaching 1, retaining the original dark channel index. Conversely, if a pixel is in a shadow area, the gradient change is gentle and unidirectional. The term approaches 1, leading to an impurity confidence level. Approaching 0, thus achieving effective suppression of shadow interference.
[0041] At this point, the impurity confidence level of each pixel has been obtained.
[0042] Step S400: Perform adaptive histogram equalization processing based on impurity confidence on the grayscale image to obtain an enhanced image, wherein the count value of each pixel is determined by its impurity confidence when constructing the local histogram; perform threshold segmentation and connected component analysis on the enhanced image to identify impurities.
[0043] It should be noted that in the traditional CLAHE algorithm, the weight of each pixel in the histogram statistics is 1 by default. This invention utilizes the impurity confidence to reconstruct the histogram counting rules, thereby achieving a differentiated enhancement effect that suppresses shadow interference and directionally enhances impurity features, and on this basis, completes the final recognition.
[0044] First, calculate the weighted contribution values of the histogram. It should be noted that the impurity confidence level is... The probability value of the interval, and the construction of the histogram requires a specific count increment. To further increase the feature difference between impurities and the background, this invention introduces a non-linear mechanism: for suspected impurity pixels with high confidence, their statistical weight in the histogram should be increased exponentially, so that they dominate in subsequent equalization; while for background or shadow pixels with low confidence, their weight should be reduced, so that their statistical contribution is significantly reduced.
[0045] Specifically, based on the impurity confidence of each pixel, its specific contribution value in histogram construction is calculated through nonlinear mapping. The weighted contribution value of each pixel when constructing the local histogram. Satisfying the relation: ; in, Therefore, the first Impurity confidence level per pixel The base is used to adjust the index. The term is a power function of the exponent; It is the magnification factor; It is a floor function.
[0046] In this relation, The impurity confidence level is nonlinearly stretched using a power function when... At the same time, it can suppress background noise with low impurity confidence and amplify the effect of high impurity confidence; As an amplification factor, the normalized impurity confidence is mapped to an integer to facilitate the counting statistics of the histogram.
[0047] It should be noted that the magnification factor With adjustment index The determination of the adjustment index was achieved through a reproducible on-site calibration process. This process involved collecting two sets of typical samples: one set of images of pure fruit and vegetable powder accumulation, and the other set of images of samples containing known smallest detectable impurities, such as metal particles with a diameter of 0.1 mm. For the adjustment index, if it is set too high, such as greater than 2.0, although it can completely suppress shadows, it may cause slightly weaker translucent impurities to be accidentally filtered out; if it is set too low, such as less than 1.0, it cannot effectively differentiate between impurities and shadows. Therefore, the range of values for the adjustment index was determined to be [range missing], ensuring a stable distinction between the weakest impurity signal and shadow noise. In this embodiment, 1.5 is preferred. Regarding the magnification factor... It is used to ensure that impurity pixels receive sufficient statistical weight in histogram equalization while avoiding numerical overflow. Experiments have determined its value range to be... In this embodiment, 10 is preferred.
[0048] Then, the local histogram is reconstructed based on the weighted contribution values, and the grayscale image is enhanced using the optimized CLAHE algorithm to obtain the enhanced image.
[0049] Specifically, the image is divided into continuous, non-overlapping segments. An image patch of pixels. When constructing a histogram for each image patch, the weighted contribution values of all pixels within that patch are summed. That is, for a grayscale value... The Update the histogram statistics of the image patch by 1 pixel. ,in, The gray level within this image block is The sum of the weighted contribution values of the pixels; It is the first The weighted contribution values of each pixel are used to construct a local histogram. Subsequently, the weighted histogram is integrated to generate a cumulative distribution function, which is then used as a mapping function to transform the pixel grayscale. Finally, bilinear interpolation is used to eliminate block artifacts and obtain a smooth enhanced image. Bilinear interpolation is an existing technique and will not be elaborated on here.
[0050] Because of the introduction of a weighting mechanism, pixels belonging to impurities have a greater statistical weight in the histogram. This allows impurity regions to be allocated a wider range of gray levels during the equalization process, thereby effectively improving their contrast. Meanwhile, shadow regions have their contrast enhancement limited due to the suppression of their weights, thus avoiding the generation of artifacts.
[0051] like Figure 2 As shown in the figure, the histograms of the original image, the image processed by the standard CLAHE algorithm, and the image processed by the CLAHE algorithm optimized by this invention compare the pixel grayscale distribution. The horizontal axis represents grayscale values, and the vertical axis represents the number of pixels. The figure shows that the pixel distribution curve corresponding to the original image is mainly concentrated in the low-brightness range of grayscale values from 0 to 100, indicating a narrow dynamic range and difficulty in distinguishing impurities from the shadow background. While the pixel distribution curve corresponding to the standard CLAHE algorithm stretches the grayscale levels to the full range of 0 to 255, its indiscriminate equalization strategy amplifies shadow noise while increasing overall brightness. In contrast, the pixel distribution curve corresponding to the optimized algorithm of this invention reconstructs the histogram based on impurity confidence, exhibiting a non-uniform selective distribution. This distribution characteristic verifies that this invention, while increasing contrast, achieves targeted enhancement of impurity signals and effective suppression of shadow backgrounds, providing a high-quality data foundation for subsequent accurate identification.
[0052] Finally, threshold segmentation is performed on the enhanced image to complete impurity identification. This invention preferably uses the Otsu's method, but implementers can choose other segmentation algorithms according to the actual scenario requirements. The reason for choosing the Otsu algorithm is that, after the aforementioned enhancement, the grayscale distribution of impurities and background in the image exhibits obvious bimodal characteristics. The Otsu algorithm can adaptively calculate the optimal threshold to distinguish between the two types of pixels, thereby accurately separating the impurity region and avoiding the subjectivity of manually setting the threshold.
[0053] Furthermore, considering that the sensor may generate isolated noise points, connected component analysis is performed on the segmented binary image. If the area of the segmented connected component is greater than the preset minimum impurity area, such as 5 pixels, it is determined that there are indeed impurities in the fruit and vegetable powder, and a removal command is issued.
[0054] This completes the accurate identification of impurities in fruit and vegetable powder images.
[0055] The second aspect of this embodiment provides an impurity identification system for fruit and vegetable powder, such as... Figure 3 As shown, the impurity identification system for fruit and vegetable powder includes a memory and a processor. The memory stores computer program instructions, which, when executed by the processor, implement the first aspect of the present invention: an impurity identification method for fruit and vegetable powder.
[0056] The impurity identification system for fruit and vegetable powder also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the setup and functions of which are known in the art and will not be described in detail here.
[0057] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (DRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (DRAM), high-bandwidth memory, hybrid memory cube, etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device.
[0058] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for impurity identification of fruit and vegetable powder, characterized by, The method comprises the following steps: Collecting the original image of fruit and vegetable powder on the conveying belt, and preprocessing the original image to obtain a gray image; Based on the gray scale distribution characteristics of all pixel points in the neighborhood window of each pixel point in the gray image, the dark channel index of each pixel point is obtained; The dispersion degree of gradient amplitude and the information entropy of gradient direction in the neighborhood window of each pixel point are counted; the dark channel index is corrected by using the dispersion degree and the information entropy, and the impurity confidence of each pixel point is obtained; The gray image is subjected to adaptive histogram equalization processing based on the impurity confidence to obtain an enhanced image, wherein the count value of each pixel point is determined by the impurity confidence when constructing a local histogram; the enhanced image is subjected to threshold segmentation and connected domain analysis to identify impurities.
2. The impurity identification method for fruit and vegetable powder according to claim 1, characterized by, The method comprises the following steps: Taking any pixel point in the gray image as a current pixel point, calculating the difference between the average gray value in the neighborhood window and the gray value of the current pixel point, and dividing the difference by the gray value of the current pixel point to obtain a gray difference ratio; A background suppression term is constructed by combining the ratio of the minimum gray value in the neighborhood window to the global average gray value; The dark channel index of each pixel point is obtained by multiplying the gray difference ratio and the background suppression term.
3. The impurity identification method for fruit and vegetable powder according to claim 2, characterized by, The dark channel index satisfies the following relationship: ; wherein, is a dark channel index of the i-th pixel point; is a gray value of the i-th pixel point; is a mean value of the gray values in a neighborhood window of the i-th pixel point; is a minimum gray value in a neighborhood window of the i-th pixel point; is a global mean value of the gray values of the gray image; is a natural exponential function; is a preset first infinitesimal value. 4. The impurity identification method for fruit and vegetable powder according to claim 1, characterized by, The dispersion degree of gradient amplitude in the neighborhood window of each pixel point is obtained by the following steps: The variance of the gradient amplitude in the neighborhood window of each pixel point is calculated as the dispersion degree of the gradient amplitude.
5. The impurity identification method for fruit and vegetable powder according to claim 4, characterized by, The impurity confidence satisfies the following relationship: ; wherein, is the impurity confidence of the i-th pixel point; is the dark channel index of the i-th pixel point; is the standard deviation of the gradient magnitude in the neighborhood window of the i-th pixel point; is the mean of the gradient magnitude in the neighborhood window of the i-th pixel point; is the information entropy of the gradient direction in the neighborhood window of the i-th pixel point; is the natural exponential function; is a preset second infinitesimal value. 6. The impurity identification method for fruit and vegetable powder according to claim 5, characterized by, The information entropy of the gradient direction in the neighborhood window of each pixel point is obtained by the following steps: The horizontal gradient and the vertical gradient of each pixel point are calculated by using an edge detection operator, and the gradient direction angle is calculated according to the ratio of the horizontal gradient to the vertical gradient; The value range of the gradient direction angle is divided into several discrete direction intervals, and the probability of the gradient direction angle falling into each direction interval in the neighborhood window is counted; The product of the logarithm value of the probability and the probability is calculated, the products of all direction intervals are accumulated and taken as negative values to obtain the information entropy of the gradient direction.
7. The impurity identification method for fruit and vegetable powder according to claim 1, characterized by, The method comprises the following steps: The impurity confidence of each pixel point is nonlinearly stretched by using a power function, and the weighted contribution value of each pixel point is obtained by rounding off in combination with a preset amplification coefficient; The gray image is divided into several non-overlapping image blocks, the sum of the weighted contribution values corresponding to each gray level in each image block is counted, and a local histogram is constructed; Based on the local histogram, the pixels in the image block are subjected to gray mapping, and each image block is fused by using interpolation operation to obtain an enhanced image.
8. The impurity identification method for fruit and vegetable powder according to claim 7, characterized by, The weighted contribution value satisfies the following relationship: ; wherein, is the weighted contribution value of the i-th pixel point when constructing the local histogram; is the impurity confidence of the i-th pixel point; is a power function term with the impurity confidence of the i-th pixel point as the base number and the adjustment exponent as the exponent; is a magnification coefficient; is a floor function. 9. The method for identifying impurities of fruit and vegetable powder according to claim 1, characterized by, The method comprises the following steps: The global threshold of the enhanced image is calculated by using the maximum inter-class variance method, and the enhanced image is segmented into a binary image according to the global threshold; The binary image is subjected to connected domain labeling to obtain several connected domains; The pixel area of each connected domain is calculated, and if the area of the connected domain is greater than a preset minimum impurity area threshold, the connected domain is determined as an impurity.
10. A system for impurity identification of fruit and vegetable powder, characterized in that, The impurity identification system for fruit and vegetable powder comprises a processor and a memory, and the memory stores computer program instructions which, when executed by the processor, implement the impurity identification method for fruit and vegetable powder according to any one of claims 1-9.
Citation Information
Patent Citations
Stevioside product impurity detection method based on machine vision
CN116721108A
Oil production quality detection method based on machine vision
CN117011303A
Dough kneading impurity detection method and system
CN118096545A
Metal powder impurity analysis method and system based on machine vision
CN120543532A
Foreign matter layered detection method and system and electronic equipment
CN120951053A
Cited By
Illite and pine needle oil load uniformity detection method based on image recognition
CN121998927A