1 Introduction

Because of the security purposes, the importance of biometric analysis is increased day by day and human identification is one of them [1,2,3,4,5,6,7,8,9]. Since detecting the gender of a face decreases the number of possible candidates, gender classification (GC) is a significant stage in human identification, Which means the accuracy of human identification can be increased by employing a successful GC method [10, 11]. Therefore, many different GC methods, which can be divided into texture, statistical, and geometry-based methods, were presented [1]. Texture analysis methods are one of the widely employed image processing method and in GC gray-level co-occurrence matrices (GLCM) [12], local binary patterns (LBP) [13, 14], Gabor filters (GF), edge histogram, and wavelet methods used successfully [15]. Each of the texture methods is built on detecting different types of textures from an image, and therefore, each of them has its own advantages and disadvantages. LBP [13] is a statistical texture method that focuses on local changes in the image. In LBP, each pixel was compared with its neighbors that are located around it. Later, the results of comparisons (binary patterns), which are a set (totally 8 digits) of 0 or 1 s, were converted to decimal numbers. Finally, the histograms of obtained decimal numbers were used as textures of the image [16, 17].

Fig. 1
figure 1

Examples of FEI face dataset. a FEI A: neutral facial images and b FEI B: smiling facial images

Due to the advantages of LBP such as being less sensitive to changes in illumination of images, requiring less computational cost, being easily implemented [18, 19], the LBP was employed in GC systems in various ways. Ahonen et al. [20] employed traditional LBP to face images. Li et al. [2] used it with Adaboost learning to near infrared images. It was also employed with Gabor filters [21]. Mäkinen and Raisamo [22] achieved 80.56% accuracy by traditional LBP and SVM. Sun et al. obtained 95.75% accuracy by LBP and Adaboost classifier [23]. Moreover, Lian and Lu [24]achieved 96.75% accuracy by LBP with SVM. Although traditional LBP employed successfully in GC, it suffers from an important disadvantage, which is it cannot capture spatial relationships among local textures [21]. The aim of this research is to investigate the applicability of two distinct spatial based LBP descriptors that were introduced by us [14]. These LBP descriptors were built on detecting the spatial relationships of pixels in different directions or distributions. Therefore, they may be more useful to understand the facial images than traditional LBP.

Identifying the gender of a subject from a single image is often difficult, even for humans and it limits the accuracy of most classifiers [7]. Therefore, in the classification stage, the gray relational analysis (GRA), which was defined as a relational measurement of an attribute in separate sequences based on similarity [25], was employed. Due to having the ability to analyze systems or data sequences with partially unknown parameters, providing reliable analytical results, not requiring any statistical assumption or distribution, and being a simple method to follow, understand and implement, GRA becomes a popular method and there is a large literature about it [26,27,28,29]. The characteristic of a GC system is very close to a gray system that is defined as a partially known system (i.e., there is incomplete or insufficient information) [30].

The remaining part of this paper is organized as follows. In Sect. 2, we introduce employee dataset. In Sect. 3, the methodology of the traditional LBP descriptor and employed descriptors, which are local binary patterns by neighborhoods (nLBP\(_{d})\) and directional local binary patterns (dLBP\(_{\alpha })\), and GRA. Section 4 consists of the experimental results and discussions. The last section concludes the paper.

2 FEI face dataset

The FEI face database contains the face images of 100 male and 100 female subjects, who are students and staff at FEI, between 19–40  years old with their own appearance, hairstyle, and adorns [31, 32]. 14 different images that have different facial expressions were taken from an upright frontal position of each subject, while their profiles were rotated up to about 180\(^\circ \). This dataset contains totally 2800 images, which are \(640\times 640\) pixels sized colorful with a homogenous white background, while the scale might vary about 10%. In this study, the images that have neutral and smile facial expressions were employed. These image set were named as FEI A and FEI B datasets, respectively, and some of them are illustrated in Fig. 1.

3 Methods

3.1 Traditional local binary pattern descriptor

The LBP operator was employed to detect micro patterns in a local region by measuring the local contrast [33]. In LBP descriptor, a binary value was generated for each pixel according to the comparison of the central pixel (\(P_{c})\) with the value of its neighbors that were around it based on a specific radius as seen in Fig. 2 [13, 19, 34,35,36]. LBP has high ability in detecting micro patterns and the change in the radius changes the scale of detectable micropatterns. But, it cannot directly detect large-scale structures. Distinct macropatterns were detected by LBP via micropatterns since macropatterns are compositions of micropatterns [13, 14].

