Tea leaf image extraction method, device, equipment and storage medium

By preprocessing and feature comparison of the color images of tea trees, the complete image of tea leaves is extracted, which solves the background interference problem and improves the accuracy of image analysis.

CN114299097BActive Publication Date: 2025-05-06INST OF AGRI QUALITY STANDARDS & TESTING TECH RES HUBEI ACADEMY OF AGRI SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111678692.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-05-06
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

During the tea image acquisition process, complex background interference leads to a decrease in the accuracy of tea image analysis, affecting the judgment of tea tree growth status.

Method used

By obtaining the color image of the tea tree, pre-processing is performed to obtain a binarized image of the leaves and the trunk, feature comparison is performed using the growth position relationship between the trunk and the leaves, the preliminary contour image of the leaves is extracted, and the complete leaf image is further extracted according to the relevant parameters of the reference leaf.

Benefits of technology

Effectively eliminate background interference, improve the accuracy of tea images, and ensure accurate judgment of tea tree growth status.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114299097B_ABST
    Figure CN114299097B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of image processing technology, and in particular, relates to a method, device, equipment and storage medium for extracting tea leaf images. The tea leaf image extraction method of the present invention comprises the following steps: S1: obtaining a color image of a tea tree containing leaves as an original image; S2: obtaining relevant parameters of a reference leaf; S3: obtaining a binary image of the leaves and the trunk after preprocessing the original image of the tea tree; S4: performing feature comparison between the binary image of the trunk and the binary image of the leaves according to the growth position relationship between the trunk and the leaves to extract a preliminary contour image of the leaves; S5: extracting a complete leaf image according to the preliminary contour image of the leaves and the relevant parameters of the reference leaves. The present invention can accurately extract the leaf image and eliminate background interference in the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a method, device, equipment and storage medium for extracting tea leaf images. Background Art

[0002] Tea is made from the buds and leaves of the tea tree after certain processing. Together with coffee and cocoa, it is known as the world's three major beverages. Tea is also one of my country's major economic crops. The tea planting area and annual tea production are both ranked first in the world. At present, for the cultivation of tea, most tea factories and tea gardens still use manual planting or manual and mechanical picking. For the monitoring of the growth of tea trees, it basically relies on the tea farmers' own planting experience to judge and monitor. For tea factories and tea gardens with a large area, cultivation monitoring is often inadequate, and judging the growth of tea trees based on experience alone can only be approximate and not accurate enough. There are also certain restrictions on the staff of the tea garden. Basically, only tea farmers with many years of experience can be invited to undertake this kind of work, and the labor intensity is also relatively high.

[0003] Therefore, it is inevitable and necessary to make the tea industry intelligent. The tea gardens should be uniformly monitored and planted. In this process, the image collection and analysis of the growth conditions of tea trees will be involved. The main part where the symptoms of tea trees appear is on the tea leaves, but when collecting images, it is generally based on a tea tree for overall image collection. The image includes tea leaves and complex background other than tea leaves. The background will interfere with the subsequent analysis of the tea images and affect the judgment of the growth conditions of the tea trees. Summary of the invention

[0004] In view of this, the embodiments of the present invention provide a method, device, equipment and storage medium for extracting tea leaf images, which are used to solve the problem of background interference on tea leaf images when collecting tea leaf images in the prior art.

[0005] The technical solution adopted by the present invention is:

[0006] In a first aspect, the present invention provides a method for extracting tea leaf images, the method comprising the following steps:

[0007] S1: Acquire a color image of a tea tree including leaves as an original image;

[0008] S2: Obtain relevant parameters of the reference blade;

[0009] S3: Preprocessing the original image of the tea tree to obtain binary images of leaves and trunks;

[0010] S4: according to the growth position relationship between the trunk and the leaves, feature comparison is performed between the binary image of the trunk and the binary image of the leaves to extract a preliminary contour image of the leaves;

[0011] S5: extracting a complete leaf image according to the preliminary leaf contour image and relevant parameters of the reference leaf.

[0012] Preferably, the step S3: preprocessing the original image of the tea tree to obtain a binary image of the leaves and the trunk comprises the following steps:

[0013] S31: performing normalization processing on the original image to obtain a first intermediate image;

[0014] S32: grayscale processing is performed on the first intermediate image using the G channel of the RGB channels to obtain a grayscale image;

[0015] S33: performing local binarization processing on the grayscale image to obtain binary images of leaves and trunks;

[0016] Preferably, the step S33: performing local binarization processing on the grayscale image to obtain a binary image of the leaves and the trunk comprises the following steps:

[0017] S331: performing target detection on the grayscale image with the trunk and leaves as detection targets to obtain a frame containing the trunk and leaves;

[0018] S332: Binarize the image in the frame, convert the pixel values ​​corresponding to the trunk to 1, and convert the rest as the background to 0, to obtain a binary image of the trunk as the second intermediate image, convert the pixel values ​​corresponding to the leaves to 1, and convert the rest as the background to 0, to obtain a binary image of the leaves as the third intermediate image.

[0019] Preferably, S4: performing feature comparison between the binary image of the trunk and the binary image of the leaf to extract a preliminary contour image of the leaf according to the growth position relationship between the trunk and the leaf also includes the following steps:

[0020] S41: establishing plane coordinates on the second intermediate image and the third intermediate image respectively;

[0021] S42: performing coordinate positioning for the contour whose pixel value is 1 in the second intermediate image, and performing coordinate positioning for the contour whose pixel value is 1 in the third intermediate image;

[0022] S43: Compare the coordinates of the contour in the second intermediate image with the coordinates of the contour in the third intermediate image, and extract the contour in the third intermediate image that has the same coordinates as the contour in the second intermediate image.

[0023] Preferably, the relevant parameters of the reference pre-blade include: a pixel number threshold of the reference blade, a pixel center point of the reference blade, a radius threshold centered on the pixel center point of the reference blade, and a minimum value of the number of pixels within a corresponding radius.

[0024] Preferably, the step S5: extracting a complete leaf image according to the preliminary leaf contour image and the relevant parameters of the reference leaf further comprises the following steps:

[0025] S51: comparing the number of pixels in the preliminary leaf contour image with a threshold value of the number of pixels of the reference leaf;

[0026] S52: if the number of pixels in the preliminary leaf contour image is within the pixel number threshold range, extracting the preliminary leaf contour image as the complete leaf image;

[0027] S53: If the number of pixels in the preliminary leaf contour image is not within the pixel number threshold range, extracting the complete leaf image from the preliminary leaf contour image according to a radius threshold centered on the pixel center point of the reference leaf.

[0028] Preferably, assuming that the pixel center point of the reference leaf is the first center point, the step S53: if the number of pixels in the preliminary leaf contour image is not within the pixel number threshold range, extracting the complete leaf image from the preliminary leaf contour image according to a radius threshold centered on the pixel center point of the reference leaf further includes the following steps:

[0029] S531: arbitrarily selecting a pixel point in the preliminary leaf contour image as a second pixel center point;

[0030] S532: Taking the second pixel center point as the circle center, obtaining a plurality of radius values ​​within the radius threshold, and respectively calculating the number of corresponding pixel points within each of the obtained radius values;

[0031] S533: Compare the number of pixels corresponding to each radius value range with the minimum number of pixels in each corresponding radius value range of the reference leaf;

[0032] S534: if the number of pixels within a certain radius value range is greater than or equal to the number of pixels within the radius range corresponding to the radius value in the reference leaf, marking the second center point as a leaf internal point;

[0033] S535: If the number of pixels within a certain radius value range is less than the number of pixels within the radius range corresponding to the radius value in the reference leaf, marking the second center point as an interference pixel point;

[0034] S536: if a certain interfering pixel point is located at a certain internal point of the leaf, then within the radius range of the radius value, the interfering pixel point is marked as a leaf edge point, otherwise, the interfering pixel point is still the interfering pixel point;

[0035] S537: Repeat steps S531 to S536 until all pixel points in the preliminary leaf contour image are marked.

[0036] In a second aspect, this embodiment provides a tea leaf image extraction device, the device comprising:

[0037] An original image acquisition module, wherein the original image acquisition module is used to acquire a color image of a tea tree including leaves as an original image;

[0038] A reference blade parameter acquisition module, wherein the reference blade parameter acquisition module is used to acquire relevant parameters of the reference blade;

[0039] A preprocessing module, wherein the preprocessing module is used to preprocess the original image of the tea tree to obtain a binary image of the leaves and the trunk;

[0040] A leaf contour preliminary extraction module, the leaf contour preliminary extraction module is used to perform feature comparison between the binary image of the trunk and the binary image of the leaf according to the growth position relationship between the trunk and the leaf, to extract a preliminary leaf contour image;

[0041] A complete leaf extraction module is used to extract a complete leaf image based on the preliminary leaf contour image and relevant parameters of the reference leaf.

[0042] In a third aspect, the present invention further provides a method and device for extracting tea leaf images, comprising: at least one processor, at least one memory, and computer program instructions stored in the memory, and when the computer program instructions are executed by the processor, the method described in the first aspect is implemented.

[0043] In a fourth aspect, the present invention further provides a storage medium having computer program instructions stored thereon, which implement the method described in the first aspect when the computer program instructions are executed by a processor.

[0044] Beneficial effect: The tea leaf image extraction method, device, equipment and storage medium of the present invention obtain binary images of leaves and trunks by preprocessing a tea tree color image containing leaves. Since the features in the two binary images are a trunk and a leaf respectively, they are structurally connected. Therefore, the growth position relationship between the trunk and the leaves can be used to determine whether the trunk and the leaves are connected from the image, so as to preliminarily judge the preliminary contour image of the leaves and exclude a part of the interfering images extracted due to color features. For the preliminary leaf contour image, the preliminary leaf contour image is compared with the preset leaves, and based on the clustering method, a complete leaf image is further extracted from the preliminary leaf contour image to avoid multiple leaves overlapping and extracting an image of a leaf, or leaves overlapping with other green backgrounds and extracting an image of a leaf, so that the complete leaf image can be separated therefrom. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings required for use in the embodiment of the present invention will be briefly introduced below. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work, and these are all within the protection scope of the present invention.

[0046] Figure 1 Schematic diagram of the process of extracting tea leaf images of the present invention;

[0047] Figure 2 It is a schematic flow chart of a method for preprocessing an original image of a tea tree according to the present invention;

[0048] Figure 3 A schematic diagram of the flow chart of the method for performing local binarization processing of the present invention;

[0049] Figure 4 A schematic diagram of the process of extracting the preliminary contour of a blade according to the present invention;

[0050] Figure 5 A schematic diagram of the process of extracting a complete leaf image according to the present invention;

[0051] Figure 6 It is a schematic diagram of the flow of the method for extracting a complete leaf image according to a radius threshold value of the present invention;

[0052] Figure 7 It is a structural block diagram of the tea leaf image extraction device of the present invention;

[0053] Figure 8 It is a schematic diagram of the structure of a device for extracting leaves under a complex background according to an embodiment of the present invention. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described in conjunction with the drawings in the embodiment of the present invention. It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. In the description of the present invention, it should be understood that the orientation or position relationship indicated by the terms "center", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such a process, method, article or device. In the absence of further restrictions, the elements defined by the phrase "comprising..." do not exclude the existence of other identical elements in the process, method, article or device comprising the elements. If there is no conflict, the embodiments of the present invention and the various features in the embodiments can be combined with each other, all within the protection scope of the present invention.

[0055] Example 1

[0056] See also Figure 1 The embodiment of the present invention provides a method for extracting leaf images in a tea tree growth environment, the method comprising:

[0057] S1: obtaining a color image of a tea tree including leaves as an original image; wherein the color image may be obtained by photographing with a camera or other photographic device, and the photographing angle is not limited. It is often necessary to photograph a tea tree from multiple angles to clearly express the entire appearance of the tea tree;

[0058] S2: Obtain relevant parameters of the reference blade;

[0059] The relevant parameters of the reference pre-blade include: a pixel point number threshold of the reference blade, a pixel center point of the reference blade, a radius threshold centered on the pixel center point of the reference blade, and a minimum value of the number of pixels within a corresponding radius.

[0060] S3: Preprocessing the original image of the tea tree to obtain binary images of leaves and trunks;

[0061] like Figure 2 As shown, the S3: obtaining a binary image of leaves and trunks after preprocessing the original image of the tea tree comprises the following steps:

[0062] S31: performing normalization processing on the original image to obtain a first intermediate image;

[0063] In order to make subsequent image processing more accurate, image normalization processing is used to reduce the influence of light on the image in subsequent processing compared with the original image. It should be noted that image normalization processing is a prior art and will not be elaborated on in detail.

[0064] S32: grayscale processing is performed on the first intermediate image using the G channel of the RGB channels to obtain a grayscale image;

[0065] In this embodiment, the color features of the first color intermediate image can be first extracted. Specifically, the extracted color features are mainly color features related to the color of the leaves, i.e., green features, and color features related to the color of the trunk, i.e., gray-brown features. Based on the green features and gray-brown features, two images are regenerated, one of which uses non-green features as the background to obtain the outline of the leaves, and the other image uses non-gray-brown features as the background to obtain the outline of the trunk. After binary processing, the second intermediate image and the third intermediate image are obtained respectively, simplifying the images and improving the subsequent operation speed.

[0066] See also Figure 2 In this step, the G channel in the RGB channel is used to grayscale the first color intermediate image to obtain a grayscale image; the first color intermediate image is set as the color image of the RGB channel, and the G channel is selected from the RGB channel, and the first color intermediate image is grayscaled based on the G channel to obtain a grayscale image. Since the proportions of various features in the image to the G channel are different, there will be certain differences between the features in the grayscale image, and the grayscale values ​​of various features are also different.

[0067] S33: performing local binarization processing on the grayscale image to obtain binary images of leaves and trunks;

[0068] This embodiment can count the grayscale mean values ​​of the trunk, the leaves and other backgrounds in the grayscale image respectively; according to the different grayscale values ​​occupied by each feature in the grayscale image, classification can be performed based on the grayscale value of each feature. Our purpose is to obtain leaves, so we only need to extract the grayscale value image related to the leaves, and then count the grayscale mean values ​​of each feature in the grayscale image respectively, and each feature refers to the trunk, leaves and other features as the background. The grayscale mean values ​​occupied by the trunk, leaves and other backgrounds are all different, so the grayscale image can be classified to obtain trunk features, leaf features and other background features. For the statistics of grayscale values, it is mainly based on the grayscale threshold value of the pre-set leaves after grayscale processing using the G channel and the grayscale threshold value of the pre-set trunk after grayscale processing using the G channel. Within the corresponding threshold range, it will be determined as the corresponding leaf or trunk grayscale image in this step. Since the grayscale is grayed using the RGB color channel, the image obtained is not an accurate leaf image or trunk image, and it will also be interfered by background features with similar colors.

[0069] like Figure 3 As shown, the step S33: performing local binarization processing on the grayscale image to obtain the binary images of leaves and trunks includes the following steps:

[0070] S331: performing target detection on the grayscale image with the trunk and leaves as detection targets to obtain a frame containing the trunk and leaves;

[0071] To avoid the problem of too many holes in the image after binarization, this embodiment first performs target detection on the trunk and leaves to obtain the approximate position and range of the trunk and leaves in the image. To facilitate subsequent processing, the area containing the trunk and leaves can be framed out in the image using a frame.

[0072] S332: Binarize the image in the frame, convert the pixel values ​​corresponding to the trunk to 1, and convert the rest as the background to 0, to obtain a binary image of the trunk as the second intermediate image, convert the pixel values ​​corresponding to the leaves to 1, and convert the rest as the background to 0, to obtain a binary image of the leaves as the third intermediate image.

[0073] S322: performing binarization processing on the image in the frame;

[0074] This step performs binarization on the selected local image, which can avoid the interference of the background area and improve the effect of subsequent image recognition. In addition, as another implementation, an image binarization method based on the U-net network can also be used to perform binarization on the grayscale image. U-net is a deep learning neural network. Using the image binarization method based on the U-net network can effectively avoid the interference of complex backgrounds in the image.

[0075] In this embodiment, the pixel values corresponding to the tree trunk can be converted to 1, and the rest are converted to 0 as the background to obtain a third intermediate image. The pixel values corresponding to the leaves are converted to 1, and the rest are converted to 0 as the background to obtain a second intermediate image. Here, for the convenience of subsequent step processing, reducing the calculation amount, and facilitating observation, the initially obtained tree trunk-like features are processed. Specifically, the pixel values corresponding to the tree trunk are converted to 1, and the pixel values of all other features are converted to 0 to regenerate a third intermediate image. This third intermediate image has only two colors, and the features of the tree trunk are more obvious. Similarly, the initially obtained leaf-like features are processed. Specifically, the pixel values corresponding to the leaves are converted to 1, and the pixel values of all other features are converted to 0 to regenerate a second intermediate image. This second intermediate image also has only two colors, and the features of the leaves are more obvious. After the above steps, a third intermediate image containing all the feature contours of the tree trunk and some other interfering background contours, and a second intermediate image containing all the feature contours of the leaves and some other interfering background contours can be obtained. It should be noted that the judgment of the tree trunk contour is relatively easy. The tree trunk is generally grayish-brown. Considering the reality, there are generally not many background colors similar to grayish-brown in the background, and according to the fact that the tree trunk contour must be a whole and there will be no phenomenon of contour separation, the accurate contour of the tree trunk can be basically determined. In the subsequent steps, the contour of the leaves will be mainly analyzed and extracted based on the tree trunk contour.

[0076] Step S4: According to the growth position relationship between the tree trunk and the leaves, perform feature comparison on the binary image of the tree trunk and the binarized image of the leaves to extract the preliminary contour image of the leaves;

[0077] As Figure 4 shown, the specific implementation includes the following steps:

[0078] S41: Establish plane coordinates on the second intermediate image and the third intermediate image respectively;

[0079] In order to obtain a preliminary leaf contour image by comparing the features between the second intermediate image and the third intermediate image, a method may be adopted in which plane coordinates are established on the second intermediate image and the third intermediate image respectively, thereby positioning the contour of the trunk and the contour of the leaves on the position image B1, and the coordinates of any point on the trunk contour or the leaf contour can be easily extracted.

[0080] S42: performing coordinate positioning for the contour whose pixel value is 1 in the second intermediate image, and performing coordinate positioning for the contour whose pixel value is 1 in the third intermediate image;

