Fruit recognition method and device based on fruit color, equipment and storage medium
By using HSV color space and Mahalanobis distance comparison technology, the problems of high labor costs and insufficient RGB color space in fruit sorting have been solved, thereby improving the accuracy and efficiency of fruit identification.
Patent Information
- Application Number
- CN202211397625.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-09
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-11-09
AI Technical Summary
Existing technologies suffer from high labor costs and the inability of the RGB color space to intuitively represent color changes during fruit sorting, resulting in low fruit recognition efficiency.
Using the HSV color space, the HSV color information of the fruit to be identified is obtained. Taking advantage of the fact that the fruit hue information conforms to the Laplace distribution, the Mahalanobis distance of the fruit to be identified is calculated and compared with the pre-established characteristic Mahalanobis distance of each type of fruit to identify the fruit type.
It improves the accuracy and efficiency of fruit sorting, reduces labor costs, and enhances the accuracy of fruit identification.
Smart Images

Figure CN116129424B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image recognition, and in particular to a fruit recognition method and device based on fruit color, an equipment and a storage medium. BACKGROUND
[0002] With the continuous development of science and technology, e-commerce emerges as the times require, and fresh food such as fruits can be quickly delivered to users. Before transportation, fruits need to be sorted and packaged.
[0003] At present, many small and medium-sized merchants manually sort and package fruits, which consumes a large amount of unnecessary labor cost. Some large-scale merchants have automated fruit sorting, but the fruit sorting is based on RGB color space. However, the RGB color space cannot directly represent the change of color, so the application in reality is greatly limited.
[0004] The HSV color space uses a form that is more easily perceived by humans to represent color changes, i.e. changes in hue, changes in brightness, and changes in color purity, by further encapsulating color information. Therefore, how to use the HSV color space to accurately identify fruits to improve fruit sorting efficiency is a problem to be solved. SUMMARY
[0005] Therefore, it is necessary to provide a fruit recognition method and device based on fruit color, an equipment and a storage medium, to accurately identify fruits and improve fruit sorting efficiency.
[0006] To achieve the above purpose, in a first aspect, the present application provides a fruit recognition method based on fruit color, comprising:
[0007] Obtaining a fruit image to be identified, and segmenting a fruit to be identified from the fruit image to be identified;
[0008] Obtaining HSV color information of the fruit to be identified, and determining hue information of the fruit to be identified in the HSV color information of the fruit to be identified;
[0009] Obtaining a feature Mahalanobis distance of each type of fruit that has been established, wherein the feature Mahalanobis distance of each type of fruit is calculated based on distribution parameters of a hue Laplace distribution of each type of fruit;
[0010] Calculating the Mahalanobis distance of the fruit to be identified based on the hue information of the fruit to be identified and the distribution parameters of the hue Laplace distribution of each type of fruit;
[0011] The Mahalanobis distance of the to-be-identified fruit is compared with the characteristic Mahalanobis distance of each type of fruit based on the distribution parameters of the hue Laplace distribution of each type of fruit, and the fruit type of the to-be-identified fruit is determined according to the comparison result.
[0012] Further, the fruit to be identified is segmented from the to-be-identified fruit image, comprising:
[0013] The to-be-identified fruit image is segmented based on a preset segmentation algorithm to obtain the segmented to-be-identified fruit.
[0014] Further, the HSV color information of the to-be-identified fruit is obtained, comprising:
[0015] The RGB color information of the to-be-identified fruit is extracted, and the RGB color information of the to-be-identified fruit is converted into HSV color information of the to-be-identified fruit based on a preset color conversion relationship.
[0016] Further, the process of establishing the characteristic Mahalanobis distance of each type of fruit comprises:
[0017] Color image data sets of different types of fruits are collected, fruits are segmented from the color image data sets of different types of fruits, and the fruits are divided into different types of fruit data sets according to categories;
[0018] The HSV color information of each type of fruit data set is extracted, and the hue information of each type of fruit data set is determined in the HSV color information of each type of fruit data set;
[0019] The hue Laplace distribution of each type of fruit data set is parameter estimated based on a maximum likelihood estimation algorithm to obtain the distribution parameters of the hue Laplace distribution of each type of fruit;
[0020] A preset probability confidence interval of the hue Laplace distribution of each type of fruit is obtained;
[0021] The characteristic Mahalanobis distance of each type of fruit is established according to the preset probability confidence interval and the distribution parameters of the hue Laplace distribution of each type of fruit.
[0022] Further, the hue Laplace distribution of each type of fruit data set is parameter estimated based on a maximum likelihood estimation algorithm to obtain the distribution parameters of the hue Laplace distribution of each type of fruit, comprising:
[0023] The hue Laplace distribution of each type of fruit data set is parameter estimated based on a maximum likelihood estimation algorithm to obtain the position parameter and the scale parameter of the hue Laplace distribution of each type of fruit;
[0024] wherein the location parameter of the fruit color tone Laplace distribution of each fruit type is an expectation of the fruit color tone Laplace distribution of each fruit type;
[0025] The scale parameter of the fruit color tone Laplace distribution of each fruit type is an average value of absolute values of differences between the fruit color tone information color tone value and the expectation.
[0026] Further, the calculation formula of the feature Mahalanobis distance of each fruit type is:
[0027]
[0028] wherein m is the feature Mahalanobis distance of each fruit type, d is a difference between a confidence upper limit of a preset probability confidence interval of the fruit color tone Laplace distribution of each fruit type and a mean value, and b is the scale parameter of the fruit color tone Laplace distribution of each fruit type.
[0029] Further, the calculation of the Mahalanobis distance of the fruit to be identified based on the fruit color tone information of the fruit to be identified and the distribution parameters of the fruit color tone Laplace distribution of each fruit type comprises:
[0030] determining each color tone value and the number of color tone values of the fruit to be identified based on the fruit color tone information of the fruit to be identified;
[0031] determining the location parameter and the scale parameter of the fruit color tone Laplace distribution of each fruit type based on the distribution parameters of the fruit color tone Laplace distribution of each fruit type;
[0032] calculating the Mahalanobis distance of the fruit to be identified according to each color tone value of the fruit to be identified, the number of color tone values of the fruit to be identified, and the location parameter and the scale parameter of the fruit color tone Laplace distribution of each fruit type;
[0033] wherein the calculation formula of the Mahalanobis distance of the fruit to be identified is:
[0034]
[0035] wherein M d is the Mahalanobis distance of the fruit to be identified, N is the number of color tone values of the fruit to be identified, x i is each color tone value of the fruit to be identified, μ is the location parameter of the fruit color tone Laplace distribution of each fruit type, and b is the scale parameter of the fruit color tone Laplace distribution of each fruit type.
[0036] In a second aspect, the present application further provides a fruit identification device based on fruit color, comprising:
[0037] an extraction module configured to acquire a fruit image to be identified, and segment the fruit to be identified from the fruit image to be identified;
[0038] determining module configured to acquire HSV color information of the fruit to be identified, and determine hue information of the fruit to be identified in the HSV color information of the fruit to be identified;
[0039] acquiring module configured to acquire a characteristic Mahalanobis distance of each type of fruit that has been established, wherein the characteristic Mahalanobis distance of each type of fruit is calculated based on distribution parameters of a hue Laplace distribution of each type of fruit;
[0040] calculating module configured to calculate a Mahalanobis distance of the fruit to be identified based on the hue information of the fruit to be identified and the distribution parameters of the hue Laplace distribution of each type of fruit;
[0041] comparing module configured to compare the Mahalanobis distance of the fruit to be identified with the characteristic Mahalanobis distance of each type of fruit based on the distribution parameters of the hue Laplace distribution of each type of fruit, and determine the type of fruit of the fruit to be identified according to a comparison result.
[0042] In a third aspect, the present application further provides an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the fruit identification method based on fruit color when executing the computer program.
[0043] In a fourth aspect, the present application further provides a computer storage medium, which stores a computer program, and the computer program implements the steps of the fruit identification method based on fruit color when executed by a processor.
[0044] The beneficial effects of the above embodiments are as follows: the fruit to be identified is obtained by segmenting and extracting the fruit to be identified image and eliminating irrelevant background factors, the HSV information of the fruit to be identified is acquired according to the human eye perception characteristics, the characteristic Mahalanobis distance of each type of fruit that has been established is acquired by using the feature that the fruit hue information conforms to the Laplace distribution, the Mahalanobis distance of the fruit to be identified is calculated according to the hue information of the fruit to be identified and the distribution parameters of the hue Laplace distribution of each type of fruit, and finally the Mahalanobis distance of the fruit to be identified is compared with the characteristic Mahalanobis distance of each type of fruit based on the distribution parameters of the hue Laplace distribution of each type of fruit, so as to identify the type of the fruit to be identified. The fruit identification is more accurate, and the efficiency of fruit sorting is further improved. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 A flowchart of an embodiment of the fruit identification method based on fruit color provided by the present application is shown in the figure;
[0046] FIG. 2 is an example of a fruit to be identified image and its segmentation provided by an embodiment of the present application;
[0047] Figure 3 A flowchart for establishing the Mahalanobis distance of each type of fruit is provided for an embodiment of the present application;
[0048] FIG. 4 is a hue distribution histogram of different fruit data sets provided for an embodiment of the present application;
[0049] Figure 5 A schematic diagram of different fruit Laplace distributions is provided for an embodiment of the present application;
[0050] FIG. 6 is a hue distribution histogram of a fruit image to be identified provided for an embodiment of the present application;
[0051] Figure 7 A structural schematic diagram of an embodiment of a fruit recognition device based on fruit color provided by the present application;
[0052] Figure 8 A structural schematic diagram of an electronic device provided by the present application. DETAILED DESCRIPTION
[0053] The preferred embodiments of the present application will be described in detail below with reference to the drawings, which form a part of this application. The drawings show, by way of illustration, the principles of the application and the preferred embodiments to convey the substance of the present application to others skilled in the art. However, it is to be understood that no limitation of the scope of the application is intended by the illustration of the preferred embodiments.
[0054] In the description of the present application, the terms "first", "second", and the like are used only to describe the purpose and are not to be construed as indicating or implying relative importance or a specific number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In addition, the meaning of "a plurality of" is two or more, unless otherwise specifically limited. In this document, the reference to "embodiments" means that the specific features, structures or characteristics described in connection with the embodiments can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it necessarily mutually exclusive or alternative to other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0055] The specific embodiments are described in detail as follows:
[0056] Please refer to Figure 1 , Figure 1 A flowchart of an embodiment of a fruit recognition method based on fruit color provided by the present application, a specific embodiment of the present application discloses a fruit recognition method based on fruit color, comprising:
[0057] Step S101: obtaining a fruit image to be identified, and segmenting the fruit to be identified from the fruit image to be identified;
[0058] Step S102: obtaining HSV color information of the fruit to be identified, and determining hue information of the fruit to be identified from the HSV color information of the fruit to be identified;
[0059] Step S103: obtaining a feature Mahalanobis distance of each type of fruit, wherein the feature Mahalanobis distance of each type of fruit is calculated based on distribution parameters of a hue Laplace distribution of each type of fruit;
[0060] Step S104: calculating a Mahalanobis distance of the fruit to be identified based on the hue information of the fruit to be identified and the distribution parameters of the hue Laplace distribution of each type of fruit;
[0061] Step S105: comparing the Mahalanobis distance of the fruit to be identified with the feature Mahalanobis distance of each type of fruit based on the distribution parameters of the hue Laplace distribution of each type of fruit, and determining a fruit type of the fruit to be identified according to a comparison result.
[0062] In the fruit identification, generally, an image of the fruit is identified. However, due to the influence of the environment, the fruit image to be identified also includes other objects, such as a packaging bag and a fruit box. Therefore, it is necessary to segment the fruit to be identified from the fruit image to be identified. In addition, if the fruit image to be identified includes multiple types of fruits, it is also necessary to segment the fruit image to be identified to obtain each type of fruit to be identified after segmentation.
[0063] It can be understood that the HSV color space represents three indexes of hue, saturation and brightness, respectively. The HSV color space represents color changes in a form that is more easily perceived by humans through further encapsulation of color information. Therefore, the color information of the fruit, such as the change of the hue, can be used for fruit identification.
[0064] Further, the feature Mahalanobis distance of each type of fruit can be obtained, wherein the feature Mahalanobis distance of each type of fruit is calculated based on the distribution parameters of the hue Laplace distribution of each type of fruit. It can be understood that the hue of each type of fruit satisfies a certain Laplace distribution. Therefore, the hue Laplace distribution of each type of fruit can be obtained, and the hue Laplace distribution of the fruit is taken as the feature distribution of the type of fruit.
[0065] Specifically, in the calculation of the characteristic Mahalanobis distance of each type of fruit by using the distribution parameters of the fruit tone Laplace distribution of each type, the distribution parameters of the fruit tone Laplace distribution of each type include a location parameter and a scale parameter, and the characteristic Mahalanobis distance of each type of fruit refers to a Mahalanobis distance satisfying a preset probability, which can be obtained by dividing the difference between the upper limit of the confidence interval of the preset probability confidence interval and the mean value by the scale parameter of the Laplace distribution, for example, dividing the difference between the upper limit of the 90% probability confidence interval and the mean value by the scale parameter of the Laplace distribution.
[0066] For the fruit to be identified, the hue information of the fruit to be identified can be used to calculate the Mahalanobis distance of the fruit to be identified and each type of fruit corresponding to the distribution parameters of the fruit tone Laplace distribution of each type. It can be understood that the Mahalanobis distance of the fruit to be identified obtained in this process is multiple, and then the Mahalanobis distance of the fruit to be identified is compared with the characteristic Mahalanobis distance of each type of fruit, and the fruit type of the fruit to be identified can be identified.
[0067] In the comparison of the Mahalanobis distance of the fruit to be identified and the characteristic Mahalanobis distance of each type of fruit, the comparison is based on the distribution parameters of the fruit tone Laplace distribution of each type. For example, assuming that the fruits for which the characteristic Mahalanobis distance has been established are apples, bananas and oranges, when the Mahalanobis distance of the fruit to be identified is obtained, the Mahalanobis distance 1 based on the distribution parameters of the apple tone Laplace distribution, the Mahalanobis distance 2 based on the distribution parameters of the banana tone Laplace distribution, and the Mahalanobis distance 3 based on the distribution parameters of the orange tone Laplace distribution can be obtained respectively; assuming that the characteristic Mahalanobis distance 1 of the apple, the characteristic Mahalanobis distance 2 of the banana and the characteristic Mahalanobis distance 3 of the orange, since the distribution parameters of each tone Laplace distribution are fixed, the comparison can be based on the distribution parameters of the fruit tone Laplace distribution of each type when the Mahalanobis distance is compared with the characteristic Mahalanobis distance. The specific comparison relationship is: comparing the Mahalanobis distance 1 of the fruit to be identified with the characteristic Mahalanobis distance 1 of the apple, comparing the Mahalanobis distance 2 of the fruit to be identified with the characteristic Mahalanobis distance 2 of the banana, and comparing the Mahalanobis distance 3 of the fruit to be identified with the characteristic Mahalanobis distance 3 of the orange. It can be seen that this comparison method only needs to be compared once when compared, which improves the identification efficiency. In addition, when compared, if the Mahalanobis distance is less than the characteristic Mahalanobis distance, for example, the Mahalanobis distance 1 of the fruit to be identified is less than the characteristic Mahalanobis distance 1 of the apple, then the fruit type of the fruit to be identified is identified as an apple.
[0068] The beneficial effects of the above embodiment are: the application extracts the to-be-identified fruit by segmenting and extracting the to-be-identified fruit image and eliminating irrelevant background factors; acquires the HSV information of the to-be-identified image according to the human eye perception characteristics, then acquires the feature Mahalanobis distance of each type of fruit pre-established by using the feature that the fruit hue information conforms to the Laplace distribution, then calculates the Mahalanobis distance of the to-be-identified fruit according to the hue information of the to-be-identified fruit and the distribution parameters of the hue Laplace distribution of each type of fruit, and finally compares the Mahalanobis distance of the to-be-identified fruit with the feature Mahalanobis distance of each type of fruit based on the distribution parameters of the hue Laplace distribution of each type of fruit to identify the type of the to-be-identified fruit. The fruit identification is more accurate, and the efficiency of fruit sorting is further improved.
[0069] In an embodiment of the application, the to-be-identified fruit is segmented from the to-be-identified fruit image, including:
[0070] The to-be-identified fruit image is segmented based on a preset segmentation algorithm to obtain the to-be-identified fruit after segmentation processing.
[0071] The preset segmentation algorithm is a Meanshift algorithm. By using the Meanshift algorithm, the irrelevant environmental factors in the to-be-identified fruit image can be filtered, and each type of fruit can be segmented from the image; and the multiple images in the to-be-identified fruit image can be distinguished and segmented. Please refer to FIG. 2, which is a to-be-identified fruit image and a segmentation example provided by an embodiment of the application. In FIG. 2, FIG. 2(a) is a to-be-identified fruit image, and FIG. 2(b) is a segmentation diagram of the to-be-identified fruit image.
[0072] In an embodiment of the application, the HSV color information of the to-be-identified fruit is acquired, including:
[0073] The RGB color information of the to-be-identified fruit is extracted, and the RGB color information of the to-be-identified fruit is converted into the HSV color information of the to-be-identified fruit based on a preset color conversion relationship.
[0074] It can be understood that the RGB color information includes red, green and blue three primary colors, and humans are more likely to perceive the HSV color information than the RGB color information. When the color space is converted, the RGB color information can be preprocessed, that is: C max =max(R′、G′、B′),C min =min(R′、G′、B′),Δ=C max -C min .
[0075] Then the conversion can be carried out by using the known color conversion relationship, taking the conversion of hue H as an example, firstly, it is needed to be explained that the value range of hue H is 0°-360°, and the calculation is carried out in the counterclockwise direction from the red color, the red color is 0°, the green color is 120°, and the blue color is 240°; their complementary colors are: the yellow color is 60°, the cyan color is 180°, and the magenta color is 300°, so the conversion relationship of hue H is as follows:
[0076]
[0077] In an embodiment of the present application, please refer to Figure 3 , Figure 3 A process schematic diagram for establishing the characteristic Mahalanobis distance of each type of fruit provided by an embodiment of the present application, comprising:
[0078] Step S301: collecting color image data sets of different types of fruits, segmenting the fruits from the color image of different types of fruits, and dividing the fruits into different types of fruit data sets according to the categories;
[0079] Step S302: extracting the HSV color information of each type of fruit data set, and determining the hue information of each type of fruit data set in the HSV color information of each type of fruit data set;
[0080] Step S303: parameter estimation of the hue Laplace distribution of each type of fruit data set based on the maximum likelihood estimation algorithm, to obtain the distribution parameters of the hue Laplace distribution of each type of fruit;
[0081] Step S304: obtaining the preset probability confidence interval of the hue Laplace distribution of each type of fruit;
[0082] Step S305: establishing the characteristic Mahalanobis distance of each type of fruit according to the preset probability confidence interval and the distribution parameters of the hue Laplace distribution of each type of fruit.
[0083] It can be understood that by converting the fruit from the RGB color space to the HSV color space, it is found that the hue of each fruit satisfies a certain Laplace distribution. Therefore, a large amount of fruit color image data of different types can be collected, and the collected fruit color image is segmented by using a preset segmentation algorithm such as the Meanshift algorithm for the main color part, irrelevant elements such as background are removed, and data sets of various types of fruits are formed according to the categories; the color conversion relationship described above is used to convert the RGB image format to the HSV image format for each data set, and the hue information of each fruit data set is extracted; then the maximum likelihood estimation algorithm is used to estimate the parameters of the hue Laplace distribution of each fruit data set, and the distribution parameters of the hue Laplace distribution of each fruit are obtained, wherein the distribution parameters include the position parameter and the scale parameter.
[0084] It should be noted that the Mahalanobis distance is a measure of distance, which can be regarded as a modification of the Euclidean distance, which modifies the problem of inconsistent and related dimensions in the Euclidean distance. When the hue Laplace distribution of each fruit is calculated and the position parameter and scale parameter of each hue Laplace distribution are determined, the preset probability confidence interval of each fruit hue Laplace distribution is obtained, wherein the preset probability confidence interval can be selected as the 90% probability confidence interval of the hue Laplace distribution, and then the difference between the upper limit of the confidence interval and the mean value is calculated times the scale parameter, which is used as the characteristic Mahalanobis distance of each fruit.
[0085] In an embodiment of the present application, the maximum likelihood estimation algorithm is used to estimate the parameters of the hue Laplace distribution of each fruit data set, and the hue Laplace distribution parameters of each fruit are obtained, including:
[0086] The maximum likelihood estimation algorithm is used to estimate the parameters of the hue Laplace distribution of each fruit data set, and the position parameter and scale parameter of the hue Laplace distribution of each fruit are obtained;
[0087] The position parameter of the hue Laplace distribution of each fruit is the expected value of the hue Laplace distribution of each fruit.
[0088] The scale parameter of the hue Laplace distribution of each fruit is the average value of the absolute value of the difference between the hue value of the hue information of each fruit and the expected value.
[0089] It should be noted that using HSV color space instead of RGB color space can better represent color changes; in HSV color space, the Hue value representing the hue is represented in Matlab as an interval of 0 to 1. The hue value from 0 to 1 corresponds to the position of the color on the color circle. As the hue increases from 0 to 1, the color transitions from red to orange, yellow, green, cyan, blue, magenta, and finally back to red. Red is near 0 and 1, and the interval of magenta is 0.9 to 1. In practice, in order to ensure the continuity of data, the hue value of 0.9 to 1 is reduced by 1 to become -0.1 to 0 according to the periodicity of the hue color circle, and the hue Laplace distribution of red can be obtained continuously. Therefore, in the embodiment of the present application, the hue value of 0.9 to 1 of the fruit in the experiment is reduced by 1.
[0090] Referring to FIG. 4, FIG. 4 is a hue distribution histogram of different fruit data sets provided by an embodiment of the present application. Specifically, FIG. 4(a) is a red apple data set and a red apple hue distribution histogram, FIG. 4(b) is an orange data set and an orange hue distribution histogram, FIG. 4(c) is a banana data set and a banana hue distribution histogram, and FIG. 4(d) is a green apple data set and a green apple hue distribution histogram.
[0091] It can be seen that the hue of each type of fruit satisfies the Laplace distribution. Specifically, by collecting the hue distribution histograms of each fruit on the same graph and using the maximum likelihood estimation algorithm to estimate the likelihood, the hue Laplace distribution of each type of fruit can be obtained. Referring to FIG. 5, Figure 5 , Figure 5 FIG. 6 is a schematic diagram of the hue Laplace distribution of different fruits provided by an embodiment of the present application.
[0092] Further, the parameter estimation of the hue Laplace distribution of each type of fruit data set can be performed based on the maximum likelihood estimation algorithm to obtain the location parameter and the scale parameter of the hue Laplace distribution of each type of fruit, wherein the location parameter of the hue Laplace distribution of each type of fruit is the expectation of the hue Laplace distribution of each type of fruit; and the scale parameter of the hue Laplace distribution of each type of fruit is the average value of the absolute value of the difference between the hue value of the hue information of each type of fruit and the expectation.
[0093] In an embodiment of the present application, the calculation formula of the feature Mahalanobis distance of each type of fruit is: wherein m is the feature Mahalanobis distance of each type of fruit, d is the difference between the upper limit of the preset probability confidence interval and the mean value of the hue Laplace distribution of each type of fruit, and b is the scale parameter of the hue Laplace distribution of each type of fruit.
[0094] It can be understood that when each fruit color tone Laplace distribution is calculated, the location parameter and the scale parameter of each color tone Laplace distribution are determined, and the difference between the confidence upper limit of the preset probability confidence interval in the color tone Laplace distribution and the mean value is calculated times the scale parameter, for example, the confidence interval of 90% probability of the color tone Laplace distribution is selected, and then the difference between the corresponding confidence upper limit and the mean value is calculated according to the confidence interval, and then divided by times the scale parameter, that is, the feature Mahalanobis distance of each fruit.
[0095] For example, assuming that μ is the location parameter of the fruit data set, b is the scale parameter of the fruit data set, the color tone Laplace distribution of the fruit has a 90% probability in the interval [μ-d, μ+d], and the corresponding feature Mahalanobis distance is m, that is, the Mahalanobis distance not greater than m has a 90% probability of belonging to the fruit, wherein,
[0096] In an embodiment of the present application, the Mahalanobis distance of the fruit to be identified is calculated based on the color tone information of the fruit to be identified and the distribution parameters of the color tone Laplace distribution of each fruit, comprising:
[0097] Based on the color tone information of the fruit to be identified, each color tone value of the fruit to be identified and the number of color tone values are determined;
[0098] Based on the distribution parameters of the color tone Laplace distribution of each fruit, the location parameter and the scale parameter of the color tone Laplace distribution of each fruit are determined;
[0099] The Mahalanobis distance of the fruit to be identified is calculated according to each color tone value of the fruit to be identified, the number of color tone values of the fruit to be identified, and the location parameter and the scale parameter of the color tone Laplace distribution of each fruit;
[0100] The formula for calculating the Mahalanobis distance of the fruit to be identified is:
[0101]
[0102] Wherein, M d is the Mahalanobis distance of the fruit to be identified, N is the number of color tone values of the fruit to be identified, x i is each color tone value of the fruit to be identified, μ is the location parameter of the color tone Laplace distribution of each fruit, and b is the scale parameter of the color tone Laplace distribution of each fruit.
[0103] It can be understood that in the fruit recognition process, for each input fruit image, the hue information of the fruit is obtained after segmentation and extraction, and then the Mahalanobis distance of the fruit to be recognized is calculated based on the hue Laplace distribution of each type of fruit, that is, the Mahalanobis distance of the fruit to be recognized is calculated according to each hue value of the fruit to be recognized, the number of hue values of the fruit to be recognized, and the position parameter and scale parameter of the hue Laplace distribution of each type of fruit.
[0104] If the Mahalanobis distance of the fruit to be recognized is less than the characteristic Mahalanobis distance of the hue Laplace distribution of a certain type of fruit, that is, the Mahalanobis distance of the fruit to be recognized is less than the characteristic Mahalanobis distance of the hue Laplace distribution of the fruit, then it is the fruit. Further, if the Mahalanobis distance of the fruit to be recognized is less than the characteristic Mahalanobis distance of the 90% probability confidence interval of the hue Laplace distribution of the fruit, that is, the input data has at least 90% probability of belonging to the fruit, and in practice, it is determined to belong to the fruit.
[0105] In addition, please refer to FIG. 6, which is a hue distribution histogram of a fruit image to be recognized according to an embodiment of the present application. Specifically, FIG. 6(a) is a red apple image to be recognized and its hue distribution histogram, FIG. 6(b) is an orange image and its hue distribution histogram, FIG. 6(c) is a banana image and its hue distribution histogram, and FIG. 6(d) is a green apple image and its hue distribution histogram. By comparing the hue histograms of FIG. 6 and FIG. 4, it can be seen that the histogram of the recognized fruit has the same trend as the hue histogram of the fruit data set.
[0106] In order to better implement the fruit recognition method based on fruit color in the embodiment of the present application, on the basis of the fruit recognition method based on fruit color, please refer to Figure 7 , Figure 7 FIG. 7 is a structural schematic diagram of an embodiment of a fruit recognition device based on fruit color provided by the present application. The embodiment of the present application provides a fruit recognition device 700 based on fruit color, which comprises:
[0107] The extraction module 701 is configured to obtain a fruit image to be recognized, and segment the fruit to be recognized from the fruit image to be recognized.
[0108] The determination module 702 is configured to obtain the HSV color information of the fruit to be recognized, and determine the hue information of the fruit to be recognized in the HSV color information of the fruit to be recognized.
[0109] The acquisition module 703 is configured to obtain the characteristic Mahalanobis distance of each type of fruit that has been established, wherein the characteristic Mahalanobis distance of each type of fruit is calculated based on the distribution parameters of the hue Laplace distribution of each type of fruit.
[0110] The computing module 704 is configured to calculate Mahalanobis distance of the fruit to be identified based on the hue information of the fruit to be identified and the distribution parameters of the hue Laplace distribution of each fruit category.
[0111] The comparing module 705 is configured to compare the Mahalanobis distance of the fruit to be identified with the characteristic Mahalanobis distance of each fruit category based on the distribution parameters of the hue Laplace distribution of each fruit category, and determine the fruit category of the fruit to be identified according to the comparison result.
[0112] It should be noted that the apparatus 700 provided in the above embodiments can implement the technical solutions described in the above method embodiments, and the principles of the implementation of the above modules or units can be referred to the corresponding content in the above method embodiments, which will not be described here.
[0113] Based on the fruit identification method based on fruit color, the embodiments of the present application also correspondingly provide an electronic device, which comprises a processor and a memory, and a computer program stored in the memory and executable on the processor; the processor implements the steps in the fruit identification method based on fruit color according to the above embodiments when executing the computer program.
[0114] Figure 8 The structure of the electronic device 800 suitable for implementing the embodiments of the present application is shown in FIG. 8. The electronic device in the embodiments of the present application can include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. Figure 8 The electronic device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.
[0115] The electronic device comprises a memory and a processor, wherein the processor can be referred to as the processing device 801 below, and the memory can include at least one of a read-only memory (ROM) 802, a random access memory (RAM) 803, and a storage device 808, as shown below:
[0116] As shown in FIG. 8, the electronic device can further include a communication interface 805, an input device 806, and a display device 807. Figure 8As shown, the electronic device 800 can include a processing device (e.g., a central processor, a graphics processor, etc.) 801 that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 802 or loaded from a storage device 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the electronic device 800 are also stored in the RAM 803. The processing device 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0117] Generally, the following devices can be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication devices 809 can allow the electronic device 800 to communicate wirelessly or wired with other devices to exchange data. Although Figure 8 The electronic device 800 is shown with various devices, but it should be understood that not all of the shown devices are required to be implemented or present. More or fewer devices can alternatively be implemented or present.
[0118] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present application. For example, embodiments of the present application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication devices 809, or installed from the storage devices 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the methods of embodiments of the present application are performed.
[0119] Based on the above fruit recognition method based on fruit color, embodiments of the present application also correspondingly provide a computer readable storage medium, the computer readable storage medium stores one or more programs, the one or more programs can be executed by one or more processors to implement the steps in the fruit recognition method based on fruit color of each of the above embodiments.
[0120] Those skilled in the art can understand that all or part of the processes of the above-mentioned embodiments can be completed by instructing relevant hardware through a computer program, and the program can be stored in a computer readable storage medium. Among them, the computer readable storage medium is a disk, an optical disk, a read-only memory or a random access memory, etc.
[0121] The above description is only the preferred embodiment of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application.
Claims
1. A fruit recognition method based on fruit color, characterized by, The method comprises the following steps: acquire the fruit image to be identified, and segment the fruit to be identified from the fruit image to be identified; acquire the HSV color information of the fruit to be identified, and determine the hue information of the fruit to be identified in the HSV color information of the fruit to be identified; acquire the characteristic Mahalanobis distance of each type of fruit, wherein the characteristic Mahalanobis distance of each type of fruit is calculated based on the distribution parameters of the hue Laplace distribution of each type of fruit; calculate the Mahalanobis distance of the fruit to be identified based on the hue information of the fruit to be identified and the distribution parameters of the hue Laplace distribution of each type of fruit; compare the Mahalanobis distance of the fruit to be identified with the characteristic Mahalanobis distance of each type of fruit based on the distribution parameters of the hue Laplace distribution of each type of fruit, and determine the fruit type of the fruit to be identified according to the comparison result.
2. The fruit recognition method based on fruit color according to claim 1, characterized in that, The segmentation of the fruit to be identified from the fruit image to be identified comprises: segment the fruit to be identified from the fruit image to be identified based on a preset segmentation algorithm.
3. The fruit recognition method based on fruit color according to claim 1, characterized in that, The acquisition of the HSV color information of the fruit to be identified comprises: extract the RGB color information of the fruit to be identified, and convert the RGB color information of the fruit to be identified into the HSV color information of the fruit to be identified based on a preset color conversion relationship.
4. The fruit color-based fruit recognition method according to claim 1, characterized by, The process of establishing the characteristic Mahalanobis distance of each type of fruit comprises: collect color image data sets of different types of fruits, segment the fruits from the color image data sets of different types of fruits, and divide the fruits into different types of fruit data sets according to the types; extract the HSV color information of each type of fruit data set, and determine the hue information of each type of fruit data set in the HSV color information of each type of fruit data set; estimate the parameters of the hue Laplace distribution of each type of fruit data set based on a maximum likelihood estimation algorithm, and obtain the distribution parameters of the hue Laplace distribution of each type of fruit; acquire a preset probability confidence interval of the hue Laplace distribution of each type of fruit; establish the characteristic Mahalanobis distance of each type of fruit according to the preset probability confidence interval and the distribution parameters of the hue Laplace distribution of each type of fruit.
5. The fruit recognition method based on fruit color according to claim 4, characterized in that, The estimation of the parameters of the hue Laplace distribution of each type of fruit data set based on the maximum likelihood estimation algorithm comprises: estimate the parameters of the hue Laplace distribution of each type of fruit data set based on the maximum likelihood estimation algorithm, and obtain the location parameter and the scale parameter of the hue Laplace distribution of each type of fruit; wherein the location parameter of the hue Laplace distribution of each type of fruit is the expectation of the hue Laplace distribution of each type of fruit; the scale parameter of the hue Laplace distribution of each type of fruit is the average value of the absolute value of the difference between the hue value of the hue information of each type of fruit and the expectation.
6. The fruit recognition method based on fruit color according to claim 5, characterized by, The calculation formula of the characteristic Mahalanobis distance of each type of fruit is: Wherein, m is the characteristic Mahalanobis distance of each fruit, d is the difference between the upper limit of the preset probability confidence interval and the mean value of the hue Laplace distribution of each fruit, and b is the scale parameter of the hue Laplace distribution of each fruit.
7. The fruit recognition method based on fruit color according to claim 6, characterized by, The method comprises the following steps: The method comprises the following steps: Based on the hue information of the fruit to be identified, the position parameter and the scale parameter of the hue Laplace distribution of each fruit are determined; Based on the hue information of the fruit to be identified, the position parameter and the scale parameter of the hue Laplace distribution of each fruit are determined; The Mahalanobis distance of the fruit to be identified is calculated according to the hue value of the fruit to be identified, the number of hue values of the fruit to be identified, and the position parameter and the scale parameter of the hue Laplace distribution of each fruit; wherein M d is the Mahalanobis distance of the fruit to be identified, N is the number of hue values of the fruit to be identified, x i is each hue value of the fruit to be identified, μ is the location parameter of the hue Laplace distribution of each class of fruit, and b is the scale parameter of the hue Laplace distribution of each class of fruit.
8. A fruit recognition apparatus based on fruit color, characterized by, The calculation formula of the Mahalanobis distance of the fruit to be identified is as follows: The method comprises the following steps: The extraction module is used to acquire the fruit image to be identified, and to segment the fruit to be identified from the fruit image to be identified; The determination module is used to acquire the HSV color information of the fruit to be identified, and to determine the hue information of the fruit to be identified in the HSV color information of the fruit to be identified; The acquisition module is used to acquire the characteristic Mahalanobis distance of each fruit, which is calculated based on the distribution parameter of the hue Laplace distribution of each fruit; The calculation module is used to calculate the Mahalanobis distance of the fruit to be identified based on the hue information of the fruit to be identified and the distribution parameter of the hue Laplace distribution of each fruit; 9. An electronic device, comprising: The comparison module is used to compare the Mahalanobis distance of the fruit to be identified with the characteristic Mahalanobis distance of each fruit based on the distribution parameter of the hue Laplace distribution of each fruit, and to determine the fruit type of the fruit to be identified according to the comparison result.
10. A computer-readable storage medium, characterized in that, The memory and the processor are included, wherein the memory is used to store programs; the processor is coupled with the memory, and is used to execute the programs stored in the memory, so as to realize the steps in the fruit identification method based on fruit color in any one of claims 1 to 7. The computer readable program or instructions are stored, and the program or instructions can realize the steps in the fruit identification method based on fruit color in any one of claims 1 to 7 when executed by the processor.
Citation Information
Patent Citations
Fruit classifying method according to surface color
CN101125333A
Medical image processing apparatus and medical image processing method
CN102724909A