Fig. 2
figure 2

Neighbors in traditional LBP

As seen in Fig. 2, assigning different radius (R) changes both the positions of neighbor pixels and the total number of neighbors (P) that will be compared. Therefore, for each R a distinct pattern will be generated. After determining neighbors of a pixel based on assigned R, a binary value will be calculated based on the comparison between the values of its neighbors with the value of the central pixel. It turns 1 if the central pixel is higher than its neighbor, otherwise, it takes 0. Results of Pcomparisons form a binary number and the histograms of decimal values of obtained binary numbers for each pixel refers to the LBP value of assessed image [13, 14].

3.2 Local binary patterns by neighborhoods (nLBP\(_{d}\))

In nLBP\(_{d}\), the neighbors are assigned around the central pixel similar to LBP. But, comparisons are done between neighbors instead of the central pixel as shown in Fig. 3 [14]. Each neighbor is compared with its neighbors at distance “d” in clockwise. Later, the same procedure of LBP is employed to determine nLBP\(_{d}\) value of an image

Fig. 3
figure 3

Spatial comparison between neighbors in the nLBP\(_{d}\)

3.3 Directional local binary patterns (dLBP\(_{\alpha }\))

In dLBP\(_{\alpha }\), the neighbors were assigned on a straight line with orientation angle (such as \(0^{\circ }, 45^{\circ }, 90^{\circ }\) or 135\(^{\circ })\) in a counterclockwise according to \(+x \)axis as in GLCM as given in Fig. 4 [12, 14]. The difference between these operators with traditional LBP descriptor is on assigning the neighbors, the other processes are same as traditional LBP. The neighborhood vectors in the horizontal, vertical, and two diagonal orientations, \(\alpha = (0^{\circ }, 45^{\circ }, 90^{\circ }\) and \(135^{\circ })\) are shown in Fig. 4.

Fig. 4
figure 4

Neighborhood vectors of dLBP\(_{\alpha }\)

Fig. 5
figure 5

The block diagram of the employed GC system

3.4 Gray relational analysis

GRA is a machine learning method that is generally employed in order to model or assess gray systems, in which the amount of data is not sufficient for recognizing it [37]. GRA works as follows. First, a reference series [(\(X_{0}=(x_{0}(1), x_{0}(2), x_{0}\) (3), ...x\(_{0}(n)] \)are selected for each class based on having maximum gray relational grade. Next, the test series \([(Xj=(xj(1), xj(2), xj(3), {\ldots }xj(n))]\) were generated from taking one sample from test dataset and taking arbitrary samples in the training dataset in order to compare it with the reference series. Later, selected reference and test series are normalized according to smaller or normal factors that were given in Eqs. 1 and 2, respectively [29].

$$\begin{aligned}&x_j^{(k)} =\frac{\max \left( x_j^{(k)} \right) -x_{ij}^{(k)} }{\left[ {\max \left( x_j^{(k)}\right) +\min \left( x_j^{(k)}\right) } \right] } \end{aligned}$$
(1)
$$\begin{aligned}&x_j^{(k)} =1-\frac{x_j^{(k)} }{\left[ {\max \left( x_j^{(k)}\right) +\min \left( x_j^{(k)}\right) } \right] } \end{aligned}$$
(2)

where k indicates criteria index, \(x_j^{(k)} \)refers series of data, max is the maximum value in the series and min is the minimum value. Next the gray relational coefficient (\(\xi _{ij} (k))\) is calculated as follows.

$$\begin{aligned} \xi _{ij} (k)=\frac{\Delta \min +\rho \Delta \max }{\Delta _{ij} (k)+\rho \Delta \max } \end{aligned}$$
(3)

where \(\rho \) shows the resolution coefficient (it is generally 0.5). \(\Delta _{ij} \)is the distance between the reference and a test series and calculated by

$$\begin{aligned} \Delta _{ij} (k)=\left| {x_i (k)-x_j (k)} \right| \end{aligned}$$
(4)

\(\Delta \min \) and \(\Delta \max \) refer the minimum absolute difference and the largest absolute difference, respectively. They calculated as follows.

$$\begin{aligned} \Delta \min =\mathop {\min }\limits _j \mathop {\min }\limits _k \left| {x_0 (k)-x_j (k)} \right| \end{aligned}$$
(5)
$$\begin{aligned} \Delta \max =\mathop {\max }\limits _j \mathop {\max }\limits _k \left| {x_0 (k)-x_j (k)} \right| \end{aligned}$$
(6)

Finally, the gray relational grade (\(\gamma _{ij} )\), which shows the grade of geometric similarity between the two series (\(x_j (k)\) and \(x_0 (k))\), is determined by:

$$\begin{aligned} \gamma _{ij} =\frac{1}{n}\sum _{k=1}^n {\xi _{ij} (k)} \end{aligned}$$
(7)

Since \(\gamma _{ij} \) is defined as a kind of correlation (similarity) metric between reference series that belongs to each class and test series [29], the class of the sample taken in the test dataset is the same of class that has the higher gray relational grade.

$$\begin{aligned} \mathrm{Classification}=\left\{ {\begin{array}{l} \mathrm{Class}\,1 ;\quad if \quad \gamma _{\mathrm{{class1}}} <\gamma _{\mathrm{{class\,2}}} \\ \mathrm{Class}\,2 ;\quad if \quad \gamma _{\mathrm{{class1}}} >=\gamma _{\mathrm{{class\,2}}} \\ \end{array}} \right. \end{aligned}$$
(8)

3.5 Employed approach

In this paper, traditional LBP and two LBP descriptors that were introduced by Kaya et al. [14] were employed in GC. The block diagram of the employed approach is displayed in Fig. 5.

Block 1 In the first block, the facial images were transformed into the LBP domain by using traditional LBP, nLBP\(_{d}, \) and dLBP\(_{\alpha }\). A decimal value that corresponds to a distinct and a special pattern (its values ranging between 0 and 255), was formed for each pixel by each LBP descriptor. After implementing their procedures, a set of decimal numbers were generated for each image by each LBP descriptor.

Block 2 The histogram of the decimal values of each pixel that were generated by traditional LBP and nLBP\(_{d}, \) and dLBP\(_{\alpha }\) descriptors were determined here. LBP histograms were extracted from facial regions as the region-level description, where the n-bin histogram is utilized as a whole. They illustrate how often each of these 256 different patterns appears in its corresponding face image. In order to exact significant and important features from the controlled face images, \(\alpha \) parameter in dLBP\(_{\alpha }\) and d parameter in nLBP\(_{d}\) were used for searching effective patterns.

Block 3–5 In the classification stage, the GRA was used to classify the extracted features. Owing to use dissimilar training-test partitions, the algorithm may produce dissimilar results. Therefore, we randomly repeated each analysis for 10 times (\(k=10)\), and the mean of obtained results are provided. In the classification process, a template-matching approach was employed.

4 Results and discussion

Experiments conducted on cropped gray-colored images, and images scaled to size of \(162\times 193\) pixels. We manually labeled ground truth regarding gender for each face. The features, which extracted by nLBP\(_{d}\) for different distances (d = 1–7), dLBP\(_{\alpha }\) in different angles (\(\alpha \) = 0\(^{\circ }\)–135\(^{\circ })\) and traditional LBP, were classified by GRA. All of these experiments were replicated 10 times with different random partitions (train and test partitions) of the data. The final results were reported as the mean, worst, and best of the results from individual runs.

4.1 Results obtained by nLBP\(_{d}\) descriptor

A sample of obtaining histograms from the FEI face image datasets with different distance values is illustrated in Fig. 6.

Fig. 6
figure 6

A sample face images from FEI database. a original images, b nLBP\(_{d=1}\), nLBP\(_{d=2}\), nLBP\(_{d=3}\) and nLBP\(_{d=4}\) images and c histograms of nLBP for different distances

As seen in this figure, employing nLBP\(_{d}\) descriptor with different distances both obtained images and their histograms were changed. To determine the optimal distance, both neutral and smile face images were assessed by different distances (d=1–7) and the accuracies obtained by GRA in these trials by nLBP\(_{d}\) are listed in Table 1.

Table 1 Obtained GC accuracies (%) by nLBP\(_{d}\) according to different distances

As seen in Table 1 and Fig. 7, different accuracies were obtained while employing different distance parameters. It can be seen that the GRA of the nLBP\(_{d=4}\) features gets the highest accuracy, which is 97.14 and 96.67% on the two data sets (smiling and neutral faces). Achieving nearly similar accuracies while using both smaller and larger training datasets showed that the employed approach is robust. Additionally, the employed approach can be successfully used in the areas that large datasets cannot be generated.

4.2 Results obtained by dLBP\(_{\alpha }\) descriptor

The obtaining histogram process for different orientations for an image in FEI face database is demonstrated in Fig. 7.

Fig. 7
figure 7

A sample face image from FEI database. a original images, b dLBP\(_{\alpha =0}\), dLBP\(_{\alpha =45}\), dLBP\(_{\alpha =90^{\circ }}\) and dLBP\(_{\alpha =135^{\circ }}\) images and c histograms of dLBP\(_{\alpha }\) for different orientations

Table 2 Obtained GC accuracies (%) by dLBP\(_{\alpha }\) according to different orientations
Table 3 GC accuracies (%) obtained by employing traditional LBP, nLBP\(_{d}\) and dLBP\(_{\alpha }\) descriptors
Fig. 8
figure 8

Classification rates (CR) of nLBP\(_{d=4,}\) dLBP\(_{\alpha =45^{\circ }}\) and traditional LBP methods. a CR for neutral facial images. b CR for smiling facial images

As seen in this figure, the optimum orientation can only be determined by trials or experience. Obtained GC accuracies by GRA using the features extracted by dLBP\(_{\alpha }\) with different orientations are summarized in Table 2.

As seen in Table 2, the highest accuracies obtained for two datasets are 93.33% (dLBP\(_{\alpha =45^{\circ }})\) and 88.57% (dLBP\(_{\alpha =45^{\circ }})\). That means the micropatterns that were obtained through a line with 45\(^{\circ }\) orientation have a higher power in distinguishing face images. This may be because of the characteristics of the faces. Additionally, these results showed that obtained accuracies are strongly related to the selected orientations.

4.3 Comparison of nLBP\(_{d}\), aLBP\(_{\alpha }\), and traditional LBP operators

Accuracies obtained by employed LBP operators (traditional LBP, nLBP\(_{d}\), and dLBP\(_{\alpha })\) are summarized in Table 3.

As it is clear from Table 3 that nLBP\(_{d}\) and dLBP\(_{\alpha }\) descriptors showed higher accuracies than traditional LBP. The highest accuracy of FEI face database is obtained, while using nLBP\(_{d=4}\) and dLBP\(_{\alpha =45^{\circ }}\) descriptors. For the first experiment the highest accuracy is 97.14% by using nLBP\(_{d=4}\) features, for 30–70% training-test partition. For the second experiment, 96.67% accuracy was obtained for 40–60% and 70–30% to 96.67% training-test partition sets. Figure 8 shows the classification rates of nLBP\(_{d=4}\) dLBP\(_{\alpha =45^{ \circ }}\)and traditional LBP features with GRA for all training-test partitions.

Table 4 Comparison of recent studies on GC

4.4 Recent studies in GC

Recent studies in GC ARE summarized in Table 4 in order to validate the performance of employed nLBP\(_{d}\) and dLBP\(_{\alpha }\) descriptors.

It can be seen in Table 4 that, employed approach could produce significant performance compared to other studies in the literature. Achieved high accuracies may be because of employed LBP descriptors that can detect different spatial patterns or GRA, which is a successful classification tool for gray systems or data.

5 Conclusions

Human faces provide important visual information in GC that may be employed as a preprocessing stage in human identification. GC from face images has received much research interest in the last two decades. Although traditional LBP operator has a high ability in detecting micro patterns and showed high accuracy in various image processing applications, it can only search patterns that have a specific neighborhood. Therefore, some versions of LBP, which can detect special patterns, have been presented. In this paper, we employed two LBP descriptors and GRA from facial images in order to achieve higher accuracies in GC. The first LBP descriptor (nLBP\(_{d})\) is based on the relations between the sequential neighbors and the other one (dLBP\(_{\alpha })\) is based on determining the neighbors in the same orientation. Because of taking into account the spatial relationships between pixels, higher accuracies in GC were obtained by both nLBP\(_{d}\) and dLBP\(_{\alpha }\) descriptors with compared to results obtained by traditional LBP and results reported in the literature.