[0081] The extraction through coordinate positioning has higher accuracy, and after the coordinate positioning, the corresponding feature contour can be directly extracted without calculation when extracting the same coordinates, which is fast and simple. The extraction of the same coordinates here refers to the coordinates in the third intermediate image that have an intersection with the second intermediate image. According to the coordinates of the intersection, it is judged whether the leaf is connected to the trunk, so as to obtain whether the leaf contour belongs to the real leaf contour or the pseudo leaf contour or the fallen leaf contour. After the judgment is completed, the preliminary contour image of the leaf in the second intermediate image can be obtained.

[0082] S43: Compare the coordinates of the contour in the second intermediate image with the coordinates of the contour in the third intermediate image, and extract the contour in the third intermediate image that has the same coordinates as the contour in the second intermediate image.

[0083] This embodiment excludes interfering background contours that do not belong to leaves based on the growth position relationship between the trunk and the leaves. The so-called growth position relationship is based on common sense. Leaves grow on the trunk, that is, the leaves and the trunk must be connected in contour. This eliminates interfering background contours that are not connected to the trunk, which are called pseudo-leaf contours. At the same time, in addition to being able to exclude pseudo-leaf contours, this method can also exclude the contours of leaves that have fallen from the trunk, preventing pseudo-leaf contours and fallen leaf contours from affecting the subsequent extraction and analysis of leaves.

[0084] S5: extracting a complete leaf image according to the preliminary leaf contour image and relevant parameters of the reference leaf.

[0085] In step S5, the preliminary leaf contour image extracted above is mainly further optimized and extracted, aiming at the interference images that cannot be removed in the above steps, such as: the background contour with a color similar to the leaf color partially overlaps with the leaf contour. From the second intermediate image, this part of the contour cannot be eliminated after the above steps S1 to S4; in addition, it is also possible that two or more leaves partially overlap, resulting in misjudgment as a leaf contour, affecting the accurate extraction of the leaves and the subsequent analysis of leaf diseases and pests.

[0086] like Figure 5 As shown, the S5: extracting a complete leaf image according to the preliminary leaf contour image and the relevant parameters of the reference leaf also includes the following steps:

[0087] S51: comparing the number of pixels in the preliminary outline image of the leaf with a threshold value of the number of pixels of the reference leaf;

[0088] The area of ​​tea leaves has a certain normal size range, that is, there is an area threshold. By determining the image size (resolution) of the preliminary leaf contour image, the image resolution can be directly determined by the shooting equipment, and the pixel threshold of the normal leaf at this resolution can be set in advance.

[0089] S52: if the number of pixels in the preliminary leaf contour image is within the pixel number threshold range, extracting the preliminary leaf contour image as the complete leaf image;

[0090] When the number of pixels in the preliminary leaf contour image is within a preset pixel threshold range, it means that the preliminary leaf contour image is a complete leaf image.

[0091] S53: If the number of pixels in the preliminary leaf contour image is not within the pixel number threshold range, extracting the complete leaf image from the preliminary leaf contour image according to a radius threshold centered on the pixel center point of the reference leaf.

[0092] When the number of pixels in the preliminary leaf outline image is less than the preset pixel threshold range, it can be said that the outline is not the outline of the leaf, but may be a small dot outline formed by other backgrounds; when the number of pixels in the preliminary leaf outline image is greater than the preset pixel threshold range, it can be said that there are other overlapping outlines on the leaf outline, which may be background outlines or outlines of other leaves on the trunk. The density-based clustering method can gradually filter out the outlines belonging to the leaves.

[0093] Assume that the pixel center point of the reference leaf is the first center point, such as Figure 6 As shown, the S53: if the number of pixels in the preliminary leaf contour image is not within the pixel number threshold range, extracting the complete leaf image from the preliminary leaf contour image according to a radius threshold centered on the pixel center point of the reference leaf also includes the following steps:

[0094] S531: arbitrarily selecting a pixel point in the preliminary leaf contour image as a second pixel center point;

[0095] S532: Taking the second pixel center point as the circle center, obtaining a plurality of radius values ​​within the radius threshold, and respectively calculating the number of corresponding pixel points within each of the obtained radius values;

[0096] In this step, the second pixel center point Q2 can be used as the center of the circle to obtain N radius values ​​Ri within the radius threshold, and the number of corresponding pixels within the obtained N radius values ​​Ri can be calculated respectively; N radius values ​​Ri can be obtained in sequence from small to large, and the obtained radius intervals can be obtained from large intervals to small intervals, and the number of corresponding pixels within the obtained corresponding radius value range can be calculated respectively. The reason why the radius is obtained in sequence from small to large and the radius interval is obtained from large intervals to small intervals is that the corresponding radius range can be determined more quickly without calculating all radius values ​​within the radius threshold, thereby reducing the amount of calculation and improving the calculation speed.

