A method and device for identifying the degree of disease of tea leaves

Through contour processing of tea leaf images and constrained algorithm model reconstruction, the accuracy problem of tea disease degree identification is solved, the digital index of disease degree is realized, and the analysis efficiency is improved.

CN117197518BActive Publication Date: 2024-08-30GUANGDONG POLYTECHNIC NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310274335.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-20
Publication Date
2024-08-30
Estimated Expiration
2043-03-20

AI Technical Summary

Technical Problem

It is difficult to accurately identify the degree of tea disease with existing technology, which mainly relies on experience and lacks specific indicators.

Method used

By taking pictures of tea leaves, extracting the contour map and smoothing it, obtaining the main veins and zero-crossing points, completing the arc, using the constraint algorithm model to reconstruct the arc, performing contour completion and ternary processing, and calculating the degree of disease.

Benefits of technology

It achieves accurate identification and indexation of tea disease levels and improves the efficiency of disease analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117197518B
    Figure CN117197518B
Patent Text Reader

Abstract

The present invention provides a method and device for identifying the disease degree of tea leaves, wherein the method comprises: finding a first arc to be completed according to a contour map of tea leaves to be identified, completing the first arc using a symmetrical third arc, thereby obtaining an ideal tea leaf map of the tea leaves to be identified, and then comparing the obtained ideal tea leaf map with a three-valued image of the tea leaves. The present invention has the beneficial effects of realizing the identification of the disease condition of tea leaves to be identified, and realizing the indexation of the disease degree, which is more conducive to the relevant personnel to analyze the disease condition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a method and device for identifying the degree of disease of tea leaves. Background Art

[0002] Tea is rich in many ingredients that are beneficial to human health and has become one of the most popular drinks in the world. In my country, tea drinking has a long history. There are many reasons for tea diseases. The current mainstream research method is to study the disease type by identifying tea images, and the degree of disease mainly depends on experience. However, it is difficult to accurately identify the degree of disease based on experience alone without a specific indicator. Therefore, a method for identifying the degree of tea disease is urgently needed. Summary of the invention

[0003] The main purpose of the present invention is to provide a method and device for identifying the disease degree of tea leaves, aiming to solve the problem that it is difficult to identify the disease degree of tea leaves.

[0004] The present invention provides a method for identifying the degree of disease of tea leaves, comprising:

[0005] S1: photographing the tea leaves to be identified to obtain a photographed picture, extracting a contour map of the tea leaves to be identified from the photographed picture, and smoothing the contour map to obtain a contour map of the target tea leaves;

[0006] S2: obtaining the main vein of the target tea contour image, and extracting the zero-crossing point of the target tea contour image according to a preset method;

[0007] S3: extracting the first arc to be completed in the target tea contour image according to the distance between the zero-crossing points;

[0008] S4: according to the direction of the target tea contour map, the zero-crossing point that is first close to the main vein and then away from the main vein is recorded as the first zero-crossing point, and the remaining zero-crossing points are recorded as the second zero-crossing points;

[0009] S5: Connecting the first zero-crossing points with a curve using a preset tool to obtain an intermediate contour map, and finding a second arc corresponding to the first arc in the intermediate contour map;

[0010] S6: mapping a third arc based on the main vein in the intermediate contour map based on the second arc;

[0011] S7: mirroring the third arc based on the main vein to obtain a fourth arc, and reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc; wherein the constraint algorithm model is trained by mirror images of different tea incomplete arcs and corresponding mapping arcs;

[0012] S8: replacing the second arc in the intermediate contour map with the fifth arc to obtain a target contour map, and obtaining a first average distance between the second zero-crossing points and a second average distance from the second zero-crossing point to the intermediate contour map;

[0013] S9: completing the contour on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map;

[0014] S10: performing ternary processing on the image in the contour image to obtain a ternary image of the captured image, and assigning a value with the largest value in the ternary image to the ideal contour image to obtain an ideal tea leaf image;

[0015] S11: Calculating the disease degree of the tea leaves to be tested according to the ideal tea leaves image and the ternary image.

[0016] Furthermore, the step S7 of reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc includes:

[0017] S701, receiving the fourth arc and the second arc through the preset constraint algorithm model;

[0018] S702: In the constraint algorithm model, substitute the fourth arc and the second arc into the formula , the alternating direction multiplication sub-algorithm is used to solve the fifth arc; wherein D represents the downsampling operator, B represents the fuzzy operator, X represents the second arc, Y represents the fourth arc, M represents other preset constraints, Z represents the variable parameter, ρ represents the penalty parameter, P is a variable parameter that changes with the number of operation steps of the alternating direction multiplication sub-algorithm. γ1 and γ2 are both preset parameters. L(X,Y,U) is the objective function.

[0019] Furthermore, the step S1 of extracting the contour of the tea leaves to be identified from the photographed image and smoothing the contour to obtain the contour of the target tea leaves comprises:

[0020] S101: Determine a contour point in the captured image as an initial contour point, and mark the coordinates of the initial contour point;

[0021] S102: searching eight neighboring pixels of the initial contour point according to the initial direction, determining the first neighboring pixel that is the same as the pixel of the initial contour point as the next contour point and marking the coordinates, and searching the remaining contour points of the captured image in sequence according to the next contour point until the searched contour point is the initial contour point; wherein the initial direction is a clockwise direction or a counterclockwise direction;

[0022] S103: representing the marked contour points with coordinates, and obtaining the contour perimeter of the contour image in the captured image according to each contour point marked with the coordinates;

[0023] S104: Smoothing the contour graph. The formula for smoothing each contour point Γ(x(μ), y(μ)) is:

[0024]

[0025]

[0026] Wherein Γ(x(μ), y(μ)) is the contour point with an arc length of μ from the current coordinate point to the initial contour point, y(μ) and x(μ) respectively represent the ordinate and abscissa of the current coordinate point, X(μ, σ) and Y(μ, σ) respectively represent the abscissa and ordinate of the current coordinate point after smoothing, σ is a parameter related to the normalization process, x(v+μ) represents the abscissa with an arc length offset distance of v, μ represents the arc length, L is the contour circumference of the target tea contour map, and 0≤μ≤L, v is a distance variable.

[0027] Furthermore, the step S103 of obtaining the contour perimeter of the contour image in the captured image according to each contour point marked with coordinates includes:

[0028] S1031: Acquire all contour points in the captured image to form the contour map;

[0029] S1032: setting all pixel points inside the contour map to the same pixel value to obtain a temporary contour map;

[0030] S1033: Detect whether each target pixel value in the temporary contour image is the same as the pixel values ​​of adjacent target pixels;

[0031] S1034: Accumulating the pixel values ​​of the pixel points that have the same pixel values ​​as the adjacent pixel points to obtain a first accumulated value;

[0032] S1035: Accumulate the pixel values ​​of all the pixels in the temporary contour image to obtain the second accumulated value, and subtract the first accumulated value from the second accumulated value to obtain the contour perimeter.

[0033] Furthermore, the step S11 of calculating the disease degree of the tea leaves to be detected according to the ideal tea leaves image and the ternary image comprises:

[0034] S1101: Obtain the number of first pixels of all pixels in the ideal tea leaf image, and the number of second pixels corresponding to the value with the largest value in the ternary image;

[0035] S1102: Compare the value obtained by subtracting the second number of pixels from the first number of pixels with the first number of pixels, and use the ratio as the disease degree of the tea leaves to be identified.

[0036] The present invention also provides a device for identifying the degree of disease of tea leaves, comprising:

[0037] A shooting module is used to shoot the tea leaves to be identified to obtain a photographed picture, extract a contour map of the tea leaves to be identified from the photographed picture, and smooth the contour map to obtain a contour map of the target tea leaves;

[0038] An acquisition module, used for acquiring the main vein of the target tea contour map, and extracting the zero-crossing point of the target tea contour map according to a preset method;

[0039] An extraction module, used for extracting the first arc to be completed in the target tea contour image according to the distance between the zero-crossing points;

[0040] A marking module, for recording the zero-crossing point that is first close to the main vein and then away from the main vein as the first zero-crossing point, and recording the remaining zero-crossing points as the second zero-crossing points according to the direction of the target tea contour map;

[0041] A connection module, used to connect the first zero-crossing points by curves through a preset tool to obtain an intermediate contour map, and find a second arc corresponding to the first arc in the intermediate contour map;

[0042] A mapping module for mapping a third arc based on the main vein in the intermediate contour map based on the second arc;

[0043] A mirror processing module, for performing mirror processing on the third arc based on the main vein to obtain a fourth arc, and reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc; wherein the constraint algorithm model is trained by mirror images of different tea incomplete arcs and corresponding mapping arcs;

[0044] A replacement module, used for replacing the second arc in the intermediate contour map with the fifth arc to obtain a target contour map, and obtaining a first average distance between the second zero-crossing points, and a second average distance from the second zero-crossing point to the intermediate contour map;

[0045] A completion module, configured to complete the contour on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map;

[0046] A ternary processing module is used to perform ternary processing on the image in the contour map to obtain a ternary image of the photographed image, and assign the value with the largest value in the ternary image to the ideal contour map to obtain an ideal tea leaf image;

[0047] A calculation module is used to calculate the disease degree of the tea leaves to be detected based on the ideal tea leaves image and the ternary image.

[0048] Furthermore, the image processing module includes:

[0049] A receiving submodule, configured to receive the fourth arc and the second arc through the preset constraint algorithm model;

[0050] The substitution submodule is used to substitute the fourth arc and the second arc into the formula in the constraint algorithm model:

[0051]

[0052] , the alternating direction multiplication sub-algorithm is used to solve the fifth arc; wherein D represents the downsampling operator, B represents the fuzzy operator, X represents the second arc, Y represents the fourth arc, M represents other preset constraints, Z represents the variable parameter, ρ represents the penalty parameter, P is a variable parameter that changes with the number of operation steps of the alternating direction multiplication sub-algorithm. γ1 and γ2 are both preset parameters. L(X,Y,U) is the objective function.

[0053] Furthermore, the shooting module includes:

[0054] A determination submodule, used to determine a contour point in the captured image as an initial contour point, and mark the coordinates of the initial contour point;

[0055] A search submodule is used to search eight neighboring pixels of the initial contour point according to an initial direction, determine the first neighboring pixel that is the same as the pixel of the initial contour point as the next contour point and mark the coordinates, and search the remaining contour points of the captured image in sequence according to the next contour point until the searched contour point is the initial contour point; wherein the initial direction is a clockwise direction or a counterclockwise direction;

[0056] A representation submodule, used to represent the marked contour points with coordinates, and obtain the contour perimeter of the contour image in the captured image according to each contour point marked by the coordinates;

[0057] The smoothing submodule is used to smooth the contour map. The formula for smoothing each contour point Γ(x(μ), y(μ)) is:

[0058]

[0059]

