A method and system for detecting the maturity of melons based on artificial intelligence

By acquiring side images of melons and performing principal component analysis and wavelet transform to obtain gray-level co-occurrence and color feature matrices, a classification network is trained. This solves the problem of low non-destructive accuracy in existing melon maturity detection, and achieves high-precision maturity detection and quality management.

CN115223164BActive Publication Date: 2025-11-14GUANGXI ZHUANG AUTONOMOUS REGION ACAD OF AGRI SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211037777.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-29
Publication Date
2025-11-14
Estimated Expiration
2042-08-29

AI Technical Summary

Technical Problem

Existing methods for detecting the ripeness of melons either require damaging the fruit's skin or have low accuracy in automatic identification, affecting the testing results for merchants.

Method used

By collecting side images of melons from multiple angles, principal component analysis and two-level wavelet transform are performed to obtain the gray-level co-occurrence matrix and color feature matrix of the detail images, and a classification network is trained to detect maturity.

Benefits of technology

It enables non-destructive and accurate detection of melon maturity, reducing waste costs and improving melon quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115223164B_ABST
    Figure CN115223164B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image processing technology, specifically to an artificial intelligence-based method and system for detecting the maturity of melons. The method acquires side images of the melon from multiple angles to obtain corresponding principal component side images. Two-stage wavelet transforms are performed on the principal component side images to obtain detail images in different directions. The gradient changes of the detail images in corresponding directions are used to obtain the corresponding step size, thereby obtaining the corresponding gray-level co-occurrence matrix. The feature parameters of the gray-level co-occurrence matrices in the three directions form the texture representation matrix of the principal component side images. The average saturation, average pixel value, pixel value variation range, and gray-level distribution uniformity of all pixels in the side images constitute a color feature matrix. The texture representation matrix and the color feature matrix form the feature analysis matrix for each side image. The maturity of the melon is detected based on the feature analysis matrix. This invention can accurately assess the maturity of melons with high recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and specifically to a method and system for detecting the maturity of melons based on artificial intelligence. Background Technology

[0002] The ripeness of melons has a significant impact on melon vendors' planning for storage, transportation, grading, and sales. Most existing methods for detecting melon ripeness require damaging the fruit's skin or performing destructive testing, which negatively impacts sales for vendors. Non-destructive testing methods using image processing mostly rely on the color of the melon's surface for ripeness detection, but these methods suffer from low accuracy and poor detection results. Summary of the Invention

[0003] To address the aforementioned technical problems, this invention provides a method and system for detecting the maturity of melons based on artificial intelligence. The specific technical solution adopted is as follows:

[0004] In a first aspect, one embodiment of the present invention provides a method for detecting the maturity of melons based on artificial intelligence, the method comprising the following steps:

[0005] Side images of the melon to be tested were collected from multiple angles, and the corresponding principal component side images were obtained by performing principal component analysis on each side image.

[0006] By performing a two-level wavelet transform on the principal component side view, detail maps in different directions are obtained, including horizontal detail maps, vertical detail maps, and diagonal detail maps. The corresponding step size is obtained by using the gradient changes of the detail maps in the corresponding directions, and the gray-level co-occurrence matrix in the corresponding direction is obtained based on the step size. The texture representation matrix of the principal component side view is composed of the feature parameters of the gray-level co-occurrence matrices in the three directions.

[0007] Calculate the average pixel value and pixel value variation range of all pixels in the side image; obtain the grayscale distribution uniformity based on the difference between the pixel values ​​of all pixels and the average pixel value; convert the side image to a color space that includes saturation, extract the saturation channel image, and calculate the average saturation in the saturation channel image; construct a color feature matrix from the average saturation, average pixel value, pixel value variation range, and grayscale distribution uniformity.

[0008] Each side image is composed of a texture representation matrix and a color feature matrix. A classification network is trained based on the feature analysis matrix. The trained classification network is used as a melon maturity detection network to detect the maturity of the melon to be detected.

[0009] Preferably, the method for obtaining the principal component side view is as follows:

[0010] Multiple principal component directions are obtained through principal component analysis. The images corresponding to the first three principal component directions are selected and the pixel values ​​at the corresponding positions are weighted and summed to obtain the principal component side view.

[0011] Preferably, the step of obtaining detail maps in different directions by performing a two-stage wavelet transform on the principal component side view includes:

[0012] The first horizontal detail image, the first vertical detail image, and the first diagonal detail image of the principal component side view are obtained by first-level wavelet transform. The second horizontal detail image, the second vertical detail image, and the second diagonal detail image of the principal component side view are obtained by second-level wavelet transform. The first horizontal detail image and the second horizontal detail image are weighted and summed according to the pixel values ​​at corresponding positions to obtain the horizontal detail image. The first vertical detail image and the second vertical detail image are weighted and summed according to the pixel values ​​at corresponding positions to obtain the vertical detail image. The first diagonal detail image and the second diagonal detail image are weighted and summed according to the pixel values ​​at corresponding positions to obtain the diagonal detail image.

[0013] Preferably, obtaining the corresponding step size using the gradient change of the detail map in the corresponding direction includes:

[0014] For the horizontal detail map, a row of pixels is extracted at each preset interval as the row of pixels to be analyzed. The horizontal gradient magnitude of each pixel in the row of pixels to be analyzed is obtained. The pixel corresponding to the horizontal gradient magnitude greater than the preset magnitude threshold is taken as the first pixel. The first pixel distance between every two adjacent first pixels in each row of pixels to be analyzed is calculated. The average value of all first pixel distances is calculated as the step size of the horizontal detail map.

[0015] For the vertical detail map, a column of pixels is extracted at every preset number of columns as the column of pixels to be analyzed. The vertical gradient magnitude of each pixel in the column of pixels to be analyzed is obtained. The pixel corresponding to the vertical gradient magnitude that is greater than the preset magnitude threshold is taken as the second pixel. The second pixel distance between every two adjacent second pixels in each column of pixels to be analyzed is calculated. The average value of all second pixel distances is calculated as the step size of the vertical detail map.

[0016] For the diagonal detail image, the pixels on the diagonal are extracted as the diagonal pixels to be analyzed. The diagonal gradient magnitude of each pixel in the diagonal pixels to be analyzed is obtained. The pixels corresponding to the diagonal gradient magnitudes that are greater than the preset diagonal magnitude threshold are taken as the third pixels. The distance between every two adjacent third pixels is calculated. The average of all third pixel distances is calculated as the step size of the diagonal detail image.

[0017] Preferably, the method for composing the texture representation matrix is ​​as follows:

[0018] For each detail image, the texture contrast, entropy, energy, and inverse variance parameters of the corresponding gray-level co-occurrence matrix are obtained as eigenvalues. The eigenvalues ​​of the three detail images are combined into a column to obtain the texture representation matrix.

[0019] Preferably, the method for obtaining the range of pixel value variation is as follows:

[0020] Obtain the first preset number of pixel values ​​with the largest pixel value in the side image, and calculate the average to obtain the maximum grayscale average value; obtain the first preset number of pixel values ​​with the smallest pixel value in the side image, and calculate the average to obtain the minimum grayscale average value; use the difference between the maximum grayscale average value and the minimum grayscale average value as the range of pixel value variation.

[0021] Preferably, training the classification network based on the feature analysis matrix includes:

[0022] Using the feature analysis matrix as input to the classification network, and manually labeling the data, the output is the maturity of the melon to be detected. The cross-entropy loss function is used as the loss function for the classification network training until the loss function converges, at which point the classification network training is complete.

[0023] Secondly, another embodiment of the present invention provides a melon maturity detection system based on artificial intelligence, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the aforementioned melon maturity detection method based on artificial intelligence.

[0024] The embodiments of the present invention have at least the following beneficial effects:

[0025] By acquiring the adaptive step size of detail images from different directions of the side image of the melon to be tested, a corresponding gray-level co-occurrence matrix is ​​constructed, which in turn yields a texture representation matrix. This matrix accurately extracts the texture of the melon's surface, serving as the basis for maturity detection. Then, image processing is used to obtain the color feature matrix of the side image, representing the color and gloss information of the melon's surface, also serving as the basis for maturity detection. A classification network is trained using a feature analysis matrix composed of the texture representation matrix and the color feature matrix. This allows the neural network to learn the relationship between texture and color and melon maturity, enabling accurate assessment of the melon's maturity based on image information. The high accuracy of this assessment allows businesses to manage the storage and transportation of melons according to their maturity, reducing losses and improving melon quality. Attached Figure Description

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

[0027] Figure 1 A flowchart illustrating the steps of an artificial intelligence-based method for detecting the maturity of melons, as provided in one embodiment of the present invention;

[0028] Figure 2 An example image of Guangmi No. 1 melon provided for one embodiment of the present invention. Detailed Implementation

[0029] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of an artificial intelligence-based melon maturity detection method and system proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0031] The application scenario of this invention is as follows: After purchasing melons from melon farmers, merchants use the method of this invention to detect their maturity. Melons with lower maturity can be stored for a longer time than those with higher maturity. Based on this, the purchased melons are then transported, stored, and sold accordingly. The specific solution of the melon maturity detection method and system based on artificial intelligence provided by this invention is described in detail below with reference to the accompanying drawings.

[0032] Please see Figure 1 The diagram illustrates a flowchart of a melon maturity detection method based on artificial intelligence, according to an embodiment of the present invention. The method includes the following steps:

[0033] Step S001: Acquire side images of the melon to be detected from multiple angles, and obtain the corresponding principal component side image by performing principal component analysis on each side image.

[0034] The specific steps include:

[0035] 1. Collect side images of the melon to be tested from multiple angles.

[0036] The melon to be tested is placed with its stem end facing down on a rotatable platform. Side images of the melon are acquired using an image acquisition device under a fixed light source. To improve detection accuracy and avoid inaccurate maturity detection due to single-data analysis, this embodiment of the invention acquires four side images at a time, rotating the melon 90° to capture images from one angle. These images are used to analyze the surface characteristics of the melon. The rotation angle of the platform and the number of side images captured can be adjusted according to actual conditions.

[0037] There are many types of melons. For example, thick-skinned melons mainly include varieties such as Gansu Bailan melon, Mama melon, and Xinjiang Hami melons such as Huangdanzi, Hongxincui, Qingxiangmapi, and Xiaoqingpi; thin-skinned melons are also known as common melons or cantaloupes.

[0038] The embodiments of the present invention are as follows Figure 2 The Green Gem melon shown is used as an example for subsequent testing.

[0039] 2. Obtain the principal component side view of each side view image.

[0040] Multiple principal component directions are obtained through principal component analysis. The images corresponding to the first three principal component directions are selected and the pixel values ​​at the corresponding positions are weighted and summed to obtain the principal component side view.

[0041] Principal component analysis (PCA) is used to perform PCA on the pixels in each side image to obtain the principal component directions for each side image. The images corresponding to the first three principal components are then used for texture feature analysis. The pixel values ​​at the corresponding positions in the images corresponding to the first three principal component directions are weighted and averaged. The weights are set to 0.5, 0.3, and 0.2 according to the order of the first, second, and third principal components, respectively, resulting in a new melon side image, denoted as the principal component side image, used for texture feature analysis. Selecting the first three principal component directions to obtain the principal component side image reduces the amount of data to be detected and avoids the influence of irrelevant data.

[0042] Step S002: Detail maps in different directions are obtained by performing a two-level wavelet transform on the principal component side view map. The detail maps include horizontal detail maps, vertical detail maps, and diagonal detail maps. The corresponding step size is obtained by using the gradient changes of the detail maps in the corresponding directions. The gray-level co-occurrence matrix in the corresponding direction is obtained based on the step size. The texture representation matrix of the principal component side view map is composed of the feature parameters of the gray-level co-occurrence matrices in the three directions.

[0043] The specific steps include:

[0044] 1. Detail images in different directions are obtained by performing a two-stage wavelet transform on the principal component side view.