[0097] S533: Compare the number of pixels corresponding to each radius value range with the minimum number of pixels in each corresponding radius value range of the reference leaf;

[0098] In this step, the number of pixels corresponding to the N radius values ​​Ri can be compared with the minimum number of pixels corresponding to the N radius values ​​Ri in the preset leaf; combined with step S532, after obtaining a radius value, a calculation based on the number of pixels in the radius value range and a comparison with the minimum number of pixels in the corresponding radius value range in the preset leaf are performed synchronously to obtain whether the number of pixels in the radius value range exceeds the minimum number of pixels in the preset leaf. And by obtaining the number of pixels once after obtaining the radius value, the corresponding radius critical value can be calculated at the first time. When the radius critical value is obtained, there is no need to continue the radius acquisition step based on the pixel center point Q2, which saves time, reduces the amount of calculation, and improves the calculation speed.

[0099] S534: if the number of pixels within a certain radius value range is greater than or equal to the number of pixels within the radius range corresponding to the radius value in the reference leaf, marking the second center point as a leaf internal point;

[0100] S535: If the number of pixels within a certain radius value range is less than the number of pixels within the radius range corresponding to the radius value in the reference leaf, marking the second center point as an interference pixel point;

[0101] S536: if a certain interfering pixel point is located at a certain internal point of the leaf, then within the radius range of the radius value, the interfering pixel point is marked as a leaf edge point, otherwise, the interfering pixel point is still the interfering pixel point;

[0102] S537: Repeat steps S531 to S536 until all pixel points in the preliminary leaf contour image are marked.

[0103] To facilitate the understanding of steps S531 to S537 by technicians, a simple example is given below:

[0104] The preliminary blade contour image is defined as image P, the pixel center points Q2 include Q21, Q22, Q23, ..., Q2i-1, Q2i, and the radius values ​​Ri include R1, R2, R3, ..., Ri.

[0105] Take any pixel center point Q21 on the image P, based on the pixel center point Q21, take a radius value R1 within the preset radius threshold, form a circular range with the radius value R1 and the pixel point Q21, calculate the number of pixels within the circular range, and then compare the number of pixels with the number of pixels within the circular range with the preset radius value R1 and the pixel center point Q1. If the number of pixels is greater than or equal to the preset number of pixels, the pixel center point Q21 is classified as an internal point of the leaf. If the number of pixels is less than the preset number of pixels, it means that the pixel center point Q21 does not belong to the internal point of the leaf and is marked as an interference pixel. ; After that, continue to take the next pixel center point Q22 on the image P, repeat the previous steps until all the pixel points on the image P are taken, and all the points belonging to the inside of the leaf are obtained; further judgment is required for the interference pixels, that is, if an interference pixel point is located in a circle with a radius value Ri as the range of one of the pixel center points, it means that the interference pixel point belongs to the edge of the leaf, and it is marked as a leaf edge point. If the interference pixel point is not in the circle, the interference pixel point is still marked as an interference pixel point. After all the interference pixels are judged and all the leaf edge points are marked, and then combined with the internal points of the leaf, a complete leaf image is obtained.

[0106] The working principle of the leaf image extraction method in the tea tree growth environment provided by the present invention is as follows:

[0107] First, a color image A1 is obtained, and parameter information such as a pixel threshold of a preset leaf, a pixel center point Q1 of the preset leaf, a radius threshold based on the pixel center point Q1, and a minimum value of the number of pixels within the corresponding radius are obtained; in order to subsequently reduce the influence of illumination on the image, the color image A1 is normalized to generate a color first intermediate image; the G channel in the RGB channel is used to grayscale the color first intermediate image to obtain a grayscale image, and each feature in the image has a different G channel grayscale value, so the grayscale image is classified according to the grayscale mean value of different types of features in the grayscale image, and is divided into trunk features, leaf features and other background features, and then the pixel values ​​are binary converted to obtain a third intermediate image about the trunk and a second intermediate image about the leaf; based on the growth position relationship between the leaf and the trunk, the contours that are not connected to the trunk can be excluded by establishing coordinates for comparison, and a preliminary leaf contour image can be further obtained, and then the preliminary leaf contour image is further processed by using a density clustering method to exclude contours where leaves overlap or where leaves overlap backgrounds with similar colors, and a complete leaf image is extracted.

[0108] Example 2

[0109] like Figure 7 As shown, this embodiment provides a tea leaf image extraction device, the device comprising:

[0110] An original image acquisition module, wherein the original image acquisition module is used to acquire a color image of a tea tree including leaves as an original image;