[0060] Wherein Γ(x(μ), y(μ)) is the contour point with an arc length of μ from the current coordinate point to the initial contour point, y(μ) and x(μ) respectively represent the ordinate and abscissa of the current coordinate point, X(μ, σ) and Y(μ, σ) respectively represent the abscissa and ordinate of the current coordinate point after smoothing, σ is a parameter related to the normalization process, x(v+μ) represents the abscissa with an arc length offset distance of v, μ represents the arc length, L is the contour circumference of the target tea contour map, and 0≤μ≤L, v is a distance variable.

[0061] Furthermore, the representation submodule includes:

[0062] An acquisition unit, used for acquiring all contour points in the captured image to form the contour map;

[0063] A setting unit, used for setting all pixel points inside the contour map to the same pixel value to obtain a temporary contour map;

[0064] A detection unit, used for detecting whether each target pixel value in the temporary contour image is the same as the pixel values ​​of adjacent target pixels;

[0065] A first accumulation unit, used for accumulating pixel values ​​of the pixel points having the same pixel values ​​as those of adjacent pixel points to obtain a first accumulated value;

[0066] A second accumulation unit is configured to accumulate the pixel values ​​of all the pixels in the temporary contour image to obtain the second accumulated value, and to subtract the first accumulated value from the second accumulated value to obtain the contour perimeter.

[0067] Furthermore, the calculation module includes:

[0068] A pixel number acquisition submodule is used to acquire a first pixel number of all pixels in the ideal tea leaf image and a second pixel number corresponding to a value with the largest value in the ternary image;

[0069] A ratio submodule is used to compare the value obtained by subtracting the second number of pixels from the first number of pixels with the first number of pixels, and use the ratio as the disease degree of the tea leaves to be identified.

[0070] The present invention also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.

[0071] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods are implemented.

[0072] The beneficial effects of the present invention are as follows: according to the contour map of the tea leaves to be identified, the first arc to be completed is found, and the first arc is completed using a symmetrical third arc, so as to obtain an ideal tea leaf map of the tea leaves to be identified, and then the obtained ideal tea leaf map is compared with the three-valued image of the tea leaves, so that the disease condition of the tea leaves to be identified can be identified, and the degree of the disease can be indexed, which is more conducive to the relevant personnel to analyze the disease condition. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] Figure 1 It is a schematic flow chart of a method for identifying the degree of disease of tea leaves according to an embodiment of the present invention;

[0074] Figure 2 It is a schematic block diagram of the structure of a device for identifying the disease degree of tea leaves according to an embodiment of the present invention;

[0075] Figure 3 A schematic block diagram of the structure of a computer device according to an embodiment of the present application.

[0076] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

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

[0078] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.

[0079] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone.

[0080] In addition, in the present invention, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0081] Reference Figure 1 The present invention provides a method for identifying the degree of disease of tea leaves, comprising:

[0082] S1: photographing the tea leaves to be identified to obtain a photographed picture, extracting a contour map of the tea leaves to be identified from the photographed picture, and smoothing the contour map to obtain a contour map of the target tea leaves;

[0083] S2: obtaining the main vein of the target tea contour image, and extracting the zero-crossing point of the target tea contour image according to a preset method;

[0084] S3: extracting the first arc to be completed in the target tea contour image according to the distance between the zero-crossing points;

[0085] S4: according to the direction of the target tea contour map, the zero-crossing point that is first close to the main vein and then away from the main vein is recorded as the first zero-crossing point, and the remaining zero-crossing points are recorded as the second zero-crossing points;

[0086] S5: Connecting the first zero-crossing points with a curve using a preset tool to obtain an intermediate contour map, and finding a second arc corresponding to the first arc in the intermediate contour map;

[0087] S6: mapping a third arc based on the main vein in the intermediate contour map based on the second arc;

[0088] S7: mirroring the third arc based on the main vein to obtain a fourth arc, and reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc; wherein the constraint algorithm model is trained by mirror images of different tea incomplete arcs and corresponding mapping arcs;

[0089] S8: replacing the second arc in the intermediate contour map with the fifth arc to obtain a target contour map, and obtaining a first average distance between the second zero-crossing points and a second average distance from the second zero-crossing point to the intermediate contour map;

[0090] S9: completing the contour on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map;

[0091] S10: performing ternary processing on the image in the contour image to obtain a ternary image of the captured image, and assigning a value with the largest value in the ternary image to the ideal contour image to obtain an ideal tea leaf image;

[0092] S11: Calculating the disease degree of the tea leaves to be tested according to the ideal tea leaves image and the ternary image.

[0093] As described in the above step S1, the tea leaves to be identified are photographed to obtain a photographed picture, the contour of the tea leaves to be identified is extracted from the photographed picture, and the contour is smoothed to obtain a contour of the target tea leaves, wherein the shooting method can be a picture taken directly with the camera of the mobile phone, or a picture taken with a specific high-definition camera. It should be noted that the background color of the shooting needs to be sufficiently different from the color of the tea leaves to be identified, otherwise it is easy to cause errors. The method of extracting the contour of the tea leaves to be identified and smoothing will be described in detail later and will not be repeated here. It should be noted that smoothing is only for eliminating some errors caused by shooting reasons or some pseudo-protrusions of the tea leaves to be identified themselves, so smoothing is required.

[0094] As described in step S2 above, the main vein of the target tea contour map is obtained, and the zero-crossing point of the target tea contour map is extracted in a preset manner, wherein the vein color of the tea leaves is different from the flesh color of the tea leaves, so the vein of the target tea contour map can be determined according to the pixels, the veins are generally continuous, and the main vein is the longest one, so the main vein can be determined. In some embodiments, the recognition model can also be used to identify the main vein of the target tea contour map. In addition, if the curvature of the adjacent points of a contour point just undergoes a transformation of positive and negative values, it means that this point is a turning point on the contour from concave to convex / from convex to concave. This point is mathematically called a zero-crossing point, so the zero-crossing point can be obtained according to each target contour map. It should be noted that the extracted zero-crossing points are mainly the protrusions and gullies on the edge of the tea leaves to be identified. For example, the edge of the tea leaves is generally jagged, and its zero-crossing point is the vertex of the jagged shape. Of course, in some embodiments, it may be a zero-crossing point formed by a disease, and all zero-crossing points are extracted here.

[0095] As described in the above step S3, the first arc to be completed in the target tea contour map is extracted according to the distance between the zero-crossing points, wherein the first arc may include multiple arcs. Since the distance between the zero-crossing points in tea leaves is generally within a certain range, when the distance between the zero-crossing points is greater than a set value, the set value can be set in advance, and the arc here can be considered to be the first arc. It should be noted that the first arc is a continuous arc, and its change rule is generally irregular. In some embodiments, the first arc can also be identified by some recognition models, that is, by using multiple tea leaves with few or no diseases as training samples, so that the corresponding recognition model can identify the first arc of tea leaves with diseases.

[0096] As described in the above steps S4-S5, according to the direction of the target tea contour map, the zero-crossing point that is first close to the main vein and then away from the main vein is recorded as the first zero-crossing point, and the remaining zero-crossing points are recorded as the second zero-crossing points. The first zero-crossing points are connected by a preset tool to obtain an intermediate contour map, and the second arc corresponding to the first arc is found in the intermediate contour map. Among them, the first zero-crossing point, that is, the bottom of the gully of the serrated tea leaves, is connected by a preset tool to obtain a curve, wherein the preset tool can be a tool such as PS. In some embodiments, the first zero-crossing point can also be connected manually, and it can also be connected through a corresponding model, that is, multiple zero-crossing points and corresponding connection patterns are obtained as training data, so as to realize the training of the model so that it can be connected by curves based on multiple first zero-crossing points. Here, the intermediate contour map obtained is a tea contour map without serrations, and then the second arc corresponding to the first arc is found. Since the shape of the second arc may have changed, the corresponding second arc can be obtained by finding the head and tail positions corresponding to the first arc, and then mapping the ordinate or abscissa.

[0097] As described in the above steps S6-S7, this step is mainly to reconstruct the second arc. Since the third arc is mapped based on the main vein of the second arc, the third arc and the second arc are symmetrical. Generally speaking, the growth degree of the mesophyll at the position of the third arc is similar to that of the mesophyll at the second arc. Therefore, using the third arc to complete the second arc is a better way. In addition, the third arc is mirrored because the third arc and the fifth arc to be completed are theoretically axially symmetrical. Therefore, the mirroring here is to better reconstruct the second arc. In addition, the specific constraint algorithm model can be a neural network model or other models, which can reconstruct the incomplete arc of the tea leaves through the corresponding mapping arc. A specific method is introduced in the subsequent embodiments, which will not be repeated here.

[0098] As described in the above steps S8-S9, the fifth arc is used to replace the second arc in the intermediate contour map to obtain the target contour map, and the first average distance between the second zero-crossing points and the second average distance from the second zero-crossing point to the intermediate contour map are obtained. The contour is completed on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map. Since the serrated mesophyll is removed by the aforementioned processing, the completion can be performed here according to the first average distance and the second average distance. The completion method can be to set the spacing distance of each tooth of the serrated mesophyll according to the first average distance, and then set the distance between each tooth and the intermediate contour map according to the second distance, so as to obtain the ideal contour map.

[0099] As described in the above steps S10-S11, the image in the contour map is processed by three-value processing to obtain the three-valued image of the photographed image, and the value with the most values ​​in the three-valued image is assigned to the ideal contour map to obtain an ideal tea image; the disease degree of the tea to be detected is calculated based on the ideal tea image and the three-valued image. The three-valued processing method is to use three values ​​to represent the pixel values ​​in the contour map. The difference between these three values ​​needs to be large enough. This is to distinguish the tea leaves from the background. Since there may be some wormholes in the middle of the tea leaves, the three-valued processing can effectively distinguish them. Since the range occupied by the leaf flesh in the tea image is generally the largest, it is assigned to the ideal contour map to obtain the ideal tea image, and then the disease degree of the tea to be detected can be obtained by comparing the ideal tea image and the three-valued image. The specific calculation method will be described in detail later and will not be repeated here. Thereby, the perfect restoration of the tea to be identified is achieved, and the obtained ideal tea image is compared with the three-valued image of the tea, so that the disease of the tea to be identified can be identified.

[0100] In one embodiment, the step S7 of reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain the fifth arc includes:

[0101] S701: receiving the fourth arc and the second arc through the preset constraint algorithm model;

[0102] S702: In the constraint algorithm model, the fourth arc and the second arc are substituted into the formula , the alternating direction multiplication sub-algorithm is used to solve the fifth arc; wherein D represents the downsampling operator, B represents the fuzzy operator, X represents the second arc, Y represents the fourth arc, M represents other preset constraints, Z represents the variable parameter, ρ represents the penalty parameter, P is a variable parameter that changes with the number of operation steps of the alternating direction multiplication sub-algorithm. γ1 and γ2 are both preset parameters. L(X, Z, U) is the objective function.

[0103] As described in steps S701-S702 above, the fourth arc and the second arc are received through the preset constraint algorithm model, and in the constraint algorithm model, the fourth arc and the second arc are substituted into the formula In the example, the alternating direction multiplication sub-algorithm is used to solve the fifth arc. It should be noted that the elements that need to be updated by the alternating direction multiplication sub-algorithm are X, Y and U, and each of them is updated in the following manner:

[0104] U k+1 =U k +X k+1 -Z k+1 , so that the final X, that is, the fifth arc, can be obtained. It should be noted that M represents other preset constraints, which can limit the positions of the starting point and the end point of the second arc to remain unchanged. In addition, the slopes of the starting point and the end point of the second arc can be integrated to make the completed fifth arc more realistic. L(X, Z, U) is the objective function, which can be a value range, that is, the values ​​that need to be calculated subsequently are within this range, so as to achieve continuous value selection of X, Z, and U.

[0105] In one embodiment, the step S1 of extracting the contour of the tea leaves to be identified from the captured image and smoothing the contour to obtain the contour of the target tea leaves comprises:

[0106] S101: Determine a contour point in the captured image as an initial contour point, and mark the coordinates of the initial contour point;

[0107] S102: searching eight neighboring pixels of the initial contour point according to the initial direction, determining the first neighboring pixel that is the same as the pixel of the initial contour point as the next contour point and marking the coordinates, and searching the remaining contour points of the captured image in sequence according to the next contour point until the searched contour point is the initial contour point; wherein the initial direction is a clockwise direction or a counterclockwise direction;

[0108] S103: representing the marked contour points with coordinates, and obtaining the contour perimeter of the contour image in the captured image according to each contour point marked with the coordinates;

[0109] S104: Smoothing the contour graph. The formula for smoothing each contour point Γ(x(μ), y(μ)) is:

[0110]

[0111]

[0112] Wherein Γ(x(μ), y(μ)) is the contour point with an arc length of μ from the current coordinate point to the initial contour point, y(μ) and x(μ) respectively represent the ordinate and abscissa of the current coordinate point, X(μ, σ) and Y(μ, σ) respectively represent the abscissa and ordinate of the current coordinate point after smoothing, σ is a parameter related to the normalization process, x(ν+μ) represents the abscissa with an arc length offset distance of v, μ represents the arc length, L is the contour circumference of the target tea contour map, and 0≤μ≤L, v is a distance variable.

[0113] As described in the above steps S101-S104, the contour map is acquired and smoothed. That is, due to the shooting of the picture, there may be some pseudo-protrusions, so smoothing is required to make the smoothed noise undistorted. First, each contour point is written in the parameter form Γ(x(μ), y(μ)), and then the horizontal and vertical coordinates are convolved respectively. The smoothing formula is:

[0114]

[0115]

[0116] Eliminate these false protrusions to reduce errors. It should be noted that after smoothing, some points may move, making the closed contour curve not closed, so it is necessary to obtain the closed curve again through the eight-neighborhood detection method.

[0117] In one embodiment, the step S103 of obtaining the contour perimeter of the contour image in the captured image according to each contour point marked with coordinates includes:

[0118] S1031: Acquire all contour points in the captured image to form the contour map;

[0119] S1032: setting all pixel points inside the contour map to the same pixel value to obtain a temporary contour map;

[0120] S1033: Detect whether each target pixel value in the temporary contour image is the same as the pixel values ​​of adjacent target pixels;

[0121] S1034: Accumulating the pixel values ​​of the pixel points that have the same pixel values ​​as the adjacent pixel points to obtain a first accumulated value;

[0122] S1035: Accumulate the pixel values ​​of all the pixels in the temporary contour image to obtain the second accumulated value, and subtract the first accumulated value from the second accumulated value to obtain the contour perimeter.

[0123] As described in the above steps S1031-S1035, the acquisition of the contour circumference is realized, all contour points in the captured image are acquired to form the contour map, all pixel points inside the contour map are set to the same pixel value, and a temporary contour map is obtained. Since the points are not on the edge of the contour, the pixel values ​​of the adjacent pixel points are the same, so the pixel values ​​corresponding to the pixel points with the same adjacent pixel values ​​can be accumulated to obtain a first accumulated value, and then the first accumulated value is subtracted from the captured image of the target image to obtain the circumference of the contour.

[0124] In one embodiment, the step S11 of calculating the disease degree of the tea leaves to be detected according to the ideal tea leaves image and the ternary image comprises:

[0125] S1101: Obtain the number of first pixels of all pixels in the ideal tea leaf image, and the number of second pixels corresponding to the value with the largest value in the ternary image;

[0126] S1102: Compare the value obtained by subtracting the second number of pixels from the first number of pixels with the first number of pixels, and use the ratio as the disease degree of the tea leaves to be identified.

[0127] As described in the above steps S1101-S1102, obtain the first number of pixels of all pixels in the ideal tea image, and the second number of pixels corresponding to the value with the largest value in the ternary image; compare the value of the first number of pixels minus the second number of pixels with the first number of pixels, and use the ratio as the degree of disease of the tea to be identified. Since this ratio can reflect the degree of disease of the tea to be identified, the larger the ratio, the greater the degree of disease, thereby digitizing and concretizing the degree of disease, and realizing the indexing of the degree of disease. In some embodiments, it can also be based on other comparison methods, which are not limited in this application, but after obtaining the ideal tea image and the ternary image, the analysis methods that can be performed are all within the scope of protection of this application.

[0128] The present invention also provides a device for identifying the degree of disease of tea leaves, comprising:

[0129] The shooting module 10 is used to shoot the tea leaves to be identified to obtain a photographed picture, extract the contour of the tea leaves to be identified from the photographed picture, and smooth the contour to obtain a contour of the target tea leaves;

[0130] An acquisition module 20 is used to acquire the main vein of the target tea contour map and extract the zero-crossing point of the target tea contour map according to a preset method;

[0131] An extraction module 30, configured to extract the first arc to be completed in the target tea contour image according to the distance between the zero-crossing points;

[0132] A marking module 40 is used to mark the zero-crossing point that is first close to the main vein and then away from the main vein as the first zero-crossing point, and mark the remaining zero-crossing points as the second zero-crossing points according to the direction of the target tea contour map;

[0133] A connection module 50, configured to connect the first zero-crossing points by curves through a preset tool to obtain an intermediate contour diagram, and to find a second arc corresponding to the first arc in the intermediate contour diagram;

[0134] A mapping module 60 for mapping a third arc based on the main vein in the intermediate contour map based on the second arc;

[0135] A mirror processing module 70 is used to perform mirror processing on the third arc based on the main vein to obtain a fourth arc, and to reconstruct the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc; wherein the constraint algorithm model is trained by mirror images of different tea incomplete arcs and corresponding mapping arcs;

[0136] A replacement module 80 is used to replace the second arc in the intermediate contour map with the fifth arc to obtain a target contour map, and obtain a first average distance between the second zero-crossing points and a second average distance from the second zero-crossing point to the intermediate contour map;

[0137] A completion module 90, configured to complete the contour on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map;

[0138] The ternary processing module 100 is used to perform ternary processing on the image in the contour image to obtain a ternary image of the photographed image, and assign the value with the largest value in the ternary image to the ideal contour image to obtain an ideal tea leaf image;

[0139] The calculation module 110 is used to calculate the disease degree of the tea leaves to be detected according to the ideal tea leaves image and the ternary image.

[0140] In one embodiment, the image processing module 70 includes:

[0141] A receiving submodule, configured to receive the fourth arc and the second arc through the preset constraint algorithm model;

[0142] The substitution submodule is used to substitute the fourth arc and the second arc into the formula in the constraint algorithm model: , the alternating direction multiplication sub-algorithm is used to solve the fifth arc; wherein D represents the downsampling operator, B represents the fuzzy operator, X represents the second arc, Y represents the fourth arc, M represents other preset constraints, Z represents the variable parameter, ρ represents the penalty parameter, P is a variable parameter that changes with the number of operation steps of the alternating direction multiplication sub-algorithm. γ1 and γ2 are both preset parameters. L(X,Y,U) is the objective function.

[0143] In one embodiment, the photographing module 10 includes:

[0144] A determination submodule, used to determine a contour point in the captured image as an initial contour point, and mark the coordinates of the initial contour point;

[0145] A search submodule is used to search eight neighboring pixels of the initial contour point according to an initial direction, determine the first neighboring pixel that is the same as the pixel of the initial contour point as the next contour point and mark the coordinates, and search the remaining contour points of the captured image in sequence according to the next contour point until the searched contour point is the initial contour point; wherein the initial direction is a clockwise direction or a counterclockwise direction;

[0146] A representation submodule, used to represent the marked contour points with coordinates, and obtain the contour perimeter of the contour image in the captured image according to each contour point marked by the coordinates;

[0147] The smoothing submodule is used to smooth the contour map. The formula for smoothing each contour point Γ(x(μ), y(μ)) is:

[0148]

[0149]

[0150] Wherein Γ(x(μ), y(μ)) is the contour point with an arc length of μ from the current coordinate point to the initial contour point, y(μ) and x(μ) respectively represent the ordinate and abscissa of the current coordinate point, X(μ, σ) and Y(μ, σ) respectively represent the abscissa and ordinate of the current coordinate point after smoothing, σ is a parameter related to the normalization process, x(v+μ) represents the abscissa with an arc length offset distance of v, μ represents the arc length, L is the contour circumference of the target tea contour map, and 0≤μ≤L, v is a distance variable.

[0151] In one embodiment, the representation submodule includes:

[0152] An acquisition unit, used for acquiring all contour points in the captured image to form the contour map;

[0153] A setting unit, used for setting all pixel points inside the contour map to the same pixel value to obtain a temporary contour map;

[0154] A detection unit, used for detecting whether each target pixel value in the temporary contour image is the same as the pixel values ​​of adjacent target pixels;

[0155] A first accumulation unit, used for accumulating pixel values ​​of the pixel points having the same pixel values ​​as those of adjacent pixel points to obtain a first accumulated value;

[0156] A second accumulation unit is configured to accumulate the pixel values ​​of all the pixels in the temporary contour image to obtain the second accumulated value, and to subtract the first accumulated value from the second accumulated value to obtain the contour perimeter.

[0157] In one embodiment, the calculation module 110 includes:

[0158] A pixel number acquisition submodule is used to acquire a first pixel number of all pixels in the ideal tea leaf image and a second pixel number corresponding to a value with the largest value in the ternary image;

[0159] A ratio submodule is used to compare the value obtained by subtracting the second number of pixels from the first number of pixels with the first number of pixels, and use the ratio as the disease degree of the tea leaves to be identified.

[0160] The beneficial effects of the present invention are as follows: according to the contour map of the tea leaves to be identified, the first arc to be completed is found, and the first arc is completed using a symmetrical third arc, so as to obtain an ideal tea leaf map of the tea leaves to be identified, and then the obtained ideal tea leaf map is compared with the three-valued image of the tea leaves, so that the disease condition of the tea leaves to be identified can be identified, and the degree of the disease can be indexed, which is more conducive to the relevant personnel to analyze the disease condition.

[0161] Reference Figure 3 In an embodiment of the present application, a computer device is also provided. The computer device may be a server, and its internal structure may be as follows: Figure 3As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store various tea outlines, etc. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the method for identifying the degree of disease of tea leaves described in any of the above embodiments can be implemented.

[0162] Those skilled in the art will understand that Figure 3 The structure shown in is merely a block diagram of a portion of the structure related to the present application solution and does not constitute a limitation on the computer device to which the present application solution is applied.

[0163] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for identifying the disease degree of tea leaves described in any of the above embodiments can be implemented.

[0164] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0165] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.

[0166] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, and can perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0167] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0168] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of the claims of the present invention.

Claims

1. A method for identifying the degree of disease of tea leaves, characterized in that: include: S1: photographing the tea leaves to be identified to obtain a photographed picture, extracting a contour map of the tea leaves to be identified from the photographed picture, and smoothing the contour map to obtain a contour map of the target tea leaves; S2: obtaining the main vein of the target tea contour image, and extracting the zero-crossing point of the target tea contour image according to a preset method; S3: extracting the first arc to be completed in the target tea contour image according to the distance between the zero-crossing points; S4: according to the direction of the target tea contour map, the zero-crossing point that is first close to the main vein and then away from the main vein is recorded as the first zero-crossing point, and the remaining zero-crossing points are recorded as the second zero-crossing points; S5: Connecting the first zero-crossing points with a curve using a preset tool to obtain an intermediate contour map, and finding a second arc corresponding to the first arc in the intermediate contour map; S6: Acquire a third arc mapped by the second arc in the intermediate contour map based on the main vein; S7: mirroring the third arc based on the main vein to obtain a fourth arc, and reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc; wherein the constraint algorithm model is trained by mirror images of different tea incomplete arcs and corresponding mapping arcs; S8: replacing the second arc in the intermediate contour map with the fifth arc to obtain a target contour map, and obtaining a first average distance between the second zero-crossing points and a second average distance from the second zero-crossing point to the intermediate contour map; S9: completing the contour on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map; S10: performing ternary processing on the image in the contour image to obtain a ternary image of the captured image, and assigning a value with the largest value in the ternary image to the ideal contour image to obtain an ideal tea leaf image; S11: Calculating the disease degree of the tea leaves to be identified based on the ideal tea leaves image and the ternary image.

2. The method for identifying the degree of disease of tea leaves according to claim 1, characterized in that: The step S7 of using a preset constraint algorithm model to reconstruct the second arc through the fourth arc to obtain the fifth arc includes: S701, receiving the fourth arc and the second arc through the preset constraint algorithm model; S702: In the constraint algorithm model, substitute the fourth arc and the second arc into the formula , the alternating direction multiplication sub-algorithm is used to solve the fifth arc; wherein D represents the downsampling operator, B represents the fuzzy operator, X represents the second arc, Y represents the fourth arc, M represents other preset constraints, Z represents the variable parameter, ρ represents the penalty parameter, P is a variable parameter that changes with the number of operation steps of the alternating direction multiplication sub-algorithm. γ1 and γ2 are both preset parameters. L(X,Y,U) is the objective function.

3. The method for identifying the degree of disease of tea leaves according to claim 2, characterized in that: The step S1 of extracting the contour of the tea leaves to be identified from the photographed image and smoothing the contour to obtain the contour of the target tea leaves comprises: S101: Determine a contour point in the captured image as an initial contour point, and mark the coordinates of the initial contour point; S102: searching eight neighboring pixels of the initial contour point according to the initial direction, determining the first neighboring pixel that is the same as the pixel of the initial contour point as the next contour point and marking the coordinates, and searching the remaining contour points of the captured image in sequence according to the next contour point until the searched contour point is the initial contour point; wherein the initial direction is a clockwise direction or a counterclockwise direction; S103: representing the marked contour points with coordinates, and obtaining the contour perimeter of the contour image in the captured image according to each contour point marked with the coordinates; S104: Smoothing the contour graph. The formula for smoothing each contour point Γ(x(μ), y(μ)) is: Wherein Γ(x(μ), y(μ)) is the contour point with an arc length of μ from the current coordinate point to the initial contour point, y(μ) and x(μ) represent the ordinate and abscissa of the current coordinate point, respectively, X(μ, σ) and Y(μ, σ) represent the abscissa and ordinate of the current coordinate point after smoothing, respectively, σ is a parameter related to the normalization process, x(v+μ) represents the abscissa with an arc length offset distance of v, μ represents the arc length, L is the contour circumference of the target tea contour map, and 0≤μ≤L, v is a distance variable.

4. The method for identifying the degree of disease of tea leaves according to claim 3, characterized in that: The step S103 of obtaining the contour perimeter of the contour image in the captured image according to each contour point marked with coordinates comprises: S1031: Acquire all contour points in the captured image to form the contour map; S1032: setting all pixel points inside the contour map to the same pixel value to obtain a temporary contour map; S1033: Detect whether each target pixel value in the temporary contour image is the same as the pixel values ​​of adjacent target pixels; S1034: Accumulating the pixel values ​​of the pixel points that have the same pixel values ​​as the adjacent pixel points to obtain a first accumulated value; S1035: Accumulate the pixel values ​​of all the pixels in the temporary contour image to obtain a second accumulated value, and subtract the first accumulated value from the second accumulated value to obtain the contour perimeter.

5. The method for identifying the degree of disease of tea leaves according to claim 1, characterized in that: The step S11 of calculating the disease degree of the tea leaves to be identified according to the ideal tea leaves image and the ternary image comprises: S1101: Obtain the number of first pixels of all pixels in the ideal tea leaf image, and the number of second pixels corresponding to the value with the largest value in the ternary image; S1102: Compare the value obtained by subtracting the second number of pixels from the first number of pixels with the first number of pixels, and use the ratio as the disease degree of the tea leaves to be identified.

