# Evaluation of Texture and Shape Features for Classification of Four Paddy Varieties

Authors: Archana Chaugule; Suresh N. Mali
Journal: Journal of Engineering
 (2014)

---

## Abstract

This research is aimed at evaluating the texture and shape features using the most commonly used neural network architectures for cereal grain classification. An evaluation of the classification accuracy of texture and shape features and neural network was done to classify four Paddy (rice) grains, namely, Karjat-6(K6), Ratnagiri-2(R2), Ratnagiri-4(R4), and Ratnagiri-24(R24). Algorithms were written to extract the features from the high-resolution images of kernels of four grain types and used as input features for classification. Different feature models were tested for their ability to classify these cereal grains. Effect of using different parameters on the accuracy of classification was studied. The most suitable feature from the features for accurate classification was identified. The shape feature set outperformed the texture feature set in almost all the instances of classification.


---

## Body

## 1. Introduction

The application of computer vision technologies along with capturing, processing, and analyzing images can be effectively used in nondestructive assessment of visual quality characteristics in agricultural and food products Chaugule and Mali [1]. Seed image analysis includes the techniques of acquisition, preprocessing, and interpretation, resulting in quantification and classification of seeds. The objective of this research is to identify and classify grain kernels of four paddy types to minimize the losses incurred during harvesting, production, and marketing by sowing proper type of seeds in the farm.Grain kernels considered as agricultural objects are of variable sizes, shapes, colors, and textures. The accuracy of the classifying algorithm depends on the extracted features which can be further processed to identify the class of the seed. The precision of computer vision can further be exploited to detect the seeds infected by insects or to detect damaged grain kernels. This process of perfectly classified seeds without any damage or infections is essential to increase the productivity of specific grains.


## 2. Related Work

Substantial work in seed texture and shape feature extraction using image processing has been carried out under the application of computer vision in agriculture.Granitto et al. [2, 3] extracted features corresponding to morphology of the weed seeds. The final six parameters that were selected for classification were ratio of semiaxis lengths of the main principal axis [
h
1
/
h
2
], ratio of seed and enclosing box areas [
A
/
(
h
1
+
h
2
)
×
(
v
1
+
v
2
)
], square root of seed area [SQRT(A)], and moments of the planar mass distribution with respect to the principal axes [
M
20
,
M
21, and M
22
]. Also features corresponding to textural characteristics of the weed seeds were extracted. Two different matrices, gray level cooccurrence matrix and gray level run-length matrix, were used to describe seed surface texture. The final two parameters selected for classification were contrast along the main principal axis direction and cluster prominence along the secondary principal axis direction. Chen et al. [4] found a total of 30 morphological features to be extracted for identifying corn varieties.Zhao et al. [5] extracted the 11 geometric features of corn kernels based on binary image including contour points, perimeter, area, circular degrees, equivalent diameter, major length, minor length, stretching of the length of the rectangle, maximum inscribed circle, and the smallest excircle. Texture features such as mean, variance, smoothness, third moment, consistency, entropy, and 7 statistical invariant moments from the gray image were obtained. Kiratiratanapruk and Sinthupinyo [6] adopted texture features such as energy, contrast, correlation, and homogeneity based on gray level cooccurrence matrix (GLCM) and local binary pattern (LBP) for corn image classification.Paliwal et al. [7] extracted area, perimeter, major axis length, minor axis length, elongation, roundness, the Feret diameter, and compactness features. Shouche et al. [8] extracted geometric features and shape related features described by moments for feature analysis of the cereal grains. Geometry related features including area, perimeter, major and minor axis lengths, compactness, axis ratio, shape factor 1 to shape factor 5, and spread and slenderness were measured from the binary images. Standard or raw, central, normalized central, and invariant moments were computed from the digital images of each grain and mean, standard deviation (S.D.), and standard error (S.E.) were calculated. Standard moments m
00, m
10, m
20, m
02, m
30, and m
12; central moments like mu00, mu20, mu02, and mu30; normalized central moments nu20, nu02, and nu30; and invariant moments M
1
,
M
2
,
M
3, and M
4 all showed coefficients of variation below 5%. The other moments showed higher coefficients of variation. Visen et al. [9] used eight morphological features, namely, area, perimeter, length of major axis, length of minor axis, elongation, roundness, the Feret diameter, and compactness.Paliwal et al. [10] extracted area, perimeter, major axis length, minor axis length, maximum radius, minimum radius, mean radius, four invariant shape moments, and 20 harmonics of Fourier descriptors Gonzalez et al. [11] Fourier descriptors were calculated for boundary pixels as well as radii. Also eight gray level cooccurrence matrix (GLCM) and six gray level run-length matrix (GLRM) models as textural features were extracted. Paliwal et al. [12] extracted 51 morphological and 56 textural features. Dubey et al. [13] used the 45 morphometric parameters. Singh et al. [14] extracted the morphological features from grain kernels. Also the textural features were derived from the gray level cooccurrence matrix (GLCM) and gray level run-length matrix (GLRM). Pourreza et al. [15] extracted 131 textural features, including 32 gray level textural features, 31 LBP features, 31 LSP features, 15 LSN, and 10 gray level cooccurrence matrix (GLCM) and 12 gray level run-length matrix (GLRM) models for each monochrome image of the bulk wheat samples.Wiwart et al. [16] determined the following descriptors for the image of each wheat kernel represented by a single blob (ROI—region of interest): area, perimeter, circularity, the Feret diameter, minimal Feret diameter, aspect ratio, roundness, and solidity. Huang [17] calculated a pair of orthogonal eigenvectors of the covariance matrix. The geometric features, the principle axis length (Lp), secondary axis (Ls), the centroid, axis number (Lp/Ls), area (A), perimeter (P), and compactness (
4
π
A
/
P
2
) were computed using eigenvectors for areca nuts. Li et al. [18] extracted fourteen shape characteristic parameters of cottonseeds: the area, perimeter, NCI ratio, circular degree, center of gravity X, center of gravity Y, major diameter, short diameter, second moment X
(
M
x
2
), second moment Y
(
M
y
2
), second moment X
Y
(
M
x
y
), major axis of oval, short axis of oval, and shape coefficient of oval.Adjemout et al. [19] found the recognition procedure on the basis of shape features separately for corn,oats, barley, and lentil. 15 shape features, the perimeter, the surface, the circularity, major axis, minor axis, Hu’s moments, and central moments of second order, were calculated from the preprocessed images. Spatial gray level dependence method was used for extracting texture features such as second angular moment (SAM) which gives information about the homogeneity of texture, contrast (CONT) which measures the local variation of texture and supports the great transitions from the gray levels, entropy (ENT) which evaluates the degree of organization of the pixels, variance (VAR), differential inverse moment (IM), and correlation (COR).Mebatsion et al. [20] determined three geometric features, namely, aspect ratio (AR), major diameter (MD), and roundness (Ceq), using ellipse fitting and Green’s transformation of curve integrals, respectively. The geometric characteristics of individual, nontouching grain kernels were estimated after the transformation of digital images to representative polygons defined by coordinates on the natural boundary of grain kernels. The morphological classification model was defined using SFX, AR, MD, and Ceq.


