Keywords

1 Introduction

Recently, the picking technology of high value crops has become a new research hot spot, and lotus belongs to high value crops because of its great medical value, high risk of picking and high labor input required [13]. Fresh lotus seeds have great medicinal value in calming nerves, having healthy brain, developing intelligence and removing fatigue, but the high risk and low efficiency of manual picking restrict the lotus market development. Therefore the study of lotus picking robot has broad research prospect.

The image segmentation and recognition algorithms are key link of lotus harvesting robot vision system, and the ability to accurately and quickly identify the lotus directly affects the reliability and timeliness of lotus harvesting robot [46]. Then many factors increase the difficulty of lotus recognition, for example, the growth of lotus is changeable and mature lotus, lotus leaf, lotus flower and lotus stem often densely distribute in an area of the image, usual recognition algorithm based on RGB components [7, 8] is difficult to distinguish the lotus from the complex background because the colors of lotus leaf and lotus stem are closer than lotus.

However it is obvious about color difference between lotus and lotus flower, and shape difference between lotus and lotus flower and lotus stem, so in this study, the chromatic aberration method and the moment invariant algorithm are selected to extract the color and shape features from the divided images [913], in which there are seven moment invariant shape characteristics and one color feature (r-g) extracted from each connected domain in divided image. The moment invariant algorithm is simple and reliable, but has too many extracted characteristic variables, that causes the calculation is too big, and the time of recognition is too long, then the principal component analysis (PCA) algorithm is introduced to reduce the dimensionality of color and shape information in order to accelerate the speed of image recognition [1417].

K-Means clustering algorithm is simple, reliable and suitable for high dimensional data clustering [1821]. Due to the higher dimension of sample characteristics and the rapid identification requirement, we choose the most classical K-Means algorithm to cluster the extracted training feature set in the case of ensuring the recognition accuracy and to get four clustering centers of lotus, lotus leaf, lotus flower and lotus stem in order to identify lotus goal.

This paper describes a machine vision recognition system of lotus picking robot, and proposes a new shape and color feature extraction method combined with K-Means clustering algorithm to get lotus recognition model. Before the feature extraction, the existing pulse coupled neural network segmentation algorithm(PCNN), combined with morphological operation [2225], is used to achieve nice segmentation image, including lotus, lotus flower, lotus leaf and stems. Then the chromatic aberration method and the moment invariant algorithm are selected to extract the color and shape features of the segmented images, in which principal component analysis algorithm is selected to reduce the dimension of the color and shape features to achieve principal components of lotus, lotus flower, lotus leaf and stems.

2 Image Acquisition and Segmentation

2.1 Image Acquisition

Lotus pictures researched in this paper are taken from the lotus pond of Jiangsu university in Jiangsu province. In here, we choose by CCD color light source with 1024 × 960 pixels resolution to get lotus color images. Then 120 images, used for training and testing experiments, are closely shot with the method of elevation shooting on the side of lotus live action, in which we adopt 15 to 30 degrees elevation through the experience summary, and each picture include lotus and lotus stem with lotus flower or lotus leaf. Moreover all lotus pictures are shot under natural light conditions, and saved by JPG format with the resolution of 320 × 240 pixels in order to improve the seed of image process. Figure 1 is a lotus real picture.

Fig. 1.
figure 1

Lotus color picture

2.2 Image Segmentation Algorithm Introduction

This paper chooses the existing PCNN segmentation algorithm proposed by Ma Yide professor from Lanzhou University to get the segmentation images. The method uses PCNN segmentation algorithm and morphological image processing algorithm to divide the acquired image [22, 23]. Neuron model of simplified PCNN is shown in Fig. 2.

Fig. 2.
figure 2

Neuron model of simplified PCNN

Mathematical model of simplified PCNN neurons describes as follows:

$$ F_{ij} (n) = S{}_{ij} $$
(1)
$$ L_{ij} (n) = V_{L} \cdot \sum {W_{ijkl} } Y{}_{kl}(n - 1) $$
(2)
$$ U_{ij} (n) = F_{ij} (n)(1 + \beta L_{ij} (n)) $$
(3)
$$ E_{ij} (n) = e^{{ - \alpha_{E} }} \cdot E_{ij} (n - 1) + V_{E} \cdot Y_{ij} (n - 1) $$
(4)
$$ Y_{ij} (n) = \left\{ {\begin{array}{*{20}c} {\begin{array}{*{20}c} 1 & {(U_{ij} (n) > E_{ij} (n - 1))} \\ \end{array} } \\ {\begin{array}{*{20}c} 0 & {(U_{ij} (n) \le E_{ij} (n - 1))} \\ \end{array} } \\ \end{array} } \right. $$
(5)

In these equations, \( F_{ij} \) is neural input item, \( S_{ij} \) is external neural input excitation, which is corresponding to the eigenvalues of pixel \( (i,j) \), \( L_{ij} \) is connection input item, \( Y_{kl} \) is pulse output item, \( W_{ijkl} \) is connecting factor of coupling connection field, \( V_{L} \) is the connection power amplification factor of \( L_{ij} \), \( U_{ij} \) is internal activity item, \( \beta \) is the connecting factor of internal activity item, \( E_{ij} \) is dynamic threshold item, \( \alpha_{E} \) is the iterative damping time constant of \( E_{ij} \), and \( V_{E} \) is amplification factor of dynamic threshold.

In this paper, we set up \( V_{L} \cdot \beta = D \), and \( W_{ijkl} = \left[ {{{0.5} \mathord{\left/ {\vphantom {{0.5} D}} \right. \kern-0pt} D}\;{1 \mathord{\left/ {\vphantom {1 D}} \right. \kern-0pt} D}\;{{0.5} \mathord{\left/ {\vphantom {{0.5} D}} \right. \kern-0pt} D},\;{1 \mathord{\left/ {\vphantom {1 D}} \right. \kern-0pt} D}\;1\;{1 \mathord{\left/ {\vphantom {1 D}} \right. \kern-0pt} D},\;{{0.5} \mathord{\left/ {\vphantom {{0.5} D}} \right. \kern-0pt} D}\;{1 \mathord{\left/ {\vphantom {1 D}} \right. \kern-0pt} D}\;{{0.5} \mathord{\left/ {\vphantom {{0.5} D}} \right. \kern-0pt} D}} \right] \). We select Fig. 1 as an example, and after PCNN segmentation and morphological noise reduction, we can get the initial segmentation figure of Fig. 1 as Fig. 3.

Fig. 3.
figure 3

Segmentation Image of Fig. 1 by PCNN

Then we use the corrosion and expansion morphology method to remove the lotus stem connected with lotus and lotus flower in Fig. 3.

3 Image Feature Extraction

Considering the color differences between lotus and lotus flower and the shape differences between lotus, lotus leaf and lotus stem, this paper takes the color and shape feature extraction algorithm to extract the color and shape features of target image.

3.1 Color Feature Extraction

This paper uses color difference method to extract the target color feature based on the difference between lotus and lotus flower.

In the RGB color space, colors can be compared directly, and the color characteristic information can be controlled easily, so we can choose RGB color difference method for feature extraction [26, 27]. The classic color feature extraction method is selected to extract the color features of target image, in which R component and G component are regarded as color feature according the color difference between lotus and lotus flower. We choose \( (r - g) \) on behalf of color difference, and \( (x,y) \) on behalf of arbitrary pixel values in the image, then the formula of color difference is

$$ r - g = \bar{R}(x,y) - \bar{G}(x,y) $$
(6)

Where \( \bar{R}(x,y) \) is average pixels of red component, \( \bar{G}(x,y) \) is average pixels of green component.

3.2 Shape Feature Extraction

Classic Hu invariant moments algorithm combined with PCA algorithm is selected to extract the shape features of segmented image considering about the significant shape differences of lotus, lotus leaf, lotus stem, and changeable growth posture of lotus. Moment invariant algorithm processes the area of the target, and has simple concept, invariant translation, scaling and rotation, and stable and reliable recognition rate, which can avoid the shape deviation caused by changeable growth posture of lotus. PCA algorithm is used to get the invariant feature extraction to obtain comprehensive shape characteristic descriptions of the target image, which avoids the low recognition rate caused by invariant moment data redundancy.

3.2.1 Hu Invariant Moment Feature Extraction

Hu invariant moments is put into use for extracting the shape features of each connected area in target image, the seven invariant moments are as follows:

$$ \begin{array}{*{20}l} {a_{1} = \eta_{02} + \eta_{20} } \hfill \\ {a_{2} = (\eta_{20} - \eta_{02} )^{2} + 4\eta_{11}^{2} } \hfill \\ {a_{3} = (\eta_{30} - 3\eta_{12} )^{2} + (3\eta_{21} - \eta_{03} )^{2} } \hfill \\ {a_{4} = (\eta_{30} + \eta_{12} )^{2} + (\eta_{21} + \eta_{03} )^{2} } \hfill \\ {a_{5} = (\eta_{30} - 3\eta_{12} )(\eta_{30} + \eta_{12} )[(\eta_{30} + \eta_{12} )^{2} - 3(\eta_{21} + \eta_{03} )^{2} ] + (3\eta_{21} - \eta_{03} )} \hfill \\ {\quad \quad (\eta_{21} + \eta_{03} )[3(\eta_{30} + \eta_{12} )^{2} - (\eta_{21} + \eta_{03} )^{2} ]} \hfill \\ {a_{6} = (\eta_{20} - \eta_{02} )[(\eta_{30} + \eta_{12} )^{2} - (\eta_{21} + \eta_{03} )^{2} ] + 4\eta_{11} (\eta_{30} + \eta_{12} )(\eta_{21} + \eta_{03} )} \hfill \\ {a_{7} = (3\eta_{21} - \eta_{03} )(\eta_{30} + \eta_{12} )[(\eta_{30} + \eta_{12} )^{2} - 3(\eta_{21} + \eta_{03} )^{2} ] + (3\eta_{12} - \eta_{30} )} \hfill \\ {\quad \quad (\eta_{21} + \eta_{03} )[3(\eta_{30} + \eta_{12} )^{2} - (\eta_{21} + \eta_{03} )^{2} ]} \hfill \\ \end{array} $$
(7)

Where, \( \eta_{pq} \) is normalized central moment, which can ensure the rotation, translation and scaling invariance of Hu invariant moments. We get the normalized center moment through the following steps.

Firstly, we set \( (x,y) \) as one pixel point on the connected domain, \( f(x,y) \) is the corresponding gray value of \( (x,y) \), then the \( (p + q) \) moment of the entire connected domain is

$$ m_{pq} = \sum\limits_{x} {\sum\limits_{y} {f(x,y)x^{p} y^{q} } } $$
(8)

From the above formula, we can get the image barycentric coordinates is

$$ \begin{aligned} x_{0} = {{m_{10} } \mathord{\left/ {\vphantom {{m_{10} } {m_{00} }}} \right. \kern-0pt} {m_{00} }} \hfill \\ y_{0} = {{m_{01} } \mathord{\left/ {\vphantom {{m_{01} } {m_{00} }}} \right. \kern-0pt} {m_{00} }} \hfill \\ \end{aligned} $$
(9)

Where, \( m_{00} \) and \( m_{01} ,m_{10} \) are zero-order and first-order moments of the target image respectively.

Then, we use barycentric coordinates to get the center distance which is as follows

$$ \mu_{pq} = \sum\limits_{x} {\sum\limits_{y} {(x - x_{0} )^{p} (y - y_{0} )^{q} f(x,y)} } $$
(10)

From the above formula, we know that central distance has translation invariance.

Then we need normalize the central distance in order to get the normalization central distance which has rotation, translation and scaling invariance. The formula of normalization central distance is as follows:

$$ \eta_{pq} = \frac{{\mu_{pq} }}{{\mu_{00}^{1 + (p + q)/2} }}\left( {p + q = 2, 3, 4\cdots } \right) $$
(11)

By the above principle formula, we can get the seven Hu invariant moment shape feature quantities of the lotus, lotus leaf, lotus flower, lotus stem.

3.2.2 PCA Feature Reduction

We can get seven Hu invariant moments which are used to describe the shape feature amounts of the lotus, lotus leaf, lotus flower, lotus stem from the Sect. 3.2.1 feature extraction principle. But the calculated amount of Hu invariant moments is bigger and the dimension of feature amount is too high, PCA algorithm is introduced, to get on the feature extraction, in order to reduce data redundancy and avoid curse of dimensionality. The PCA algorithm gets the linear combination for the obtained seven invariant moments, and extracts the principal components which can able to represent the different shape features of lotus, lotus leaf, lotus flower and lotus stem.

Suppose, the sample size is n, each sample has p invariant moments, so there is a \( n \times p \) matrix,

$$ A = \left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} {a_{11} } \\ {a_{21} } \\ \vdots \\ {a_{n1} } \\ \end{array} } & {\begin{array}{*{20}c} {a_{12} } \\ {a_{22} } \\ \vdots \\ {a_{n2} } \\ \end{array} } & {\begin{array}{*{20}c} \cdots \\ \cdots \\ \vdots \\ \cdots \\ \end{array} } & {\begin{array}{*{20}c} {a_{1p} } \\ {a_{2p} } \\ \vdots \\ {a_{np} } \\ \end{array} } \\ \end{array} } \right] $$
(12)

