Hyperspectral separation and extraction method, apparatus, equipment, and medium for tea leaf stems and leaves
The method automates the separation and extraction of tea leaf stems and leaves using hyperspectral imaging, enhancing efficiency and accuracy through binarization and skeleton analysis, addressing the limitations of manual processing.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2025-09-29
- Publication Date
- 2026-07-07
Smart Images

Figure 0007886064000014 
Figure 0007886064000015 
Figure 0007886064000016
Abstract
Description
[Technical Field]
[0001] This application relates to the field of image processing, and more particularly to a method, apparatus, device, and medium for hyperspectral separation and extraction of tea leaf stems and leaves. [Background technology]
[0002] In the processing of tea leaves, distinguishing between stems and leaves using hyperspectral imaging is a crucial step. Most existing methods rely on manual operation, resulting in low efficiency and insufficient accuracy. Therefore, there is an urgent need for automated image processing methods that can distinguish and separate tea stems and leaves and extract corresponding hyperspectral data. [Overview of the project] [Problems that the invention aims to solve]
[0003] The purpose of this application is to provide a hyperspectral separation and extraction method, apparatus, equipment, and medium for tea leaf stems and leaves that can improve the degree of automation and accuracy of hyperspectral image recognition of tea leaf stems and leaves. [Means for solving the problem]
[0004] To achieve the above objective, this application provides the following solutions.
[0005] In a first aspect, the present application provides a hyperspectral separation and extraction method for tea leaf stems and leaves, which involves obtaining a binarized image of the tea leaf based on a hyperspectral image of the tea leaf, removing edge pixels of the tea leaf from the binarized image to obtain a skeletal image of the tea leaf, determining the starting point and branching point of the tea leaf skeleton in the skeletal image of the tea leaf, determining the skeletal lines connecting the starting point and branching point, and the skeletal lines connecting adjacent branching points from the skeletal image of the tea leaf using a breadth-first search algorithm based on the starting point and branching point to obtain the skeletal lines of the stem, and searching for the connected regions of the stem based on the skeletal lines of the stem to obtain the stem image of the tea leaf This includes obtaining a tea leaf stem image, removing the stem image from the binarized tea leaf image to obtain a binarized image of the tea leaf with the stem removed, removing noise-connected regions from the binarized image of the tea leaf with the stem removed to obtain a binarized image of the tea leaf with unconnected leaf positions, marking the leaf positions in the binarized image of the tea leaf with unconnected leaf positions based on branching points, and extracting hyperspectral data of the tea leaf stem and hyperspectral data of the tea leaf leaf from the hyperspectral image of the tea leaf, respectively, based on the pixel positions of the stem-connected regions and the marked leaf positions.
[0006] In a second aspect, the present application provides a hyperspectral separation and extraction apparatus for tea leaf stems and leaves, comprising a binarization module, an edge pixel removal module, a branch 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 configured to acquire a binarized image of tea leaves based on a hyperspectral image of tea leaves. The edge pixel removal module is configured to acquire a skeleton image of tea leaves by removing edge pixels of tea leaves from the binarized image of tea leaves. The branch point determination module is configured to determine the starting point and branch points of the tea leaf skeleton in the tea leaf skeleton image. The skeleton line search module is configured to acquire a stem skeleton by determining, using a breadth-first search algorithm, the skeleton lines connecting the starting point and branch points, and the skeleton lines connecting adjacent branch points, from the tea leaf skeleton image based on the starting point and branch points. The stem search module is configured to acquire a tea leaf stem image by searching for connected regions of the stem based on the stem skeleton. The stem removal module is configured to remove the stem image of the tea leaf from the binarized image of the tea leaf to obtain a binarized image of the tea leaf with the stem removed. The leaf acquisition module is configured to remove noise-connected regions from the binarized image of the tea leaf with the stem removed to obtain a binarized image of the tea leaf with the leaf positions not attached. The leaf position marking module is configured to mark the leaf positions in the binarized image of the tea leaf with the leaf positions not attached, based on branching points. The extraction module is configured to extract hyperspectral data of the tea leaf stem and hyperspectral data of the tea leaf from the hyperspectral image of the tea leaf, based on the pixel positions of the stem-connected regions and the marked leaf positions, respectively.
[0007] In a third aspect, the present application provides a computer device comprising memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor executes the computer program to realize the hyperspectral separation and extraction method of tea leaf stems and leaves described in any of the above aspects.
[0008] In a fourth aspect, the application provides a computer-readable storage medium in which a computer program is stored, and when the computer program is executed by a processor, a hyperspectral separation and extraction method for tea stems and leaves described in any of the above aspects is realized. [Effects of the Invention]
[0009] According to the specific embodiments provided in this application, this application has the following technical effects. This application provides a method, apparatus, device, and medium for hyperspectral separation and extraction of tea leaf stems and leaves. It can perform binarization on a hyperspectral image of tea leaves, extract the tea leaf skeleton from the binarized image, search for the stem skeleton line based on the starting point and branching point of the tea leaf skeleton to determine the tea leaf stem image, remove the tea leaf stem image from the binarized image to determine the binarized image of the tea leaf leaf and the leaf position, automatically identify and separate the tea leaf stem and tea leaf, and finally extract the corresponding hyperspectral data. This overcomes the shortcomings of manual operation, which is inefficient and inaccurate, and improves the degree of automation and accuracy of hyperspectral image recognition of tea leaf stems and leaves. [Brief explanation of the drawing]
[0010] To more clearly illustrate the embodiments of this application or the technical solutions of related technologies, the drawings that need to be used in the embodiments are briefly described below. Clearly, the drawings described below represent only some embodiments of this application, and those skilled in the art can obtain other drawings based on these without requiring any creative effort.
[0011] [Figure 1] This figure shows the application environment for the hyperspectral separation and extraction method for tea leaf stems and leaves in one embodiment of this application. [Figure 2] This is a schematic flowchart of a hyperspectral separation and extraction method for tea leaf stems and leaves provided in one embodiment of this application. [Figure 3]It is a diagram showing the overall operating principle of the hyperspectral separation and extraction method for tea stems and leaves provided by one embodiment of this application. [Figure 4] It is an RGB image obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 5] It is an HSV image obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 6] It is a histogram of the H channel data in the HSV image obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 7] It is a binarized image of the initial tea leaves obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 8] It is a binarized image of the final tea leaves obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 9] It is a skeleton image of tea leaves obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 10] It is a schematic diagram of the starting points and branching points of the tea leaf skeletons for identifying tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 11] It is a schematic diagram of the stem skeleton line obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 12] It is a stem image of tea leaves obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 13] It is a binarized image of the leaves of tea leaves with the stems removed, obtained from tea leaves picked using the method of this application provided by another embodiment of this application. <^ [Figure 14] It is a binarized image of the leaves of tea leaves with the leaf positions not stuck together, obtained from tea leaves picked using the method of this application provided by another embodiment of this application. [Figure 15]This is a schematic diagram of leaf position markings obtained from tea leaves picked using the method of this application, as provided in another embodiment of this application. [Figure 16] This is a schematic diagram of the structure of a computer device provided in one embodiment of this application. [Modes for carrying out the invention]
[0012] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the drawings of the embodiments of this application, and it is clear that the embodiments described are only a selection of embodiments of this application, not all embodiments. All other embodiments obtained by those skilled in the art without creative effort based on the embodiments of this application all fall within the technical scope of the present invention.
[0013] To make the above-mentioned objectives, features, and advantages of this application clearer and easier to understand, this application will be described in more detail below with reference to the drawings and specific embodiments.
[0014] The hyperspectral separation and extraction method for tea leaf stems and leaves provided in the embodiment of this application can be applied to the application environment shown in Figure 1. In this configuration, terminal 102 communicates with server 104 via a network. A data storage system can store data that server 104 needs to process. The data storage system may be installed independently, integrated with server 104, or located in the cloud or on another server. Terminal 102 can transmit a hyperspectral image of tea leaves to server 104. After server 104 receives the hyperspectral image, server 104 obtains a binarized image of the tea leaves based on the hyperspectral image, removes edge pixels of the tea leaves from the binarized image to obtain a skeletal image of the tea leaves, determines the starting point and branching point of the tea leaf skeleton in the skeletal image, and, based on the starting point and branching point, uses a breadth-first search algorithm to determine the skeletal lines connecting the starting point and branching point, and the skeletal lines connecting adjacent branching points from the skeletal image of the tea leaves to obtain the skeletal lines of the stem. Based on the skeletal structure of the stem, the system searches for the stem connection region to obtain an image of the tea leaf stem, removes the tea leaf stem image from the binarized image of the tea leaf to obtain a binarized image of the tea leaf with the stem removed, removes noise connection regions from the binarized image of the tea leaf with the stem removed to obtain a binarized image of the tea leaf where the leaf positions are not attached, marks the leaf positions in the binarized image of the tea leaf where the leaf positions are not attached based on the branching points, and extracts hyperspectral data of the tea leaf stem and hyperspectral data of the tea leaf leaf from the hyperspectral image of the tea leaf, respectively. Server 104 can then feed back the obtained hyperspectral data of the tea leaf stem and hyperspectral data of the tea leaf leaf to terminal 102.Furthermore, in some embodiments, the hyperspectral separation and extraction method for tea leaf stems and leaves may be implemented independently by server 104 or terminal 102. For example, terminal 102 may directly perform hyperspectral separation and extraction of tea leaf stems and leaves on a hyperspectral image of tea leaves, or server 104 may acquire a hyperspectral image of tea leaves from a data storage system and then perform hyperspectral separation and extraction of tea leaf stems and leaves on the hyperspectral image.
[0015] Of these, terminal 102 may be, but is not limited to, various desktop computers, notebook computers, smartphones, tablet computers, Internet of Things devices, and portable wearable devices. Internet of Things devices may include smart speakers, smart TVs, smart air conditioners, smart in-car devices, etc. Portable wearable devices may include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 may be implemented as an independent server or a server cluster consisting of multiple servers, or it may be a cloud server.
[0016] In one exemplary embodiment, as shown in Figure 2, a hyperspectral separation and extraction method for tea leaf stems and leaves is provided, which is performed by computer equipment, specifically, by computer equipment such as a terminal or server alone, or by a terminal and a server together, and in the embodiments of this application, the method is described as being applied to server 104 in Figure 1 as an example, and includes the following steps 201 to 209.
[0017] Step 201: Obtain a binarized image of the tea leaves based on the hyperspectral image of the tea leaves.
[0018] Step 202: Remove the edge pixels of the tea leaves from the binarized image of the tea leaves to obtain a skeletal image of the tea leaves.
[0019] Step 203: Determine the starting point and branching point of the tea leaf skeleton in the aforementioned tea leaf skeleton image.
[0020] Step 204: Based on the starting point and branching points, a breadth-first search algorithm is used to determine the skeletal lines connecting the starting point and branching points, and the skeletal lines connecting adjacent branching points, from the skeletal image of the tea leaf, thereby obtaining the skeletal lines of the stem.
[0021] Step 205: Based on the skeletal structure of the stem, search for the connecting regions of the stem and obtain an image of the tea leaf stem.
[0022] Step 206: Remove the image of the tea leaf stem from the binarized image of the tea leaf to obtain a binarized image of the tea leaf with the stem removed.
[0023] Step 207: Remove the noise-connected regions from the binarized image of the tea leaves from which the stems have been removed to obtain a binarized image of tea leaves from which the leaf positions are not attached.
[0024] Step 208: Based on the branching point, mark the leaf positions in the binarized image of tea leaves whose leaf positions are not attached.
[0025] Step 209: Based on the pixel positions of the stem connection regions and the marked leaf positions, hyperspectral data of the tea leaf stem and hyperspectral data of the tea leaf are extracted from the hyperspectral image of the tea leaf.
[0026] By performing steps 201 to 209 above, the hyperspectral image of the tea leaves is binarized, the leaf skeleton is extracted from the binarized image of the tea leaves, the stem skeleton is searched based on the starting point and branching point of the tea leaf skeleton to determine the tea leaf stem image, the tea leaf stem image is deleted from the binarized image of the tea leaves to determine the binarized image of the tea leaves and the leaf position, the tea leaf stem and tea leaf are automatically identified and separated, and finally the corresponding hyperspectral data is extracted, overcoming the shortcomings of manual operation, which is inefficient and inaccurate, and improving the degree of automation and accuracy of hyperspectral image recognition of tea leaf stems and leaves.
[0027] In another exemplary embodiment of this application, the process of obtaining a binarized image of tea leaves in step 201 above can be replaced by the following steps 301 to 306.
[0028] Step 301: Collect hyperspectral images of the tea leaves.
[0029] Specifically, the picked tea leaves are spread flat on a blue background plate, and a 400nm-1700nm line scan hyperspectral camera is turned on to acquire a hyperspectral image of the tea leaves.
[0030] Step 302: Extract the R-band, G-band, and B-band images from the hyperspectral image of the tea leaves and synthesize the RGB image.
[0031] The R band, G band, and B band may be set to the 470nm band, 540nm band, and 650nm band, respectively.
[0032] Step 303: Convert the RGB image to an HSV image and draw a histogram of the H channel data in the HSV image.
[0033] The calculation method for converting an RGB image to the H channel in an HSV image is as follows:
[0034] First, the values of the three RGB channels in an RGB image.
number
[0035] The maximum value of the normalized channel, the minimum value of the channel, and the difference between them (C max =max(R′,G′,B′),C min =min(R′,G′,B′), Δ=C max -C min ) is calculated. Here, C max is the maximum value of the normalized channel, and C min Δ is the minimum value of the normalized channel, Δ is the difference between the maximum and minimum values of the normalized channel, max is the maximum value function, and min is the minimum value function.
[0036] There are four cases for calculating H-channel data.
[0037] When Δ=0, H′=0. Here, H′ is the H channel data.
[0038] C max In the case of =R′,
number
number
[0039] C max In the case of =G′,
number
[0040] C max When it is equal to B',
Number
[0041] After calculating the H-channel data, the H-channel data is corrected. When H' is a negative number, H” = H' + 360°. H” represents the corrected H-channel data.
[0042] Step 304: Search for the peak of the histogram within a preset pixel value range, and use the pixel value corresponding to the peak as the green eigenvalue.
[0043] Step 305: Compare all pixel values of the H channel in the HSV image with the green eigenvalue, set pixel values less than or equal to the green eigenvalue to 255, and set pixel values greater than the green eigenvalue to 0 to obtain an initial binary image of tea leaves.
[0044] Perform binarization processing on the HSV image based on the green eigenvalue, compare all pixel values of the H channel with the green eigenvalue, set pixel values less than or equal to the green eigenvalue to 255, and set pixel values greater than the green eigenvalue to 0 to obtain a binary image of tea leaves and the background, where white (255) represents tea leaves and black (0) represents the background.
[0045] Step 306: Perform morphological dilation on the initial binary image of tea leaves to obtain a final binary image of tea leaves.
[0046] Perform a convolution kernel operation on the binary image to perform morphological dilation processing. The size of the convolution kernel used is 3×3, and the convolution process is performed twice to obtain a better dilation effect.
[0047] In another exemplary embodiment of the present application, tensor analysis and the principal curvature direction are used to subdivide the skeleton of tea leaves to obtain a skeleton image of tea leaves. The above step 202 can be replaced by the following steps 401 to step 306.
[0048] Step 401: Formula I x =I(x,y)*G x and I y =(x,y)*G y Based on this, the horizontal and vertical gradients of each pixel point in the binarized image of the tea leaves are calculated using the Sobel operator, where I(x,y) represents a pixel point whose horizontal coordinate is x and vertical coordinate is y, and I x It is a horizontal slope, I y This is a vertical slope, G x This is the Sobel operator for horizontal gradients, and G y This is the Sobel operator for vertical gradients.
[0049] Sobel operator G of horizontal slope x The following applies:
number
[0050] Sobel operator G for vertical gradient y The following applies:
number
[0051] Step 402: Based on the horizontal and vertical gradients of each pixel point in the binarized image of the tea leaves, the formula
number
[0052] Step 403: Perform eigenvalue decomposition on the structure tensor matrix of each pixel point to obtain two eigenvalues and their corresponding eigenvectors.
[0053] The formula used for eigenvalue decomposition is T(x,y)v s =λ s vs, s=1,2 and λ s is the s-th eigenvalue, and v s is the eigenvector corresponding to the s-th eigenvalue. The eigenvalue is λ 1≧ λ² represents the two main directions in the image, with corresponding eigenvectors v1 and v2. v1 is the principal direction, corresponding to the direction in which the gradient change is greatest.
[0054] Step 404: Based on the two eigenvalues, formula
number
[0055] The curvature k(x,y) can be approximately expressed by the relationship between eigenvalues, and by considering the anisotropy of the local structure, a formula for calculating the curvature k(x,y) can be obtained.
[0056] Step 405: Along the principal direction, it is sequentially determined whether each pixel point in the binarized image of the tea leaf satisfies k(x,y)<ε and λ1>λ2. The pixel values of the pixel points that satisfy k(x,y)<ε and λ1>λ2 are set to 0 to obtain a skeletal image of the tea leaf. Here, the principal direction refers to an eigenvector representing the direction in which the gradient change in the binarized image of the tea leaf is maximized, and ε is a predetermined threshold, which is arranged to control the degree of subdivision.
[0057] Setting a pixel value to 0 is equivalent to removing that pixel based on its curvature and principal direction.
[0058] In another exemplary embodiment of this application, step 203, which determines the starting point and branching point of the tea leaf skeleton in the tea leaf skeleton image, can be replaced by the following steps 501 to 505.
[0059] Step 501: Scan the skeletal image of the tea leaves from top to bottom, row by row, and mark the first scanned white pixel as the starting point.
[0060] The pixel value of a white pixel is 255, and the pixel value of a black pixel is 0.
[0061] Step 502: Starting from the starting point, each scanned white pixel point is sequentially designated as the current pixel point.
[0062] Step 503: Perform a topological analysis on the 8 neighbors of the current pixel point, record the white and black pixel points in the 8 neighbors, and statistically calculate the number of white pixel points in the 8 neighbors.
[0063] The eight neighbors that define a white pixel are as follows:
number
[0064] Here, P0 is the current pixel point, and P1, ..., P8 are the neighboring pixel points around it.
[0065] Step 504: Calculate the number of transitions from black pixel points to white pixel points within the 8 neighborhood, and the formula for calculating the number of transitions is A(P0)=[Pi= 0 And Pi+1 = 255, A(P0) is the number of transitions, Pi is the i-th neighboring pixel in the 8 neighborhoods, and the i-th neighboring pixel is a black pixel, and Pi+1 is the (i+1)th neighboring pixel in the 8 neighborhoods, and the (i+1)th neighboring pixel is a white pixel.
[0066] The transition count is an important topological metric for determining whether multiple connected regions surround the current pixel.
[0067] 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 to be the branch point. For example, the preset number is 3.
[0068] In another exemplary embodiment of this application, the specific steps of the breadth-first search algorithm described in step 204 above are as follows:
[0069] Step 601: Create a queue and add the starting point to it. Define direction vectors to represent movement in 8 directions (up, down, left, right, and 4 diagonal directions). Create a set 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.
[0070] Step 602: If the queue is not empty, run the loop. Pop the first node from the queue as the current node, check if the current node is the endpoint, and if it is, exit the loop. If it is not the endpoint, check each adjacent pixel in the 8 directions of the current node to check if the adjacent pixel is within the image range, has not been visited, and is a skeleton pixel (pixel value is 255). If the conditions are met, add the adjacent node to the queue and set, and record its parent node.
[0071] Step 603: After finding the endpoint, reconstruct the path from the endpoint to the starting point in reverse using a dictionary, calculate the length of all paths, determine the shortest path, reverse the shortest path to obtain the order from the starting point to the endpoint, and obtain the skeletal line image of the stem.
[0072] In another exemplary embodiment of this application, the process of acquiring images of tea leaf stems in step 205 above can be replaced by the following steps 701 to 303.
[0073] Step 701: Create a mask image of the stem's skeletal structure. This mask image is the same size as the stem image of the tea leaf to be acquired.
[0074] Step 702: Traverse all pixel points on the mask image.
[0075] Step 703: If the traversed pixel point is a white pixel point on the mask image, begin searching for one pixel point on each side, left and right.
[0076] Step 704: 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, the distance being the distance between the searched pixel point and the traversed white pixel point, and the maximum width is set to 7, for example.
[0077] Step 705: If a black pixel point in the mask image is found, or if the distance exceeds the maximum width, the search is stopped.
[0078] Step 706: All marked stem portions are configured as stem connecting regions to form a tea leaf stem image.
[0079] In another exemplary embodiment of the present application, step 206 above involves creating a mask image the same size as the tea leaf stem image, marking pixels in the tea leaf stem image with a pixel value of 255, setting the pixel values at the corresponding positions in the binarized tea leaf image to 0, applying the processed binarized tea leaf image to the created mask image, and obtaining a binarized image of the tea leaf with the stem removed.
[0080] In another exemplary embodiment of this application, step 207 above can be replaced by steps 801 to 804 below.
[0081] Step 801: The binarized image of the tea leaves from which the stems have been removed is subjected to two erosion operations using a 3x3 convolution kernel.
[0082] Step 802: Use the connectivity extraction method to determine the connected regions in the binarized image of the eroded tea leaves.
[0083] 8-connectivity: In 8-connectivity, the connected neighborhood of a pixel point includes pixels above, below, to the left, to the right, and along its four diagonal directions. The 8-connected neighborhood of the current pixel point P0 is P1 through P8.
number
[0084] In this method, all adjacent pixel points in eight directions are considered to be connected. Traverse each pixel point in the image. If a pixel point is a white pixel point (pixel value 255) and is not marked as visited, this pixel point is taken as the starting point of a new connected region. From this point, extend using a 4-connected or 8-connected method to search for all white pixel points connected to this point. Mark all connected white pixel points as visited until all pixels in this connected region have been processed. Repeat this process until all white pixel points in the image have been traversed. In this way, all connected regions in the image are obtained.
[0085] Step 803: Determine connected regions whose area is smaller than a preset area threshold as noise connected regions. For example, the preset area threshold is 100.
[0086] Step 804: Remove noise-connected regions from the binarized image of the eroded tea leaves to obtain a binarized image of tea leaves where the leaf positions are not attached.
[0087] In another exemplary embodiment of this application, when the order of leaf positions is determined based on the position of the branch point, the size of the connecting region of each leaf position, and the position of the uppermost pixel in the connecting region, step 208 above is replaced by steps 901 to 908 below.
[0088] Step 901: Determine the highest point position of each connected region and the area of each connected region in the binarized image of the tea leaves whose leaf positions are not attached.
[0089] Step 902: Select the branching point that is furthest from the starting point as the first branching point.
[0090] Step 903: Calculate the distance between the highest point of all connected regions and the first branching point, and select the two connected regions with the closest distance as the target connected regions.
[0091] Step 904: Mark the smaller junction areas in the target junction region as bud heads, and mark the larger junction areas as first leaf positions.
[0092] Step 905: Remove the first branching point from the branching points of the tea leaf structure. If branching points still remain, set j to 2.
[0093] Step 906: Select the branching point that is furthest from the starting point as the jth branching point.
[0094] Step 907: Calculate the distance between the highest point of an unmarked connected region and the first branching point, and select the connected region with the closest distance as the jth leaf position.
[0095] Step 908: Continue removing the jth branch point from the branch points of the tea leaf skeleton. If branch points still remain, increment the value of j by 1 and return to the step of "selecting the branch point furthest from the starting point as the jth branch point." Continue removing the jth branch point from the branch points of the tea leaf skeleton until no more branch points remain.
[0096] In another exemplary embodiment of this application, step 209 above extracts hyperspectral data of tea leaf stems and hyperspectral data of tea leaf leaves and saves them in different CSV files.
[0097] Figure 3 shows the overall operating principle of the hyperspectral separation and extraction method for tea leaf stems and leaves according to this application. This method includes acquiring a hyperspectral image, selecting bands and synthesizing RGB images, converting to an HSV image, calculating an HSV histogram, automatically searching for green bands, binarizing the image based on band ranges, performing dilation to remove interferences, extracting the tea leaf skeleton using a subdivision algorithm, finding the branching points of the skeleton, finding the stem skeleton using a breadth-first search algorithm, extracting the stem mask from the undiluted image based on the stem skeleton, removing smaller connected regions, dividing the tea leaf mask, determining the first leaf position, second leaf position, etc., and extracting hyperspectral data for stems and leaves based on the masks. Of these, extracting the stem mask from the undiluted image based on the stem skeleton corresponds to step 205 above. Dividing the tea leaf mask corresponds to step 207 above. Extracting hyperspectral data for stems and leaves based on the masks corresponds to step 209 above.
[0098] Figure 4 shows an RGB image obtained from tea leaves picked using the method of this application, where the blue color represents a blue background. Figure 5 shows an HSV image obtained from tea leaves picked using the method of this application. Figure 6 shows a histogram of the H channel data in the HSV image obtained from tea leaves picked using the method of this application. Figure 7 shows an initial binarized image of tea leaves obtained from tea leaves picked using the method of this application. Figure 8 shows a final binarized image of tea leaves obtained from tea leaves picked using the method of this application. Figure 9 shows a skeletal image of tea leaves obtained from tea leaves picked using the method of this application. Figure 10 shows the starting point and branching point of the tea leaf skeleton identified from tea leaves picked using the method of this application. The red dots in Figure 10 represent the starting point and branching point. Figure 11 shows the skeletal line of the stem obtained from tea leaves picked using the method of this application. Figure 12 shows an image of the tea leaf stem obtained from tea leaves picked using the method of this application. Figure 13 shows a binarized image of a tea leaf with the stem removed, obtained from tea leaves picked using the method of this application. Figure 14 shows a binarized image of a tea leaf with the leaf position not attached, obtained from tea leaves picked using the method of this application. Figure 15 shows the leaf position marking obtained from tea leaves picked using the method of this application. In Figures 4-5 and 7-15, the horizontal coordinate indicates the width of the image, and the vertical coordinate indicates the height of the image. The units of width and height are pixels, expressed in pixels. In Figure 6, the horizontal coordinate indicates the hue range of the H channel of the HSV image, with a hue range of 0-180, and the vertical coordinate indicates the frequency with which each hue appears in the image.
[0099] Based on the same inventive concept, embodiments of this application further provide a hyperspectral separation and extraction apparatus for tea stems and leaves to realize the above-described hyperspectral separation and extraction method for tea stems and leaves. Since the means for realizing the problem provided by this apparatus are similar to the means for realizing the problem described in the above-described method, specific limitations in the embodiments of one or more hyperspectral separation and extraction apparatus for tea stems and leaves provided below can be made by referring to the limitations of the above-described hyperspectral separation and extraction method for tea stems and leaves, and are therefore omitted from this explanation.
[0100] In one exemplary embodiment, a hyperspectral separation and extraction apparatus for tea leaf stems and leaves is provided, which includes a binarization module, an edge pixel removal module, a branch point determination module, a skeleton line search module, a stem search module, a stem removal module, a leaf acquisition module, a leaf position marking module, and an extraction module.
[0101] The binarization module is configured to obtain a binarized image of the tea leaves based on the hyperspectral image of the tea leaves. The edge pixel removal module is configured to remove the edge pixels of the tea leaves from the binarized image of the tea leaves to obtain a skeletal image of the tea leaves. The branch point determination module is configured to determine the starting point and branch points of the tea leaf skeleton in the skeletal image of the tea leaves. The skeleton line search module is configured to obtain the stem skeleton lines by determining the skeleton lines connecting the starting point and branch points, and the skeleton lines connecting adjacent branch points, from the skeletal image of the tea leaves using a breadth-first search algorithm based on the starting point and branch points. The stem search module is configured to obtain a stem image of the tea leaves by searching for connected regions of the stems based on the stem skeleton lines. The stem deletion module is configured to delete the stem image of the tea leaves from the binarized image of the tea leaves to obtain a binarized image of the tea leaves from which the stems have been removed. The leaf acquisition module is configured to remove noise-connected regions from the binarized image of the tea leaves from which the stems have been removed, thereby acquiring a binarized image of the tea leaves from which the leaf positions are not attached. The leaf position marking module is configured to mark the leaf positions in the binarized image of the tea leaves from which the leaf positions are not attached, based on branching points. The extraction module is configured to extract hyperspectral data of the tea leaf stems and hyperspectral data of the tea leaf leaves from the hyperspectral image of the tea leaves, based on the pixel positions of the stem-connected regions and the marked leaf positions.
[0102] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure is shown in Figure 16. This computer device includes a processor, memory, an input / output interface (I / O), and a communication interface. Of these, the processor, memory, and input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. Of these, the processor of this computer device is arranged to provide computing and control capabilities. The memory of this computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and a database. The internal memory provides an environment for the execution of the operating system and computer programs on the non-volatile storage medium. The database of this computer device is arranged to store hyperspectral data of tea leaf stems and hyperspectral data of tea leaf leaves. The input / output interface of this computer device is arranged to exchange information between the processor and external devices. The communication interface of this computer device is arranged to communicate with an external terminal via a network connection. When this computer program is executed by the processor, it realizes a hyperspectral separation and extraction method for tea stems and leaves.
[0103] Those skilled in the art will know that the structure shown in Figure 16 is merely a block diagram of a part of the structure relating to the solution of this application, and does not limit the computer equipment to which the solution of this application applies. Specific computer equipment may include more or fewer components than those shown, or may combine some components, or have a different arrangement of components. In one exemplary embodiment, a computer device is provided including memory and a processor, where a computer program is stored in the memory, and the processor performs the steps in each embodiment of the above method when executing the computer program.
[0104] In one exemplary embodiment, a computer-readable storage medium is provided in which a computer program is stored, and when this computer program is executed by a processor, the steps in each embodiment of the above method are realized.
[0105] The technical features of the above embodiments can be combined in any way, and for the sake of brevity, not all possible combinations of the technical features of the above embodiments will be described. However, as long as these combinations of technical features are inconsistent, they should all be considered to be within the scope described herein.
[0106] This specification has used specific examples to illustrate the principles and embodiments of this application, but the above description of embodiments is merely intended to aid in understanding the method and core idea of this application. Furthermore, those skilled in the art can modify both the specific embodiments and the scope of application based on the idea of this application. In summary, the contents of this specification should not be construed as limiting this application.
Claims
1. A hyperspectral separation and extraction method for tea leaf stems and leaves, Based on the hyperspectral image of the tea leaves, a binarized image of the tea leaves is obtained, The process involves removing the edge pixels of the tea leaves from the binarized image of the tea leaves to obtain a skeletal image of the tea leaves, To determine the starting point and branching point of the tea leaf skeleton in the aforementioned tea leaf skeleton image, Based on the starting point and branching points, a breadth-first search algorithm is used to determine the skeletal lines connecting the starting point and branching points, and the skeletal lines connecting adjacent branching points, from the skeletal image of the tea leaf, thereby obtaining the skeletal line of the stem. Based on the skeletal structure of the stem, the connecting regions of the stem are searched to obtain an image of the tea leaf stem, The process involves removing the stem image of the tea leaf from the binarized image of the tea leaf to obtain a binarized image of the tea leaf with the stem removed, The process involves removing noise-connected regions from the binarized image of the tea leaves from which the stems have been removed, thereby obtaining a binarized image of tea leaves from which the leaf positions are not attached. Based on the branching point, the leaf positions in the binarized image of tea leaves where the leaf positions are not attached are marked, A method for separating and extracting hyperspectral data of tea leaf stems and leaves, characterized by comprising extracting hyperspectral data of tea leaf stems and hyperspectral data of tea leaf leaves from a hyperspectral image of tea leaves based on the pixel position of the stem connection region and the marked leaf position.
2. Obtaining a binarized image of tea leaves based on a hyperspectral image of the tea leaves specifically means: To collect hyperspectral images of tea leaves, The process involves extracting R-band, G-band, and B-band images from the hyperspectral image of the aforementioned tea leaves, and then synthesizing them into an RGB image. Converting an RGB image to an HSV image and plotting a histogram of the H channel data in the HSV image, The process involves searching for a peak in the histogram within a predetermined range of pixel values, and designating the pixel value corresponding to the peak as the green eigenvalue. The process involves comparing all pixel values in the H channel of an HSV image with the green eigenvalue, setting pixel values less than or equal to the green eigenvalue to 255, and setting pixel values greater than the green eigenvalue to 0 to obtain a binarized image of the initial tea leaves. The hyperspectral separation and extraction method for tea leaf stems and leaves according to claim 1, characterized by comprising: performing morphological expansion on an initial binarized image of tea leaves to obtain a final binarized image of tea leaves.
3. Specifically, removing the edge pixels of the tea leaves in the binarized image of the tea leaves to obtain a skeletal image of the tea leaves means: Based on the equations Ix = I(x,y) * Gx and Iy = I(x,y) * Gy, the horizontal and vertical gradients of each pixel point in the binarized image of the tea leaves are calculated using the Sobel operator, where I(x,y) represents a pixel point with horizontal coordinate x and vertical coordinate y, Ix is the horizontal gradient, Iy is the vertical gradient, Gx is the Sobel operator of the horizontal gradient, and Gy is the Sobel operator of the vertical gradient. Based on the horizontal and vertical gradients of each pixel point in the binarized image of the tea leaves, the formula [Math 1] Using this, the structure tensor matrix of each pixel point in the binarized image of the tea leaves is calculated, and in the formula, T(x,y) is the structure tensor matrix. This involves performing eigenvalue decomposition on the structure tensor matrix of each pixel point to obtain two eigenvalues and their corresponding eigenvectors, Based on the two eigenvalues, the formula [Math 2] Using this, the curvature of each pixel point is calculated, and in the formula, k(x,y) is the curvature of the pixel point whose horizontal coordinate is x and vertical coordinate is y, and λ1 and λ2 are two eigenvalues. The method for hyperspectral separation and extraction of tea leaf stems and leaves according to claim 1, comprising: sequentially determining whether each pixel point in the binarized image of the tea leaf satisfies k(x,y) < ε and λ1 > λ2 along the principal direction; setting the pixel value of the pixel points that satisfy k(x,y) < ε and λ1 > λ2 to 0 to obtain a skeletal image of the tea leaf; wherein the principal direction refers to an eigenvector representing the direction in which the gradient change in the binarized image of the tea leaf is maximized, and ε is a predetermined threshold.
4. Determining the starting point and branching point of the tea leaf skeleton in the aforementioned tea leaf skeleton image means, specifically, The aforementioned skeletal image of the tea leaves is scanned row by row from top to bottom, and the first scanned white pixel point is designated as the starting point. Starting from the starting point, each scanned white pixel point is sequentially designated as the current pixel point, Topological analysis is performed on the eight neighboring pixels of the current pixel point, the white and black pixel points in the eight neighboring pixels are recorded, and the number of white pixel points in the eight neighboring pixels is statistically calculated. The number of transitions from a black pixel to a white pixel within an 8-neighborhood is calculated, and the formula for calculating the number of transitions is A(P0) = [Pi = 0 and Pi + 1 = 255], where A(P0) is the number of transitions, Pi is the i-th neighboring pixel within the 8-neighborhood, and the i-th neighboring pixel is a black pixel, and Pi + 1 is the (i+1)th neighboring pixel within the 8-neighborhood, and the (i+1)th neighboring pixel is a white pixel. The hyperspectral separation and extraction method for tea leaf stems and leaves according to claim 1, characterized in that, if the number of white pixel points in the 8th neighborhood is greater than or equal to a predetermined number and the number of transitions is greater than or equal to a predetermined number, the current pixel point is determined to be a branching point.
5. Specifically, obtaining a tea leaf stem image involves searching for the stem's connecting regions based on its skeletal structure. A mask image of the stem's skeletal structure is created, and the mask image is the same size as the stem image of the tea leaf to be acquired. Traversing all pixel points on the aforementioned mask image, If the traversed pixel point is a white pixel point on the mask image, the search for one pixel point is started on each side, both left and right. 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, and the distance is the distance between the searched pixel point and the traversed white pixel point. The search is stopped when a black pixel point is found in the aforementioned mask image, or when the distance exceeds the maximum width. The method for hyperspectral separation and extraction of tea leaf stems and leaves according to claim 1, characterized by comprising: configuring all marked stem portions as stem linkage regions, thereby forming a stem image of the tea leaf.
6. Specifically, removing the noise-connected regions from the binarized image of the tea leaves from which the stems have been removed, and obtaining a binarized image of tea leaves where the leaf positions are not attached, involves: The process involves performing a 3x3 convolution kernel erosion operation twice on the binarized image of the tea leaves from which the stems have been removed, Using an 8-connectivity extraction method, determine the connected regions in the binarized image of eroded tea leaves, The connected region whose area is smaller than a predetermined area threshold is determined to be a noise connected region, The hyperspectral separation and extraction method for tea leaf stems and leaves according to claim 1, characterized by comprising: removing noise-connected regions from the binarized image of the eroded tea leaf to obtain a binarized image of tea leaf where the leaf positions are not attached.
7. Specifically, marking the leaf positions in the binarized image of tea leaves where the leaf positions are not attached, based on the branching point, The process involves determining the highest point position of each connected region and the area of each connected region in the binarized image of tea leaves where the leaf positions are not attached, The branching point furthest from the starting point is selected as the first branching point, The distance between the highest point of all connected regions and the first branching point is calculated, and the two connected regions with the closest distance are selected as the target connected regions. The smaller area of the target junction region is marked as the bud tip, and the larger area of the junction region is marked as the first leaf position. Remove the first branching point from the branching points of the tea leaf's structure, and if branching points still remain, set j to 2. The branching point furthest from the starting point is selected as the jth branching point, The distance between the highest point of an unmarked connected region and the first branching point is calculated, and the connected region with the closest distance is selected as the jth leaf position. The hyperspectral separation and extraction method for tea leaf stems and leaves according to claim 1, comprising: continuously removing the j-th branch point from the branch points of the tea leaf skeleton; if branch points still remain, increasing the value of j by 1 and returning to the step of "selecting the branch point furthest from the starting point as the j-th branch point"; and continuing to remove the j-th branch point from the branch points of the tea leaf skeleton until no branch points remain.
8. A hyperspectral separation and extraction apparatus for tea leaf stems and leaves, wherein the hyperspectral separation and extraction apparatus for tea leaf stems and leaves is A binarization module for obtaining binarized images of tea leaves based on hyperspectral images of tea leaves, An edge pixel removal module for removing edge pixels of tea leaves in the binarized image of tea leaves to obtain a skeletal image of tea leaves, A branching point determination module for determining the starting point and branching point of the tea leaf skeleton in the aforementioned tea leaf skeleton image, A skeleton line search module for obtaining the stem skeleton line by determining the skeleton lines connecting the starting point and branching point, and the skeleton lines connecting adjacent branching points, from the skeletal image of the tea leaf using a breadth-first search algorithm based on the starting point and branching point, A stem search module for obtaining images of tea leaf stems by searching for stem connection regions based on the stem's skeletal structure, A stem removal module for removing the stem image of the tea leaf from the binarized image of the tea leaf and obtaining a binarized image of the tea leaf with the stem removed, A leaf acquisition module for removing noise-connected regions in the binarized image of tea leaves from which the stems have been removed, in order to obtain a binarized image of tea leaves from which the leaf positions are not attached, A leaf position marking module for marking leaf positions in a binarized image of tea leaves where the leaf positions are not attached, based on branching points, A hyperspectral separation and extraction apparatus for tea leaf stems and leaves, comprising: an extraction module for extracting hyperspectral data of tea leaf stems and hyperspectral data of tea leaf leaves from a hyperspectral image of tea leaves, based on the pixel position of the stem connection region and the marked leaf position.
9. A computer device comprising memory, a processor, and a computer program stored in memory and executable by the processor, wherein the processor executes the computer program to realize the hyperspectral separation and extraction method of tea leaf stems and leaves described in any one of claims 1 to 7.
10. A computer-readable storage medium in which a computer program is stored, characterized in that when the computer program is executed by a processor, it realizes the hyperspectral separation and extraction method of tea leaf stems and leaves described in any one of claims 1 to 7.