[0111] A reference blade parameter acquisition module, wherein the reference blade parameter acquisition module is used to acquire relevant parameters of the reference blade;

[0112] A preprocessing module, wherein the preprocessing module is used to preprocess the original image of the tea tree to obtain a binary image of the leaves and the trunk;

[0113] A leaf contour preliminary extraction module, the leaf contour preliminary extraction module is used to perform feature comparison between the binary image of the trunk and the binary image of the leaf according to the growth position relationship between the trunk and the leaf, to extract a preliminary leaf contour image;

[0114] A complete leaf extraction module is used to extract a complete leaf image based on the preliminary leaf contour image and relevant parameters of the reference leaf.

[0115] Example 3

[0116] This embodiment combines Figures 1 to 6 In addition, combined with Figure 8The tea leaf image extraction method of the aforementioned embodiment of the present invention can be implemented by the tea leaf image extraction method device of this embodiment. Figure 8 The hardware structure diagram of the tea leaf image extraction method and device provided by the embodiment of the present invention is shown.

[0117] The tea leaf image extraction method and device of this embodiment may include a processor 401 and a memory 402 storing computer program instructions.

[0118] Specifically, the processor 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiment of the present invention.

[0119] Memory 402 may include a large capacity memory for data or instructions. For example, but not limitation, memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, memory 402 may include a removable or non-removable (or fixed) medium. In appropriate cases, memory 402 may be inside or outside a data processing device. In a specific embodiment, memory 402 is a non-volatile solid-state memory. In a specific embodiment, memory 402 includes a read-only memory (ROM). In appropriate cases, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these.

[0120] The processor 401 reads and executes the computer program instructions stored in the memory 402 to implement the data addressing method of any one of the regional random tea leaf image extraction methods in the above embodiments.

[0121] In one example, the tea leaf image extraction method and device of this embodiment may also include a communication interface 403 and a bus 410. Figure 8 As shown, the processor 401, the memory 402, and the communication interface 403 are connected via a bus 410 and communicate with each other.

[0122] The communication interface 403 is mainly used to implement the communication between the modules, devices, units and / or equipment in the embodiment of the present invention.

[0123] Bus 410 includes hardware, software or both, and the components for the output of small multiples of ink volume are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransmission (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 410 may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection.

[0124] In addition, in combination with the leaf extraction method based on complex background in the above embodiment, the embodiment of the present invention can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, the leaf image extraction method in any tea tree growth environment in the above embodiment is implemented.

[0125] In summary, the method, device, equipment and storage medium for extracting leaves under a complex background provided by the embodiments of the present invention obtain a first color intermediate image by normalizing the color image A1, thereby reducing the influence of illumination on subsequent image processing, reducing local shadows in the image, and avoiding large exposure of the local surface in the texture intensity of the image; by extracting color features in the first color intermediate image, identifying and regenerating a third intermediate image about the trunk feature and a second intermediate image about the leaf feature, the first color intermediate image is separated into two binary images with a single feature, and the features in the two binary images are a trunk and a leaf. It is a leaf, which is structurally connected. Therefore, through the growth position relationship between the trunk and the leaf, it can be seen from the image whether the trunk and the leaf are connected, and the preliminary contour image of the leaf can be preliminarily judged, eliminating a part of the interference image extracted due to color characteristics; for the preliminary leaf contour image, the preliminary leaf contour image is compared with the reference leaf, and the complete leaf image is further extracted from the preliminary leaf contour image to avoid multiple leaves overlapping and extracting an image of a leaf, or the leaves overlapping with other green backgrounds and extracting an image of a leaf, so that the complete leaf image can be separated from them.

[0126] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.

[0127] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0128] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.

[0129] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be covered within the protection scope of the present invention.

Claims