To calculate the correlation coefficient matrix \( r_{ij} \),

$$ r_{ij} = \frac{{\sum\limits_{k = 1}^{n} {(a_{ki} - \bar{a}_{i} )(a_{kj} - \bar{a}_{j} )} }}{{\sqrt {\sum\limits_{k = 1}^{n} {(a_{ki} - \bar{a}_{i} )^{2} \sum\limits_{k = 1}^{n} {(a_{kj} - \bar{a}_{j} )^{2} } } } }} $$
(13)

According to the correlation coefficient matrix \( R \) to construct characteristic equation \( \left| {\lambda I - R} \right| = 0 \), and to calculate the eigenvalue, and sorted them by their value, that is, \( \lambda_{1} \ge \lambda_{2} \ge \cdots \ge \lambda_{p} \).

By the eigenvalue, to calculate the principal component contribution rate \( \alpha \) and the accumulative contribution rate \( \eta \),

$$ {{\alpha = \lambda_{i} } \mathord{\left/ {\vphantom {{\alpha = \lambda_{i} } {\sum\limits_{i = 1}^{p} {\lambda_{i} } }}} \right. \kern-0pt} {\sum\limits_{i = 1}^{p} {\lambda_{i} } }}{\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} (i = 1,2, \ldots ,p) $$
(14)
$$ {{\eta = \sum\limits_{i = 1}^{m} {\lambda_{i} } } \mathord{\left/ {\vphantom {{\eta = \sum\limits_{i = 1}^{m} {\lambda_{i} } } {\sum\limits_{i = 1}^{p} {\lambda_{i} } }}} \right. \kern-0pt} {\sum\limits_{i = 1}^{p} {\lambda_{i} } }}{\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} (i = 1,2, \ldots ,p) $$
(15)