## 3. Proposed Methodology

The block diagram for the proposed methodology is as shown in Figure1. The steps are as follows.Figure 1
Block diagram.


### 3.1. Material and Grain Samples

Sony make 18.9 megapixels digital camera, black cloth sheet for background, and photographs of the paddy seeds. The Seed Testing Laboratory Pune, India, provided the grain samples used in this study. The unclean commercial samples of four paddy grains, K6, R2, R4, and R24, were collected.


### 3.2. Image Capturing

The images were acquired using the above specified digital camera from different distances. Randomly any numbers of seeds were placed on the black background with the kernels not touching each other. The sample images and number of seeds for the specific type are shown in Table1.Table 1
Type of different variety of grains and Number of seeds.
Type of seed
Number of seeds
1919
1863
1780
3417


### 3.3. Image Preprocessing

The image analysis software was developed in Matlab version 7.12.0.635 (R2011a). In order to extract object features, image segmentation and any necessary morphological filtering were done. A total of sixty-four features which included twenty texture features and forty-four shape features were extracted by the algorithm and then used for evaluating the performance and the obtained statistics were fed to ANN classifier.


### 3.4. Feature Extraction

#### 3.4.1. Texture Features Extraction

Texture consists of texture primitives, texels, which are a contiguous set of pixels with some tonal and/or regional property. Texture can be characterized by intensity (color) properties of texels and structure spatial relationships of texels. Textures are highly scale dependent. Texture features are categorized as statistical/structural and syntactical. In statistical texture analysis, texture features are computed from the statistical distribution of observed combinations of intensities at specified positions relative to each other in the image. According to the number of intensity points (pixels) in each combination, statistics are classified into first-order, second-order, and higher-order statistics.(a) Second-Order Statistics Features. First-order statistics features provide information related to gray level distribution of the image but not about relative position of the various gray levels within image. Second-order statistics features do this where pixels are considered in pairs. Two parameters or more, such as relative distance and the orientation among the pixels, are used.(b) Gray Level Cooccurrence Matrices. The gray level cooccurrence matrix (GLCM) method is a way of extracting second-order statistical texture features. The GLCM gives information about the distribution of gray level intensities. A GLCM is a matrix where the number of rows and columns is equal to the number of gray levels, G, in the image. The matrix element P
(
i
,
j
∣
Δ
x
,
Δ
y
) is the relative frequency with which two pixels, separated by a pixel distance (
Δ
x
,
Δ
y
), occur within a given neighborhood, one with intensity i and the other with intensity j. One may also say that the matrix element P
(
i
,
j
∣
d
,
θ
) contains the second-order statistical probability values for changes between gray levels i and j at a particular displacement distance d and at a particular angle (
θ
). The image features derived from the GLCM are contrast, correlation, energy, homogeneity, and entropy which are explained below are taken from [11].(
1) Contrast. This is also called sum of squares variance. This measure of contrast or local intensity variation will favour contributions from P
(
i
,
j
) away from the diagonal; that is, i
≠
j. It is a measure of the intensity contrast between a pixel and its neighbor over the whole image. The value is 0 for a constant image.Contrast equation:
(1)
CTR
=
∑
n
=
0
G
-
1
n
2
{
∑
i
=
1
G
∑
j
=
1
G
P
(
i
,
j
)
}
,
|
i
-
j
|
=
n
.
When i and j are equal, the cell is on the diagonal and (
i
-
j
)
=
0. These values represent pixels entirely similar to their neighbor, so they are given a weight of 0. If i and j differ by 1, there is a small contrast, and the weight is 1. If i and j differ by 2, contrast is increasing and the weight is 4. The weights continue to increase exponentially as (
i
-
j
) increases.(
2) Correlation. Correlation is a measure of gray level linear dependence between the pixels at the specified positions relative to each other. It is a measure of how correlated a pixel is to its neighbor over the whole image. The range of correlation is in [
-
1
1
]. Correlation is 1 or −1 for a perfectly positively or negatively correlated image. Correlation is NaN for a constant image.Correlation equation:
(2)
COR
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
i
-
μ
i
)
(
j
-
μ
j
)
P
(
i
,
j
)
σ
i
σ
j
,
μ
i
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
i
P
(
i
,
j
)
,
σ
i
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
i
-
μ
i
)
2
P
(
i
,
j
)
,
μ
j
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
j
P
(
i
,
j
)
,
σ
j
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
j
-
μ
j
)
2
P
(
i
,
j
)
.(
3) Energy. Energy returns the sum of squared elements in the GLCM. The range is in [
0
1
]. Energy is 1 for a constant image.Energy equation:
(3)
Energy
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
{
P
(
i
,
j
)
}
2
.(
4) Homogeneity. Homogeneity returns a value that measures the closeness of the distribution of elements in the GLCM to the GLCM diagonal. The range is in [
0
1
]. Homogeneity is 1 for a diagonal GLCM.Homogeneity equation:
(4)
Homogeneity
=
∑
i
G
-
1
∑
j
G
-
1
P
(
i
,
j
)
1
+
|
i
-
j
|
.(
5) Entropy. Homogeneous scene has high entropy while inhomogeneous scenes have a low first-order entropy. Maximum entropy is reached when all probabilities are equal.Entropy equation:
(5)
Entropy
=
-
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
P
(
i
,
j
)
×
log
⁡
(
P
(
i
,
j
)
)
.
To study the effect of parameters on the classification ability of the ANN, twenty texture features concerning five features described above for all the four offsets were used for classifying the grains in four categories. To specify the distance between the pixel of interest and its neighbor, offset (the relationship, of a pair of pixels) is used. The offset is expressed as an angle. Figure 2 illustrates the offset values that specify common angles, given the pixel distance; the distance specified here is 1 from the center pixel. Consider
(6)
Offset
=
{
[
0
1
]
for
(
0
°
)
;
[
-
1
1
]
for
(
45
°
)
;
[
-
1
0
]
for
(
90
°
)
;
[
-
1
-
1
]
for
(
135
°
)
}
.Figure 2
Offset values.


#### 3.4.2. Shape Features Extraction

For a set of complete and compact descriptors to characterize the seeds algorithms were written to extract region descriptors. Region descriptors characterize an arrangement of pixels within the area. There are actually many techniques that can be used to obtain region descriptors of an object. Here, we have extracted two forms of region descriptors: basic descriptors (geometric features) and statistical descriptors (shape related features) defined by moments.Feature analysis of grains include extraction of a total of eight geometric features, five shape factors, ten standard moments, seven central moments (μ), seven invariant moments (φ), and seven normalized central moments from the high-resolution images of kernels of paddy grains. Geometric descriptors include area, perimeter, major axis length, minor axis length, axis ratio, and compactness. From the values of axis length, perimeter, and area, shape factors 1–5 were derived, as described in [8, 21]:
(7)
Shape
factor
1
=
1
compactness
,
Shape
factor
2
=
Major
axis
length
Area
,
Shape
factor
3
=
Area
Major
axis
length
3
,
Shape
factor
4
=
Area
(
Major
axis
length
/
2
)
(
Major
axis
length
/
2
)
π
,
Shape
factor
5
=
Area
(
Major
axis
length
/
2
)
(
Minor
axis
length
/
2
)
π
.
Moments include standard, central, normalized central, and invariant moments. Moments were also used to find the spread and slenderness of individual grains according to Hu [22]. However, moments include ten standard moments m
00
,
m
01
,
m
10
,
m
02
,
m
20
,
m
03
,
m
30
,
m
11
,
m
12, and m
21, seven central moments μ
11
,
μ
02
,
μ
20
,
μ
03
,
μ
30
,
μ
12, and μ
21, seven normalized central moments η
11
,
η
02
,
η
20
,
η
03
,
η
30
,
η
12, and η
21, and seven invariant moments φ
1, φ
2, φ
3, φ
4, φ
5, φ
6, and φ
7. Standard formulae from [11, 23] were used to calculate the moments. Moments describe a shape’s layout (the arrangement of its pixels), a bit like combining area, compactness, irregularity, and higher-order descriptions together [24].The above sixty-four features are used to study their effect on the classification ability of the ANN.


## 3.1. Material and Grain Samples

Sony make 18.9 megapixels digital camera, black cloth sheet for background, and photographs of the paddy seeds. The Seed Testing Laboratory Pune, India, provided the grain samples used in this study. The unclean commercial samples of four paddy grains, K6, R2, R4, and R24, were collected.


## 3.2. Image Capturing

The images were acquired using the above specified digital camera from different distances. Randomly any numbers of seeds were placed on the black background with the kernels not touching each other. The sample images and number of seeds for the specific type are shown in Table1.Table 1
Type of different variety of grains and Number of seeds.
Type of seed
Number of seeds
1919
1863
1780
3417


## 3.3. Image Preprocessing

The image analysis software was developed in Matlab version 7.12.0.635 (R2011a). In order to extract object features, image segmentation and any necessary morphological filtering were done. A total of sixty-four features which included twenty texture features and forty-four shape features were extracted by the algorithm and then used for evaluating the performance and the obtained statistics were fed to ANN classifier.


## 3.4. Feature Extraction

### 3.4.1. Texture Features Extraction

Texture consists of texture primitives, texels, which are a contiguous set of pixels with some tonal and/or regional property. Texture can be characterized by intensity (color) properties of texels and structure spatial relationships of texels. Textures are highly scale dependent. Texture features are categorized as statistical/structural and syntactical. In statistical texture analysis, texture features are computed from the statistical distribution of observed combinations of intensities at specified positions relative to each other in the image. According to the number of intensity points (pixels) in each combination, statistics are classified into first-order, second-order, and higher-order statistics.(a) Second-Order Statistics Features. First-order statistics features provide information related to gray level distribution of the image but not about relative position of the various gray levels within image. Second-order statistics features do this where pixels are considered in pairs. Two parameters or more, such as relative distance and the orientation among the pixels, are used.(b) Gray Level Cooccurrence Matrices. The gray level cooccurrence matrix (GLCM) method is a way of extracting second-order statistical texture features. The GLCM gives information about the distribution of gray level intensities. A GLCM is a matrix where the number of rows and columns is equal to the number of gray levels, G, in the image. The matrix element P
(
i
,
j
∣
Δ
x
,
Δ
y
) is the relative frequency with which two pixels, separated by a pixel distance (
Δ
x
,
Δ
y
), occur within a given neighborhood, one with intensity i and the other with intensity j. One may also say that the matrix element P
(
i
,
j
∣
d
,
θ
) contains the second-order statistical probability values for changes between gray levels i and j at a particular displacement distance d and at a particular angle (
θ
). The image features derived from the GLCM are contrast, correlation, energy, homogeneity, and entropy which are explained below are taken from [11].(
1) Contrast. This is also called sum of squares variance. This measure of contrast or local intensity variation will favour contributions from P
(
i
,
j
) away from the diagonal; that is, i
≠
j. It is a measure of the intensity contrast between a pixel and its neighbor over the whole image. The value is 0 for a constant image.Contrast equation:
(1)
CTR
=
∑
n
=
0
G
-
1
n
2
{
∑
i
=
1
G
∑
j
=
1
G
P
(
i
,
j
)
}
,
|
i
-
j
|
=
n
.
When i and j are equal, the cell is on the diagonal and (
i
-
j
)
=
0. These values represent pixels entirely similar to their neighbor, so they are given a weight of 0. If i and j differ by 1, there is a small contrast, and the weight is 1. If i and j differ by 2, contrast is increasing and the weight is 4. The weights continue to increase exponentially as (
i
-
j
) increases.(
2) Correlation. Correlation is a measure of gray level linear dependence between the pixels at the specified positions relative to each other. It is a measure of how correlated a pixel is to its neighbor over the whole image. The range of correlation is in [
-
1
1
]. Correlation is 1 or −1 for a perfectly positively or negatively correlated image. Correlation is NaN for a constant image.Correlation equation:
(2)
COR
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
i
-
μ
i
)
(
j
-
μ
j
)
P
(
i
,
j
)
σ
i
σ
j
,
μ
i
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
i
P
(
i
,
j
)
,
σ
i
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
i
-
μ
i
)
2
P
(
i
,
j
)
,
μ
j
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
j
P
(
i
,
j
)
,
σ
j
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
j
-
μ
j
)
2
P
(
i
,
j
)
.(
3) Energy. Energy returns the sum of squared elements in the GLCM. The range is in [
0
1
]. Energy is 1 for a constant image.Energy equation:
(3)
Energy
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
{
P
(
i
,
j
)
}
2
.(
4) Homogeneity. Homogeneity returns a value that measures the closeness of the distribution of elements in the GLCM to the GLCM diagonal. The range is in [
0
1
]. Homogeneity is 1 for a diagonal GLCM.Homogeneity equation:
(4)
Homogeneity
=
∑
i
G
-
1
∑
j
G
-
1
P
(
i
,
j
)
1
+
|
i
-
j
|
.(
5) Entropy. Homogeneous scene has high entropy while inhomogeneous scenes have a low first-order entropy. Maximum entropy is reached when all probabilities are equal.Entropy equation:
(5)
Entropy
=
-
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
P
(
i
,
j
)
×
log
⁡
(
P
(
i
,
j
)
)
.
To study the effect of parameters on the classification ability of the ANN, twenty texture features concerning five features described above for all the four offsets were used for classifying the grains in four categories. To specify the distance between the pixel of interest and its neighbor, offset (the relationship, of a pair of pixels) is used. The offset is expressed as an angle. Figure 2 illustrates the offset values that specify common angles, given the pixel distance; the distance specified here is 1 from the center pixel. Consider
(6)
Offset
=
{
[
0
1
]
for
(
0
°
)
;
[
-
1
1
]
for
(
45
°
)
;
[
-
1
0
]
for
(
90
°
)
;
[
-
1
-
1
]
for
(
135
°
)
}
.Figure 2
Offset values.