[0045] The first horizontal detail map, the first vertical detail map, and the first diagonal detail map of the principal component side view are obtained through the first-level wavelet transform. The second horizontal detail map, the second vertical detail map, and the second diagonal detail map of the principal component side view are obtained through the second-level wavelet transform. The first horizontal detail map and the second horizontal detail map are weighted and summed according to the pixel values ​​at corresponding positions to obtain the horizontal detail map. The first vertical detail map and the second vertical detail map are weighted and summed according to the pixel values ​​at corresponding positions to obtain the vertical detail map. The first diagonal detail map and the second diagonal detail map are weighted and summed according to the pixel values ​​at corresponding positions to obtain the diagonal detail map.

[0046] The principal component side view image is decomposed into sub-band images of different resolutions using wavelet transform. The high-frequency sub-band images mainly reflect the detailed texture information of the image, while the low-frequency sub-band images mainly reflect the general outline information after overall smoothing. A two-stage wavelet transform is performed on the principal component side view image. The first-stage wavelet transform decomposition yields the first horizontal detail image of the principal component side view image. First vertical detail image And the first diagonal detail image The second level detail map of the principal component side view is obtained after decomposition by the second-level wavelet transform. Second vertical detail image Detail of the second diagonal Then, a weighted summation of the corresponding detail map pixels in each direction is performed. In this embodiment, the weight of the detail map corresponding to the first-level wavelet transform is set to 0.6, and the weight of the detail map corresponding to the second-level wavelet transform is set to 0.4, thus obtaining the horizontal detail map. Vertical detail images and diagonal detail images .

[0047] Wavelet transform is a well-known technique, and the specific transformation process will not be described in detail in this embodiment of the invention.

[0048] 2. Obtain the step size corresponding to the detail images in different directions, and obtain the gray-level co-occurrence matrix in the corresponding direction based on the step size.

[0049] If the step size parameter of the gray-level co-occurrence matrix is ​​not set appropriately, it will cause deviation in the extracted texture information and insufficient texture representation. Therefore, in this embodiment of the invention, the step size of the gray-level co-occurrence matrix will be adaptively set based on the gradient information of different detail images.

[0050] For the horizontal detail map, a row of pixels is extracted at each preset interval as the row of pixels to be analyzed. The horizontal gradient magnitude of each pixel in the row of pixels to be analyzed is obtained. The pixel corresponding to the horizontal gradient magnitude greater than the preset magnitude threshold is taken as the first pixel. The first pixel distance between every two adjacent first pixels in each row of pixels to be analyzed is calculated. The average value of all first pixel distances is calculated as the step size of the horizontal detail map.

[0051] The horizontal detail map represents high-frequency texture information in the horizontal direction. The gray-level co-occurrence matrix corresponding to the 0° direction value of the horizontal detail map is obtained and used to analyze the regularity of its horizontal texture information. Specifically, the horizontal detail map is analyzed by equal intervals of row pixels. Every t rows, a row of pixels is extracted as the row pixels to be analyzed. This is used to analyze the gradient primitives of the horizontal detail map in the horizontal direction, that is, the gradient change.

[0052] Taking the extracted c-th row of pixels to be analyzed as an example, obtain the horizontal gradient magnitude of the c-th row of pixels and set a preset magnitude threshold. Pixel values ​​greater than a preset amplitude threshold are set to 1, otherwise they are set to 0. Then, the pixel distance between two adjacent pixels with a value of 1 in the c-th row is taken as the first pixel distance, and the average of all first pixel distances in that row is obtained. Then calculate the average of all means among all pixels in all rows to be analyzed: , where N is the number of rows of selected rows of pixels to be analyzed.

[0053] d 1 is the step size parameter for extracting the gray-level co-occurrence matrix of the horizontal detail map, in order to obtain a gray-level co-occurrence matrix that is more suitable for representing the texture feature information of the horizontal detail map.

[0054] For the vertical detail map, a column of pixels is extracted at every preset interval as the column of pixels to be analyzed. The vertical gradient magnitude of each pixel in the column of pixels to be analyzed is obtained. The pixel corresponding to the vertical gradient magnitude that is greater than the preset magnitude threshold is taken as the second pixel. The second pixel distance between every two adjacent second pixels in each column of pixels to be analyzed is calculated. The average value of all second pixel distances is calculated as the step size of the vertical detail map.

