A color detection method for fruit and vegetable images based on color value level proximity weighting

By constructing the color value grade difference sampling objective function and ring weighting coefficient, and selecting pixels as cluster centers, the problem of insufficient utilization of color value grade differences in fruit and vegetable image color detection is solved, and efficient color detection and features of fruit and vegetable images are achieved. extract.

CN116630654BActive Publication Date: 2024-09-27REEMOON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310663455.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-06
Publication Date
2024-09-27
Estimated Expiration
2043-06-06

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively utilize the color value level differences of pixels in the color detection of fruit and vegetable images, resulting in inaccurate image segmentation and inability to effectively reduce local information redundancy and extract image features.

Method used

By constructing a color value level difference sampling objective function, using the color value level proximity weighting status of pixels to recommend ring weighting coefficients, selecting pixels as the clustering centers of super pixel blocks, and dividing fruit and vegetable images into different color value levels. Superpixel block.

Benefits of technology

It achieves efficient color detection of fruit and vegetable images, reduces the redundancy of local information in the image, and improves the accuracy and application effect of image feature calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116630654B
    Figure CN116630654B
Patent Text Reader

Abstract

The invention discloses a color detection method for fruit and vegetable images based on the weighted condition of color value level neighborhood. The method constructs a color value level difference sampling condition objective function by randomly selecting the sum of the difference between the weighted condition of color value level neighborhood of a plurality of pixel points in a training set of weighted coefficients of fruit and vegetable images and the expert evaluation value of the pixel point being able to become a cluster center. Then, the weighted condition of color value level neighborhood of different pixel points is determined by multiplying the value of a plurality of rings starting from the number of color value level consistent neighboring rings by the weighted value of the color value level consistent ratio, thereby judging whether a certain pixel point becomes the cluster center of a super pixel block. The color detection is completed by dividing the detected fruit and vegetable images into super pixel blocks corresponding to the cluster centers of different color value levels.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image detection, and specifically relates to constructing a color value level difference sampling status objective function by arbitrarily selecting the sum of the differences between the color value level neighboring weighted status of a number of pixel points in a fruit and vegetable image weighted coefficient training set and the expert evaluation value that the pixel point can become a cluster center to give a recommended value of the neighboring ring number weighted coefficient, and using the color value level neighboring weighted status as an evaluation criterion for whether the pixel point is a cluster center of a super pixel block, and completing the fruit and vegetable image color detection by dividing the detected fruit and vegetable image into super pixel blocks corresponding to cluster centers of different color value levels. Background Art

[0002] Superpixel technology can calculate pixel similarity based on the visual characteristics or spatial distance of the target image, integrate pixels with similar characteristics, and finally form several pixel areas with the same geometric shape, similar characteristics, and similar structure. Superpixel blocks have the characteristics of separability, connectivity, boundary adhesion, compactness, and controllable quantity. Superpixel segmentation is to aggregate pixels with the same characteristics into many small blocks. Each pixel block has its own unique local information, and pixels in different pixel blocks have different characteristics. Superpixel segmentation can effectively reduce the redundancy of local information in the image and calculate image features. It has achieved good application results in image information extraction and target detection in the field of fruit and vegetable sorting technology. Summary of the invention

[0003] The purpose of the present invention is to construct a color value level difference sampling condition objective function to obtain a recommended value of a neighboring ring number weighted coefficient to select a pixel point with the largest color value level neighboring weighted condition among pixels as a clustering center of a certain area as a super pixel block, thereby dividing the detected fruit and vegetable image into super pixel blocks of different color value levels to realize fruit and vegetable image color detection;

[0004] To achieve the above purpose, the technical solution proposed by the present invention is as follows:

[0005] According to the technical solution provided by the present invention, a method for detecting color of fruit and vegetable images based on the weighted condition of color value level proximity comprises: Figure 1 The following is shown in:

[0006] A) Assuming that the color of the fruit and vegetable image can be divided by color value level, by comparing the color value level of a certain pixel in the fruit and vegetable image with the color value level of the neighboring pixels of the th ring of the pixel, wherein the th ring of a certain pixel refers to a square ring-shaped area formed by the neighboring pixels that are separated from the pixel by the number of rings minus one pixel, the number of color value level differences of the th ring of the pixel can be obtained; if the color value levels of all neighboring pixels in the th ring of a certain pixel are consistent with the color value level of the pixel, but the color value levels of some neighboring pixels on the ring outside the ring of the pixel are inconsistent with the color value level of the pixel, the number of neighboring rings with consistent color value levels of the pixel can be determined; assuming that the color value level consistency ratio of the pixel with respect to the th ring can be determined by dividing the number of neighboring pixels on the th ring of a certain pixel with consistent color value level of the pixel by the number of all neighboring pixels on the th ring of the pixel;