### 3.4.2. Shape Features Extraction

For a set of complete and compact descriptors to characterize the seeds algorithms were written to extract region descriptors. Region descriptors characterize an arrangement of pixels within the area. There are actually many techniques that can be used to obtain region descriptors of an object. Here, we have extracted two forms of region descriptors: basic descriptors (geometric features) and statistical descriptors (shape related features) defined by moments.Feature analysis of grains include extraction of a total of eight geometric features, five shape factors, ten standard moments, seven central moments (μ), seven invariant moments (φ), and seven normalized central moments from the high-resolution images of kernels of paddy grains. Geometric descriptors include area, perimeter, major axis length, minor axis length, axis ratio, and compactness. From the values of axis length, perimeter, and area, shape factors 1–5 were derived, as described in [8, 21]:
(7)
Shape
factor
1
=
1
compactness
,
Shape
factor
2
=
Major
axis
length
Area
,
Shape
factor
3
=
Area
Major
axis
length
3
,
Shape
factor
4
=
Area
(
Major
axis
length
/
2
)
(
Major
axis
length
/
2
)
π
,
Shape
factor
5
=
Area
(
Major
axis
length
/
2
)
(
Minor
axis
length
/
2
)
π
.
Moments include standard, central, normalized central, and invariant moments. Moments were also used to find the spread and slenderness of individual grains according to Hu [22]. However, moments include ten standard moments m
00
,
m
01
,
m
10
,
m
02
,
m
20
,
m
03
,
m
30
,
m
11
,
m
12, and m
21, seven central moments μ
11
,
μ
02
,
μ
20
,
μ
03
,
μ
30
,
μ
12, and μ
21, seven normalized central moments η
11
,
η
02
,
η
20
,
η
03
,
η
30
,
η
12, and η
21, and seven invariant moments φ
1, φ
2, φ
3, φ
4, φ
5, φ
6, and φ
7. Standard formulae from [11, 23] were used to calculate the moments. Moments describe a shape’s layout (the arrangement of its pixels), a bit like combining area, compactness, irregularity, and higher-order descriptions together [24].The above sixty-four features are used to study their effect on the classification ability of the ANN.


## 3.4.1. Texture Features Extraction

Texture consists of texture primitives, texels, which are a contiguous set of pixels with some tonal and/or regional property. Texture can be characterized by intensity (color) properties of texels and structure spatial relationships of texels. Textures are highly scale dependent. Texture features are categorized as statistical/structural and syntactical. In statistical texture analysis, texture features are computed from the statistical distribution of observed combinations of intensities at specified positions relative to each other in the image. According to the number of intensity points (pixels) in each combination, statistics are classified into first-order, second-order, and higher-order statistics.(a) Second-Order Statistics Features. First-order statistics features provide information related to gray level distribution of the image but not about relative position of the various gray levels within image. Second-order statistics features do this where pixels are considered in pairs. Two parameters or more, such as relative distance and the orientation among the pixels, are used.(b) Gray Level Cooccurrence Matrices. The gray level cooccurrence matrix (GLCM) method is a way of extracting second-order statistical texture features. The GLCM gives information about the distribution of gray level intensities. A GLCM is a matrix where the number of rows and columns is equal to the number of gray levels, G, in the image. The matrix element P
(
i
,
j
∣
Δ
x
,
Δ
y
) is the relative frequency with which two pixels, separated by a pixel distance (
Δ
x
,
Δ
y
), occur within a given neighborhood, one with intensity i and the other with intensity j. One may also say that the matrix element P
(
i
,
j
∣
d
,
θ
) contains the second-order statistical probability values for changes between gray levels i and j at a particular displacement distance d and at a particular angle (
θ
). The image features derived from the GLCM are contrast, correlation, energy, homogeneity, and entropy which are explained below are taken from [11].(
1) Contrast. This is also called sum of squares variance. This measure of contrast or local intensity variation will favour contributions from P
(
i
,
j
) away from the diagonal; that is, i
≠
j. It is a measure of the intensity contrast between a pixel and its neighbor over the whole image. The value is 0 for a constant image.Contrast equation:
(1)
CTR
=
∑
n
=
0
G
-
1
n
2
{
∑
i
=
1
G
∑
j
=
1
G
P
(
i
,
j
)
}
,
|
i
-
j
|
=
n
.
When i and j are equal, the cell is on the diagonal and (
i
-
j
)
=
0. These values represent pixels entirely similar to their neighbor, so they are given a weight of 0. If i and j differ by 1, there is a small contrast, and the weight is 1. If i and j differ by 2, contrast is increasing and the weight is 4. The weights continue to increase exponentially as (
i
-
j
) increases.(
2) Correlation. Correlation is a measure of gray level linear dependence between the pixels at the specified positions relative to each other. It is a measure of how correlated a pixel is to its neighbor over the whole image. The range of correlation is in [
-
1
1
]. Correlation is 1 or −1 for a perfectly positively or negatively correlated image. Correlation is NaN for a constant image.Correlation equation:
(2)
COR
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
i
-
μ
i
)
(
j
-
μ
j
)
P
(
i
,
j
)
σ
i
σ
j
,
μ
i
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
i
P
(
i
,
j
)
,
σ
i
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
i
-
μ
i
)
2
P
(
i
,
j
)
,
μ
j
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
j
P
(
i
,
j
)
,
σ
j
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
(
j
-
μ
j
)
2
P
(
i
,
j
)
.(
3) Energy. Energy returns the sum of squared elements in the GLCM. The range is in [
0
1
]. Energy is 1 for a constant image.Energy equation:
(3)
Energy
=
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
{
P
(
i
,
j
)
}
2
.(
4) Homogeneity. Homogeneity returns a value that measures the closeness of the distribution of elements in the GLCM to the GLCM diagonal. The range is in [
0
1
]. Homogeneity is 1 for a diagonal GLCM.Homogeneity equation:
(4)
Homogeneity
=
∑
i
G
-
1
∑
j
G
-
1
P
(
i
,
j
)
1
+
|
i
-
j
|
.(
5) Entropy. Homogeneous scene has high entropy while inhomogeneous scenes have a low first-order entropy. Maximum entropy is reached when all probabilities are equal.Entropy equation:
(5)
Entropy
=
-
∑
i
=
0
G
-
1
∑
j
=
0
G
-
1
P
(
i
,
j
)
×
log
⁡
(
P
(
i
,
j
)
)
.
To study the effect of parameters on the classification ability of the ANN, twenty texture features concerning five features described above for all the four offsets were used for classifying the grains in four categories. To specify the distance between the pixel of interest and its neighbor, offset (the relationship, of a pair of pixels) is used. The offset is expressed as an angle. Figure 2 illustrates the offset values that specify common angles, given the pixel distance; the distance specified here is 1 from the center pixel. Consider
(6)
Offset
=
{
[
0
1
]
for
(
0
°
)
;
[
-
1
1
]
for
(
45
°
)
;
[
-
1
0
]
for
(
90
°
)
;
[
-
1
-
1
]
for
(
135
°
)
}
.Figure 2
Offset values.


## 3.4.2. Shape Features Extraction

For a set of complete and compact descriptors to characterize the seeds algorithms were written to extract region descriptors. Region descriptors characterize an arrangement of pixels within the area. There are actually many techniques that can be used to obtain region descriptors of an object. Here, we have extracted two forms of region descriptors: basic descriptors (geometric features) and statistical descriptors (shape related features) defined by moments.Feature analysis of grains include extraction of a total of eight geometric features, five shape factors, ten standard moments, seven central moments (μ), seven invariant moments (φ), and seven normalized central moments from the high-resolution images of kernels of paddy grains. Geometric descriptors include area, perimeter, major axis length, minor axis length, axis ratio, and compactness. From the values of axis length, perimeter, and area, shape factors 1–5 were derived, as described in [8, 21]:
(7)
Shape
factor
1
=
1
compactness
,
Shape
factor
2
=
Major
axis
length
Area
,
Shape
factor
3
=
Area
Major
axis
length
3
,
Shape
factor
4
=
Area
(
Major
axis
length
/
2
)
(
Major
axis
length
/
2
)
π
,
Shape
factor
5
=
Area
(
Major
axis
length
/
2
)
(
Minor
axis
length
/
2
)
π
.
Moments include standard, central, normalized central, and invariant moments. Moments were also used to find the spread and slenderness of individual grains according to Hu [22]. However, moments include ten standard moments m
00
,
m
01
,
m
10
,
m
02
,
m
20
,
m
03
,
m
30
,
m
11
,
m
12, and m
21, seven central moments μ
11
,
μ
02
,
μ
20
,
μ
03
,
μ
30
,
μ
12, and μ
21, seven normalized central moments η
11
,
η
02
,
η
20
,
η
03
,
η
30
,
η
12, and η
21, and seven invariant moments φ
1, φ
2, φ
3, φ
4, φ
5, φ
6, and φ
7. Standard formulae from [11, 23] were used to calculate the moments. Moments describe a shape’s layout (the arrangement of its pixels), a bit like combining area, compactness, irregularity, and higher-order descriptions together [24].The above sixty-four features are used to study their effect on the classification ability of the ANN.


## 4. Artificial Neural Network Architectures

Artificial neural network (ANN) classifier is emerging as the best suited classifiers for pattern recognition which are regarded as an extension of many classification techniques. They are based on the concept of biological nervous system. NNs explore many hypotheses simultaneously using massive parallelism instead of sequentially performing a programme of instructions.Pattern classification was done using a two-layer (i.e., one-hidden-layer) backpropagation supervised neural network with a single hidden layer of 20 neurons with Levenberg-Marquardt training functions. A backpropagation network (BPN) consists of an input layer, one or more hidden layers, and an output layer and has ability to generalize. The number of neurons was varied to see any significant improvement in performance. As no improvement was observed, the number of neurons as 20 was used to train the network. The choice of the BPN classifier was based on previous research conducted in [4]. The transfer function used was tangent sigmoid. The data division function divided the targets into three sets, Training (70%), Validation (15%), and Testing (15%), using random indices. The feature vectors were split into Training and Testing sets. The accuracy was computed on Testing set. The trained neural network was tested with the testing samples to find how well the network will do when applied to data from the real world. One measure to find how well the neural network has fit the data, the confusion matrix, was plotted across all samples. The sixty-four features were used as inputs to a neural network and the type of the seed was used as target. Given an input, which constitutes the features of a seed, the neural network is expected to identify the type of the seed which is achieved by neural network training. Figure 3 shows the ANN topology.Figure 3
ANN topology:x
i is the xth input feature; i
i is the ith input node; j
i is the jth hidden layer; k
i is the kth output layer neuron and y
i is the yth output; w
i
j is weight between input and hidden layers and w
h
o is weight between hidden and output layers.The objectives of this study are as follows:(1)
to extract sixty-four texture-n-shape features and form three different feature sets, namely, shape, texture, and texture-n-shape feature set,
(2)
to compare the performance of three feature sets for classification of K6, R2, R4, and R24 paddy types,
(3)
to find the most suitable feature set from the three feature sets for accurate classification.


## 5. Mathematical Model Using Set Theory

(1) LetS be system that classifies seeds from the four varieties S
=
{
I
,
O
,
P
1
,
P
2
,
F
,
G
∣
φ
s
}.(2) IdentifyI
/
P as I:
(8)
S
=
{
I
,
…
}
,
where I
∈ images.(3) IdentifyO
/
P as O:
(9)
S
=
{
I
,
O
,
…
}
O
=
{
T
∣
T
is
type
of
seed
from
the
four
types
to
be
classified
}
.(4) Identify Process asP
1:
(10)
S
=
{
I
,
O
,
P
1
,
…
.
}
,
P
1
=
{
f
1
,
f
2
,
f
3
}
,
where
(11)
f
1
=
{
FE
(
)
∣
FE
(
)
extracts
the
features
and
returns
a
feature
vector
}
f
1
:
I
⟶
F
.
F is the feature vector = {contrast1, correlation1, energy1, homogeneity1, entropy1, contrast2, correlation2, energy2, homogeneity2, entropy2, contrast3, correlation3, energy3, homogeneity3, entropy3, contrast4, correlation4, energy4, homogeneity4, entropy4, area, perimtr, maxlen, minlen, axisratio, compactness, spread, slender, shapefactor1, shapefactor2, shapefactor3, shapefactor4, shapefactor5, stdmom1, stdmom2, stdmom3, stdmom4, stdmom5, stdmom6, stdmom7, stdmom8, stdmom9, stdmom10, mu1, mu2, mu3, mu4, mu5, mu6, mu7, phi1, phi2, phi3, phi4, phi5, phi6, phi7, centralmom1, centralmom2, centralmom3, centralmom4, centralmom5, centralmom6, centralmom7}.Three feature set models are derived from the above set as follows:(a)
First feature set: texture⊆
F feature set; which are the first twenty features.
(b)
Second feature set: shape⊆
F feature set; which are the next forty-four features.
(c)
Third feature set: texture-n-shape =
F feature set
(12)
f
2
=
{
net
(
)
∣
net
(
)
returns
a
pattern
recognition
neural
network
to
classify
inputs
n
according
to
target
classes
}
,
f
3
=
{
train
(
)
∣
train
(
)
trains
the
neural
network
and
returns
the
new
network
}
f
3
:
net
,
F
⟶
N
.(5) Identify Process asP
2:
(13)
S
=
{
I
,
O
,
P
1
,
P
2
,
…
.
}
,
P
2
=
{
f
4
(
)
∣
f
4
(
)
hhhhhh
perform
match
of
seed
with
the
features
from
hhhhhh
feature
vector
}
,
f
4
:
N
,
F
⟶
O
.(6) Identify failure cases asF:
(14)
S
=
{
I
,
O
,
P
1
,
P
2
,
F
,
…
}
.Failure occurs when(i)
the training is not properly done,
(ii)
the images are taken in variable illumination,
(iii)
the different types of seeds have same features.(7) Identify success cases asG:
(15)
S
=
{
I
,
O
,
P
1
,
P
2
,
F
,
G
}
.Success is defined as, for given set of images, system gives output with exact match.


## 6. Results and Discussions

The effect of texture, shape, and texture-n-shape features on the sensitivity of class was studied using the selected ANN configuration described above. Table 2 shows the sensitivity and total accuracy for different feature sets and different variety of grains using a BPN classifier. The results showed that the accuracy of classification of the ANN was best most of the time when shape features were used. This proves that the texture of the seed has less discriminating power than shape. The sensitivity and accuracy are calculated as follows.Table 2
Sensitivity for class and Total Accuracy %.
Seeds
Sensitivity for class
Total Accuracy
Texture features
K6
86.9
82.61%
R2
83.6
R4
70.4
R24
85.0
Shape features
K6
82.0
88.00%
R2
96.3
R4
90.4
R24
93.6
Texture-n-shape features
K6
80.6
87.27%
R2
96.1
R4
88.5
R24
94.8Sensitivity. The sensitivity for ith class is defined as the number of patterns correctly predicted to be in class i with respect to the total number of patterns in class i:
(16)
Sensitivity
=
n
i
i
f
i
,
where f
i is number of patterns associated with class i and is given by f
i
=
∑
j
=
1
C
n
i
j, i
=
1
,
…
,
C, and n
i
i is number of times the patterns were predicted to be in class i, when they really are in the same class, that is, number of correctly classified patterns.Accuracy. The accuracy is defined as the sum of number of correctly classified patterns upon the number of testing patterns:
(17)
Accuracy
=
(
1
N
)
∑
i
=
1
C
n
i
i
,
where C is number of classes, here four, N  is testing patterns, and n
i
i  is the same as in (16).Figure4 shows the sensitivity for different variety of grains. Class-1 in the plot indicates K6, class-2 indicates R2, class-3 indicates R4, and class-4 indicates R24.Figure 4
Plot of sensitivity classwise.


## 7. Conclusions and Future Scope

The texture, shape, and texture-n-shape features were extracted from images of individual grains and the same were assessed for classification of grains. The accuracy shown is 82.61%, 88.00%, and 87.27% with texture, shape, and texture-n-shape features, respectively. The most satisfactory results were delivered by the shape feature set. Texture feature set gave lower accuracy than all the other sets because the difference between the features (contrast, energy, and homogeneity) of different varieties is negligible. It can be concluded that invariant moments, standard moments, and central moments of shape have a significant role in discriminating the paddy varieties. Thus shape moments have the potential to improve the classification accuracy of the computer vision systems used for classification of paddy grains.



---

*Source: 617263-2014-08-18.xml*