The front \( m \) eigenvalues make η ≥ 85 %, to calculate their corresponding eigenvectors, and to calculate the loading \( l_{ij} \) of invariant moments \( a_{1} ,a_{2} , \cdots ,a_{7} \) load on the principal components \( z_{1} ,z_{2} , \cdots ,z_{m} \)

$$ l_{ij} = p(z_{i} ,a_{j} ) = \sqrt {\lambda_{i} } \overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\rightharpoonup}$}} {e}_{ij} (i,j = 1,2, \ldots ,p) $$
(16)

And extract the front \( m \) principal components

$$ Z = \left[ {\begin{array}{*{20}c} {z_{1} } \\ {z_{2} } \\ \ldots \\ {z_{m} } \\ \end{array} } \right] = \left[ {\begin{array}{*{20}c} {l_{11} } & {l_{12} } & \ldots & {l_{17} } \\ {l_{21} } & {l_{22} } & \ldots & {l_{27} } \\ \ldots & \ldots & \ldots & \ldots \\ {l_{m1} } & {l_{m2} } & \ldots & {l_{m7} } \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {a_{1} } \\ {a_{2} } \\ \ldots \\ {a_{7} } \\ \end{array} } \right] = \left\{ {\begin{array}{*{20}c} {l_{11} a_{1} + l_{12} a_{2} + l_{13} a_{3} + \ldots + l_{17} a_{7} } \\ {l_{21} a_{1} + l_{22} a_{2} + l_{23} a_{3} + \ldots + l_{27} a_{7} } \\ \ldots \\ {l_{m1} a_{1} + l_{m2} a_{2} + l_{m3} a_{3} + \ldots + l_{m7} a_{7} } \\ \end{array} } \right. $$
(17)

The basic steps of optimized Hu invariant moments algorithm based on PCA are as follow:

  • Step 1 to extract the \( p + q \) moments of each segmented image’s connected domain, according to Eq. (8) calculate the barycentric coordinate \( (x_{0} ,y_{0} ) \);

  • Step 2 according to Eq. (9) calculates the center distance, and normalized by Eq. (10);

  • Step 3 by Eq. (11) to calculate the each eigenvalue of invariant moments corresponding with connected domain, and extract the shape features, then obtained invariant moments’ information of all samples;

  • Step 4 aim at the data sample matrix, to calculate its the correlation coefficient matrix \( R \) by Eq. (13);

  • Step 5 to calculate the eigenvalue of matrix \( R \), and sorted them by their value;

  • Step 6 according to Eq. (15) determine the front \( m \) principal components;

  • Step 7 by Eq. (16) to calculate the load of principal components, and obtained the principal features \( Z \).

4 K-Means Cluster Analysis

K-means cluster algorithm is one of classic cluster algorithm, it has the advantages of description easy, algorithm simple, operating efficient high, and suitable for large-scale data processing. In this study, using the K-means cluster algorithm can be accurately obtain the lotus clustering center, to achieve the purpose of fast recognition for lotus.

In the clustering process, the selection of parameters is directly influence the reliability and recognition efficiency of the experiment. The number of clusters is \( K \), the \( K \) initial clustering centers and the distance parameter \( d \) plays a decisive role for K-Means cluster algorithm. The selection of \( K \) has a certain human factors, and the selection of \( K \) initial clustering centers has a certain randomness, all of these have a directly impact on the result of clustering.

In this study, the city distance is adopted,

$$ d = \left| {x - x^{\prime}} \right| + \left| {y - y^{\prime}} \right| + \left| {z - z^{\prime}} \right| + \ldots $$
(18)

where, \( (x,y,z, \cdots ) \) and \( (x^{\prime},y^{\prime},z^{\prime} \cdots ) \) respectively represent the cluster center and the coordinate point of sample.

Suppose the number of samples is \( n \), using the color and shape features to cluster by K-means algorithm, the basic steps are as follow.

  • Step 1 the color and shape features of \( n \) samples as inputs;

  • Step 2 to determine \( K \) initial clustering centers \( c = \left\{ {c_{1} ,c_{2} , \cdots ,c_{k} } \right\} \) randomly, the samples is divided into \( K \) classes;

  • Step 3 to calculate the city distance between eigenvalue of each sample to the center of clustering, according the principle of the shortest distance, each sample is divided into the sub-classes of corresponding cluster center;

  • Step 4 to calculate the average value of each sub-class, and regard as the new cluster center;

  • Step 5 repeat the step 3 to 4, until the cluster center no longer changes, the algorithm stop, and output the cluster graph and cluster center \( C \).

5 Image Recognition

The lotus image recognition algorithm based on machine vision is roughly divided into four steps, that is, image segmentation, feature extraction, recognition model training, and sample recognition. The flow chart of feature extraction is show in Fig. 4, the flow chart of model training is show in Fig. 5, the flow chart of sample recognition is show in Fig. 6.

Fig. 4.
figure 4

The flow chart of feature extraction

Fig. 5.
figure 5

The flow chart of K-means cluster training

Fig. 6.
figure 6

The flow chart of testing sample recognition

The basic steps of lotus image recognition algorithm are as follow.

  • Step 1 the captured image is segmented by PCNN algorithm, get the segmented images;

  • Step 2 to extract the color feature information of segmented images by color difference method;

  • Step 3 to extract the Hu invariant moments of segmented images, using PCA algorithm to reduce dimension, get the principle component data of sample;

  • Step 4 the color feature and principle components as the inputs, for the training samples, by K-means clustering algorithm, to determine the four cluster centers, that is, lotus, lotus leaf, lotus flower and lotus stem, and then get the trained recognition model;

  • Step 5 to calculate the distance between test samples to each cluster center;

  • Step 6 to judge the distance to lotus cluster center whether is closest, if yes, the sample is the lotus target.

6 Experiments

6.1 Experiment Design

This experiment’s operation platform, CPU: Intel(R) Core(TM) 2 Duo E7300 @ 2.66 GHz, RAM: 1.99 GB, operating environment: windows XP and matlab R2012a, graphic card: Intel® G33/G31 ECF.

In the experiment, the captured 120 images, all of these images are captured under natural light. In the image process, the pictures are converted to 320 × 240 pixels to improve the speed of image processing. After the image segmentation, the segmented images are divided into training samples and testing samples.

This experiment firstly uses combination method of PCNN and morphological processing to segment the captured images, obtained segmented images; respectively uses color difference method to extract the color feature of segmented images, uses Hu invariant moments method based on PCA to extract the shape feature of segmented images; and then uses K-means algorithm to cluster the training samples, obtained \( K \) cluster center; finally, classifies the test sample according to the distance to cluster center in order to verify the reliability, recognition precision and operating efficiency of the lotus recognition model.

6.2 Lotus Image Segmentation

All images are segmented by PCNN method described in Sect. 2, and then do some morphological processing, obtained the segmented images. Segmentation images are pictured above Fig. 3. Then we select 3 × 3 circular structure element to etch Fig. 3 and use 4 × 4 structural elements to expand corrosion image, and then make ‘&’ operation between expansion image and original image. The final segmentation image as shown in Fig. 7.

Fig. 7.
figure 7

Final segmentation image

From Fig. 7, most lotus stem has been removed, only leaving a small part connected with lotus and lotus flower for the positioning of the fruit and picking, and the outline of segmentation target is clear, the connected area is obvious. In other words, it is easy to extract the target’s features. So the result shows that PCNN used to segment lotus image is feasible and reliable.

The captured 120 images, after segmentation, obtained 200 segmented images, among 73 lotus images, 39 lotus flower images, 44 lotus leaf images and 46 lotus stem images. Respectively, selected 20 images from each type segmented images as training sample, the rest of the images as the test sample.

6.3 Lotus Image Feature Extraction

6.3.1 Hu Invariant Moments

For all segmented images, using the invariant moment algorithm to extract the shape feature, and get the invariant moment data of all samples, each sample has seven feature variables \( a_{1} ,a_{2} , \cdots ,a_{7} \). Invariant moments feature of 8 examples are listed in Table 1.

Table 1. Invariant moment data

From Table 1, the results show that the value of invariant moments has a descending trend, except lotus stem, this is caused by the particularity of the shape of lotus stem. The scope of invariant moment of lotus is part overlap with lotus flower and lotus leaf, this will bring some interference for lotus recognition. Thus it can be seen, single from the shape feature to recognize lotus, lotus flower, lotus leaf, is very difficult, so in this study, need to combine with the color feature.

6.3.2 PCA Feature Reduction

Invariant moment information is not directly used to recognize the lotus, lotus flower, lotus leaf and lotus stem. The data information is too redundant, is not convenient to cluster analysis. So in this study, in order to using these invariant moment information, need to dimension reduction. PCA algorithm is introduced, and the invariant moment information is integrated into a few principal components.

We do principle component analysis for 200 segmented sample, and the eigenvalue, contribution rate (CR) and accumulative contribution rate (ACR) are listed in Table 2.

Table 2. Eigenvalue, contribution rates and accumulative contribution rates

Table 2 shows that, if the amount of information can reach 85 %, the solution will not be influenced, in this study need to extract 3 principal components. That is, the dimension of the shape features is reduced from 7 to 3. These 3 principal components represent the shape feature of lotus, lotus flower, lotus leaf and lotus stem.

6.3.3 Combination of Color and Shape Feature

Combination of one color feature and three shape features, using these four variables to describe the characteristics of the sample. Take Table 1 as an example, the samples corresponding feature are listed in Table 3.

Table 3. Feature variables of example samples

Table 3 shows that, these four variables regard as the inputs of the training and recognition model.

6.4 Training

In the process of lotus recognition, the interference factors mainly include lotus flower, lotus leaf, lotus stem, so in the training, set \( K = 4 \). The determination of cluster center is randomly, selected the city distance as the criteria of similarity and discriminated. From 200 samples, respectively, choose 20 lotus, 20 lotus flowers, 20 lotus leaves and 20 lotus stems, so total 80 samples as training sample. The 80 training samples can be divided into four classes by K-means cluster algorithm, four cluster centers \( \left\{ {c_{1} ,c_{2} ,c_{3} ,c_{4} } \right\} \) are obtained. In order to the clustering figure show in 2 dimension coordinate, for 4 extracted features \( (z_{1} ,z_{2} ,z_{3} ,(r - g)) \) to do linear combination, get a new feature \( (z',(r - g)') \). The transfer formula is

$$ \left\{ {\begin{array}{*{20}l} {z' = \lg |z_{1} .*z_{2} .*z_{3} |} \hfill \\ {(r - g)' = 0.01(r - g)} \hfill \\ \end{array} } \right. $$
(20)

The clustering figure is show as Fig. 6.

Note: Abscissa represents the linear combination of principal components \( (\lg |z_{1} .*z_{2} .*z_{3} |) \), ordinate represents color feature value after the linear operation \( (0.01(r - g)) \); peach ‘o’ area represents lotus, red ‘*’ area represents lotus flower, green ‘+’ area represents lotus leaf, blue ‘△’ area represents lotus stem; ‘□’ represents the cluster center of each cluster area.

The cluster centers’ coordinate is

$$ C = \left\{ {\begin{array}{*{20}c} {c1} & {c2} & {c3} & {c4} \\ { - 4. 1 3 8 9} & { - 3.4894} & { - 3. 3 2 1 4} & {0.0637} \\ { - 0.1536} & { + 0.6433} & { - 0.5244} & { - 0.1928} \\ \end{array} } \right. $$
(21)

Figure 8 shows that, the 80 samples are clustered into four classes, the cluster area is obvious. It is illustrate that K-means cluster algorithm is suitable for distinguish lotus, lotus flower, lotus leaf, lotus stem. Lotus flower area locate at above coordinate axis \( (x,0) \), it well to distinguish the lotus flower and the lotus, lotus leaf, and to avoid the lotus recognition interference caused by lotus flower. Lotus flower area locate at right coordinate axis \( ( - 1,y) \), the cluster area is fragmented, it is verify that the difference of lotus stem shape is bigger, the recognition interference is small.

Fig. 8.
figure 8

Clustering chart of K-Means (Color figure online)

The cluster area of lotus is relatively concentrated, it has obvious boundary with lotus leaf, noninterference with each other. It is further illustrating that K-Mean clustering algorithm for lotus recognition is simple and reliable.

6.5 Testing

For 120 test samples, to calculate the city distance of each sample to each cluster center, according the shortest distance to judge the sample belong to which class. The results of recognition are listed in Table 4.

From Table 4, the results show that, using for testing 53 lotus images, the number of correct recognition image is 48, 2 images are misrecognized to lotus flower, 3 images are misrecognized to lotus leaf, the recognition precision of lotus is 90.57 %.

Table 4. Recognition result of testing images

For 19 lotus flowers, the recognition precision is 84.21 %, 3 images are misrecognized to lotus, because they are un-blooming lotus flower, their shape is very similar with lotus, and color also is very close.

For 22 lotus leaves, the recognition precision is 90.91 %, 2 images are misrecognized to lotus, due to the different shooting angle of the camera, and the growth posture of the lotus is variety.

For 26 lotus stems, the recognition precision is 100 %, because the shape of lotus is difference with other target.

To test 120 images, the average recognition time of each image is 0.0473 s, recognition time include feature extraction and testing time.

7 Conclusion

In order to achieve the automatic harvesting lotus, this paper carries on some related preliminary study of lotus harvesting robot, and a lotus recognition method for vision system of harvesting robot is designed.

Lotus target image recognition based on machine vision, the target image segmentation by PCNN, and obtained the segmented lotus image, lotus flower image, lotus leaf image, and lotus stem image. Due to the lotus has color difference with lotus flower, has the shape difference with lotus leaf and lotus stem, so the feature extraction method of lotus target adopts the combination of color and shape feature. In the color feature extraction, color difference method is used to extract the red and green feature difference, to avoid the interference from lotus flower to the lotus and lotus leaf recognition. In the shape feature extraction, Hu invariant moment algorithm is adopted, combine with PCA algorithm, to reduce the dimension of shape features. The extracted principal components represent the shape feature of lotus, lotus flower, lotus leaf and lotus stem. It reduces the data redundancy, improve the computing speed.

All samples are divided into training sample and testing sample. For training sample, by K-means cluster algorithm to determine four cluster center of lotus, lotus flower, lotus leaf and lotus stem, obtained the lotus recognition model. In the K-means cluster algorithm, city distance is adopted as the criteria of similarity and discriminated. In order to easily observe the cluster figure, make its display in 2d coordinate system, the extracted four features need to be done linear combination. Finally, the city distance of each testing sample to four cluster center has been calculated, according the shortest distance to discriminate sample of belonging.

By the experiment analysis, from image segmentation and feature extraction, to recognition model training and testing sample recognition, this study adopts the method of lotus image processing, it gets the better effect, and the results are practical and reliable. From the lotus correct recognition rate, this study achieves the desired effect. This paper implements the preliminary discussion on the lotus auto-harvesting, next step of study, we will do some improvement on the recognition accuracy and efficiency.