Tea stem and leaf hyperspectral separation and extraction method, device, equipment and medium

By performing binarization of tea hyperspectral images and skeleton extraction, combining breadth-first search algorithm to identify stems and segment leaves, the problem of low efficiency and insufficient accuracy of automated tea processing identification and segmentation in the existing technology is solved, and efficient hyperspectral data extraction of tea stems and leaves is achieved.

CN119251683BActive Publication Date: 2025-04-18ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411729945.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-04-18
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

The prior art relies on manual operations during tea processing, which is inefficient and lacks accuracy, making it difficult to automatically identify and segment tea stems and leaves, and extract hyperspectral data.

Method used

By binarizing the tea hyperspectral image, the tea skeleton was extracted, and the breadth-first search algorithm was used to determine the stem skeleton line based on the starting point and bifurcation point of the skeleton, and then the tea stem image was identified, the leaf image was segmented after the stem was deleted, and the leaf position was marked, and the hyperspectral data of the stem and leaves were finally extracted.

Benefits of technology

Automatic recognition and segmentation of tea stems and leaves is realized, the degree of automation and accuracy of hyperspectral image recognition is improved, and the shortcomings of low manual operation efficiency and insufficient accuracy are overcome.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119251683B_ABST
    Figure CN119251683B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, equipment and medium for separating and extracting tea stems and leaves from a high spectrum, and relates to the field of image processing technology. The method comprises obtaining a tea binary image based on a tea hyperspectral image, and extracting a tea skeleton image; determining the starting point and bifurcation point of the tea skeleton in the tea skeleton image; obtaining a stalk skeleton line based on the starting point and bifurcation point using a breadth-first search algorithm; searching for a stalk connected domain based on the stalk skeleton line to obtain a tea stem image; deleting the tea stem image from the tea binary image, obtaining a stalk-removed tea leaf binary image, removing the noise connected domain therein, obtaining a leaf position-non-adhesive tea leaf binary image; marking the leaf position; extracting the hyperspectral data of tea stems and leaves from the tea hyperspectral image respectively according to the pixel position of the stalk connected domain and the marked leaf position. The present application can improve the automation and accuracy of hyperspectral image recognition of tea stems and leaves.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method, device, equipment and medium for separating and extracting tea stems and leaves using high-spectral spectra. Background Art

[0002] In the tea processing process, using hyperspectral images to identify tea stems and leaves is an important step. Most existing methods rely on manual operations, which are inefficient and inaccurate. Therefore, there is an urgent need for an automated image processing method to identify and segment tea stems and leaves and extract the corresponding hyperspectral data. Summary of the invention

[0003] The purpose of this application is to provide a method, device, equipment and medium for hyperspectral separation and extraction of tea stems and leaves, which can improve the automation and accuracy of hyperspectral image recognition of tea stems and leaves.

[0004] To achieve the above objectives, this application provides the following solutions.

[0005] In a first aspect, the present application provides a method for hyperspectral separation and extraction of tea stems and leaves, comprising: obtaining a tea binary image based on a tea hyperspectral image; removing edge pixels of tea leaves in the tea binary image to obtain a tea skeleton image; determining the starting point and bifurcation point of the tea skeleton in the tea skeleton image; according to the starting point and bifurcation point, using a breadth-first search algorithm to determine the skeleton line connecting the starting point and the bifurcation point and the skeleton line connecting adjacent bifurcation points from the tea skeleton image to obtain a stalk skeleton line; searching for a stalk connected domain based on the stalk skeleton line to obtain a tea stem image; deleting the tea stem image from the tea binary image to obtain a stalk-removed tea leaf binary image; removing the noise connected domain in the stalk-removed tea leaf binary image to obtain a leaf position non-adhesive tea leaf binary image; marking the leaf position in the leaf position non-adhesive tea leaf binary image according to the bifurcation point; extracting the hyperspectral data of the tea stem and the hyperspectral data of the tea leaf from the tea hyperspectral image respectively according to the pixel position of the stalk connected domain and the marked leaf position.

[0006] In the second aspect, the present application provides a hyperspectral separation and extraction device for tea stems and leaves, including: a binarization module, an edge pixel removal module, a bifurcation point determination module, a skeleton line search module, a stem search module, a stem deletion module, a leaf acquisition module, a leaf position marking module and an extraction module. The binarization module is used to obtain a tea binary image based on the tea hyperspectral image. The edge pixel removal module is used to remove edge pixels of tea leaves in the tea binary image to obtain a tea skeleton image. The bifurcation point determination module is used to determine the starting point and bifurcation point of the tea skeleton in the tea skeleton image. The skeleton line search module is used to determine the skeleton line connecting the starting point and bifurcation point and the skeleton line connecting adjacent bifurcation points from the tea skeleton image based on the starting point and bifurcation point using a breadth-first search algorithm to obtain a stem skeleton line. The stem search module is used to search for a stem connected domain based on the stem skeleton line to obtain a tea stem image. The stem deletion module is used to delete the tea stem image from the tea binary image to obtain a tea leaf binary image after the stems are removed. The leaf acquisition module is used to remove the noise point connected domain in the binary image of tea leaves after removing the stems, and obtain the binary image of tea leaves with non-adhesive leaf positions. The leaf position labeling module is used to label the leaf positions in the binary image of tea leaves with non-adhesive leaf positions according to the bifurcation points. The extraction module is used to extract the hyperspectral data of tea stems and the hyperspectral data of tea leaves from the hyperspectral image of tea leaves according to the pixel positions of the connected domain of the stems and the labeled leaf positions.

[0007] In a third aspect, the present application provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the above-described methods for hyperspectral separation and extraction of tea stems and leaves.

[0008] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for hyperspectral separation and extraction of tea stems and leaves.

[0009] According to the specific embodiments provided in this application, this application has the following technical effects.

[0010] The present application provides a method, device, equipment and medium for separating and extracting tea stems and leaves from high spectra, performs binarization processing on tea hyperspectral images, extracts tea skeletons from the tea binary images, searches for stem skeleton lines based on the starting points and bifurcation points of the tea skeletons, thereby determining the tea stem images, deleting the tea stem images from the tea binary images, determining tea leaf binary images and leaf positions, realizing automatic identification and segmentation of tea stems and tea leaves, and finally extracting corresponding hyperspectral data, overcoming the defects of low efficiency and insufficient accuracy of manual operation, and improving the automation and accuracy of hyperspectral image recognition of tea stems and leaves. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0012] Figure 1 This is a diagram of the application environment of the hyperspectral separation and extraction method of tea stems and leaves in one embodiment of the present application.

[0013] Figure 2 A schematic diagram of the process of a method for hyperspectral separation and extraction of tea stems and leaves provided in one embodiment of the present application.

[0014] Figure 3 This is a diagram showing the overall working principle of the hyperspectral separation and extraction method for tea stems and leaves provided in one embodiment of the present application.

[0015] Figure 4 Another embodiment of the present application provides an RGB image of picked tea leaves obtained using the method of the present application.

[0016] Figure 5 Another embodiment of the present application provides an HSV image of picked tea leaves obtained using the method of the present application.

[0017] Figure 6 Another embodiment of the present application provides a histogram of H channel data in an HSV image obtained for picked tea leaves using the method of the present application.

[0018] Figure 7 Another embodiment of the present application provides an initial binary image of tea leaves obtained from picked tea leaves using the method of the present application.

[0019] Figure 8 Another embodiment of the present application provides a final binary image of tea leaves obtained from picked tea leaves using the method of the present application.

[0020] Fig. 9 Another embodiment of the present application provides a skeleton image of tea leaves obtained from picked tea leaves using the method of the present application.

[0021] Fig.10 A schematic diagram of the starting point and bifurcation point of the tea skeleton for identifying picked tea leaves using the method of the present application is provided as another embodiment of the present application.

[0022] Fig.11 Another embodiment of the present application provides a schematic diagram of the stalk skeleton line obtained from picked tea leaves using the method of the present application.

[0023] Fig.12 Another embodiment of the present application provides an image of tea stems obtained from picked tea leaves using the method of the present application.

[0024] Fig.13 Another embodiment of the present application provides a binary image of tea leaves after the stems are removed, obtained by using the method of the present application for plucked tea leaves.

[0025] Fig.14 Another embodiment of the present application provides a binary image of tea leaves without adhesion obtained from plucked tea leaves using the method of the present application.

[0026] Fig.15 Another embodiment of the present application provides a schematic diagram of leaf position marking obtained by using the method of the present application on picked tea leaves.

[0027] Fig.16 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0029] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0030] The tea stem and leaf hyperspectral separation and extraction method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be set up separately, integrated on the server 104, or placed on the cloud or other servers. The terminal 102 can send the hyperspectral image of the tea leaves to the server 104. After the server 104 receives the hyperspectral image of the tea leaves, for the hyperspectral image of the tea leaves, the server 104 obtains a binary image of the tea leaves based on the hyperspectral image of the tea leaves; removes edge pixels of the tea leaves in the binary image of the tea leaves to obtain a skeleton image of the tea leaves; determines the starting point and bifurcation point of the tea skeleton in the tea skeleton image; according to the starting point and bifurcation point, uses a breadth-first search algorithm to determine the skeleton line connecting the starting point and the bifurcation point and the skeleton line connecting adjacent bifurcation points from the skeleton image of the tea leaves to obtain the stem skeleton. Wires are drawn; searching for a stem connected domain based on the stem skeleton line to obtain a tea stem image; deleting the tea stem image from the tea binary image to obtain a tea leaf binary image after the stems are removed; removing the noise connected domain in the tea leaf binary image after the stems are removed to obtain a tea leaf binary image with non-adhesive leaf positions; marking the leaf positions in the tea leaf binary image with non-adhesive leaf positions according to the bifurcation points; extracting the hyperspectral data of the tea stem and the hyperspectral data of the tea leaf from the tea hyperspectral image according to the pixel positions of the stem connected domain and the marked leaf positions. The server 104 can feed back the obtained hyperspectral data of the tea stem and the hyperspectral data of the tea leaf to the terminal 102. In addition, in some embodiments, the hyperspectral separation and extraction method of tea stems and leaves can also be implemented independently by the server 104 or the terminal 102. For example, the terminal 102 can directly perform hyperspectral separation and extraction of tea stems and leaves on the hyperspectral image of tea, or the server 104 can obtain the hyperspectral image of tea from the data storage system and perform hyperspectral separation and extraction of tea stems and leaves on the hyperspectral image of tea.

[0031] The terminal 102 may be, but is not limited to, various desktop computers, laptop computers, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers, or may be a cloud server.

[0032] In an exemplary embodiment, Figure 2 As shown, a method for separating and extracting tea stems and leaves from high spectra is provided. The method is executed by a computer device, and can be executed by a computer device such as a terminal or a server alone, or can be executed by a terminal and a server together. In the embodiment of the present application, the method is applied to Figure 1 The server 104 in the example is used for explanation, and the steps include the following steps 201 to 209.

[0033] Step 201: Obtain a tea leaf binary image based on the tea leaf hyperspectral image.

[0034] Step 202: removing edge pixels of the tea leaves in the binary tea leaf image to obtain a tea leaf skeleton image.

[0035] Step 203: determining the starting point and bifurcation point of the tea skeleton in the tea skeleton image.

[0036] Step 204: According to the starting point and the bifurcation point, a breadth-first search algorithm is used to determine a skeleton line connecting the starting point and the bifurcation point and a skeleton line connecting adjacent bifurcation points from the tea skeleton image to obtain a stalk skeleton line.

[0037] Step 205: searching for a stem connected domain based on the stem skeleton line to obtain a tea stem image.

[0038] Step 206: deleting the tea stem image from the tea binary image to obtain a tea leaf binary image after the stems are removed.

[0039] Step 207: removing the noise connected domain in the binary image of tea leaves after the stems are removed, to obtain a binary image of tea leaves without adhesion of leaf positions.

[0040] Step 208: According to the bifurcation points, the leaf positions in the binary image of the tea leaves where the leaf positions are not adhered are marked.

[0041] Step 209: extracting the hyperspectral data of tea stems and the hyperspectral data of tea leaves from the tea hyperspectral image according to the pixel positions of the stem connected domain and the marked leaf positions.

[0042] By implementing the above-mentioned steps 201 to 209, the hyperspectral image of tea leaves is binarized, the skeleton of tea leaves is extracted from the binary image of tea leaves, the skeleton line of the stem is searched based on the starting point and bifurcation point of the skeleton of tea leaves, so as to determine the image of tea stems, delete the image of tea stems from the binary image of tea leaves, determine the binary image of tea leaves and the leaf position of tea leaves, realize automatic identification and segmentation of tea stems and tea leaves, and finally extract corresponding hyperspectral data, thus overcoming the defects of low efficiency and insufficient accuracy of manual operation, and improving the automation and accuracy of hyperspectral image recognition of tea stems and leaves.

[0043] In another exemplary embodiment of the present application, the process of obtaining the binary image of tea leaves in the above step 201 can be replaced by the following steps 301 to 306.

[0044] Step 301: Collect tea hyperspectral images.

[0045] Specifically, the picked tea leaves can be spread on a blue background board, and a 400nm-1700nm line scanning hyperspectral camera can be turned on to obtain a hyperspectral image of the tea leaves.

[0046] Step 302: extracting the R band image, the G band image and the B band image from the tea hyperspectral image, and synthesizing the RGB image.

[0047] The R band, the G band and the B band can be set to the 470nm band, the 540nm band and the 650nm band respectively.

[0048] Step 303: Convert the RGB image into an HSV image, and draw a histogram of the H channel data in the HSV image.

[0049] The calculation method for converting RGB image to HSV image H channel is as follows.

[0050] First, normalize the values ​​of the RGB three channels in the RGB image: .in, , and is the value of the RGB three channels before normalization, , and It is the value of the normalized RGB three channels.

[0051] Calculate the normalized channel maximum and channel minimum values ​​and their differences: , .in, is the normalized maximum value of the channel, is the normalized channel minimum value, is the difference between the normalized maximum channel value and the normalized minimum channel value, To obtain the maximum value function, is the minimum value function.

[0052] There are four cases for calculating H channel data.

