CN114565525A - Method for distinguishing tree species based on leaf picture - Google Patents
Method for distinguishing tree species based on leaf picture Download PDFInfo
- Publication number
- CN114565525A CN114565525A CN202210158900.3A CN202210158900A CN114565525A CN 114565525 A CN114565525 A CN 114565525A CN 202210158900 A CN202210158900 A CN 202210158900A CN 114565525 A CN114565525 A CN 114565525A
- Authority
- CN
- China
- Prior art keywords
- formula
- tree species
- feature vectors
- denoising
- leaf
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 60
- 239000013598 vector Substances 0.000 claims abstract description 33
- 238000012549 training Methods 0.000 claims abstract description 27
- 238000012360 testing method Methods 0.000 claims abstract description 17
- 238000013528 artificial neural network Methods 0.000 claims abstract description 16
- 238000004364 calculation method Methods 0.000 claims abstract description 13
- 238000007781 pre-processing Methods 0.000 claims abstract description 11
- 241000894007 species Species 0.000 claims description 30
- 210000002569 neuron Anatomy 0.000 claims description 20
- 238000001914 filtration Methods 0.000 claims description 14
- 238000003708 edge detection Methods 0.000 claims description 8
- 230000004913 activation Effects 0.000 claims description 7
- 238000010606 normalization Methods 0.000 claims description 7
- 230000002902 bimodal effect Effects 0.000 claims description 5
- 238000005260 corrosion Methods 0.000 claims description 4
- 230000007797 corrosion Effects 0.000 claims description 4
- 238000012545 processing Methods 0.000 claims description 4
- 241000208140 Acer Species 0.000 claims description 3
- 244000274847 Betula papyrifera Species 0.000 claims description 3
- 235000009113 Betula papyrifera Nutrition 0.000 claims description 3
- 235000009109 Betula pendula Nutrition 0.000 claims description 3
- 235000010928 Betula populifolia Nutrition 0.000 claims description 3
- 235000002992 Betula pubescens Nutrition 0.000 claims description 3
- 235000011201 Ginkgo Nutrition 0.000 claims description 3
- 235000008100 Ginkgo biloba Nutrition 0.000 claims description 3
- 244000194101 Ginkgo biloba Species 0.000 claims description 3
- 235000014360 Punica granatum Nutrition 0.000 claims description 3
- 241000124033 Salix Species 0.000 claims description 3
- 230000003044 adaptive effect Effects 0.000 claims description 3
- 244000294611 Punica granatum Species 0.000 claims 1
- 230000010354 integration Effects 0.000 claims 1
- 238000004422 calculation algorithm Methods 0.000 abstract description 9
- 238000000605 extraction Methods 0.000 abstract description 6
- 238000003909 pattern recognition Methods 0.000 abstract description 6
- 230000006870 function Effects 0.000 description 13
- 238000010586 diagram Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 238000004458 analytical method Methods 0.000 description 3
- 210000003462 vein Anatomy 0.000 description 3
- 241000219991 Lythraceae Species 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 241000196324 Embryophyta Species 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 150000001875 compounds Chemical class 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003628 erosive effect Effects 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008961 swelling Effects 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/22—Matching criteria, e.g. proximity measures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/084—Backpropagation, e.g. using gradient descent
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/20—Image enhancement or restoration using local operators
- G06T5/30—Erosion or dilatation, e.g. thinning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/60—Analysis of geometric attributes
- G06T7/62—Analysis of geometric attributes of area, perimeter, diameter or volume
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Life Sciences & Earth Sciences (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Biomedical Technology (AREA)
- Health & Medical Sciences (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Geometry (AREA)
- Image Analysis (AREA)
Abstract
The invention relates to the field of pattern recognition, in particular to a method for distinguishing tree species based on leaf pictures. The method solves the problems of complex algorithm, large calculation amount and low identification accuracy. The method comprises the following steps: collecting a leaf picture, and dividing a training set and a testing set; preprocessing a picture; extracting the characteristics of the leaves of the training set; integrating the extracted shape features to be used as feature vectors, normalizing the feature vectors, and inputting the normalized feature vectors into a BP neural network for training to obtain a tree species identification model; and extracting the characteristics of the leaves of the test set, inputting the characteristics into the tree species identification model, and outputting an identification result. According to the invention, the picture is preprocessed, so that the subsequent extraction and identification of leaf characteristics are facilitated; the extracted feature vectors are normalized, the statistical distribution of unified samples is summarized, and the convergence rate of the model is improved; the BP neural network is used for training to obtain the tree species distinguishing model, the robustness of the algorithm is enhanced, and the method can be applied to more scenes.
Description
Technical Field
The invention relates to the field of pattern recognition, in particular to a method for distinguishing tree species based on leaf pictures.
Background
The pattern recognition is born in 20 actual 20 s, and with the appearance of computers in 40 s and the rise of artificial intelligence in 50 s, the pattern recognition rapidly develops into a subject in the early 60 s. The pattern recognition is a process of performing various analysis and judgment according to the alignment of input original data so as to obtain the category attribute and the characteristic judgment of the input original data. The purpose and function of pattern recognition is to correctly classify a particular object into a class.
With the continuous development and progress of scientific technology, the mode recognition is more and more widely applied, and the mode recognition can more accurately and rapidly classify things, so that a great amount of time, manpower and material resources of people are saved.
The proponents propose a vein extraction method of a neural network, accurately extract vein images through the trained neural network, and realize the extraction of the veins; the Zhunning scholars use a local binary mode method to put forward that the method is applied to the extraction of the texture features of the plant leaf images, various operators for extracting the leaf sample features are realized, and the leaf identification based on the local binary mode is realized.
However, the following problems exist in the identification and classification based on the leaf image:
1. the algorithm is complex, the calculation amount is large, and the realization is difficult;
2. the recognition result is interfered by factors such as environment, background and the like, and the recognition accuracy is not high.
Disclosure of Invention
The invention aims to provide a method for distinguishing tree species based on a leaf image, which is used for solving the problems of complex algorithm, large calculation amount and low identification accuracy and improving the robustness of the algorithm.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method for distinguishing tree species based on leaf pictures is characterized by comprising the following steps:
step 1, collecting leaf pictures, and dividing a training set and a testing set;
step 2, preprocessing the picture;
step 3, extracting the characteristics of the leaves of the training set;
step 4, integrating the extracted shape features to be used as feature vectors, normalizing the feature vectors, and inputting the normalized feature vectors into a BP neural network for training to obtain a tree species discrimination model;
and 5, extracting the characteristics of the leaves of the test set, inputting the characteristics into the tree species identification model, and outputting an identification result.
Preferably, in step 1, pictures of different tree species are collected, and the tree species include: the number of each tree leaf of ginkgo, maple, willow, pomegranate and white birch is not less than 100, the size of the picture is 300 pixels by 300 pixels, the collected picture is used as a data set, the data set is divided into a training set and a testing set, and the ratio of the training set to the testing set is 8: 2.
Preferably, in the step 2, the picture preprocessing includes: denoising, graying, binaryzation, edge detection, corrosion, expansion and filling;
the denoising method is characterized in that one of Butterworth low-pass filter denoising, FIR low-pass filter denoising, moving average filtering denoising, median filtering denoising, wiener filtering denoising, adaptive filtering denoising and wavelet denoising is selected as a denoising mode;
the graying adopts a maximum value method to graye the picture, and the formula is as follows:
Gray(x,y)=max{R(x,y),G(x,y),B(x,y)} (1)
in formula (1), R (x, y), G (x, y), B (x, y) represent RGB three components, respectively;
the formula of the binarization processing is as follows:
in the formula (2), T is a binarization threshold, and one of a bimodal method, a P parameter method, a maximum class variance method, a maximum entropy threshold method and an optimal threshold method is determined and selected as the threshold in binarization;
the edge detection adopts a Prewitt operator, and the operator can detect edges and can also inhibit the influence of noise;
preferably, in step 3, the extracted features include: circularity, rectangularity, aspect ratio of the minimum circumscribed rectangle, invariant moment, fourier descriptor;
wherein the degree of circularity represents the degree of similarity of the object edge and circle, and the computational formula is as follows:
in the formula (3), S represents the area of the object, L represents the perimeter of the object, and e represents the circularity;
wherein the rectangle degree represents the similarity degree of the object and the rectangle, and the calculation formula is as follows:
in the formula (4), S represents the area of the object, SRRepresenting the area of the smallest circumscribed rectangle of the object, R representing the squareness;
wherein the aspect ratio of the minimum circumscribed rectangle is the ratio of the long axis to the short axis of the minimum circumscribed rectangle, and the calculation formula is as follows:
in the formula (5), a represents the long axis of the minimum circumscribed rectangle, b represents the short axis of the minimum circumscribed rectangle, and epsilon represents the aspect ratio of the minimum circumscribed rectangle;
the invariant moment mainly represents the geometric characteristics of an image region, and 7 moment groups which are not changed along with horizontal, rotation and geometric scaling and proposed by Hu.M.K are adopted and defined as follows:
M1=μ20+μ02 (6)
M2=(μ20-μ02)2+4μ11 2 (7)
M3=(μ30-3μ12)2+(3μ21-μ03)2 (8)
M4=(μ30+μ12)2+(μ21+μ03)2 (9)
M5=(μ30-3μ12)(μ30+μ12)[(μ30+μ12)2-3(μ21+μ03)2]+(3μ21-μ03)(μ21+μ03)[3(μ30+μ12)2-(μ21+μ03)2] (10)
M6=(μ20-μ02)[(μ30+μ12)2-(μ21+μ03)2]+4μ11(μ30+μ12)(μ21+μ03) (11)
M7=(3μ21-μ03)(μ30+μ12)[(μ30+μ12)2-3(μ21+μ03)2]-(μ30-3μ12)(μ21+μ03)[3(μ30+μ12)2-(μ21+μ03)2] (12)
in formulae (6) to (12), μpqRepresents normalized (p + q) -order central moment, p, q ═ 0, 1, 2, 3;
the Fourier descriptor is a Fourier transform coefficient for describing the shape boundary of an object, and the calculation formula is as follows:
assuming a closed boundary composed of N points, starting from any point P, one circle around the boundary is obtained:
s(k)=x(k)+jy(k),k=0,1,...,N-1 (13)
in formula (13), x (k) and y (k) are coordinates of the moving point P, and j is a coefficient;
the Discrete Fourier Transform (DFT) of s (k) is:
in formula (14), u is 0, 1., N-1, a (u) is a fourier descriptor of the boundary
The normalized fourier descriptor d' (k) is:
in the present invention, the first 10 coefficients are taken as fourier descriptor features.
Preferably, in the step 4, the extracted shape features are integrated to be used as feature vectors, 20 feature parameters including circularity, rectangularity, aspect ratio of the minimum circumscribed rectangle, 7 invariant moments and 10 fourier descriptors are extracted, and are integrated to obtain a 20-dimensional feature vector, the feature vectors are normalized, and then the normalized feature vectors are input to a BP neural network for training to obtain a plane geometric shape recognition model;
the normalization adopts linear normalization, and the formula is as follows:
in the formula (16), x is the original data, xminRepresenting the minimum, x, of the original data setmaxA maximum value representing the original data set;
the BP neural network comprises 20 neurons in an input layer, 64 neurons in a hidden layer, 5 neurons in an output layer and 5 trees in an output layer, wherein the values of the output layer are in a range of [ -1,1], the activation function of the output layer is a softmax function, and the activation function of the hidden layer is a Sigmoid function.
Preferably, in the step 5, the features of the leaves of the test set are extracted and integrated to obtain a 20-dimensional feature vector, the feature vector is normalized and then input into the tree species identification model to output the identification result, and the accuracy of the tree species identification model is verified to be 96.8%.
The invention has the beneficial effects that:
1. according to the invention, a large amount of leaf images are collected, and preprocessing such as denoising, graying, binarization and the like is carried out on the images, so that the subsequent extraction and identification of leaf characteristics are facilitated.
2. By carrying out normalization processing on the extracted feature vectors, the statistical distribution of unified samples is summarized, and the convergence rate of the model is improved.
3. The BP neural network is used for training to obtain the tree species distinguishing model, the robustness of the algorithm is enhanced, the identification accuracy is improved, and the method can be applied to more scenes.
Drawings
FIG. 1 is a diagram of mean filtering according to the present invention.
Fig. 2 is a comparison between the original image and the gray scale image according to the present invention.
FIG. 3 is a diagram illustrating binarization according to the present invention.
FIG. 4 is a schematic of a bimodal process of the present invention.
FIG. 5 is a schematic diagram of edge detection according to the present invention.
FIG. 6 is a schematic view of the swelling, erosion, and filling of the present invention.
FIG. 7 is a diagram of a post-preprocessing partial data set according to the present invention.
FIG. 8 is a schematic diagram of a minimum circumscribed rectangle of the present invention.
FIG. 9 is a schematic diagram of the first 10 Fourier descriptors of the present invention.
FIG. 10 is a flowchart of the BP neural network training process according to the present invention.
FIG. 11 is a flowchart illustrating a method for identifying tree species based on leaf images according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
As shown in fig. 11, a method for distinguishing tree species based on leaf images includes the following steps:
step 1, collecting leaf pictures, and dividing a training set and a testing set;
collecting pictures of different tree species, wherein the tree species comprise: the number of each leaf of ginkgo, maple, willow, pomegranate and white birch is 100, the total number is 500, the size of the picture is 300 pixels by 300 pixels, the collected picture is used as a data set, the data set is divided into a training set and a testing set, and the ratio of the training set to the testing set is 8: 2.
Step 2, preprocessing the picture;
preprocessing the acquired picture, wherein the preprocessing comprises the following steps: denoising, graying, binarization, edge detection, corrosion, expansion and filling;
the denoising method includes butterworth low-pass filter denoising, FIR low-pass filter denoising, moving average filtering denoising, median filtering denoising, wiener filtering denoising, adaptive filtering denoising, wavelet denoising and the like, and the median filtering denoising is adopted in the invention, and the process is shown in FIG. 1.
The graying mode includes a component method, a maximum value method, an average value method and a weighted average method, the invention adopts the maximum value method to graye the picture, as shown in fig. 2, the formula is as follows:
Gray(x,y)=max{R(x,y),G(x,y),B(x,y)} (1)
in formula (1), R (x, y), G (x, y), B (x, y) represent RGB three components, respectively;
the binarization processing is shown in fig. 3, and the formula is as follows:
in the formula (2), T is a binarization threshold value;
the common methods for selecting the threshold value in the binarization include: a bimodal method, a P parameter method, a maximum class variance method, a maximum entropy threshold method, an optimal threshold method and the like are adopted, the bimodal method is adopted, as shown in figure 4, and the value T is 200;
the algorithm for edge detection is as follows: reberts operators, Prewitt operators, Sobel operators, Laplacian operators, Canny operators, and the like.
The invention adopts Sobel operator to carry out edge detection on the binary image to obtain a contour map, as shown in figure 5, and then carries out expansion and corrosion operation and image filling on the image, as shown in figure 6.
The acquired picture is preprocessed, and the finally obtained picture is shown in fig. 7.
Step 3, extracting the characteristics of the leaves of the training set;
the extracted features include: the circularity, the squareness, the aspect ratio of the minimum circumscribed rectangle, the invariant moment and the Fourier descriptor have the following specific parameters:
feature numbering | Feature name | Description of the invention |
1 | Degree of circularity | Indicating how similar the edge of the object is to the circle |
2 | Degree of rectangularity | Representing the degree of similarity of an object to a rectangle |
3 | Aspect ratio of minimum bounding rectangle | Aspect ratio of minimum bounding rectangle |
4-10 | Moment-invariant type | Characterizing shape features of image regions |
11-20 | Fourier descriptor | Profiling an object |
TABLE 1
Wherein the degree of circularity represents the degree of similarity of the object edge and circle, and the computational formula is as follows:
in the formula (3), S represents the area of an object, L represents the perimeter of the object, e represents the circularity, and when e is 1, the graph is circular; the smaller e is, the more irregular the graph is, and the larger the difference with the circle is;
wherein the rectangle degree represents the similarity degree of the object and the rectangle, and the calculation formula is as follows:
in the formula (4), S represents the area of the object, SRThe area of the minimum bounding rectangle of the object is represented, R represents the rectangularity, and the rectangularity reflects the filling degree of the object in the minimum bounding rectangle;
wherein the aspect ratio of the minimum circumscribed rectangle is the ratio of the major axis to the minor axis of the minimum circumscribed rectangle, the minimum circumscribed rectangle is shown in fig. 8, and the calculation formula is as follows:
in the formula (5), a represents the long axis of the minimum circumscribed rectangle, b represents the short axis of the minimum circumscribed rectangle, and epsilon represents the aspect ratio of the minimum circumscribed rectangle;
the invariant features mainly characterize the geometric features of the image regions, which are also called as geometric moments and invariant features with the characteristics of rotation, translation, scale and the like, and the principal idea of the invariant features is to use region-based moments which are insensitive to transformation as shape features.
For a two-dimensional (N × M) digitized image f (x, y), (p + q) orders can be defined as:
its corresponding (p + q) order central moment can be defined as:
the normalized (p + q) -order central moment of f (x, y) can be defined as:
the 7 moment groups proposed by hu.m.k, which do not vary with horizontal, rotational, and geometric scaling, can be defined as:
M1=μ20+μ02 (9)
M2=(μ20-μ02)2+4μ11 2 (10)
M3=(μ30-3μ12)2+(3μ21-μ03)2 (11)
M4=(μ30+μ12)2+(μ21+μ03)2 (12)
M5=(μ30-3μ12)(μ30+μ12)[(μ30+μ12)2-3(μ21+μ03)2]+(3μ21-μ03)(μ21+μ03)[3(μ30+μ12)2-(μ21+μ03)2] (13)
M6=(μ20-μ02)[(μ30+μ12)2-(μ21+μ03)2]+4μ11(μ30+μ12)(μ21+μ03) (14)
M7=(3μ21-μ03)(μ30+μ12)[(μ30+μ12)2-3(μ21+μ03)2]-(μ30-3μ12)(μ21+μ03)[3(μ30+μ12)2-(μ21+μ03)2] (15)
the fourier descriptor is the fourier transform coefficients describing the shape boundaries of the object, which is the result of a frequency domain analysis of the object boundary curve signal.
Assuming a closed boundary composed of N points, starting from any point P, one circle around the boundary is obtained:
s(k)=x(k)+jy(k),k=0,1,...,N-1 (16)
in formula (16), x (k) and y (k) are coordinates of the moving point P, and j is a coefficient;
the Discrete Fourier Transform (DFT) of s (k) is:
in formula (17), u is 0, 1., N-1, a (u) is a fourier descriptor of the boundary
The normalized fourier descriptor d' (k) is:
in the present invention, the first 10 coefficients are taken as the characteristics of the fourier descriptor, and as shown in fig. 9, it can be seen that the fourier descriptor of the same leaf is not changed regardless of the direction.
Step 4, training a tree species distinguishing model;
and integrating the extracted shape features to be used as feature vectors, extracting 20 feature parameters including circularity, rectangularity, aspect ratio of the minimum circumscribed rectangle, 7 invariant moments and 10 Fourier descriptors, integrating to obtain a 20-dimensional feature vector, normalizing the feature vectors, and inputting the normalized feature vectors into a BP (back propagation) neural network for training to obtain a plane geometric shape recognition model.
The normalization adopts linear normalization, and the formula is as follows:
in the formula (19), x is the original data, xminRepresenting the minimum, x, of the original data setmaxRepresenting the maximum value of the original data set.
As shown in fig. 10, the specific process of the BP neural network training is as follows:
the BP neural network input layer is provided with n neurons, the hidden layer is provided with p neurons, and the output layer is provided with q neurons.
Step S1, variable definition:
the output layer unit has n × p connecting lines to the hidden layer unit, and the connecting weight is Wih;
The unit from the hidden layer unit to the output layer has p × q connecting lines for connecting the weight Who;
The input vector is x ═ x1,……,xn);
The hidden layer input variable is hi ═ hi (hi)1,……,hip);
The hidden layer output variable is ho ═ ho (ho)1,……,hop);
The input variable of the output layer is yi ═ y (yi)1,……,yiq);
The input variable of the output layer is yo ═ yo1,……,yoq);
The desired output vector is do=(d1,……,dq);
The threshold of each neuron in the hidden layer is bh;
The threshold of each neuron of the output layer is bo;
The number of sample data is k is 1, 2, … …, m;
the activation function is f (·);
As a preferred embodiment of the present invention, the input layer has 20 neurons, the hidden layer has 64 neurons, the output layer has 5 neurons, which correspond to 5 kinds of trees, respectively, the value range of the output layer is [ -1,1], the activation function of the output layer is a softmax function, the activation function of the hidden layer is a Sigmoid function, and the formula is as follows:
step S2, network initialization: assigning random numbers in an interval (-1, 1) to each connection weight, setting an error function e, and giving a calculation precision epsilon and a maximum learning frequency M;
as a preferred embodiment of the present invention, the calculation accuracy ∈ is 0.0001, and the maximum number of learning times M is 500.
Step S3, random selection: randomly selecting a kth input sample and a corresponding expected output;
the k-th input sample is x (k) ═ x1(k),……,xn(k));
The corresponding desired output is do(k)=(d1(k),……,dq(k));
Step S4, calculating the input and output of each neuron of the hidden layer;
hih(k)=f(hih(k)) (h=1,2,......,p) (22)
yoo(k)=f(yio(k)) (o=1,2,......,q) (24)
step S5, calculating a global error E, wherein the formula is as follows:
step S6, calculating a partial derivative: calculating partial derivatives delta of error function to each neuron of output layer by using expected output and actual output of networko(k);
Step S7, correcting the weight: using delta of each neuron of the output layero(k) Correcting the connection weight W according to the output of each neuron of the hidden layerho(k) (ii) a Using delta of neurons of the hidden layerh(k) Correcting the connection weight W according to the output of each neuron of the input layerih(k);
Step S8, whether training is terminated: judging whether the global error E and the errors E of the hidden layer and the output layer meet the requirements, and ending the algorithm when the errors reach preset precision or the learning times are larger than the designed maximum times; otherwise, the next learning sample and the corresponding output expectation are selected, and the process returns to step S4 to enter the next learning round.
And 5, extracting the characteristics of the leaves of the test set, inputting the characteristics into the tree species identification model, and outputting an identification result.
And extracting the characteristics of the leaves of the test set, integrating to obtain 20-dimensional characteristic vectors, normalizing the characteristic vectors, inputting the normalized characteristic vectors into a tree species identification model, and outputting an identification result.
The tree species identification model is established according to the method, the result is shown in the table, the accuracy rate of tree species identification is 96.8%, and the method has good identification effect.
TABLE 2
Thus, the flow of the whole method is completed.
By combining with specific implementation, the method has the advantages that the method is beneficial to subsequent extraction and identification of leaf characteristics by preprocessing the picture; the extracted feature vectors are normalized, the statistical distribution of unified samples is summarized, and the convergence rate of the model is improved; the BP neural network is used for training to obtain the tree species distinguishing model, the robustness of the algorithm is enhanced, and the method can be applied to more scenes.
The invention is not described in detail, but is well known to those skilled in the art.
The foregoing detailed description of the preferred embodiments of the invention has been presented. It should be understood that numerous modifications and variations could be devised by those skilled in the art in light of the present teachings without departing from the inventive concepts. Therefore, the technical solutions available to those skilled in the art through logic analysis, reasoning and limited experiments based on the prior art according to the concept of the present invention should be within the scope of protection defined by the claims.
Claims (6)
1. A method for distinguishing tree species based on leaf pictures is characterized by comprising the following steps:
step 1, collecting leaf pictures, and dividing a training set and a testing set;
step 2, preprocessing the picture;
step 3, extracting the characteristics of the leaves of the training set;
step 4, integrating the extracted shape features to be used as feature vectors, normalizing the feature vectors, and inputting the normalized feature vectors into a BP neural network for training to obtain a tree species discrimination model;
and 5, extracting the characteristics of the leaves of the test set, inputting the characteristics into the tree species identification model, and outputting an identification result.
2. The method as claimed in claim 1, wherein in step 1, the method for distinguishing the tree species based on the leaf image is to collect images of different tree species, and the tree species comprises: the number of each tree leaf of ginkgo, maple, willow, pomegranate and white birch is not less than 100, the size of the picture is 300 pixels by 300 pixels, the collected picture is used as a data set, the data set is divided into a training set and a testing set, and the ratio of the training set to the testing set is 8: 2.
3. The method as claimed in claim 2, wherein in step 2, the pre-processing of the picture comprises: denoising, graying, binarization, edge detection, corrosion, expansion and filling;
the denoising method is characterized in that one of Butterworth low-pass filter denoising, FIR low-pass filter denoising, moving average filtering denoising, median filtering denoising, wiener filtering denoising, adaptive filtering denoising and wavelet denoising is selected as the denoising mode;
the graying adopts a maximum value method to graye the picture, and the formula is as follows:
Gray(x,y)=max{R(x,y),G(x,y),B(x,y)} (1)
in formula (1), R (x, y), G (x, y), B (x, y) represent RGB three components, respectively;
the formula of the binarization processing is as follows:
in the formula (2), T is a binarization threshold, and one of a bimodal method, a P parameter method, a maximum class variance method, a maximum entropy threshold method and an optimal threshold method is determined and selected as the threshold in binarization.
The edge detection adopts a Prewitt operator, and the operator can detect edges and can also inhibit the influence of noise;
4. the method as claimed in claim 3, wherein the step 3 of extracting features comprises: circularity, rectangularity, aspect ratio of the minimum circumscribed rectangle, invariant moment, fourier descriptor;
wherein the degree of circularity represents the degree of similarity of the object edge and circle, and the computational formula is as follows:
in the formula (3), S represents the area of the object, L represents the perimeter of the object, and e represents the circularity;
wherein the rectangle degree represents the similarity degree of the object and the rectangle, and the calculation formula is as follows:
in the formula (4), S represents the area of the object, SRRepresenting the area of the smallest circumscribed rectangle of the object, R representing the squareness;
wherein the aspect ratio of the minimum circumscribed rectangle is the ratio of the long axis to the short axis of the minimum circumscribed rectangle, and the calculation formula is as follows:
in the formula (5), a represents the long axis of the minimum circumscribed rectangle, b represents the short axis of the minimum circumscribed rectangle, and epsilon represents the aspect ratio of the minimum circumscribed rectangle;
the invariant moment mainly represents the geometric characteristics of an image region, and 7 moment groups which are not changed along with horizontal, rotation and geometric scaling and proposed by Hu.M.K are adopted and defined as follows:
M1=μ20+μ02 (6)
M2=(μ20-μ02)2+4μ11 2 (7)
M3=(μ30-3μ12)2+(3μ21-μ03)2 (8)
M4=(μ30+μ12)2+(μ21+μ03)2 (9)
M5=(μ30-3μ12)(μ30+μ12)[(μ30+μ12)2-3(μ21+μ03)2]+(3μ21-μ03)(μ21+μ03)[3(μ30+μ12)2-(μ21+μ03)2] (10)
M6=(μ20-μ02)[(μ30+μ12)2-(μ21+μ03)2]+4μ11(μ30+μ12)(μ21+μ03) (11)
M7=(3μ21-μ03)(μ30+μ12)[(μ30+μ12)2-3(μ21+μ03)2]-(μ30-3μ12)(μ21+μ03)[3(μ30+μ12)2-(μ21+μ03)2] (12)
in formulae (6) to (12), μpqRepresents normalized (p + q) -order central moment, p, q ═ 0, 1, 2, 3;
the Fourier descriptor is a Fourier transform coefficient for describing the shape boundary of an object, and the calculation formula is as follows:
assuming a closed boundary composed of N points, starting from any point P, one circle around the boundary is obtained:
s(k)=x(k)+jy(k),k=0,1,...,N-1 (13)
in formula (13), x (k) and y (k) are coordinates of the moving point P, and j is a coefficient;
the Discrete Fourier Transform (DFT) of s (k) is:
in formula (14), u is 0, 1., N-1, a (u) is a fourier descriptor of the boundary
The normalized fourier descriptor d' (k) is:
in the present invention, the first 10 coefficients are taken as fourier descriptor features.
5. The method for identifying tree species based on leaf images as claimed in claim 4, wherein in the step 4, the extracted shape features are integrated as feature vectors, 20 feature parameters including circularity, rectangularity, aspect ratio of minimum circumscribed rectangle, 7 invariant moments and 10 Fourier descriptors are extracted, a 20-dimensional feature vector is obtained by integration, the feature vectors are normalized, and then the normalized feature vectors are input into a BP neural network for training to obtain a plane geometric shape recognition model; the normalization adopts linear normalization, and the formula is as follows:
in the formula (16), x is the original data, xminRepresenting the minimum, x, of the original data setmaxA maximum value representing the original data set;
the BP neural network comprises 20 neurons in an input layer, 64 neurons in a hidden layer, 5 neurons in an output layer and 5 trees in an output layer, wherein the values of the output layer are in a range of [ -1,1], the activation function of the output layer is a softmax function, and the activation function of the hidden layer is a Sigmoid function.
6. The method as claimed in claim 5, wherein in step 5, the features of the leaves in the test set are extracted and integrated to obtain 20-dimensional feature vectors, the feature vectors are normalized and then input to the tree species identification model to output the identification result, and the accuracy of the tree species identification model is verified to be 96.8%.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210158900.3A CN114565525A (en) | 2022-02-21 | 2022-02-21 | Method for distinguishing tree species based on leaf picture |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210158900.3A CN114565525A (en) | 2022-02-21 | 2022-02-21 | Method for distinguishing tree species based on leaf picture |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114565525A true CN114565525A (en) | 2022-05-31 |
Family
ID=81713631
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210158900.3A Pending CN114565525A (en) | 2022-02-21 | 2022-02-21 | Method for distinguishing tree species based on leaf picture |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114565525A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114972276A (en) * | 2022-06-05 | 2022-08-30 | 长沙烽铭智能科技有限公司 | Automatic driving distance judgment algorithm for vehicle |
-
2022
- 2022-02-21 CN CN202210158900.3A patent/CN114565525A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114972276A (en) * | 2022-06-05 | 2022-08-30 | 长沙烽铭智能科技有限公司 | Automatic driving distance judgment algorithm for vehicle |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105956582B (en) | A kind of face identification system based on three-dimensional data | |
CN106529447B (en) | Method for identifying face of thumbnail | |
CN106897673B (en) | Retinex algorithm and convolutional neural network-based pedestrian re-identification method | |
CN108154519A (en) | Dividing method, device and the storage medium of eye fundus image medium vessels | |
CN103886589B (en) | Object-oriented automated high-precision edge extracting method | |
CN108694393A (en) | A kind of certificate image text area extraction method based on depth convolution | |
CN111027570B (en) | Image multi-scale feature extraction method based on cellular neural network | |
Wang et al. | Recognition and localization of occluded apples using K-means clustering algorithm and convex hull theory: a comparison | |
CN110837768A (en) | Rare animal protection oriented online detection and identification method | |
CN109102004A (en) | Cotton-plant pest-insects method for identifying and classifying and device | |
CN112597812A (en) | Finger vein identification method and system based on convolutional neural network and SIFT algorithm | |
CN115578603A (en) | Panax plant leaf identification method based on multi-feature extraction | |
Backes et al. | Plant leaf identification using multi-scale fractal dimension | |
CN106599891A (en) | Remote sensing image region-of-interest rapid extraction method based on scale phase spectrum saliency | |
CN117593540A (en) | Pressure injury staged identification method based on intelligent image identification technology | |
CN114863189B (en) | Intelligent image identification method based on big data | |
CN114565525A (en) | Method for distinguishing tree species based on leaf picture | |
CN112270271A (en) | Iris identification method based on wavelet packet decomposition | |
CN112102189B (en) | Line structure light bar center line extraction method | |
CN117635615B (en) | Defect detection method and system for realizing punching die based on deep learning | |
CN113989196A (en) | Vision-based earphone silica gel gasket appearance defect detection method | |
Mustaghfirin et al. | The comparison of iris detection using histogram equalization and adaptive histogram equalization methods | |
Shanmugavadivu et al. | Segmentation of pectoral muscle in mammograms using Fractal method | |
Wang et al. | Color edge detection using the normalization anisotropic Gaussian kernel and multichannel fusion | |
CN114565841A (en) | Vehicle type recognition method based on image processing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |