Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Computers and Electronics in Agriculture 162 (2019) 493–504

Contents lists available at ScienceDirect

Computers and Electronics in Agriculture


journal homepage: www.elsevier.com/locate/compag

Original papers

Segmentation and counting algorithm for touching hybrid rice grains T


a,b b,⁎ a b b
Suiyan Tan , Xu Ma , Zhijie Mai , Long Qi , Yuwei Wang
a
College of Electronic Engineering, South China Agricultural University, Guangzhou 501642, China
b
College of Engineering, South China Agricultural University, Guangzhou 501642, China

A R T I C LE I N FO A B S T R A C T

Keywords: The ability to segment and count of touching hybrid rice grains can enable the automatic evaluation of seeding
Hybrid rice performance. In this paper, an algorithm that separates and counts touching rice grain, which consists of the
Watershed algorithm watershed algorithm, an improved corner point detection algorithm, and neural network classification algo-
Neural network rithm, is presented. To reduce the over-segmentation regions caused by the watershed algorithm, wavelet
Corner point
transform and Gaussian filter are first applied to enhance the contrast intensity of grayscale image and to reduce
Circular template
noise, followed by an improved corner point detection algorithm based on adaptive-radius circular template. The
over-segmentation regions are identified and merged by detecting whether the end points of the splitting lines
coincide with the corner points. Considering that regions of different grain quantity vary in appearance and
corner point characteristic, a Back Propagation (BP) neural network classifier is employed to classify the under-
segmentation regions into five categories: one grain, two grains, three grains, four grains, and more than four
grains. The proposed algorithm was tested on three hybrid rice varieties under different realistic touching
scenarios formed in the sowing process. The tests results showed that the corner point detection algorithm using
an adaptive-radius circular template achieved better corner point accuracy than that using a fixed-radius tem-
plate, and the over-segmentation regions were more accurately merged. For grain regions of different grain
quantity, BP neural classifier achieved an average classification accuracy of 92.4%, which was suitable for
counting rice grains in under-segmentation regions. The overall segmentation and counting method proposed in
this study could achieve an average accuracy of 94.63%, which was verified by manual counting results.

1. Introduction adjustment to the seeder can be timely implemented. However, auto-


matic counting rice grains in a seeding tray is challenging, since once
Hybrid rice is one of the most important grain crops in China. hybrid rice grains are sown onto the soil in the nursery tray through the
Currently, commercial farming of hybrid rice mostly employs trans- precision seeder, seeds usually touch each other. When imaged under a
planting techniques, where seeds are sown and raised in nursery trays camera, only some grains appear as single grain, while the others ap-
into seedlings. Seedlings are later transplanted using compatible ma- pear as a cluster of multiple touching grains. The multiple touching
chinery. Due to hybrid rice’s strong tiller ability and proper seeding grains often touch each other by adhesion, overlapping, and cross-
rate, around one to three grains sown in each hole of nursery tray, is linking. Therefore, accurate segmentation and counting of the hybrid
desired for optimum growth and efficient utilization of rice grains (He rice grains is the key to the precise evaluation of seeding performance.
et al., 2018). In the actual sowing process, the seeding performance are In the literatures, previous studies have been conducted on the
hard to predict, since it is influenced by many parameters, including the automatic segmentation and counting of touching objects, including
operational parameters of precision seeder and the physical properties touching grains and cells. Techniques for segmenting and counting of
of rice (Zhan et al., 2015). Physical properties of rice grain, such as size, touching objects mainly include ellipse-fitting, Active Contour Model
moisture and weight, are affected by the external environment, such as (ACM), watershed algorithm, and concave point detection. Zhang et al.
the hot weather. In order to ensure proper and precise seeding rate, it is (2005) utilized an ellipse-fitting algorithm to separate and count
necessary to accurately evaluate seeding performance, especially the touching grains. In Zhang’s method, the edges between touching grains
seeding quantity in each hole of the trays. In this way, when the me- were fitted by a direct least-square ellipse-fitting method, and the
chanical seeding performance degrades due to external environments, touching grains were separated by morphology transform with re-
manual and mechanical reseeding or automatic operation parameter presentative ellipse. Wang and Chou (2004) developed an ACM to


Corresponding author.
E-mail address: maxu1959@scau.edu.cn (X. Ma).

https://doi.org/10.1016/j.compag.2019.04.030
Received 20 June 2018; Received in revised form 11 April 2019; Accepted 23 April 2019
Available online 02 May 2019
0168-1699/ © 2019 Elsevier B.V. All rights reserved.
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

automatically segment the touching rice kernels. Wang first introduced segmentation accuracy by searching concave point pairs. Despite this,
an Inverse Gradient Vector Flow (IGVF) to automatically generate a applications of watershed-based segmentation algorithm have been
field center for individual rice kernel, then the centers were employed limited to separating scenario of simple touching grains. In one study,
as references for setting initial deformable contours that were required grains were placed on a black or white background instead of more
for building an ACM. The final contours of rice kernels were calculated, realistic environments, where the noise level was low and image con-
and touching rice were successfully separated. Duan et al. (2011) used trast intensity was good. In the other study, grains were placed manu-
watershed algorithm to segment and count the touching rice spikelet. ally or by a vibrator, so that the pattern of how they touched was
Qin et al. (2013) proposed a modified watershed segmentation algo- generated artificially, where most of them only slightly adhered to each
rithm based on the extended-maxima transform to segment the other. To address the problem of segmentation and counting rice grains
touching corn kernels, and the algorithm improved the over-segment in more realistic and challenging overlapping conditions, we directly
problem brought by traditional watershed algorithm. Mebatsion and worked on hybrid rice grains that were sown onto the soil by the pre-
Paliwal (2011) employed a Fourier analysis-based and edge curvature cision seeder, from a height of 20–30 cm. Grains touched each other in a
algorithm to separate touching kernels. He applied Fourier approx- natural and complex pattern, including serious and slight adhesion,
imation to smooth the boundary contours. The curvature values along cross-linking, and overlapping. To overcome the limitations of the
boundary were calculated and the concave points were detected. For watershed algorithm and concave points method, an improved algo-
multiple concave points, nearest-neighbor and radian critical distance rithm that separated and counted touching grains, which combined
difference criteria were used to draw segmentation lines. Visen et al. with watershed algorithm, an adaptive-radius circular template-based
(2001) segmented the occluding grains using classification and concave corner point algorithm and neural network-based classification of
point detection. Grains were first characterized as either an isolated under-segmentation rice grains, was proposed. First, some image pre-
kernel or a group of occluding kernels by determining the degree of processing was performed to improve image quality. Then, over-seg-
their inertial equivalent ellipse. Then, for the occluding kernels, con- mentation regions were identified and merged based on whether the
cave points were detected and splitting lines were drawn under mul- endpoints of splitting lines coincided with corner points after the wa-
tiple criteria. Zhong et al. (2009) employed a combined watershed and tershed algorithm. Meanwhile, an improved corner point detection al-
concave points algorithm to segment the touching rice kernels. Similar gorithm using adaptive-radius circular template was proposed.
algorithms were used for cell separation. Bai et al. (2009) developed a Considering that regions with different number of rice grain varied in
cell segmentation technique based on concave point detection and el- appearance and corner point characteristic, the under-segmentation
lipse fitting. Wang et al. (2012) segmented the touching cells by gen- regions were classified by BP neural network into five categories: single
erating a classifier and detecting the bottleneck of the cells. In Wang’s grain, two grains, three grains, four grains, and more than four grains.
method, Wang firstly constructed a classifier to classify the shape of the Finally, accuracy of the proposed methods was assessed by comparing
cells, and these cells were determined whether they need to be seg- the proposed counting algorithm with the manually counted results.
mented. The segmentation line was then determined by detecting the The proposed algorithm overcome the over-segmentation and under-
bottleneck part of the touching cells. segmentation problems that were inherent in the watershed method. In
The above algorithms to segment and count the touching objects this paper, seeding images were acquired with a low-cost webcam,
have their own advantages and disadvantages. The ellipse fitting which was economically suitable for applications in actual agricultural
method demands the object to have approximately regular ellipsoid production. The objective of this paper is to develop an algorithm to
shape, otherwise the splitting rate would decrease and the time con- separate and count the touching rice grains, which provides a reference
sumption would increase (Grbić et al., 2016). The watershed algorithm for precise evaluation of hybrid rice seeding performance.
is widely used for separation, which uses topological theory and iden-
tifies separation lines through a simulation process of water flooding 2. Materials and methods
(Wang and Paliwal, 2006, Bleau and Leon, 2000,). Its major deficiency
is that it is sensitive to noise and rough boundaries in digital image, 2.1. Test system
hence prone to be over-segmented. In addition, when the grains are
tightly stuck to each other, it is likely to cause under-segmentation. The The test system consisted of an HD Logitech C920 Webcam, a three
concave point detection is based on the principle that touching objects dimensional rail, an illuminant cabinet, and a computer, as presented in
generally form concave points at the adhesion part and that splitting Fig. 1 The Logitech C920 featured autofocus capability, which was
lines can be generated through concave point pair search (Zhang and Li, mounted on the illuminant cabinet and aimed vertically downward to
2017). The concave points are obtained by detecting the abrupt change capture the top view of nursery seeding tray. The range of view could
of the boundary curvature of touching object. However, previous re- be adjusted through the three-dimensional rail. The computer was
searches (Hobson et al., 2009, Mebatsion and Paliwal, 2011) have connected to the camera with a USB cable, through which the nursery
shown that the boundary curvature is severely influenced by noise and tray images can be received and processed. The illuminant cabinet was
boundary roughness. To address these problems, Liu et al., 2017 used installed in the captured area. Five LED surface illuminants were fixed
changes in the response value of a circular template as it moves along on the top and four sides of the cabinet, which ensured the uniform
the boundary to detect concave points, which is less affected by noise. distribution of illumination. To obtain good quality images, the illu-
However, when the grains are under complicated touching conditions, a minants were adjusted for optimal illumination. The test system was
fixed-radius circular template may lead to false or missed corner point installed on the 2SJB-500 automatic sowing line, and it was placed
detection, and the corner point detection accuracy decreases. Further- between the precision seeder and soil coverer device. The hybrid rice
more, concave point pair matching is the hardest step in the separation grains were sown by the precision seeder onto the soil on the nursery
process, and the determination of splitting lines consider multiple cri- tray, resulting in different patterns of touching grains.
teria, for example the nearest-neighbor criterion and radian critical Matlab2014a was used as the image processing tool. The computer
distance criterion (Lin et al., 2014, Yao et al., 2017). was configured with a 3.19 GHz Intel Core i5-4200U processor.
In summary, different techniques have been applied to the separa-
tion and counting of touching grains. Among them, the watershed al- 2.2. Test materials
gorithm and concave point detection are most effective, yet they have
limitations in several aspects. For example, watershed algorithm may Hybrid rice conventionally has an elliptical shape. To explore the
lead to over-segmentation and under-segmentation. Methods such as adaptability of proposed algorithm to different types of rice grains,
concave point method can be a supplemental method that improve three hybrid rice varieties, Teyou 338, Peizataifeng, and Taifengyou

494
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

1 5 4
3 2

1. Precision seeder, 2. Soil coverer, 3. Digital camera, 4. Illuminants, 5. Illuminant cabinet, 6. Nursery tray, 7. Computer
Fig. 1. Test system and its structure diagram.

Table 1 208, were used in the tests. Among these, Teyou 338 was relatively
Mean and standard errors of grain physical properties. plump and round with a length-width ratio of 2.6, Peizataifeng was
Physical Length (mm) Width (mm) Thickness (mm) Thousand grain
slender with a length-width ratio of 3.6, and Taifengyou 208 was even
property weight (g) more slender with a length-width ratio of 4.4. A total of 300 seeds of
each variety were randomly selected to measure their length, width and
Teyou 338 8.15 ± 0.36 3.10 ± 0.14 2.17 ± 0.09 28.8 ± 0.5 thickness. The thousand grain weight of each variety was measured 20
Peizataifeng 8.77 ± 0.45 2.44 ± 0.10 1.94 ± 0.06 25.0 ± 0.7
Taifengyou 9.58 ± 0.40 2.18 ± 0.14 1.89 ± 0.07 24.8 ± 0.6
times. The physical properties of rice grains are shown in Table 1.
208 Fig. 2a1, a2 and a3 show the images of the three varieties of hybrid rice.
Rice grains were soaked for several hours before the sowing process.
Then they were germinated to the chest breaking stage, with little or no
bud present.

(a1) (b1) (c1) (d1)

(a2) (b2) (c2) (d2)

(a3) (b3) (c3) (d3)

Fig. 2. Image preprocessing and the watershed algorithm: Row (1) Teyou 338, Row (2) Peizataifeng, Row (3) Taifengyou 208, Column (a) RGB image of seeding tray,
Column (b) Grayscale image, Column (c) Watershed algorithm was directly applied on grayscale image, Column (d) Watershed algorithm was applied after image
preprocessing.

495
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

2.3. Image preprocessing 2.4.1. Corner point detection along rice grain boundaries using circular
template
The watershed algorithm is a classical segmentation algorithm that In this study, circular template is used to perform corner point de-
identifies separation lines between different regions through the si- tection. First, the binary image threshold between rice grains and the
mulation of water flooding process. However, the watershed algorithm background is obtained using Otsu’s method (Otsu, 1979), as shown in
is susceptive to noise and the inconspicuous contrast intensity of Fig. 4b, and the grain boundary pixels are obtained using the Canny
grayscale in the image (Liu et al., 2016). The existence of noise pro- operator (Canny, 1986), as shown in Fig. 4c. Next, an appropriate ra-
duces many spurious lines, forming many over-segmentation regions. dius of the circle template is selected, and the center point of template
The existence of inconspicuous contrast intensity of grayscale image moves along the boundary of grain. At each boundary pixel p, where p
lead to the loss of the correct separation lines, forming under-segmen- runs over the grain boundary, a Corner Response Function (CRF) is
tation regions. In Fig. 2, column (a) shows the RGB seeding images and proposed to identify corner points. At point of boundary p, its CRF value
column (b) shows the corresponding grayscale images. When watershed is,
algorithm is directly applied on the grayscale image, many spurious np
separation lines are identified, leading to serious over-segmentation CRF (p) =
ap (1)
problems, as shown in column (c).
The inconspicuous contrast intensity of gray scale problem can be where ap is the area (pixels) of circular template and np is grain area
reduced by enhancing the contrast intensity of a grayscale image. To (pixels) inside the circular template. Hence, CRF(p) is a ratio between
this end, wavelet transform is applied to enhance the edge information two areas. If the radius of template is fixed, then ap is fixed. The CRF(p)
and change the gray-scale of different regions in the images (Kim et al., values along different points on the boundary of a rice grain is shown in
2016). Since the applied wavelet transform may have amplified noise Fig. 5, where it can be observed that the changes of CRF are in ac-
and details in the images, Gaussian filter is then applied to reduce noise cordance with the changes of boundary curvature. The abrupt change of
and smooth rough edges. Finally, watershed algorithm is applied. After the CRF value indicates a corner point. Hence, when a boundary pixel
the preprocessing steps on the grayscale image using wavelet transform that is a local maximum of the CRF curve, with a CRF value greater than
and Gaussian filter, the over-segmentation is significantly alleviated, as a threshold, it can be considered as a concave point. Similarly, when a
shown in column (d) of Fig. 2. boundary pixel that is the local minimum of the CRF curve, with a CRF
Although the image preprocessing steps improve the image seg- value less than a threshold, it can be considered as a convex point
mentation quality, over-segmentation problems still present due to (Zhong et al., 2009). To avoid identifying the two local maximums of
noise, fine textures and rough image boundaries. Further, under-seg- the CRFs on the flat sides of grain as corner points, as point p2 and p6 in
mentation problems caused by touching rice grains still needs to be Fig. 5, the local maximum threshold for concave points and the local
solved. Solving over-segmentation and under-segmentation problems minimum threshold for convex points are set to 0.6 and 0.4 respec-
are crucial for the accurate automatic counting of hybrid rice grains. tively, based on simulation and test experimental results.

2.4.2. Drawbacks of the fixed-radius circular template method


2.4. Merging of over-segmentation regions based on an improved corner Although the circular template is widely adopted in the literatures
point detection for concave point detection, it cannot correctly identify corner points in
all situations. Since using circular template, an abrupt change of CRF
A corner point refers to a point with sharp change of the boundary indicates a corner point, only one continuous grain boundary, which
curvature, which can be either the intersection of two edges or a feature encloses the grain area np, is allowed in a circular template. Otherwise,
point with two main directions in the neighborhood. According to the an abrupt change of CRF might not correspond to an abrupt change of
direction of the curvature variation, the corner points can be divided grain boundary curvature, which may lead to false or missed detection
into concave points and convex points. of corner points.
Fig. 3 shows images of some touching rice grain. Hybrid rice grains For example, Fig. 6a shows a binary image of three touching grains
are elliptic and have two obvious convex points at both ends of the long and its corner points detected by a fixed-radius circular template. Fig. 6f
axis. When two hybrid rice grains touch each other, concave points are shows the CRF along the boundary, where points b' and e' are not corner
formed at the touching points. In some cases, convex points may also be points. However points b' and e' are the local maximums of the CRF
formed. More than two touching grains sometimes form a closed region, curve with CRF values greater than the threshold 0.6, hence are falsely
as shown in Fig. 3c, whose boundary pixels are referred to as a hole. It identified as concave points using the fixed-radius circular template
was previously reported that endpoints of the splitting lines must be the method. These are because as circular template moves to b' or e', as
concave, convex points or holes (Liu et al., 2017). Since spurious shown in Fig. 6b and c, two different grains very close to each other are
splitting lines whose endpoints are not cancave points, convex points or both within the circular template, thus the corresponding np values are
holes can be removed, the key to identifying and merging over-seg- made up of two disjoint areas enclosed by two separate grain bound-
mentation regions is to detect the corner points along the grain aries, denoted as S0 and S1 in Fig. 6b and c. The abrupt changes in the
boundaries and the endpoints of the splitting lines. CRF values at positions b' and e' do not reflect abrupt changes in the
curvature of the local segments of the boundary that the center point
located on. Similarly, although points c' and k' are concave points, they

Fig. 3. Touching rice grains and corner


points: Concave and convex points formed
at the touching point, (c) Closed region en-
closed by three touching grains. Note that: a
concave points marked with a blue ‘o’ and a
convex points marked with a red ‘+’. (For
interpretation of the references to colour in
this figure legend, the reader is referred to
the web version of this article.)

496
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

Fig. 4. Image processing: (a) RGB image, (b) Binary image after Otsu’s method, (c) Grain boundary image using Canny operator.

Fig. 5. Corner point detection with circular template and the CRF.

497
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

Fig. 6. Corner points detection using circular template with fixed radius: (a) Corner points detection using fixed-radius circular template. Concave points marked
with blue ‘o’ and convex points marked with red ‘+’, (b) Circular templates at position b’, (c) Circular templates at position e’, (d) Circular template at position c’, (e)
Circular template at position k’, (f) CRF along the boundary. Note that: In image (b), (c), (d) and (e), grain boundary pixels marked with green ‘*’, circular template
center marked with blue ‘o’, and circular template boundary marked with yellow ‘*’. (For interpretation of the references to colour in this figure legend, the reader is
referred to the web version of this article.)

are not correctly identified as concave points using the fix-radius cir- boundary that the center point located on.
cular template method. c' is supposed to be a local maximum of the CRF
curve, but it is detected as a non-local maximum. Although k' is a local 2.4.3. An improved adaptive-radius circular template method
maximum of the CRF curve, its CRF values is less than the 0.6 threshold. To alleviate the aforementioned problems related to using the fixed-
These are because when the circular template moves to c' and k', as radius circular template method for corner point detection, an im-
shown in Fig. 6d and e, parts from two different grains are within the proved corner point detection algorithm, which uses an adaptive-radius
circular template and the corresponding np value is the area that is circular template, is proposed. The radius of template adjusts adap-
enclosed by two separate boundaries, denoted as S0 and S1 in Fig. 6d tively according to local situation to ensure that only one continuous
and e. The abrupt changes in the CRF values at positions c' and k' do not grain boundary is within the template all the time. Thus, the np value
reflect abrupt changes in the curvature of the local segments of the corresponds to one area enclosed by one continuous grain boundary.

498
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

Fig. 7. Corner points detection using circular template with adaptive radius: (a) Corner points detection using adaptive-radius circular template. Concave points
marked with blue ‘o’ and convex points marked with red ‘+’, (b) The adaptive-radius circular templates at corner points, (c) The discontinuous boundaries S0 and S1
within circular template at position k, (d) The discontinuous boundaries S0 and S1 within circular template at position c, (f) CRF along the boundary. Note that: In
image (c) and (d), the initial radius template boundary marked with yellow ‘*’ and adaptive-radius template boundary marked with pink ‘*’. (For interpretation of the
references to colour in this figure legend, the reader is referred to the web version of this article.)

499
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

The change of CRF can accurately reflect the change of the grain The merge of over-segmentation regions is achieved using the fol-
boundary curvature. lowing steps:
The improved algorithm is applied to the same grain region in
Fig. 6a, as shown in Fig. 7a. The algorithm is described in details as (1) Firstly, corner points along the grain boundaries are identified by
follow. First, an initial value r is set as template radius, for example the improved corner point method using adaptive-radius circular
r = 5 which corresponds to a circular template with a radius of 5 pixels. template, and the coordinates of corner points are saved, as shown
Then, the radius of the circular template centered at p is adjusted as it in Fig. 8b. Closed regions in the image are then found by subtrac-
moves along the grain boundaries. If one continuous grain boundary is tion of binary image from the filled grain image obtained by the
within the template with radius r, the radius r is set as the initial value. hole filling algorithm (Soille, 2003). Holes coordinates are saved.
Otherwise, the radius adjusts to an appropriate value according to the (2) Secondly, the splitting lines images are obtained from the wa-
following rules. Among the n + 1 (n > 0) disjoint grain boundaries in tershed algorithm. Then the splitting lines images are skeletonized
the template with radius r, there is only one boundary that contains the (Liu et al., 2016) and the endpoints of the splitting lines are ex-
center point p, which is marked as S0 and categorized as Group1. Apart tracted, as shown in Fig. 8c. Coordinates of the endpoints are saved.
from S0, the other n discontinuous boundaries are categorized as (3) Next, the distances between each endpoint and all corner points are
Group2. These boundaries in Group2 are marked as S1, S2…Sn. In most calculated. Since that the CRF curve is smoothened, the end points
cases, there are two discontinuous grain boundaries in the template, of a correct splitting line might not coincide with a corner point
one boundary that contains the center point p is marked as S0 and the exactly. Therefore, if the distances between an endpoint and a
other boundary is in Group2 marked as S1, as shown in Fig. 7c and d. corner point is less than two pixels, the endpoint is considered to
The discontinuous boundaries can be obtained by applying the AND coincide with a corner point. Then, this endpoint is eliminated. As
operation on the grain boundary image and the circular template shown in Fig. 8d, the remaining over-splitting lines and their re-
image. The distances from the template center p to each point of the n maining endpoints are plotted together with the correct splitting
boundaries in Group2 are calculated, which are denoted as d1, d2…dm. lines.
m is the total number of pixels in all n boundaries. Among these dis- (4) Finally, the over-segmentation regions are merged. Two regions
tances, the minimum distance dmin = min(d1, d2…dm) is taken as the that share an identified over-splitting line are merged using mor-
appropriate radius of the circular template. Fig. 7b shows the adaptive phological close operation. Then the resulting merged regions are
radius of the circular templates at different corner points. added to the binary image, as shown in Fig. 8g.
Fig. 7a shows the results of the corner points detected by circular
templates with adaptive-radius, and Fig. 7f shows the corresponding
2.5. Classification of the under-segmentation regions based on BP neural
CRF curve along the boundary of the touching rice grain. Here, the
network
adaptive-radius template ensures that the np value is one area enclosed
by one grain boundary where the template center is located and the
After the previous segmentation and merging steps, there are under-
change of CRF is in accordance with the change of local boundary
segmentation regions left either because some correct splitting lines are
curvature. Thus, if a local maximum and the local minimum of CRF
not formed by the watershed algorithm, or because the correct splitting
satisfy the threshold condition, it can be correctly detected as concave
lines are misjudged as over-splitting lines. In the literatures, splitting
and convex point. Table 2 lists the CRF values and template radius
lines for under-segmentation regions are identified by concave point
when the fixed-radius and adaptive-radius methods are adopted in
pair search. Multiple criteria should be considered, and the algorithm is
Figs. 6a and 7a respectively.
complicated. In some cases, the splitting lines are formed under dif-
ferent criteria, the counting results are wrong. For example, as shown in
2.4.4. Merging of over-segmentation regions Fig. 9a, there are two cross-linking grains. After concave point pair
When multiple grains touch each other, concave or convex points search and the drawing of splitting lines, the counting results, as shown
occur at the touching points. As introduced in Section 2.4, the end- in Fig. 9b–d, are incorrect, which are three grains, three grains and four
points of splitting lines must be the corner points or holes in regions. In grains respectively.
this paper, the over-segmentation regions are identified by individual Regions formed by different number of rice grain vary in appear-
splitting lines. A splitting line, whose endpoints are holes or corner ance, which can be characterized by features such as area and corner
point, is identified as a correct splitting line. While a splitting line, point characteristics (Liu et al., 2017). Feature extracted from under-
whose endpoints are neither holes nor corner points, is identified as an segmentation grain regions, such as area, number of concave points and
over-segmentation line. The two grain regions that have the over- convex points and number of closed regions, are useful indicators for
splitting line are identified as over-segmented regions and merged into counting quantity of grains within. To exploit all available features for
one region using morphological operations. under-segmentation regions to achieve high accuracy counting result, a

Table 2
CRF values and template radius using the fixed-radius and adaptive-radius methods.
Circular template with fixed radius Circular template with adaptive radius

p radius/pixel np/pixel ap/pixel CRF(p) p radius/pixel np/pixel ap/pixel CRF (p)

a' 5 21 71 0.29 a 5 21 71 0.29


b' 5 50 71 0.71 b 2 6 11 0.54
c' 5 52 71 0.73 c 2 8 11 0.73
d' 5 53 71 0.75 d 2 8 11 0.77
e' 5 50 71 0.71 e 2 6 11 0.58
f' 5 25 71 0.35 f 5 25 71 0.35
g' 5 36 71 0.51 g 5 38 71 0.52
h' 5 42 71 0.6 h 2 7 11 0.65
i' 5 25 71 0.36 i 5 26 71 0.36
j' 5 26 71 0.37 j 5 27 71 0.38
k' 5 42 71 0.59 k 2 7 11 0.65

500
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

Fig. 8. Determining and merging of the over-segmentation regions: (a) Part of RGB image of seeding tray, (b) Watershed segmentation after image preprocessing, and
corner point detection, (c) Splitting lines and endpoints, (d) Over-splitting lines and their remaining endpoints, (e) Partial enlargement of image (c), (f) Partial
enlargement of image (d), (g) Merging result of over-segmentation regions. Note that endpoints of splitting lines marked with green ‘Δ’, convex points marked with
red ‘+’ and concave points marked with blue ‘o’. Part of the seeding tray was captured, and the shapes of grain regions that connected to image edges were irregular.
Therefore, these grain regions were eliminated. (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this
article.)

Back Propagation (BP) neural network classifier is employed to classify corner point step, the Otsu’s method and the Canny operator are first
the under-segmentation regions into five categories. Neural networks used to obtain grain boundary pixels. Since most of the regions are
can learn and model non-linear and complex relationships between the single-grain after watershed algorithm and the merging of over-seg-
input and output variable, and hence is suitable for the rice grain task. mentation regions, to speed up the algorithm, grain regions, whose area
Neural network classifiers have been previously implemented for grain is less than a certain threshold, are considered as one grain and ex-
quality inspection and variety classification (Chaugule and Mali, 2017, cluded from the under-segmentation classification step. The remaining
Kurtulmuş and Ünal, 2015). The neural network structure used in this regions are further classified and counted by the BP neural network.
study is a two-layer BP neural network. The number of input neurons is The threshold for identifying single-grain region is 1.2 times the
four, representing the four input features, including area, number of average of 500 single-grain areas for three hybrid rice varieties.
concave points, number of convex points, and number of closed regions.
The hidden layer is set to six neurons. The number of output neuron is
3. Results and analysis
five, corresponding to the five categories of under-segmentation re-
gions, including those containing one grain, two grains, three grains,
3.1. Performance of corner point detection methods
four grains, or more than four grains.
To demonstrate the performance of the proposed corner point al-
2.6. The overall process for segmentation and counting of touching hybrid gorithm, two seeding images of each hybrid rice variety were acquired
rice grains from the test system, and the performance of using fixed-radius and
adaptive-radius circular template method in separating touching grain
In conclusion, the complete process of separating and counting the are compared. After applying image preprocessing and watershed al-
touching grains is shown in Fig. 10, where the steps including image gorithm, the corner points along grains boundaries were detected using
preprocessing, watershed segmentation, merging over-segmentation the circular template with a fixed-radius and adaptive-radius, respec-
regions based on corner point detection, and classification of under- tively. Then, the over-segmentation regions were determined and
segmentation regions using BP neural network are demonstrated. In the merged. The results containing the number of concave and convex

Fig. 9. Error counting results after concave point pairs search.

501
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

Fig. 10. Block diagram of separation and counting the touching hybrid rice grains.

Table 3
Comparison results of corner point methods.
Hybrid rice Image No. Circular template with a fixed radius Circular template with adaptive radius

Number of Number of Number of Number of under Number of Number of Number of Number of


concave convex regions segmentation regions concave convex regions undersegmentation regions
points points merged left points points merged left

Taifengyou 208 1 232 965 461 58 450 1341 404 32


2 213 1020 445 48 414 956 383 27
Teyou338 1 273 1132 477 38 367 1116 440 20
2 252 1075 464 27 348 1060 432 15
Perzataifeng 1 244 954 324 50 351 939 286 33
2 203 907 408 32 284 898 385 19

Table 4
Grain regions classification result of Teyou 338.
Results Number of regions

1grain 2grains 3grains 4grains The others

Size of training set 2000 600 300 150 100


Size of test set 2852 691 349 204 108 Fig. 11. Two misclassified results.
Correct classification 2835 685 318 171 88
False classification 17 6 31 33 20
Classification accuracy/% 99.4 99.1 91.2 83.8 81.5 points, number of regions that merged, and under-segmentation regions
left to be counted are listed in Table 3.

Table 5
3.2. Classification results of grain regions based on BP neural network
Grain regions classification result of Peizataifeng.
Results Number of regions In this study, BP neural network was employed to classify and count
the number of rice grains in under-segmentation regions. To demon-
1grain 2grains 3grains 4grain The others
strate the classification accuracy, twenty-five seeding images of each
Size of training set 2300 650 275 150 150 hybrid rice variety were acquired from the test system. The single-grain
Size of test set 2327 650 283 146 155 regions, two-grain regions, three-grain regions, four-grain regions, and
Correct classification 2313 633 248 127 149 more than four grains regions were extracted. These five types of re-
False classification 14 17 35 19 27
Classification accuracy/% 93.2 99.4 97.4 87.6 87.0
gions were divided into a training set and a test set. Four feature
parameters, including area, number of concave points, number of
convex points, number of closed regions, were extracted automatically
Table 6 for each region, The BP neural network was first trained only using the
Grain regions classification result of Taifengyou 208. training set and later tested using the test set. Table 4–6 shows the
classification results on the test set for different hybrid rice varieties.
Results Number of regions
Overall, the mean classification accuracy was 91% for Teyou338,
1grain 2grains 3grains 4grain The others 92.92% for Peizataifeng and 93.2% for Taifengyou208. The overall
average accuracy of the three varieties was 92.4%.
Size of training set 2000 600 270 150 150 In general, the accuracy decreased a little when regions of more
Size of test set 1952 609 299 173 181
Correct classification 1949 599 265 140 178
than three grains are present. The more grains stick together, the more
False classification 3 10 34 33 3 complicate appearance they may have. For instance, grains are standing
Classification accuracy/% 99.8 98.4 88.6 80.9 98.3 upright or upper and lower overlapping after sowing process. Those
regions are inclined to be misclassified. As shown in Fig. 11, grain re-
gion1 has four grains stuck together with two of them heavily upper
and lower overlapping, therefore it is misclassified as three grains. In
another case, grain region2 has five grains. One of the grains is mil-
dewed and its color is similar to the soil (background), therefore grain

502
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

Table 7
Counting accuracy of the proposed method.
Peizataifeng Teyou338 Taifengyou208

1 2 3 1 2 3 1 2 3

Manual count 466 462 552 568 550 613 445 560 455
Proposed method 498 485 568 597 518 656 464 593 480
Accuary/% 93.13 95.02 97.1 94.89 94.18 92.98 95.73 94.10 94.50

Fig. 12. Segmentation and counting result of Teyou338: (a) RGB image of Teyou338, (b) After detection of corner point and endpoint of splitting line, over-splitting
lines left and marked with pink line, (c) Determining and merging of over-segmentation regions, (d) Classification result of under-segmentation regions.

region2 is misclassified as four grains. left were marked in pink. Merging results of the over-segmentation
regions were shown in Fig. 12c. The overall counting results were
3.3. Accuracy of the overall algorithm for segmentation and counting of shown in Fig. 12d. In this study, grain regions whose area is less than
touching rice grains 220 pixels were considered as single grain regions and filled with
yellow, as shown in Fig. 12d. These regions were counted and excluded
Finally, the overall accuracy of the proposed algorithm in seg- from the classification step. Then, the remaining regions were classified
menting and counting touching rice gains, which combined watershed using the BP neural network. Regions classified as one-grain region
algorithm, corner point detection and neural network classification, were filled with green. Regions classified as two-grain region were filled
was verified by manual counting. The proposed method was tested on with red, and regions classified as three-grain region were filled with
three RGB images for each of the three hybrid varieties, including blue.
Peizataifeng, Teyou338 and Taifengyou 208. Each RGB image con-
tained from 400 to 700 grains. The counting results of the proposed 3.4. Discussions
algorithm were compared to that of manual counting. The accuracy of
the proposed method was shown in Table 7, indicating that the average (1) From the test results of Table 3, corners point detection using
accuracy of three varieties was 94.63%. Fig. 12 showed the inter- adaptive-radius circular template has a better accuracy than that
mediate steps of separating and counting of touching grains. Fig. 12a using fixed-radius circular template. Fixed-radius circular template
showed one of the RGB seeding images of Teyou 338. Fig. 12b showed is likely to cause false or miss detection of corner points, resulting in
the image after the watershed segmentation. In Fig. 12b, after detection misjudging correct splitting lines as over-segmentation lines and
of corner point and end points of splitting lines, the over-splitting lines merging of wrong grain regions. From Table 3, the number of

503
S. Tan, et al. Computers and Electronics in Agriculture 162 (2019) 493–504

under-segmentation regions left after merging are significantly ellipse fitting. Pattern Recognit. https://doi.org/10.1016/j.patcog.2009.04.003.
lower when adaptive-radius template method used, despite that Bleau, A., Leon, L.J., 2000. Watershed-based segmentation and region merging. Comput.
Vis. Image Underst. https://doi.org/10.1006/cviu.1999.0822.
more regions are merged when the fixed-radius circular template Canny, J., 1986. A computational approach to edge detection. IEEE Trans. Pattern Anal.
method used. Therefore, the improved corner points method using Mach. Intell. https://doi.org/10.1109/TPAMI.1986.4767851.
adaptive-radius circular template improves the overall touching Chaugule, A., Mali, S.N., 2017. A new method using feature extraction for identifying
paddy rice species for quality seed selection. Imaging Sci. J. https://doi.org/10.1080/
rice grain segmentation and counting problem. 13682199.2017.1317901.
(2) The average classification accuracy of grain regions based on the BP Duan, L., Yang, W., Bi, K., Chen, S., Luo, Q., Liu, Q., 2011. Fast discrimination and
neural network was 92.4%. Table 4–6 showed that BP neural counting of filled/unfilled rice spikelets based on bi-modal imaging. Comput.
Electron. Agric. https://doi.org/10.1016/j.compag.2010.11.004.
classifier achieves high classification accuracy for regions of single- Grbić, R., Grahovac, D., Scitovski, R., 2016. A method for solving the multiple ellipses
grain, two-grains, and three-grains. The accuracy decreased when detection problem. Pattern Recognit. https://doi.org/10.1016/j.patcog.2016.06.031.
regions of more than three grains were present. In this paper, some He, H., You, C., Wu, H., Zhu, D., Yang, R., He, Q., Xu, L., Gui, W., Wu, L., 2018. Effects of
nursery tray and transplanting methods on rice yield. Agron. J. https://doi.org/10.
simple characteristics, such as area, corner points and hole, were
2134/agronj2017.06.0334.
used for classification. To improve the classification accuracy of Hobson, D.M., Carter, R.M., Yan, Y., 2009. Rule based concave curvature segmentation
regions of more than four grains, more characteristics would be for touching rice grains in binary digital images. In: 2009 IEEE Instrumentation and
explored, for example shape and texture. Measurement Technology Conference, I2MTC 2009, https://doi.org/10.1109/IMTC.
2009.5168727.
(3) In this study, the watershed algorithm and corner point detection Kim, S.E., Jeon, J.J., Eom, I.K., 2016. Image contrast enhancement using entropy scaling
were first applied to separate touching grain. Under-segmentation in wavelet domain. Signal Process. https://doi.org/10.1016/j.sigpro.2016.02.016.
grain regions that left mostly had less than three grains. Therefore, Kurtulmuş, F., Ünal, H., 2015. Discriminating rapeseed varieties using computer vision
and machine learning. Exp. Syst. Appl. https://doi.org/10.1016/j.eswa.2014.10.003.
the high classification accuracy of BP neural network for regions of Lin, P., Chen, Y.M., He, Y., Hu, G.W., 2014. A novel matching algorithm for splitting
less than three grains is suitable for our counting task for under- touching rice kernels based on contour curvature analysis. Comput. Electron. Agric.
segmentation regions. https://doi.org/10.1016/j.compag.2014.09.015.
Liu, T., Chen, W., Wang, Y., Wu, W., Sun, C., Ding, J., Guo, W., 2017. Rice and wheat
(4) The overall method proposed in this study can achieve an average grain counting method and software development based on android system. Comput.
accuracy of 94.63%, when verified by manual counting results. This Electron. Agric. https://doi.org/10.1016/j.compag.2017.08.011.
approach is prone to fail in detecting corner points where the Liu, T., Wu, W., Chen, W., Sun, C., Zhu, X., Guo, W., 2016a. Automated image-processing
for counting seedlings in a wheat field. Precis. Agric. https://doi.org/10.1007/
boundary curvature change is not obvious. To this end, further re- s11119-015-9425-6.
search will focus on developing corner point algorithm where the Liu, Z., Cheng, F., Zhang, W., 2016b. A novel segmentation algorithm for clustered
curvatures change is subtle or slow. flexional agricultural products based on image analysis. Comput. Electron. Agric.
https://doi.org/10.1016/j.compag.2016.05.009.
Mebatsion, H.K., Paliwal, J., 2011. A Fourier analysis based algorithm to separate
4. Conclusions touching kernels in digital images. Biosyst. Eng. https://doi.org/10.1016/j.
biosystemseng.2010.10.011.
In this paper, an accurate segmentation and counting algorithm for Otsu, N., 1979. A threshold selection method from gray-level histograms. IEEE Trans.
Syst. Man. Cybern. https://doi.org/10.1109/TSMC.1979.4310076.
touching hybrid rice grains was proposed. The algorithm separates and Qin, Y., Wang, W., Liu, W., Yuan, N., 2013. Extended-maxima transform watershed
counts touching rice grains based on the watershed segmentation al- segmentation algorithm for touching corn kernels. Adv. Mech. Eng. https://doi.org/
gorithm, an improved corner point algorithm and a BP neural network 10.1155/2013/268046.
Soille, P., 2003. Morphological image analysis: principles and applications. Comput.
classification algorithm. The proposed algorithm was tested for three Simul. Stud. https://doi.org/10.1007/978-3-662-05088-0.
hybrid rice varieties with different realistic touching scenarios formed Visen, N.S., Shashidhar, N.S., Paliwal, J., Jayas, D.S., 2001. Identification and segmen-
in the sowing process. The proposed method achieved an average ac- tation of occluding groups of grain kernels in a grain sample image. J. Agric. Eng. Res.
https://doi.org/10.1006/jaer.2000.0690.
curacy of 94.63%, compared to the manual counting results. The pro- Wang, H., Zhang, H., Ray, N., 2012. Clump splitting via bottleneck detection and shape
posed method has the potential to improve the precise evaluation of classification. Pattern Recognit. https://doi.org/10.1016/j.patcog.2011.12.020.
seeding performance and be used in actual agricultural production, Wang, W., Paliwal, J., 2006. Separation and identification of touching kernels and
dockage components in digital images. Can. Biosyst. Eng. / Le Genie des Biosyst. au
once integrated into the automatic rice grain seeding and sowing pi-
Canada.
peline developed in our research group. Wang, Y.C., Chou, J.J., 2004. Automatic segmentation of touching rice kernels with an
active contour model. Trans. ASAE 47, 1803–1811.
Yao, Y., Wu, W., Yang, T., Liu, T., Chen, W., Chen, C., Li, R., Zhou, T., Sun, C., Zhou, Y., Li,
Acknowledgements
X., 2017. Head rice rate measurement based on concave point matching. Sci. Rep.
https://doi.org/10.1038/srep41353.
The authors gratefully acknowledge the financial support from the Zhan, Z., Yafang, W., Jianjun, Y., Zhong, T., 2015. Monitoring method of rice seeds mass
National Key Research and Development Program of China (Grant No. in vibrating tray for vacuum-panel precision seeder. Comput. Electron. Agric. https://
doi.org/10.1016/j.compag.2015.03.007.
2017YFD0700802); the National Natural Science Foundation of China Zhang, G., Jayas, D.S., White, N.D.G., 2005. Separation of touching grain kernels in an
(Grant No. 51675188); the Earmarked Fund for Modern Agro-industry image by ellipse fitting algorithm. Biosyst. Eng. https://doi.org/10.1016/j.
Technology Research System (Grant No. CARS-01-43); the PHD Start- biosystemseng.2005.06.010.
Zhang, W., Li, H., 2017. Automated segmentation of overlapped nuclei using concave
up Fund of the Natural Science Foundation of Guangdong Province of point detection and segment grouping. Pattern Recognit. https://doi.org/10.1016/j.
China (Grant No. 2017A030310354), and the China Scholarship patcog.2017.06.021.
Council. Zhong, Q., Zhou, P., Yao, Q., Mao, K., 2009. A novel segmentation algorithm for clustered
slender-particles. Comput. Electron. Agric. https://doi.org/10.1016/j.compag.2009.
06.015.
References

Bai, X., Sun, C., Zhou, F., 2009. Splitting touching cells based on concave points and

504

You might also like