[0007] B) Assuming that the weighted condition of the color value level of a certain pixel point can be determined by multiplying the weighted value of several rings starting from the number of neighboring rings with consistent color value level by the ratio of consistent color value level; after introducing the Lagrange coefficient and the weighted power exponent greater than 1, the color value level difference sampling condition objective function can be constructed as the sum of the difference between the color value level neighboring weighted conditions of several pixels randomly selected in the training set of weighted coefficients of fruit and vegetable images and the expert evaluation value that the pixel point can become the cluster center, wherein the expert evaluation value that the pixel point can become the cluster center is the expert evaluation probability that the pixel point can become the cluster center multiplied by the color value level neighboring weighted condition of the corresponding cluster center; respectively giving the first-order derivative and the second-order derivative of the color value level difference sampling condition objective function to the neighboring ring number weighting coefficient; when the first-order derivative is zero and the second-order derivative is greater than zero, then under the condition that the neighboring ring number weighting coefficient has normalization, giving the recommended value of the neighboring ring number weighting coefficient corresponding to the specified number of rings can minimize the color value level difference sampling condition objective function;

[0008] C) The part of the detected fruit and vegetable image that has not completed superpixel segmentation is randomly divided into several areas, and several pixels are randomly selected near the geometric center of each area, and the pixel point with the largest weighted neighboring color value level among the pixels is used as the cluster center of the superpixel block in the area; if the ratio of the number of pixels in the area whose color value level is consistent with the color value level of the cluster center to the number of pixels in the entire area is less than or equal to the superpixel block color value level consistency ratio threshold, then the entire area is used as the superpixel block corresponding to the cluster center, otherwise the maximum tolerable number of rings of the cluster center in the area is determined, and the area within the ring is used as the superpixel block corresponding to the cluster center; if there is still a part of the detected fruit and vegetable image that has not completed superpixel segmentation, the division is continued.

[0009] The above-mentioned A) specifically includes the following:

[0010] A1) Assume that the color of the fruit and vegetable image can be divided by color value level. The color value level SD(k) of the pixel k in the fruit and vegetable image is compared with the color value levels of the neighboring pixels of the lth ring of the pixel k, where the lth ring of the pixel k refers to the square ring area formed by the neighboring pixels that are l-1 pixels away from the pixel k. For example, the neighboring pixels of the first ring, the second ring and the third ring of the pixel k are respectively as follows: Figure 2 As shown in (a), (b) and (c), the color value level difference DIF of the lth ring of pixel k can be obtained. l (k) shall take the following forms:

[0011]

[0012] Among them, Φ l (k) is the set of neighboring pixels of the lth ring of pixel k, x is the intermediate variable, SD is the color value level function, true is the judgment function, the correct output is 1, and the wrong output is 0;

[0013] A2) If the color value levels of all neighboring pixels in the lth ring of pixel k are consistent with the color value level of pixel k, but the color value levels of some neighboring pixels in the l+1th ring of pixel k are inconsistent with the color value level of pixel k, then the number of neighboring rings D of pixel k with consistent color value levels can be determined. k , the specific form is as follows:

[0014]

[0015] Among them, y is the intermediate variable;

[0016] A3) Assume that the color value level consistency ratio SYB of pixel k with respect to the lth ring can be determined by dividing the number of neighboring pixels of pixel k on the lth ring with the color value level of pixel k by the number of all neighboring pixels of pixel k on the lth ring. l (k) shall take the following forms:

[0017]

[0018] The above-mentioned B) specifically includes the following contents:

[0019] B1) Assume that the weighted state of the color value level of pixel k SJZ(k) can be obtained by the number of neighboring rings with consistent color value levels D k The value of the L ring starting from the outside is multiplied by the weighted value of the color value level consistency ratio, which is determined in the following form:

[0020]

[0021] Where l is the specified number of rings, ω l is the weight coefficient of the number of adjacent rings corresponding to the specified number of rings l, and L is the total number of rings;