1. A method for extracting tea leaf images, characterized in that: The method comprises: S1: Acquire a color image of a tea tree including leaves as an original image; S2: Obtain relevant parameters of the reference blade; S3: Preprocessing the original image of the tea tree to obtain binary images of leaves and trunks; S4: according to the growth position relationship between the trunk and the leaves, feature comparison is performed between the binary image of the trunk and the binary image of the leaves to extract a preliminary contour image of the leaves; S5: extracting a complete leaf image according to the preliminary leaf contour image and relevant parameters of the reference leaf; The step S3: preprocessing the original image of the tea tree to obtain a binary image of the leaves and the trunk comprises the following steps: S31: performing normalization processing on the original image to obtain a first intermediate image; S32: grayscale processing is performed on the first intermediate image using the G channel of the RGB channels to obtain a grayscale image; S33: performing local binarization processing on the grayscale image to obtain binary images of leaves and trunks; The step S33: performing local binarization processing on the grayscale image to obtain a binary image of leaves and trunks comprises the following steps: S331: performing target detection on the grayscale image with the trunk and leaves as detection targets to obtain a frame containing the trunk and leaves; S332: Binarization is performed on the image in the frame, pixel values ​​corresponding to the trunk are converted to 1, and the rest are converted to 0 as background, to obtain a binary image of the trunk as the second intermediate image, pixel values ​​corresponding to the leaves are converted to 1, and the rest are converted to 0 as background, to obtain a binary image of the leaves as the third intermediate image; The step S4: performing feature comparison between the binary image of the trunk and the binary image of the leaf according to the growth position relationship between the trunk and the leaf to extract a preliminary contour image of the leaf also includes the following steps: S41: establishing plane coordinates on the second intermediate image and the third intermediate image respectively; S42: performing coordinate positioning for the contour whose pixel value is 1 in the second intermediate image, and performing coordinate positioning for the contour whose pixel value is 1 in the third intermediate image; S43: Compare the coordinates of the contour in the second intermediate image with the coordinates of the contour in the third intermediate image, and extract the contour in the third intermediate image that has the same coordinates as the contour in the second intermediate image.

2. The tea leaf image extraction method according to claim 1, characterized in that: The relevant parameters of the reference leaf include: a pixel point number threshold of the reference leaf, a pixel center point of the reference leaf, a radius threshold centered on the pixel center point of the reference leaf, and a minimum value of the number of pixels within a corresponding radius.

3. The tea leaf image extraction method according to claim 2, characterized in that: The step S5: extracting a complete leaf image according to the preliminary leaf contour image and the relevant parameters of the reference leaf further comprises the following steps: S51: comparing the number of pixels in the preliminary outline image of the leaf with a threshold value of the number of pixels of the reference leaf; S52: if the number of pixels in the preliminary leaf contour image is within the pixel number threshold range, extracting the preliminary leaf contour image as the complete leaf image; S53: If the number of pixels in the preliminary leaf contour image is not within the pixel number threshold range, extracting the complete leaf image from the preliminary leaf contour image according to a radius threshold centered on the pixel center point of the reference leaf.

4. The tea leaf image extraction method according to claim 3, characterized in that The pixel center point of the reference leaf is the first center point, and the step S53: if the number of pixels in the preliminary leaf contour image is not within the pixel number threshold range, extracting the complete leaf image from the preliminary leaf contour image according to a radius threshold centered on the pixel center point of the reference leaf also includes the following steps: S531: randomly selecting a pixel point in the preliminary leaf contour image as a second pixel center point; S532: Taking the second pixel center point as the circle center, obtaining a plurality of radius values ​​within the radius threshold, and respectively calculating the number of corresponding pixel points within each of the obtained radius values; S533: Compare the number of pixels corresponding to each radius value range with the minimum number of pixels in each corresponding radius value range of the reference leaf; S534: if the number of pixel points within a certain radius value range is greater than or equal to the number of pixel points within the radius range corresponding to the radius value in the reference leaf, marking the second pixel center point as a leaf internal point; S535: if the number of pixels within a certain radius value range is less than the number of pixels within the radius range corresponding to the radius value in the reference leaf, marking the second pixel center point as an interference pixel point; S536: if a certain interfering pixel point is located at a certain internal point of the leaf, then within the radius range of the radius value, the interfering pixel point is marked as a leaf edge point, otherwise, the interfering pixel point is still the interfering pixel point; S537: Repeat steps S531 to S536 until all pixel points in the preliminary leaf contour image are marked.

5. A tea leaf image extraction device, characterized in that: The device uses the method of any one of claims 1 to 4 to extract tea leaf images, and the device comprises: An original image acquisition module, wherein the original image acquisition module is used to acquire a color image of a tea tree including leaves as an original image; A reference blade parameter acquisition module, wherein the reference blade parameter acquisition module is used to acquire relevant parameters of the reference blade; A preprocessing module, wherein the preprocessing module is used to preprocess the original image of the tea tree to obtain a binary image of the leaves and the trunk; A leaf contour preliminary extraction module, the leaf contour preliminary extraction module is used to perform feature comparison between the binary image of the trunk and the binary image of the leaf according to the growth position relationship between the trunk and the leaf, to extract a preliminary leaf contour image; A complete leaf extraction module is used to extract a complete leaf image based on the preliminary leaf contour image and relevant parameters of the reference leaf.

6. Tea leaf image extraction device, characterized in that: include: At least one processor, at least one memory and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, implement the method according to any one of claims 1 to 4.

7. A storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Tea tender shoot recognition and positioning algorithm

    CN111784764A

  • Coin identification device / Method

    JP1996016869A