6. A device for identifying the degree of disease of tea leaves, characterized in that: include: A shooting module is used to shoot the tea leaves to be identified to obtain a photographed picture, extract a contour map of the tea leaves to be identified from the photographed picture, and smooth the contour map to obtain a contour map of the target tea leaves; An acquisition module, used for acquiring the main vein of the target tea contour map, and extracting the zero-crossing point of the target tea contour map according to a preset method; An extraction module, used for extracting the first arc to be completed in the target tea contour map according to the distance between the zero-crossing points; A marking module, for recording the zero-crossing point that is first close to the main vein and then away from the main vein as the first zero-crossing point, and recording the remaining zero-crossing points as the second zero-crossing points according to the direction of the target tea contour map; A connection module, used to connect the first zero-crossing points by curves through a preset tool to obtain an intermediate contour map, and find a second arc corresponding to the first arc in the intermediate contour map; A mapping module, configured to obtain a third arc mapped based on the main vein in the intermediate contour map by the second arc; A mirror processing module, for performing mirror processing on the third arc based on the main vein to obtain a fourth arc, and reconstructing the second arc through the fourth arc using a preset constraint algorithm model to obtain a fifth arc; wherein the constraint algorithm model is trained by mirror images of different tea incomplete arcs and corresponding mapping arcs; A replacement module, used for replacing the second arc in the intermediate contour map with the fifth arc to obtain a target contour map, and obtaining a first average distance between the second zero-crossing points, and a second average distance from the second zero-crossing point to the intermediate contour map; A completion module, configured to complete the contour on the target contour map according to the first average distance and the second average distance to obtain an ideal contour map; A ternary processing module is used to perform ternary processing on the image in the contour map to obtain a ternary image of the photographed image, and assign the value with the largest value in the ternary image to the ideal contour map to obtain an ideal tea leaf image; A calculation module is used to calculate the disease degree of the tea leaves to be identified based on the ideal tea leaves image and the ternary image.

7. The tea disease degree identification device according to claim 6, characterized in that: The image processing module comprises: A receiving submodule, configured to receive the fourth arc and the second arc through the preset constraint algorithm model; The substitution submodule is used to substitute the fourth arc and the second arc into the formula in the constraint algorithm model: , the alternating direction multiplication sub-algorithm is used to solve the fifth arc; wherein D represents the downsampling operator, B represents the fuzzy operator, X represents the second arc, Y represents the fourth arc, M represents other preset constraints, Z represents the variable parameter, ρ represents the penalty parameter, P is a variable parameter that changes with the number of operation steps of the alternating direction multiplication sub-algorithm. γ1 and γ2 are both preset parameters. L(X,Y,U) is the objective function.

8. The tea disease degree identification device according to claim 7, characterized in that: The shooting module comprises: A determination submodule, used to determine a contour point in the captured image as an initial contour point, and mark the coordinates of the initial contour point; A search submodule is used to search eight neighboring pixels of the initial contour point according to an initial direction, determine the first neighboring pixel that is the same as the pixel of the initial contour point as the next contour point and mark the coordinates, and search the remaining contour points of the captured image in sequence according to the next contour point until the searched contour point is the initial contour point; wherein the initial direction is a clockwise direction or a counterclockwise direction; A representation submodule, used to represent the marked contour points with coordinates, and obtain the contour perimeter of the contour image in the captured image according to each contour point marked by the coordinates; The smoothing submodule is used to smooth the contour map. The formula for smoothing each contour point Γ(x(μ), y(μ)) is: Wherein Γ(x(μ), y(μ)) is the contour point with an arc length of μ from the current coordinate point to the initial contour point, y(μ) and x(μ) represent the ordinate and abscissa of the current coordinate point, respectively, X(μ, σ) and Y(μ, σ) represent the abscissa and ordinate of the current coordinate point after smoothing, respectively, σ is a parameter related to the normalization process, x(v+μ) represents the abscissa with an arc length offset distance of v, μ represents the arc length, L is the contour circumference of the target tea contour map, and 0≤μ≤L, v is a distance variable.

9. The tea disease degree identification device according to claim 8, characterized in that: The representation submodule comprises: An acquisition unit, used for acquiring all contour points in the captured image to form the contour map; A setting unit, used for setting all pixel points inside the contour map to the same pixel value to obtain a temporary contour map; A detection unit, used for detecting whether each target pixel value in the temporary contour image is the same as the pixel values ​​of adjacent target pixels; A first accumulation unit, used for accumulating pixel values ​​of the pixel points having the same pixel values ​​as those of adjacent pixel points to obtain a first accumulated value; The second accumulation unit is used to accumulate the pixel values ​​of all the pixel points in the temporary contour image to obtain a second accumulated value, and subtract the first accumulated value from the second accumulated value to obtain the contour perimeter.

10. The tea disease degree identification device according to claim 6, characterized in that: The computing module comprises: A pixel number acquisition submodule is used to acquire a first pixel number of all pixels in the ideal tea leaf image and a second pixel number corresponding to a value with the largest value in the ternary image; A ratio submodule is used to compare the value obtained by subtracting the second number of pixels from the first number of pixels with the first number of pixels, and use the ratio as the disease degree of the tea leaves to be identified.

Citation Information

Patent Citations

  • Tea disease identification method, device, equipment and storage medium

    CN110378305A

  • Insect pest recognition model training method, insect pest monitoring method and electronic equipment

    CN114511801A