[0022] B2) After introducing the Lagrangian coefficient λ and the weighted power index h, the color value level difference sampling condition objective function F can be constructed as K arbitrarily selected weighted coefficients in the fruit and vegetable image training set Θ GT The sum of the differences between the weighted color value level of the pixel point in the cluster and the expert evaluation value that the pixel point can become the cluster center, where the expert evaluation value that the pixel point can become the cluster center is the expert evaluation probability that the pixel point can become the cluster center multiplied by the weighted color value level of the corresponding cluster center. The specific form is as follows:

[0023]

[0024] Among them, CXS(k) is the cluster center corresponding to pixel k, and the weighted power index h should satisfy h>1;

[0025] B3) respectively give the relationship between F and ω l The first derivative of and the second derivative The specific form is as follows:

[0026]

[0027]

[0028] B4) When is 0 and When it is greater than 0, Recommended value of weighted coefficient of neighboring rings corresponding to the specified number of rings l under normalized conditions It can minimize F, and the specific form is as follows:

[0029]

[0030] The above, C) specifically includes Figure 3 The following steps are shown:

[0031] C1) Let the set of all pixels of the detected fruit and vegetable image that has completed color value classification be Ψ0, set the number of loop steps t to 0 and the set of pixels that have completed superpixel segmentation when t=0 Ξ t for

[0032] C2) randomly divides the unsegmented superpixel parts of the detected fruit and vegetable images into at most regions, where M is the number of target pixels in the superpixel block, w is the curvature reduction of the superpixel block pixels, and size is a function of the number of elements in the set;

[0033] C3) Randomly select at most pixels, where N is the number of randomly selected pixels, according to the specific form of the weighted condition of the color value level in B) and the recommended value of the weighted coefficient of the number of neighboring rings Calculate the weighted proximity of the color value level corresponding to each randomly selected pixel point;

[0034] C4) The pixel with the largest weighted color value level among the randomly selected pixels in each region is used as the cluster center of the superpixel block in the region; if the ratio of the number of pixels in the region whose color value levels are consistent with the color value level of the cluster center p to the number of pixels in the entire region is less than or equal to η, where η is the ratio threshold of the color value level consistency of the superpixel block, then the entire region is used as the superpixel block corresponding to the cluster center p; otherwise, the gth superpixel block of the cluster center p is used. p The area inside the ring is the superpixel block corresponding to the cluster center p, where g p is the maximum tolerable number of rings of the cluster center p in this area, and its specific form is as follows:

[0035]

[0036] Among them, q is an intermediate variable, which takes a positive integer;

[0037] C5) Add the pixel points of the superpixel block corresponding to each region to t In the above example, we judge whether Ψ0-Ξ t Is it If Ψ0-Ξ t for Then enter C6; if Ψ0-Ξ t Not for Then enter C2, and t+1 replaces t;

[0038] C6) Merge the superpixel blocks with the same color value level and output the fruit and vegetable image with completed color detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 The flowchart of color detection of fruit and vegetable images based on the weighted condition of color value level proximity;

[0040] Figure 2 Schematic diagram of neighboring pixels of the first ring, the second ring and the third ring of pixel k;

[0041] Figure 3 is a specific step diagram in C);

[0042] Figure 4 For different L values Status map;

[0043] Figure 5 The ratio of completed superpixel segmentation at different numbers of loop steps. DETAILED DESCRIPTION

[0044] The present invention will be further described below in conjunction with the accompanying drawings by applying the fruit and vegetable image color detection method based on the weighted color value level proximity condition to a Red Fuji apple color image.

[0045] In an embodiment of the present invention, a method for detecting color of fruit and vegetable images based on the weighted state of color value level proximity includes the following contents:

[0046] A) Considering that the HSI color model mainly represents color by three components: hue, saturation, and brightness, chromaticity is the characteristic that distinguishes colors from each other. Since chromaticity contains necessary color information, it can reflect the composition of the color on the surface of the fruit, and thus the color features are extracted based on the chromaticity histogram of the fruit. According to the provisions of the national standard GB10651-89 on the color grade of Red Fuji apples, by performing chromaticity analysis on the color composition of the apple surface, the area from red to green and magenta in the chromaticity histogram of Red Fuji apples is evenly divided into 15 equal parts according to numerical values ​​for use as color value grades; the color value grade SD(k) of pixel k in the Red Fuji apple color image can be compared with the color value grades of the neighboring pixels of the lth ring of pixel k, where the lth ring of pixel k refers to the square ring area formed by the neighboring pixels that are l-1 pixels away from pixel k, to obtain the color value grade difference number DIF of the lth ring of pixel k. l (k); If the color value levels of all neighboring pixels in the lth ring of pixel k are consistent with the color value level of pixel k, but the color value levels of some neighboring pixels in the l+1th ring of pixel k are inconsistent with the color value level of pixel k, then the number of neighboring rings D of pixel k with consistent color value levels can be determined. k ; Assume that the color value level consistency ratio SYB of pixel k with respect to the lth ring can be determined by dividing the number of neighboring pixels of pixel k on the lth ring with the same color value level as pixel k by the number of all neighboring pixels of pixel k on the lth ring. l (k);

[0047] B) Assume that the weighted state of the color value level of pixel k in the color image of Red Fuji apple can be obtained by the number of neighboring rings with consistent color value levels D kThe value of the L ring starting from the outside is multiplied by the weighted value after the color value level consistency ratio is determined; after introducing the Lagrange coefficient λ and the weighted power index h, the weighted coefficient training set Θ of the fruit and vegetable image can be established by setting 200 Red Fuji apple color images GT And from the θ GT In any image, K = 500 pixels are selected to construct the color value level difference sampling condition objective function F. is 0 and When it is greater than 0, Recommended value of weighted coefficient of neighboring rings corresponding to the specified number of rings l under normalized conditions Can make F tend to minimize; Figure 4 The results for different L values ​​are given in Status diagram, it can be seen from the figure that D k The corresponding The maximum, and then decreases successively. When l=5,6,7, it can be seen that the corresponding Compared with the previous ones, they are smaller, and as the L value increases, from l = 1 to l = 4, The total has exceeded 99%, which shows that selecting L=4 in specific use can meet the expected effect;

[0048] C) specifically includes the following steps:

[0049] C1) Let the set of all pixels of the detected Red Fuji apple color image that has completed color value grading be Ψ0, where the pixels of the detected Red Fuji apple color image are set to 1024*768, the number of loop steps t is set to 0 and the set of pixels that have completed superpixel segmentation when t=0 is Ξ t for

[0050] C2) Randomly divide the unsegmented superpixel parts of the Fuji apple color image into at most regions, where the target number M of superpixel blocks can be set to 1024, and the curvature w of superpixel block pixel reduction can be set to 0.1;

[0051] C3) Randomly select at most pixel points, where the number of randomly selected pixel points N can be set to 16, and the color value level neighboring weighted condition corresponding to each randomly selected pixel point is calculated according to the specific form of the color value level neighboring weighted condition in B), where L = 4, corresponding to l = 1, 2, 3 and 4 They are 0.417, 0.308, 0.18 and 0.095 respectively;

[0052] C4) The pixel with the largest weighted neighboring color value level among the randomly selected pixels in each region is used as the cluster center of the superpixel block in the region; if the ratio of the number of pixels in the region whose color value levels are consistent with the color value level of the cluster center p to the number of pixels in the entire region is less than or equal to η, where the superpixel block color value level consistency ratio threshold η is set to 0.98, then the entire region is used as the superpixel block corresponding to the cluster center p; otherwise, the gth superpixel block of the cluster center p is used. p The area inside the ring is taken as the superpixel block corresponding to the cluster center p;

[0053] C5) Add the pixel points of the superpixel block corresponding to each region to t In the above example, we judge whether Ψ0-Ξ t Is it If Ψ0-Ξ t for Then enter C6; if Ψ0-Ξ t Not for Then enter C2, and t+1 replaces t;

[0054] C6) The color image of Red Fuji apple is output after merging superpixel blocks of the same color value level.

[0055] Figure 5 The figure shows the completed superpixel segmentation ratio of four Fuji apple color images at different cycle steps, where the completed superpixel segmentation ratio is set as the ratio of the number of elements in the pixel point set that has completed superpixel segmentation to the number of elements in the total pixel point set. Figure 5 It can be seen that for the Red Fuji apple color images a, b, c and d, the superpixel segmentation ratio has basically reached more than 55% after the first cycle. After the number of cycle steps reaches 9, all pixel points of the detected Red Fuji apple color images have basically completed the division of the corresponding superpixel blocks, thereby realizing color detection based on color value levels.

[0056] Any part not specified in this embodiment can be implemented using existing technologies.

[0057] For those skilled in the art, according to the teachings of the present invention, without departing from the principles and spirit of the present invention, changes, modifications, substitutions and variations made to the implementation methods are still within the protection scope of the present invention.

Claims

1. A method for color detection of fruit and vegetable images based on the weighted state of color value level proximity, characterized in that: The method includes the following: A) Assuming that the color of the fruit and vegetable image can be divided by color value level, by comparing the color value level of a certain pixel in the fruit and vegetable image with the color value level of the neighboring pixels of the th ring of the pixel, wherein the th ring of a certain pixel refers to a square ring-shaped area formed by the neighboring pixels that are separated from the pixel by the number of rings minus one pixel, the number of color value level differences of the th ring of the pixel can be obtained; if the color value levels of all neighboring pixels in the th ring of a certain pixel are consistent with the color value level of the pixel, but the color value levels of some neighboring pixels on the ring outside the ring of the pixel are inconsistent with the color value level of the pixel, the number of neighboring rings with consistent color value levels of the pixel can be determined; assuming that the color value level consistency ratio of the pixel with respect to the th ring can be determined by dividing the number of neighboring pixels on the th ring of a certain pixel with consistent color value level of the pixel by the number of all neighboring pixels on the th ring of the pixel; B) Assuming that the weighted condition of the color value level of a certain pixel point can be determined by multiplying the weighted value of several rings starting from the number of neighboring rings with consistent color value level by the ratio of consistent color value level; after introducing the Lagrange coefficient and the weighted power exponent greater than 1, the color value level difference sampling condition objective function can be constructed as the sum of the difference between the color value level neighboring weighted conditions of several pixels randomly selected in the training set of weighted coefficients of fruit and vegetable images and the expert evaluation value that the pixel point can become the cluster center, wherein the expert evaluation value that the pixel point can become the cluster center is the expert evaluation probability that the pixel point can become the cluster center multiplied by the color value level neighboring weighted condition of the corresponding cluster center; respectively giving the first-order derivative and the second-order derivative of the color value level difference sampling condition objective function to the neighboring ring number weighting coefficient; when the first-order derivative is zero and the second-order derivative is greater than zero, then under the condition that the neighboring ring number weighting coefficient has normalization, there is a recommended value of the neighboring ring number weighting coefficient corresponding to the specified number of rings, which can minimize the color value level difference sampling condition objective function; C) The part of the detected fruit and vegetable image that has not completed superpixel segmentation is randomly divided into several areas, and several pixels are randomly selected near the geometric center of each area, and the pixel point with the largest weighted neighboring color value level among the pixels is used as the cluster center of the superpixel block in the area; if the ratio of the number of pixels in the area whose color value level is consistent with the color value level of the cluster center to the number of pixels in the entire area is less than or equal to the superpixel block color value level consistency ratio threshold, then the entire area is used as the superpixel block corresponding to the cluster center, otherwise the maximum tolerable number of rings of the cluster center in the area is determined, and the area within the ring is used as the superpixel block corresponding to the cluster center; if there is still a part of the detected fruit and vegetable image that has not completed superpixel segmentation, the division is continued.

2. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 1, characterized in that: A) The specific method for obtaining the number of color value level differences of a certain ring of pixel points is: Assume that the color of the fruit and vegetable image can be divided by color value level. By comparing the color value level SD(k) of pixel k in the fruit and vegetable image with the color value levels of the neighboring pixels of the i-th ring of pixel k, where the l-th ring of pixel k refers to the square ring area formed by the neighboring pixels separated from pixel k by i-1 pixels, the color value level difference number DIFi(k) of the l-th ring of pixel k can be obtained. The specific form is as follows: Among them, Φ l (k) is the set of neighboring pixels of the lth ring of pixel k, SD is the color value level function, true is the judgment function, the correct output is 1, and the wrong output is 0.

3. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 2, characterized in that: A) The specific method for determining the number of neighboring rings with consistent color value levels of a pixel is: If the color value levels of all neighboring pixels in the lth ring of pixel k are consistent with the color value level of pixel k, but the color value levels of some neighboring pixels in the i+1th ring of pixel k are inconsistent with the color value level of pixel k, then the number of neighboring rings D of pixel k with consistent color value levels can be determined. k , the specific form is as follows: Among them, y is the intermediate variable.

4. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 3, characterized in that: A) The specific method for determining the color value level consistency ratio of the pixel points with respect to a certain ring is: Suppose that the color value level consistency ratio SYB of pixel k with respect to the i-th ring can be determined by dividing the number of neighboring pixels of pixel k on the l-th ring with the same color value level as pixel k by the number of all neighboring pixels of pixel k on the i-th ring. i (k) shall take the following forms:

5. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 4, characterized in that: The weighted condition of the color value level of a certain pixel in B) can be determined by multiplying the weighted value of the values ​​of several rings starting from the number of neighboring rings with consistent color value levels by the consistent color value level ratio. The specific method is: Assume that the weighted state of the color value level of pixel k SJZ(k) can be obtained by the number of neighboring rings with consistent color value levels D k The value of the L ring starting from the outside is multiplied by the weighted value of the color value level consistency ratio to determine the specific form is as follows: Among them, ω l is the weighted coefficient of the number of adjacent rings corresponding to the specified number of rings l, and L is the total number of rings.

6. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 5, characterized in that: The specific method of constructing the color value level difference sampling condition objective function in B) is: After introducing the Lagrangian coefficient λ and the weighted power index h, the color value level difference sampling condition objective function F can be constructed as K arbitrarily selected weighted coefficients in the fruit and vegetable image training set Θ GT The sum of the differences between the weighted color value level of the pixel point in the cluster and the expert evaluation value that the pixel point can become the cluster center, where the expert evaluation value that the pixel point can become the cluster center is the expert evaluation probability that the pixel point can become the cluster center multiplied by the weighted color value level of the corresponding cluster center. The specific form is as follows: Among them, CXS(k) is the cluster center corresponding to pixel k, η k is the ratio threshold of the color value level consistency of the superpixel block corresponding to pixel k.

7. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 6, characterized in that B) The specific method of giving the first-order derivative and the second-order derivative of the weighted coefficient of the adjacent ring number of the color value level difference sampling condition objective function is:

8. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 7, characterized in that B) The specific method for giving the recommended value of the neighboring ring number weighting coefficient corresponding to the specified number of rings under the condition that the neighboring ring number weighting coefficient has normalization is: when is 0 and When it is greater than 0, Recommended value of weighted coefficient of neighboring rings corresponding to the specified number of rings l under normalized conditions It can minimize F, and the specific form is as follows:

9. The method for color detection of fruit and vegetable images based on weighted color value level proximity according to claim 8, characterized in that: Described C) is implemented according to the following steps: C1) Let the set of all pixels of the detected fruit and vegetable image that has completed color value classification be Ψ0, set the number of loop steps t to 0 and the set of pixels that have completed superpixel segmentation when t=0 Ξ t for C2) randomly divides the unsegmented superpixel parts of the detected fruit and vegetable images into at most regions, where M is the number of target pixels in the superpixel block, w is the curvature reduction of the superpixel block pixels, and size is a function of the number of elements in the set; C3) Randomly select at most pixels, where N is the number of randomly selected pixels, according to the specific form of the weighted condition of the color value level in B) and the recommended value of the weighted coefficient of the number of neighboring rings Calculate the weighted proximity of the color value level corresponding to each randomly selected pixel point; C4) taking the pixel with the largest weighted neighboring color value level among the randomly selected pixels in each region as the cluster center of the superpixel block in the region; if the ratio of the number of pixels in the region whose color value levels are consistent with the color value level of the cluster center p to the number of pixels in the entire region is less than or equal to n, where n is the superpixel block color value level consistency ratio threshold, then the entire region is taken as the superpixel block corresponding to the cluster center p; Otherwise, take the gth cluster center p p The area inside the ring is the superpixel block corresponding to the cluster center p, where g p is the maximum tolerable number of rings of the cluster center p in this area, and its specific form is as follows: Among them, q is an intermediate variable, which takes a positive integer; C5) Add the pixel points of the superpixel block corresponding to each region to t In the above example, we judge whether Ψ0-Ξ t Is it If Ψ0-Ξ t for Then enter C6; if Ψ0-Ξ t Not for Then enter C2, and t+1 replaces t; C6) Merge the superpixel blocks with the same color value level and output the fruit and vegetable image with completed color detection.