[0055] The vertical detail map represents high-frequency texture information in the vertical direction. The gray-level co-occurrence matrix corresponding to the 90° direction value of the vertical detail map is obtained and used to analyze the regularity of its vertical texture information.

[0056] Similar to the step selection method for the horizontal detail image, the column pixels of the vertical detail image are analyzed at equal intervals. The vertical gradient of each column of pixels extracted at equal intervals is analyzed. Specifically, every t columns of pixels are obtained as the column pixels to be analyzed. Taking the extracted k-th column of pixels as an example, the vertical gradient magnitude of the k-th column of pixels is obtained. The gradient magnitude is greater than the preset vertical magnitude threshold. The pixel value is set to 1 if it is not 1, otherwise it is set to 0. The pixel distance between two adjacent pixels with a value of 1 in the k-th column is taken as the second pixel distance, and the average value of the second pixel distances of the pixels in that column is obtained. Then calculate the average of all the mean values ​​in all the pixels of the columns to be analyzed: , where M is the number of columns of the selected column of pixels to be analyzed.

[0057] d2 is the step size parameter for extracting the gray-level co-occurrence matrix of the vertical detail map, in order to obtain a gray-level co-occurrence matrix that is more suitable for representing the texture feature information of the vertical detail map.

[0058] For the diagonal detail image, the pixels on the diagonal are extracted as the diagonal pixels to be analyzed. The diagonal gradient magnitude of each pixel in the diagonal pixels to be analyzed is obtained. The pixels corresponding to the diagonal gradient magnitudes that are greater than the preset diagonal magnitude threshold are taken as the third pixels. The distance between every two adjacent third pixels is calculated. The average of all third pixel distances is calculated as the step size of the diagonal detail image.

[0059] The diagonal detail map represents the high-frequency texture information in the diagonal direction. The gray-level co-occurrence matrix corresponding to the 135° direction of the diagonal detail map is obtained and used to analyze the regularity of its texture information in the diagonal direction.

[0060] The method for obtaining the step size in the diagonal detail image is as follows: Pixels along the 135° diagonal of the diagonal detail image are selected as the diagonal pixels to be analyzed. The gradient magnitude of each pixel in the diagonal pixels to be analyzed is calculated. A preset diagonal magnitude threshold is used; pixel values ​​greater than the threshold are set to 1, otherwise to 0. The pixel distance between two adjacent pixels with a value of 1 is calculated as the third pixel distance, and the average of all third pixel distances in the diagonal pixels to be analyzed is obtained. This is used as the step size parameter for extracting the gray-level co-occurrence matrix corresponding to the diagonal detail map, so as to accurately obtain the co-occurrence matrix that can accurately represent the texture feature information of the corresponding image.

[0061] The gray-level co-occurrence matrix in the corresponding direction is obtained based on the step size in each direction. Each side image has gray-level co-occurrence matrices in three directions.

[0062] 3. The texture representation matrix of the principal component side view is composed of the feature parameters of the gray-level co-occurrence matrix in three directions.

[0063] For each detail image, the texture contrast, entropy, energy, and inverse variance parameters of the corresponding gray-level co-occurrence matrix are obtained as eigenvalues. The eigenvalues ​​of the three detail images are combined into a column to obtain the texture representation matrix.

[0064] Obtain the eigenvalues ​​of the gray-level co-occurrence matrix corresponding to the horizontal detail map. Each parameter in the eigenvalues ​​represents a feature index corresponding to the gray-level co-occurrence matrix: Con is the texture contrast, Ent is the entropy value, Asm is the energy value, and H is the inverse variance parameter. Similarly, the eigenvalues ​​of the gray-level co-occurrence matrix corresponding to the vertical detail map are obtained. And the eigenvalues ​​of the gray-level co-occurrence matrix corresponding to the diagonal detail map. .

[0065] For the i-th principal component side view, the eigenvalues ​​of the corresponding three detail views are grouped into a column to obtain the texture representation matrix. . It is a 3×4 matrix, where i=1,2,3,4 for each side image of the melon to be detected.

[0066] The texture representation matrix is ​​used to detect and analyze the overall surface texture of melons. Unripe melons have fuzz on their surface, which makes the surface texture unclear. When melons are ripe, the surface texture is clear, the net pattern is distinct, and the lines are smooth. The texture representation matrix reflects the texture characteristics of the melon surface, so as to accurately analyze its ripeness.

[0067] Step S003: Calculate the average pixel value and the range of pixel value variation of all pixels in the side image; obtain the grayscale distribution uniformity based on the difference between the pixel values ​​of all pixels and the average pixel value; convert the side image to a color space that includes saturation, extract the saturation channel image, and calculate the average saturation in the saturation channel image; construct a color feature matrix from the average saturation, average pixel value, range of pixel value variation, and grayscale distribution uniformity.

[0068] The surface color of melons changes during the ripening process, with color saturation gradually decreasing and surface gloss varying significantly. Therefore, further analysis of side images of melons is necessary to obtain color characteristic parameters of the melon surface for analyzing the ripening status.

[0069] The specific steps include:

[0070] 1. Calculate the average pixel value, pixel value variation range, and grayscale distribution uniformity of all pixels in the side image.

[0071] The grayscale value of the side image can reflect the gloss information of the melon surface. Therefore, the pixel value of the side image can be used to characterize the gloss information of the melon surface.

[0072] Taking the i-th side view image as an example, calculate the average pixel value of all pixels in the i-th side view image. It is used to characterize the light intensity information on the surface of melons.

[0073] To obtain the range of pixel value variation for all pixels in the i-th side image: obtain the first preset number of pixel values ​​with the largest pixel value in the side image, calculate the average to obtain the maximum grayscale average; obtain the first preset number of pixel values ​​with the smallest pixel value in the side image, calculate the average to obtain the minimum grayscale average; use the difference between the maximum grayscale average and the minimum grayscale average as the range of pixel value variation.

[0074] In this embodiment of the invention, the preset quantity is 10, that is, the average value of the top 10 pixel values ​​with the largest pixel values ​​in the i-th side image is calculated to obtain the maximum grayscale average value. The minimum grayscale mean is obtained by averaging the 10 smallest pixel values. The difference between the maximum and minimum grayscale values The range of pixel values ​​in the i-th side image is used to reflect the brightness changes on the image surface.

[0075] The grayscale distribution is represented by the variance of all pixel values ​​in the side view image, i.e., the grayscale distribution of the i-th side view image. , Let q represent the pixel value of the q-th pixel, where Q is the number of pixels in the i-th side view image.

[0076] The gloss information of the melon surface is represented by the average pixel value, pixel value variation range, and grayscale distribution uniformity of the side image as grayscale conditions.

[0077] 2. Convert the side image to a color space that includes saturation to obtain the average saturation.

[0078] There are many color spaces that include saturation. In this embodiment of the invention, the side image is converted to the HSV color space. Taking the i-th side image as an example, the saturation S-channel image corresponding to the i-th side image is extracted to obtain the saturation of each pixel in the saturation channel image. Then, the average saturation of all pixels in the saturation channel image is calculated. It is used to accurately characterize the color of the surface of melons.

[0079] 3. The color feature matrix is ​​composed of average saturation, average pixel value, pixel value variation range, and grayscale distribution uniformity.

[0080] Establish color feature vectors This is used for accurate detection of melon maturity. To improve data regularity, the color feature vector is padded with zeros to obtain a color feature matrix, ensuring that its size is consistent with the texture representation matrix. This color feature matrix is ​​as follows: ,for The color feature matrix is ​​used to characterize the color of the melon surface. For each side image of the melon to be detected, i = 1, 2, 3, 4.

[0081] Step S004: The feature analysis matrix of each side image is composed of the texture representation matrix and the color feature matrix. A classification network is trained based on the feature analysis matrix. The trained classification network is used as the melon maturity detection network to detect the maturity of the melon to be detected.

[0082] The specific steps include:

[0083] 1. The feature analysis matrix of each side image is composed of the texture representation matrix and the color feature matrix, and the classification network is trained based on the feature analysis matrix.

[0084] The feature analysis matrix is ​​used as the input to the classification network. The output is the maturity of the melon to be detected by manual labeling. The cross-entropy loss function is used as the loss function of the classification network for training until the loss function converges, and the classification network training is completed.

[0085] The extracted texture representation matrix and color feature matrix are integrated to establish a feature analysis matrix as the feature matrix for melon maturity analysis: Then, a melon maturity detection network was constructed to automatically detect the maturity status of melons based on the feature analysis matrix.

[0086] The maturity level of melons is classified into five levels, from 1 to 5, based on a feature analysis matrix using a classification network. The higher the level, the more mature the melon. The classification network is an existing network. The network input is the feature analysis matrix corresponding to four side images of the melon, and the network output is the melon maturity level. The network label is a manually labeled maturity level. The loss function for network training is the cross-entropy loss function. The network is trained until the loss function converges, and the classification network training is completed. The trained classification network is used as the melon maturity detection network.

[0087] 2. Conduct maturity testing on the melons to be tested.

[0088] By inputting the feature analysis matrix of the melon to be tested into the melon maturity detection network, the network outputs the corresponding maturity level, enabling rapid and accurate automatic detection of melon maturity. Furthermore, its non-contact nature avoids secondary damage to the melon.

[0089] In summary, this invention acquires side images of a melon from multiple angles and obtains corresponding principal component side images by performing principal component analysis on each side image. Two-stage wavelet transform is performed on the principal component side images to obtain detail images in different directions, including horizontal, vertical, and diagonal detail images. The gradient changes of the detail images in corresponding directions are used to obtain the corresponding step size, and the gray-level co-occurrence matrix in the corresponding direction is obtained based on the step size. The feature parameters of the gray-level co-occurrence matrices in the three directions form the texture representation matrix of the principal component side image. The average pixel value of all pixels in the side image is calculated. The invention employs several methods to determine the maturity of melons. These methods include: 1) determining the range of pixel value variations; 2) obtaining the uniformity of grayscale distribution based on the difference between the pixel values ​​of all pixels and the average pixel value; 3) converting the side image to a color space that includes saturation, extracting the saturation channel image, and calculating the average saturation in the saturation channel image; 4) constructing a color feature matrix based on the average saturation, average pixel value, pixel value range, and grayscale distribution uniformity; 5) forming a feature analysis matrix for each side image based on the texture representation matrix and the color feature matrix; 6) training a classification network based on the feature analysis matrix; and 7) using the trained classification network as a melon maturity detection network to detect the maturity of the melons to be detected. This invention can accurately assess the maturity of melons based on image information with high recognition accuracy. This allows businesses to process melons according to their maturity, reducing losses caused by maturity and improving melon quality.

[0090] This invention also proposes an artificial intelligence-based melon maturity detection system, including a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the computer program to perform the steps described above. Since a method for detecting melon maturity based on artificial intelligence has been described in detail above, it will not be repeated here.