[0053] like ,but .in, It is the H channel data.

[0054] like ,but ,in, Express The remainder of a modulo operation.

[0055] like ,but .

[0056] like ,but .

[0057] After calculating the H channel data, correct the H channel data: if is a negative number, then . Indicates the corrected H channel data.

[0058] Step 304: Search for a peak of the histogram within a preset pixel value range, and use the pixel value corresponding to the peak as a green feature value.

[0059] Step 305: Compare all pixel values ​​of the H channel in the HSV image with the green feature value, set the pixel value that is less than or equal to the green feature value to 255, and the pixel value that is greater than the green feature value to 0, to obtain the initial tea binary image.

[0060] The HSV image is binarized according to the green eigenvalue, and all pixel values ​​of the H channel are compared with the green eigenvalue. The pixel value that is less than or equal to the green eigenvalue is 255, and the pixel value that is greater than the green eigenvalue is 0. A binary image of tea leaves and background is obtained, where white (255) is tea leaves and black (0) is background.

[0061] Step 306: Perform morphological dilation on the initial binary image of tea leaves to obtain a final binary image of tea leaves.

[0062] The binary image is subjected to convolution kernel operation and morphological dilation processing. The convolution kernel size used is 3×3, and the convolution processing is performed twice to obtain a better dilation processing effect.

[0063] In another exemplary embodiment of the present application, the tea skeleton is refined using tensor analysis and the principal curvature direction to obtain a tea skeleton image. Then the above step 202 can be replaced by the following steps 401 to 306.

[0064] Step 401: According to the formula and , the Sobel operator is used to calculate the horizontal gradient and vertical gradient of each pixel in the binary image of tea leaves; where, The horizontal coordinate is , the vertical coordinate is Pixels of is the horizontal gradient, is the vertical gradient, is the Sobel operator (Sobel operator) of the horizontal gradient, is the Sobel operator for the vertical gradient.

[0065] Sobel operator for horizontal gradient : .

[0066] Sobel operator for vertical gradient : .

[0067] Step 402: According to the horizontal gradient and vertical gradient of each pixel in the binary image of tea leaves, the formula , calculate the structure tensor matrix of each pixel in the binary image of tea leaves; where, is the structure tensor matrix.

[0068] Step 403: Perform eigenvalue decomposition on the structure tensor matrix of each pixel point to obtain two eigenvalues ​​and corresponding eigenvectors.

[0069] The formula used for eigenvalue decomposition is: , For the eigenvalues, For the The eigenvalues ​​correspond to the eigenvectors. And the corresponding eigenvector and They represent the two main directions in the image. is the main direction, corresponding to the direction of maximum gradient change.

[0070] Step 404: Based on the two eigenvalues, use the formula , calculate the curvature of each pixel; where, The horizontal coordinate is , the vertical coordinate is The curvature of the pixel, and are two eigenvalues.

[0071] Curvature It can be approximated by the relationship between the eigenvalues, taking into account the anisotropy of the local structure, and the curvature is obtained The calculation formula for .

[0072] Step 405: Determine along the main direction whether each pixel in the binary image of tea leaves satisfies and , and will satisfy and The pixel value of the pixel point is set to 0 to obtain a tea skeleton image; wherein the main direction refers to a feature vector representing the direction of the maximum gradient change in the tea binary image; To set the threshold, used to control the degree of refinement.

[0073] Setting the pixel value to 0 is equivalent to removing the pixel based on the curvature and the main direction.

[0074] In another exemplary embodiment of the present application, the above step 203 of determining the starting point and bifurcation point of the tea skeleton in the tea skeleton image may be replaced by the following steps 501 to 505.

[0075] Step 501: Scan the tea skeleton image line by line from top to bottom, and record the white pixel point scanned for the first time as the starting point.

[0076] The pixel value of a white pixel is 255, and the pixel value of a black pixel is 0.

[0077] Step 502: Starting from the starting point, each scanned white pixel is sequentially used as the current pixel.

[0078] Step 503: Perform a topological analysis on the 8-neighborhood of the current pixel, record the white pixels and black pixels in the 8-neighborhood, and count the number of white pixels in the 8-neighborhood.

[0079] The 8-neighborhood of a white pixel is defined as: .

[0080] in is the current pixel, ,……, are the pixels in its surrounding neighborhood.

[0081] Step 504: Calculate the number of transitions from black pixels to white pixels in the 8-neighborhood. The calculation formula for the number of transitions is: , is the number of transitions, The 8th neighborhood Neighborhood pixels, and the Neighborhood pixels are black pixels; The 8th neighborhood Neighborhood pixels, and the The neighboring pixels are white pixels.

[0082] The transition count is a key topological metric used to determine whether there are multiple connected domains surrounding the current pixel.

[0083] Step 505: If the number of white pixels in the 8-neighborhood is greater than or equal to a preset number, and the number of transitions is greater than or equal to a preset number, the current pixel is determined as a bifurcation point. Exemplarily, the preset number is 3.

[0084] In another exemplary embodiment of the present application, the specific process of the breadth-first search algorithm mentioned in the above step 204 is as follows.

[0085] Step 601: Create a queue and add the starting point to the queue. Define a direction vector to represent movement in eight directions (up, down, left, right, and four diagonal directions). Create a collection to record visited nodes to avoid repeated visits. Create a dictionary to store the parent node of each node so that the path can be reconstructed.

[0086] Step 602: When the queue is not empty, execute the loop: pop the first node from the queue as the current node, check whether the current node is the end point, if it is the end point, exit the loop. If it is not the end point, check each neighbor pixel in the eight directions of the current node to check whether the neighbor is within the image range, whether it has not been visited, and whether it is a skeleton pixel (pixel value is 255). If the conditions are met, add the neighbor node to the queue and set, and record its parent node.

[0087] Step 603: After finding the end point, the path is reconstructed from the end point in reverse through the dictionary to the starting point, the length of all paths is calculated, the shortest path is determined, and the shortest path is reversed to obtain the order from the starting point to the end point to obtain the stalk skeleton line image.

[0088] In another exemplary embodiment of the present application, the process of obtaining the tea stem image in the above step 205 can be replaced by the following steps 701 to 303.

[0089] Step 701: creating a mask image of the skeleton line of the tea stem; the mask image has the same size as the tea stem image to be obtained.

[0090] Step 702: traverse all pixel points on the mask image.

[0091] Step 703: when the traversed pixel point is a white pixel point on the mask image, start searching pixel points one by one on both sides.

[0092] Step 704: If the searched pixel is a white pixel in the mask image and the distance does not exceed the maximum width, the searched pixel is marked as a stem part; the distance is the distance between the searched pixel and the traversed white pixel. Exemplarily, the maximum width is set to 7.

[0093] Step 705: If a black pixel in the mask image is found or the distance exceeds the maximum width, the search is stopped.

[0094] Step 706: All marked stem parts are combined into a stem connected domain to form a tea stem image.

[0095] In another exemplary embodiment of the present application, the above step 206 creates a mask image of the same size as the tea stem image, marks the pixels with a pixel value of 255 in the tea stem image, sets the pixel value of the corresponding position of the tea binary image to 0, assigns the processed tea binary image to the created mask image, and obtains a binary image of the tea leaves after removing the stems.

[0096] In another exemplary embodiment of the present application, the above step 207 can be replaced by the following steps 801 to 804.

[0097] Step 801: performing two 3×3 convolution kernel corrosion operations on the binary image of tea leaves after removing the stems.

[0098] Step 802: using the 8-connectivity extraction method to determine the connected domains in the eroded binary image of tea leaves.

[0099] 8-connectivity: In 8-connectivity, the connected neighborhood of a pixel includes the pixels above, below, left, right, and four diagonal directions. The 8-connected neighborhood of arrive : .

[0100] This method assumes that all adjacent pixels in 8 directions are connected. Traverse each pixel in the image. If a pixel is found to be a white pixel (pixel value is 255) and has not been marked as visited, use this pixel as the starting point of a new connected domain. Starting from this point, use 4-connected or 8-connected methods to expand and find all white pixels connected to this point. Mark all connected white pixels as visited until all pixels in the connected domain have been processed. Repeat this process until all white pixels in the image have been traversed. In this way, all connected domains in the image are obtained.

[0101] Step 803: Determine a connected domain whose area is smaller than a preset area threshold as a noise point connected domain. Exemplarily, the preset area threshold is 100.

[0102] Step 804: removing the noise point connected domain from the eroded tea leaf binary image to obtain a tea leaf binary image with non-adhesive leaf positions.

[0103] In another exemplary embodiment of the present application, the leaf position order is determined according to the bifurcation point position, the size of the connected domain of each leaf position, and the top pixel position of the connected domain, and the above step 208 is replaced by the following steps 901 to 908.

[0104] Step 901: determining the highest point position of each connected domain in the binary image of the tea leaves whose leaf positions are not adhered, and the area of ​​each connected domain.

[0105] Step 902: Select the bifurcation point farthest from the starting point as the first bifurcation point.

[0106] Step 903: Calculate the distance between the highest point position of all connected domains and the first bifurcation point, and select the two connected domains with the closest distance as target connected domains.

[0107] Step 904: Mark the connected domain with a smaller area in the target connected domain as a bud, and mark the connected domain with a larger area as the first leaf position.

[0108] Step 905: Remove the first bifurcation point from the bifurcation points of the tea skeleton. If there are still bifurcation points, Equals 2.

[0109] Step 906: Select the bifurcation point farthest from the starting point as the Bifurcation point.

[0110] Step 907: Calculate the distance between the highest point of the unlabeled connected domain and the first bifurcation point, and select the connected domain with the closest distance as the first bifurcation point. Leaf position.

[0111] Step 908: Continue to remove the first tea leaf from the bifurcation point of the tea leaf skeleton. If there is a bifurcation point, then The value of is increased by 1, and the process returns to step "Select the bifurcation point farthest from the starting point as the The bifurcation point is then removed until the first After the fork point, there is no more fork point, stop.

[0112] In another exemplary embodiment of the present application, after the hyperspectral data of tea stems and the hyperspectral data of tea leaves are extracted in the above step 209, they are stored in different csv files.

[0113] Figure 3The overall working principle diagram of the hyperspectral separation and extraction method of tea stems and leaves of this application. The method can be summarized as follows: obtaining a hyperspectral image, selecting a band to synthesize an RGB image, converting it to an HSV image, calculating an HSV histogram, automatically searching for the green band, binarizing the image according to the band range, performing expansion processing to eliminate interference, extracting the tea skeleton using a refinement algorithm, finding the skeleton bifurcation point, using a breadth-first search algorithm to find the stem skeleton, extracting the unexpanded image stem mask based on the stem skeleton, removing smaller connected domains, segmenting the tea leaf mask, determining the 1st, 2nd... leaf position of the leaf, and extracting the hyperspectral data of the stem and leaf respectively according to the mask. Among them, extracting the unexpanded image stem mask according to the stem skeleton corresponds to the above step 205. Segmenting the tea leaf mask corresponds to the above step 207. Extracting the hyperspectral data of the stem and leaf respectively according to the mask corresponds to the above step 209.

[0114] Figure 4 The RGB image obtained by using the method of the present application for the picked tea leaves is shown. Figure 4 The blue color in the background is blue. Figure 5 The HSV image of the tea leaves after picking is obtained by using the method of the present application. Figure 6 The histogram of the H channel data in the HSV image obtained by using the method of the present application for the picked tea leaves is shown. Figure 7 The initial binary image of tea leaves obtained by using the method of the present application for picked tea leaves is shown. Figure 8 The final binary image of tea leaves obtained by using the method of the present application for picked tea leaves is shown. Fig. 9 The figure shows a skeleton image of tea leaves obtained by using the method of the present application for picked tea leaves. Fig.10 The starting point and bifurcation point of the tea skeleton identified by the method of the present application for the picked tea leaves are shown. Fig.10 The red dots in the figure represent the starting point and the bifurcation point. Fig.11 The stalk skeleton line obtained by using the method of the present application for picking tea leaves is shown. Fig.12 The image of tea stems obtained by using the method of the present application for plucked tea leaves is shown. Fig.13 The binary image of tea leaves after the stalks are removed is shown using the method of the present application. Fig.14 The binary image of tea leaves without adhesion obtained by the method of the present application after picking tea leaves is shown. Fig.15 The diagram shows the leaf position marking of picked tea leaves obtained using the method of the present application. Figures 4 to 5 as well as Figures 7 to 15 The horizontal axis represents the width of the picture, and the vertical axis represents the height of the picture. The units of width and height are pixels, expressed as pixel. Figure 6The horizontal axis shows the hue range of the HSV image H channel, which ranges from 0 to 180. Figure 6 The vertical axis represents the frequency of each hue in the image.

[0115] Based on the same inventive concept, the embodiment of the present application also provides a tea stem and leaf hyperspectral separation and extraction device for implementing the tea stem and leaf hyperspectral separation and extraction method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more tea stem and leaf hyperspectral separation and extraction device embodiments provided below can refer to the limitations of the tea stem and leaf hyperspectral separation and extraction method above, and will not be repeated here.

[0116] In an exemplary embodiment, a tea stem and leaf hyperspectral separation and extraction device is provided, comprising: a binarization module, an edge pixel removal module, a bifurcation point determination module, a skeleton line search module, a stem search module, a stem deletion module, a leaf acquisition module, a leaf position marking module and an extraction module.

[0117] A binarization module is used to obtain a binary image of tea leaves based on a hyperspectral image of tea leaves. An edge pixel removal module is used to remove edge pixels of tea leaves in the binary image of tea leaves to obtain a skeleton image of tea leaves. A bifurcation point determination module is used to determine the starting point and bifurcation point of the tea skeleton in the skeleton image of tea leaves. A skeleton line search module is used to determine the skeleton line connecting the starting point and bifurcation point and the skeleton line connecting adjacent bifurcation points from the skeleton image of tea leaves based on the starting point and bifurcation point using a breadth-first search algorithm to obtain a stalk skeleton line. A stalk search module is used to search for a stalk connected domain based on the stalk skeleton line to obtain a tea stalk image. A stalk deletion module is used to delete the tea stalk image from the binary image of tea leaves to obtain a binary image of tea leaves after the stalks are removed. A leaf acquisition module is used to remove the noise connected domain in the binary image of tea leaves after the stalks are removed to obtain a binary image of tea leaves with non-adhesive leaf positions. A leaf position annotation module is used to annotate the leaf positions in the binary image of tea leaves with non-adhesive leaf positions based on the bifurcation point. The extraction module is used to extract the hyperspectral data of tea stems and the hyperspectral data of tea leaves from the tea hyperspectral image according to the pixel positions of the stem connected domain and the marked leaf positions.

[0118] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Fig.16As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the hyperspectral data of tea stems and the hyperspectral data of tea leaves. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for separating and extracting hyperspectral tea stems and leaves is implemented.

[0119] Those skilled in the art will understand that Fig.16 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components. In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0120] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0121] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0122] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A method for separating and extracting tea stems and leaves using high-spectrum spectra, characterized in that: include: According to the tea hyperspectral image, a tea binary image is obtained; removing edge pixels of the tea leaves in the binary tea leaf image to obtain a tea leaf skeleton image; Determine the starting point and bifurcation point of the tea skeleton in the tea skeleton image; According to the starting point and the bifurcation point, a skeleton line connecting the starting point and the bifurcation point and a skeleton line connecting adjacent bifurcation points are determined from the tea skeleton image using a breadth-first search algorithm to obtain a stalk skeleton line; Search the connected domain of the stems according to the skeleton lines of the stems to obtain the tea stem image; Deleting the tea stem image from the tea binary image to obtain a tea leaf binary image after the stems are removed; Removing the noise point connected domain in the binary image of tea leaves after the stems are removed, to obtain a binary image of tea leaves without adhesion of leaf positions; According to the bifurcation point, the leaf positions in the binary image of the tea leaves where the leaf positions are not adhered are marked; According to the pixel positions of the stem connected domain and the marked leaf positions, the hyperspectral data of the tea stems and the hyperspectral data of the tea leaves are respectively extracted from the tea hyperspectral image.

2. The method for separating and extracting tea stems and leaves from a high-spectrum spectrum according to claim 1, characterized in that: According to the tea hyperspectral image, a tea binary image is obtained, which specifically includes: Collect hyperspectral images of tea leaves; Extracting an R band image, a G band image and a B band image from the tea hyperspectral image, and synthesizing an RGB image; Convert the RGB image to an HSV image and draw a histogram of the H channel data in the HSV image; Search for the peak of the histogram within the preset pixel value range, and use the pixel value corresponding to the peak as the green feature value; Compare all pixel values ​​of the H channel in the HSV image with the green eigenvalue, set the pixel value less than or equal to the green eigenvalue to 255, and the pixel value greater than the green eigenvalue to 0, and obtain the initial tea binary image; The initial binary image of tea leaves is morphologically expanded to obtain the final binary image of tea leaves.

3. The method for separating and extracting tea stems and leaves from high-spectrum spectrum according to claim 1, characterized in that: Removing edge pixels of tea leaves in the tea leaf binary image to obtain a tea leaf skeleton image specifically includes: According to the formula and , the Sobel operator is used to calculate the horizontal gradient and vertical gradient of each pixel in the binary image of tea leaves; where, The horizontal coordinate is , the vertical coordinate is Pixels of is the horizontal gradient, is the vertical gradient, is the Sobel operator of the horizontal gradient, is the Sobel operator of the vertical gradient; According to the horizontal gradient and vertical gradient of each pixel in the binary image of tea leaves, the formula , calculate the structure tensor matrix of each pixel in the binary image of tea leaves; where, is the structure tensor matrix; Perform eigenvalue decomposition on the structure tensor matrix of each pixel to obtain two eigenvalues ​​and corresponding eigenvectors; According to the two eigenvalues, using the formula , calculate the curvature of each pixel; where, The horizontal coordinate is , the vertical coordinate is The curvature of the pixel, and are two eigenvalues; Determine along the main direction whether each pixel in the binary image of tea leaves satisfies and , and will satisfy and The pixel value of the pixel point is set to 0 to obtain a tea skeleton image; wherein the main direction refers to a feature vector representing the direction of the maximum gradient change in the tea binary image; To set the threshold.

4. The method for separating and extracting tea stems and leaves from a high-spectrum spectrum according to claim 1, characterized in that: Determining the starting point and bifurcation point of the tea skeleton in the tea skeleton image specifically includes: Scan the tea skeleton image line by line from top to bottom, and record the white pixel point scanned for the first time as the starting point; Starting from the starting point, each white pixel scanned is used as the current pixel in turn; Perform topological analysis on the 8-neighborhood of the current pixel, record the white pixels and black pixels in the 8-neighborhood, and count the number of white pixels in the 8-neighborhood; Calculate the number of transitions from black pixels to white pixels in the 8-neighborhood. The calculation formula for the number of transitions is: , is the number of transitions, The first Neighborhood pixels, and the Neighborhood pixels are black pixels; The first Neighborhood pixels, and the Neighborhood pixels are white pixels; If the number of white pixels in the 8-neighborhood is greater than or equal to a preset number, and the number of transitions is greater than or equal to a preset number, the current pixel is determined as a bifurcation point.

5. The method for separating and extracting tea stems and leaves from a high-spectrum spectrum according to claim 1, characterized in that: Search the connected domain of the stems according to the stem skeleton lines to obtain the tea stem image, which includes: Creating a mask image of the stem skeleton line; the mask image has the same size as the tea stem image to be obtained; Traversing all pixels on the mask image; When the traversed pixel point is a white pixel point on the mask image, start searching pixel points one by one on the left and right sides respectively; If the searched pixel point is a white pixel point in the mask image and the distance does not exceed the maximum width, the searched pixel point is marked as a stem part; the distance is the distance between the searched pixel point and the traversed white pixel points; If a black pixel in the mask image is found or the distance exceeds the maximum width, the search is stopped; All marked stem parts constitute a stem connected domain and form a tea stem image.

6. The method for separating and extracting tea stems and leaves from a high-spectrum spectrum according to claim 1, characterized in that: Removing the noise point connected domain in the binary image of tea leaves after removing the stems to obtain a binary image of tea leaves without adhesion of leaf positions, specifically includes: Performing two 3×3 convolution kernel corrosion operations on the binary image of tea leaves after removing the stems; The 8-connectivity extraction method is used to determine the connected domains in the binary image of the eroded tea leaves. Determine a connected domain whose area is smaller than a preset area threshold as a noise point connected domain; The noise point connected domain is removed from the corroded tea leaf binary image to obtain a tea leaf binary image in which the leaf positions are not adhered.

7. The method for separating and extracting tea stems and leaves from high-spectrum spectrum according to claim 1, characterized in that: According to the bifurcation point, the leaf positions in the binary image of the tea leaves where the leaf positions are not adhered are marked, specifically including: Determine the highest point position of each connected domain in the binary image of the tea leaves whose leaf positions are not adhered, and the area of ​​each connected domain; Select the bifurcation point farthest from the starting point as the first bifurcation point; Calculate the distance between the highest point of all connected domains and the first bifurcation point, and select the two connected domains with the closest distance as the target connected domains; The connected domain with a smaller area in the target connected domain is marked as the bud head, and the connected domain with a larger area is marked as the first leaf position; Remove the first bifurcation point from the bifurcation points of the tea skeleton. If there are still bifurcation points, let is equal to 2; Select the bifurcation point farthest from the starting point as the Bifurcation point; Calculate the distance between the highest point of the unlabeled connected domain and the first bifurcation point, and select the connected domain with the closest distance as the first leaf position; Continue to remove the first If there is a bifurcation point, then The value of is increased by 1, and the process returns to step "Select the bifurcation point farthest from the starting point as the The bifurcation point is then removed until the first After the fork point, there is no more fork point, stop.

8. A tea stem and leaf hyperspectral separation and extraction device, characterized in that: The tea stem and leaf hyperspectral separation and extraction device comprises: A binarization module is used to obtain a binary image of tea leaves based on the hyperspectral image of tea leaves; An edge pixel removal module is used to remove edge pixels of tea leaves in the tea leaf binary image to obtain a tea leaf skeleton image; A bifurcation point determination module, used to determine the starting point and bifurcation point of the tea skeleton in the tea skeleton image; A skeleton line search module is used to determine the skeleton line connecting the starting point and the bifurcation point and the skeleton line connecting adjacent bifurcation points from the tea skeleton image according to the starting point and the bifurcation point, and obtain the stalk skeleton line; A stem search module is used to search for a stem connected domain based on the stem skeleton line to obtain a tea stem image; A stem removal module is used to remove the tea stem image from the tea binary image to obtain a tea leaf binary image after the stems are removed; A leaf acquisition module, used to remove the noise point connected domain in the binary image of tea leaves after the stems are removed, so as to obtain a binary image of tea leaves without adhesion of leaves; A leaf position marking module, used for marking the leaf positions in the binary image of tea leaves where the leaf positions are not adhered, according to the bifurcation points; The extraction module is used to extract the hyperspectral data of tea stems and the hyperspectral data of tea leaves from the tea hyperspectral image according to the pixel positions of the stem connected domain and the marked leaf positions.

9. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the hyperspectral separation and extraction method for tea stems and leaves according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for hyperspectral separation and extraction of tea stems and leaves according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Mind map image recognition method and device, electronic equipment and storage medium

    CN115984881A

  • Seed germination rate determination method, system and device based on machine vision

    CN116420465A