[0091] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0092] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0093] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them; modifications to the technical solutions described in the foregoing embodiments, or equivalent substitutions of some of the technical features, do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for detecting the maturity of melons based on artificial intelligence, characterized in that, The method includes the following steps: Side images of the melon to be tested were collected from multiple angles, and the corresponding principal component side images were obtained by performing principal component analysis on each side image. By performing a two-level wavelet transform on the principal component side view, detail maps in different directions are obtained, including horizontal detail maps, vertical detail maps, and diagonal detail maps. The corresponding step size is obtained by using the gradient changes of the detail maps in the corresponding directions, and the gray-level co-occurrence matrix in the corresponding direction is obtained based on the step size. The texture representation matrix of the principal component side view is composed of the feature parameters of the gray-level co-occurrence matrices in the three directions. Calculate the average pixel value and pixel value variation range of all pixels in the side image; obtain the grayscale distribution uniformity based on the difference between the pixel values ​​of all pixels and the average pixel value; convert the side image to a color space that includes saturation, extract the saturation channel image, and calculate the average saturation in the saturation channel image; construct a color feature matrix from the average saturation, average pixel value, pixel value variation range, and grayscale distribution uniformity. Each side image is composed of a texture representation matrix and a color feature matrix. A classification network is trained based on the feature analysis matrix. The trained classification network is used as a melon maturity detection network to detect the maturity of the melon to be detected. The method for obtaining the principal component side view is as follows: Multiple principal component directions are obtained through principal component analysis. The images corresponding to the first three principal component directions are selected and the pixel values ​​at the corresponding positions are weighted and summed to obtain the side view of the principal components. The method of obtaining detail maps in different directions by performing two-level wavelet transforms on the principal component side view includes: The first horizontal detail image, the first vertical detail image, and the first diagonal detail image of the principal component side view are obtained through a first-level wavelet transform. The second horizontal detail image, the second vertical detail image, and the second diagonal detail image of the principal component side view are obtained through a second-level wavelet transform. The first horizontal detail image and the second horizontal detail image are weighted and summed according to the pixel values ​​at corresponding positions to obtain the horizontal detail image. The first vertical detail image and the second vertical detail image are weighted and summed according to the pixel values ​​at corresponding positions to obtain the vertical detail image. The first diagonal detail image and the second diagonal detail image are weighted and summed according to the pixel values ​​at corresponding positions to obtain the diagonal detail image. The step size obtained by utilizing the gradient change of the detail map in the corresponding direction includes: For the horizontal detail map, a row of pixels is extracted at each preset interval as the row of pixels to be analyzed. The horizontal gradient magnitude of each pixel in the row of pixels to be analyzed is obtained. The pixel corresponding to the horizontal gradient magnitude greater than the preset magnitude threshold is taken as the first pixel. The first pixel distance between every two adjacent first pixels in each row of pixels to be analyzed is calculated. The average value of all first pixel distances is calculated as the step size of the horizontal detail map. For the vertical detail map, a column of pixels is extracted at every preset number of columns as the column of pixels to be analyzed. The vertical gradient magnitude of each pixel in the column of pixels to be analyzed is obtained. The pixel corresponding to the vertical gradient magnitude that is greater than the preset magnitude threshold is taken as the second pixel. The second pixel distance between every two adjacent second pixels in each column of pixels to be analyzed is calculated. The average value of all second pixel distances is calculated as the step size of the vertical detail map. For the diagonal detail image, the pixels on the diagonal are extracted as the diagonal pixels to be analyzed. The diagonal gradient magnitude of each pixel in the diagonal pixels to be analyzed is obtained. The pixels corresponding to the diagonal gradient magnitude that are greater than the preset diagonal magnitude threshold are taken as the third pixel. The distance between the third pixels between every two adjacent third pixels is calculated. The average of all third pixel distances is calculated as the step size of the diagonal detail image. The method for composing the texture representation matrix is ​​as follows: For each detail image, the texture contrast, entropy, energy, and inverse variance parameters of the corresponding gray-level co-occurrence matrix are obtained as eigenvalues. The eigenvalues ​​of the three detail images are combined into a column to obtain the texture representation matrix. The method for obtaining the range of pixel value changes is as follows: Obtain the first preset number of pixel values ​​with the largest pixel value in the side image, and calculate the average to obtain the maximum grayscale average value; obtain the first preset number of pixel values ​​with the smallest pixel value in the side image, and calculate the average to obtain the minimum grayscale average value; use the difference between the maximum grayscale average value and the minimum grayscale average value as the range of pixel value variation; The training of the classification network based on the feature analysis matrix includes: Using the feature analysis matrix as input to the classification network, and manually labeling the data, the output is the maturity of the melon to be detected. The cross-entropy loss function is used as the loss function for the classification network training until the loss function converges, at which point the classification network training is complete.

2. A melon maturity detection system based on artificial intelligence, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the artificial intelligence-based melon maturity detection method as described in claim 1.

Citation Information

Patent Citations

  • Imitated artificial haze monitoring system and method

    CN103940714A

  • Wheat plant nitrogen content estimation method based on unmanned aerial vehicle image fusion characteristics

    CN112418073A