Comparative Analysis of Euclidean, Manhattan, Canberra, and Squared Chord Methods in Face Recognition

Comparative Analysis of Euclidean, Manhattan, Canberra, and Squared Chord Methods in Face Recognition

Sunardi | Abdul Fadlil Novi Tristanti*

Department of Electrical Engineering, Universitas Ahmad Dahlan, Yogyakarta 55164, Indonesia

Master Program of Informatics, Universitas Ahmad Dahlan, Yogyakarta 55164, Indonesia

Corresponding Author Email: 
novi2008048027@webmail.uad.ac.id
Page: 
593-599
|
DOI: 
https://doi.org/10.18280/ria.370308
Received: 
25 December 2022
|
Revised: 
26 January 2023
|
Accepted: 
2 Feburary 2023
|
Available online: 
30 June 2023
| Citation

© 2023 IIETA. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

Face recognition is currently widely used as a security component. In facial recognition, the image used will be converted into a grayish image and subsequently converted into a binary image. The binary image obtained in the next process will be analyzed. The analysis was carried out by calculating the similarity distance between the training data and the test data. In the process of measuring the distance of similarity between data sets, there are often obstacles to the implementation of complex algorithm formulas. This study solves this problem by analyzing the distance functions of Euclidean, Manhattan, Canberra, and the Squared Chord to perform facial recognition. Based on the research that has been carried out, the Euclidean distance function gets an accuracy of 58%, the Manhattan distance function gets an accuracy of 70%, the Canberra distance function gets an accuracy of 92%, and the Squared Chord distance function gets an accuracy of 66%. Based on these results, it can be concluded that Canberra's distance function with a highest accuracy result compared to the other three distance functions is better and more suitable for facial recognition.

Keywords: 

Euclidean, Manhattan, Canberra, Squared Chord, face, recognition

1. Introduction

The development of technology is currently experiencing very rapid progress, which encourages the development of facial recognition systems by utilizing the characteristics of the human face [1]. Facial recognition systems are widely used as surveillance, identification, and security systems. Before performing facial recognition, the system will measure the similarity distance of the data. But there are often problems when measuring data [2].

Malkauthekar [3] conducted Euclidean and Manhattan analyses aimed at determining the most suitable distance function to apply to facial recognition. Tolentino et al. [4] conducting an analysis of Canberra's methods for conducting emotion recognition. Batra and Sharma [5] conducted an analysis of distance measurements in content-based shooting using the CBIR method, distance metrics, euclidean distance, Manhattan distance, confusion matrix, Mahalanobis distance, cityblock distance, and Chebychev distance. Belattar and Mostefai [6] conducted similarity measurements for content-based dermoscopic image capture in a comparative study using the Euclidean distance method.

In previous studies, no analysis of the four functions of distance has been carried out, namely: Euclidean (L1), Manhattan (L2), Canberra (L3), and Squared Chord (L4). This study compared the effectiveness of using the distance function as a classifier in the facial recognition biometric system.

The Euclidean, Manhattan, Canberra, and Squared Chord methods were chosen because they have simple measurement formulas to apply to the system [7-9]. The accuracy of this study was measured using a confusion matrix that has criteria, namely: true positive (TP), true negative (TN), false positive (FP), and false negative (FN), which makes it easier to calculate of the accuracy. The greater accuracy value obtained, the better the results obtained.

The first step of face detection is to input photos that will be used in research. Photos will be converted from RGB images to grayscale images in the grayscale process [10, 11]. The gray image will be converted into histogram data, which will later be saved into an Excel file. The histogram data of each photo will be used to calculate the distance of similarity between the data using the distance function.

This study was carried out on an Acer Intel(R) Core (TM) i5-7200U laptop with 4 GB of memory running Windows 10 with the application Matlab 2015a. This application is used because it is supported with graphical math software and programming capabilities [12-14]. Previous research has proven that the Matlab application can be used well to support the development of facial recognition systems [15, 16]. The paper has four parts. The first section contains the background of the research and some of the previous research related to this research. The second part is about the methodology of the research conducted. The third section is about the results and the discussion that took place. The fourth part is drawing conclusions about the research that has been done.

2. Research Methodology

The first stage in this research is to convert the RGB image into a grayscale image. The grayscale image obtained will be converted into histogram data. Next, we will calculate the similarity of distances from the histogram data obtained. In general, the facial recognition system can be shown in Figure 1.

In principle, the facial recognition system is divided into 5 parts, namely: data acquisition, initial processing, feature extraction, classifier, and final processor, which are carried out using distance functions, namely Euclidean (L1), Manhattan (L2), Canberra (L3), and Squared Chord (L4). Based on the results obtained, an analysis will be carried out to determine the most suitable distance function to apply to facial recognition.

2.1 Data acquisition

The first step in this study's facial recognition process was data acquisition, which involved photographing faces with the Samsung S10 smartphone camera's main camera resolution of 12 mega pixels. The limitations of this study used 10 respondents who were students of the master of informatics engineering at Ahmad Dahlan University and were represented as men due to the conditions at that time in which men were willing to be the object of research. The photos used in this study can be seen in Table 1.

Figure 1. Block diagram of a face recognition system

Table 1. Research photo samples

Number Pictures

Name

Template Image

Testing Image

1

2

3

4

5

1

Jaya

2

Tri

3

Amirul

4

Yahmin

5

Lonang

6

Galih

7

Awaludin

8

Muhrisal

9

Jogo

10

Rahmat

Based on Table 1, data is divided into 2 parts, namely, data used for template or reference patterns and data used for testing. Each respondent received six data samples, one of which served as a template or reference pattern and the other five as a test pattern. The total number of all test data is 50 data which focuses only on the facial expressions of the respondents not involving hat or eyeglass accessories with a data resolution of 719×719.

2.2 Processor initial and extraction characteristics

At this stage, preliminary processing is carried out aimed at obtaining data of the same size on each [17, 18]. The facial image data used in this study had a resolution of 719×719 pixels. Resolution equalization is done to optimize the accuracy results. If researchers didn't use the same resolution, each photo would have a different pixel value. The initial face image data is in the form of an RGB image generated by Program Code 1. The function of the Img code is to call the photo into the system, and it is read by the I code. The results of program code 1 can be seen in Figure 2.

Program Code 1. Image input

Img=('C:\Users\Novi\Documents\dataset baru\latih\10a.jpg'); I = imread(img);

Figure 2. RGB image

The RGB image will be converted into an image that has only one scale, namely grayscale. The grayscaling process is performed using Program Code 2. The J code function is a command to convert an RGB image into a grayscale image. The results of program code 2 can be seen in Figure 3.

The RGB image will be converted into an image that has only one scale, namely grayscale. The grayscaling process is performed using Program Code 2. The J code function is a command to convert an RGB image into a grayscale image. The results of program code 2 can be seen in Figure 3.

Program Code 2. Grayscaling

J = rgb2gray(I);

Figure 3. Grayscale image

The grayscale image will be converted into histogram form, and the histogram data will be saved in Excel format. Converting a grayscale image into histogram data is performed using Program Code 3. The gray_histogram code is a command to convert grayscale images into histogram data. The histogram data obtained will be saved to an Excel file with the xlswrite command.

Program Code 3. Histogram

gray_histogram = imhist(J); xlswrite(‘data10A.xls’,gray_histogram);

Figure 4 is an image of the histogram data. The histogram data obtained is 256; this data is the pixel value of the grayscale image. In the next step, the histogram data obtained will be used to calculate the similarity distance.

Figure 4. Histogram image

2.3 Classification and END processors

At this stage, the classification is carried out using the distance function by measuring the similarity or difference between one pattern and another [19, 20]. The pattern used in this study was obtained from histogram data. The basis of facial recognition is the measurement of similarity. In this study, the effectiveness of four distance functions will be compared, namely Euclidean (L1), Manhattan (L2), Canberra (L3), and Squared Chord (L4) as classifiers. The four distance functions can be successively defined as follows:

$d_E(x, y)=\sqrt{\sum_{i=1}^d\left(x_i-y_i\right)^2}$      (1)

$d_M(x, y)=\sum_{i=1}^n\left|x_i-y_i\right|$        (2)

$d_C(x, y)=\sum_{i=1}^n \frac{\left|x_i-y_i\right|}{\left|x_i\right|+\left|y_i\right|}$     (3)

$d_{S C}(x, y)=\sum_{i=1}^n\left(\sqrt{x_i}-\sqrt{y_i}\right)^2$    (4)

Based on the equation above, xi is the test pattern and yi is the template or reference pattern, both having the same size, namely the d-dimensional. The test pattern is a pattern obtained from the histogram data of the test image. Meanwhile, the template pattern is a pattern that is used as a reference in measuring distances.

The accuracy of the facial recognition system in this study can be calculated using Eq. (5):

Accuracy $(\%)=\frac{T P+T N}{T P+F P+T N+F P} \quad\,\,\times 100 \%$      (5)

True Positive (TP) is a facial image that is in the database and that can be recognized by the system according to the dataset. False Positive (FP) is a face image in a database that the system cannot identify based on the dataset. True Negative (TN) is an image of a face that is not in a database and has been identified as unknown. False negative (FN) is an image of a face that is not in the database but can be identified with other data in the dataset.

3. Results and Discussion

This study used 10 respondents, each with one photo that will be used as a template or reference data, for a total of 10 photos. While the test data used 5 photos from each respondent, the total test data used was 50 photos. The photos used were taken using the Samsung S10 smartphone camera, which has a main camera resolution of 12 MP. The photo used has a size of 719×719 pixels. At this stage, testing was carried out using the Euclidean, Manhattan, Canberra, and Squared Chord methods. Matlab 2015a was used for the test, which included hardware support for the Intel(R) Core (TM) i5-7200U CPU at 2.50 GHz, 2.71 GHz, and 4 GB memory.

Table 2. Euclidean test results

Test Image

Euclidean (L1)

Template/Reference Image

1

2

3

4

5

6

7

8

9

10

1

3

1

0

0

1

0

0

0

0

0

2

0

1

1

0

0

0

0

1

2

0

3

0

0

5

0

0

0

0

0

0

0

4

0

0

0

5

0

0

0

0

0

0

5

0

4

0

0

1

0

0

0

0

0

6

0

0

0

0

0

5

0

0

0

0

7

1

0

0

0

2

0

1

0

1

0

8

0

0

0

0

0

0

0

4

0

1

9

0

1

0

0

3

0

0

0

1

0

10

0

0

0

0

0

1

0

1

0

3

Accuracy %

58%

Based on the test results using the Euclidean method in Table 2, it can be seen that from 50 experiments carried out, there are 29 experiments obtained the same facial results and 21 experiments obtained unequal facial results.

Table 3. Manhattan test results

Test Image

Manhattan (L2)

Template/Reference Image

1

2

3

4

5

6

7

8

9

10

1

4

0

1

0

0

0

0

0

0

0

2

0

1

0

0

1

0

0

1

2

0

3

0

0

5

0

0

0

0

0

0

0

4

0

0

0

5

0

0

0

0

0

0

5

0

1

0

1

3

0

0

0

0

0

6

0

0

0

0

0

5

0

0

0

0

7

0

0

0

0

1

1

2

0

1

0

8

0

0

0

0

0

0

0

5

0

0

9

1

0

0

0

1

0

0

0

3

0

10

0

0

0

0

0

2

0

1

0

2

Accuracy %

70%

Table 4. Canberra test results

Test Image

Canberra (L3)

Image Template/Reference

1

2

3

4

5

6

7

8

9

10

1

5

0

0

0

0

0

0

0

0

0

2

0

4

0

0

0

0

0

1

0

0

3

0

0

5

0

0

0

0

0

0

0

4

0

0

0

5

0

0

0

0

0

0

5

0

0

0

0

5

0

0

0

0

0

6

0

0

0

0

0

5

0

0

0

0

7

0

0

0

0

1

0

2

2

0

0

8

0

0

0

0

0

0

0

5

0

0

9

0

0

0

0

0

0

0

0

5

0

10

0

0

0

0

0

0

0

0

0

5

Accuracy %

92%

Based on the test results using the Manhattan method in Table 3, it can be seen that from the 50 experiments that have been carried out, the results of 35 experiments were obtained to get the same facial results and 15 times the number of experiments were obtained to get unequal facial results.

According to the test results obtained using the Canberra method in Table 4, there are 46 of the 50 experiments obtained the same facial results and 4 obtained unequal facial results.

Table 5. Squared Chord test results

Test Image

Squared Chord (L4)

Image Template/Reference

1

2

3

4

5

6

7

8

9

10

1

3

0

1

0

0

1

0

0

0

0

2

0

1

0

0

1

0

0

1

2

0

3

0

0

5

0

0

0

0

0

0

0

4

0

0

0

5

0

0

0

0

0

0

5

1

2

0

1

1

0

0

0

0

0

6

0

0

0

0

0

5

0

0

0

0

7

1

0

0

0

0

0

1

0

3

0

8

0

0

0

0

0

0

0

5

0

0

9

1

0

0

0

1

0

0

0

3

0

10

0

0

0

0

0

0

0

1

0

4

Accuracy %

66%

Based on the test results using the square chord method in Table 5, it can be seen that, of the 50 experiments that have been carried out, there are 33 experiments obtained the same facial results and 17 experiments obtained unequal facial results. The following sample calculations were made for Lonang respondents with the first test image, as shown in Table 2, Table 3, Table 4, and Table 5:

a. Euclidean distance function (L1)

d1

(distance of the first test photo with the Jaya template)

= 5341327.409

d2

(distance of the first test photo with the Tri template)

= 4908472.87

d3

(distance of the first test photo with the Amirul template)

= 8163247.6

d4

(distance of the first test photo with the Yahmin template)

= 5726289.5

d5

(distance of the first test photo with the Lonang template)

= 5170383.1

d6

(distance of the first test photo with the Galih template)

= 9801670.908

d7

(distance of the first test photo with the Awaludin template)

= 9044134.5

d8

(distance of the first test photo with the Muhrisal template)

= 11788255.63

d9

(distance of the first test photo with the Jogo template)

= 7736244.329

d10

(distance of the first test photo with the Rahmat template)

= 13210093.94

Result

= min (d1, d2, d3, d4, d5, d6, d7, d8, d9, d10) = 4908472.87 (d2)

Based on the calculations made on the respondents Lonang photo of the first test image with the distance function, L1 got the smallest value on d2, which means that the test got unsuitable results because it was recognized as a Tri respondent.

b. Manhattan distance function (L2)

d1

(distance of the first test photo with the Jaya template)

= 324898699

d2

(distance of the first test photo with the Tri template)

= 33442051

d3

(distance of the first test photo with the Amirul template)

= 47116308

d4 

(distance of the first test photo with the Yahmin template)

= 34105297

d5

(distance of the first test photo with the Lonang template)

= 25119832

d6

(distance of the first test photo with the Galih template)

= 57557156

d7

(distance of the first test photo with the Awaludin template)

= 49655788

d8

(distance of the first test photo with the Muhrisal template)

= 74138122

d9 

(distance of the first test photo with the Jogo template)

= 44658713

d10

(distance of the first test photo with the Rahmat template)

= 132186082382

Result

= min (d1, d2, d3, d4, d5, d6, d7, d8, d9, d10) = 25119832 (d5)

Based on calculations made on Lonang respondents, the first test image with the L2 distance function got the smallest value on d5, which means that the test got a suitable result because it was recognized as a Lonang respondent.

c. Canberra distance function (L3)

d1

(distance of the first test photo with the Jaya template)

= 68.35266714

d2

(distance of the first test photo with the Tri template)

= 61.48369964

d3

(distance of the first test photo with the Amirul template)

= 68.2279721

d4 

(distance of the first test photo with the Yahmin template)

= 67.09242785

d5

(distance of the first test photo with the Lonang template)

= 36.84202

d6

(distance of the first test photo with the Galih template)

= 72.81554161

d7

(distance of the first test photo with the Awaludin template)

= 60.58912133

d8

(distance of the first test photo with the Muhrisal template)

= 82.56411356

d9 

(distance of the first test photo with the Jogo template)

= 70.16805245

d10

(distance of the first test photo with the Rahmat template)

= 93.38596664

Result

= min (d1, d2, d3, d4, d5, d6, d7, d8, d9, d10) = 36.84202 (d5)

Based on calculations performed on Lonang respondents, the first test image with the distance function L3 gets the smallest value at d5, which means that the test results match because they are identified as Lonang respondents.

d. Squared Chord distance function (L4)

d1

(distance of the first test photo with the Jaya template)

= 5855671

d2

(distance of the first test photo with the Tri template)

= 5969644.895

d3

(distance of the first test photo with the Amirul template)

= 12156712.03

d4 

(distance of the first test photo with the Yahmin template)

= 6107081.623

d5

(distance of the first test photo with the Lonang template)

= 7483662.401

d6

(distance of the first test photo with the Galih template)

= 24985221.6

d7

(distance of the first test photo with the Awaludin template)

= 16057564.23

d8

(distance of the first test photo with the Muhrisal template)

= 31465069.05

d9 

(distance of the first test photo with the Jogo template)

= 13908852.18

d10

(distance of the first test photo with the Rahmat template)

= 48870534.35

Result

= min (d1, d2, d3, d4, d5, d6, d7, d8, d9, d10) = 5855671 (d1)

Based on calculations performed on Lonang respondents, the first test image with the L4 distance function obtained the smallest value at d1, which means that the test results did not match because they were identified as Jaya respondents.

In the calculations already done, overall the accuracy of facial recognition with the Euclidean distance function is 58%, Manhattan is 70%, Canberra is 92%, and Squared Chord is 66%.

4. Conclusion

Face recognition research using the Euclidean, Manhattan, Canberra, and Squared Chord methods has been carried out using 10 respondents as a dataset, with each respondent having 1 sample for the template/reference pattern and 5 sample photos for the test pattern. Based on the experiments that have been carried out, as many as 50 trials using the Euclidean distance function (L1) obtained 29 experiments that were successfully carried out and 21 trials that were failed, so as to obtain an accuracy of 58%; 50 experiments were carried out using the Manhattan distance function (L2) obtained 35 trials that were successfully carried out and 15 failed attempts were carried out, resulting in an accuracy of 70%; 50 trials were carried out using the Canberra distance function (L3) obtained 46 trials that were successfully carried out and 4 trials that were failed, resulting in an accuracy of 92%; and 50 experiments were carried out using the Squared distance function (chord) (L4) obtained 33 successful trials and 17 failed attempts, resulting in an accuracy of 66% Based on the function is the best and most suitable for application to facial recognition. Accuracy that has been obtained, it can be concluded that the Canberra method has the highest accuracy result, namely 92%. This shows that of the four distance functions used in this study, the Canberra distance.

  References

[1] Khan, S.A., Ishtiaq, M., Nazir, M., Shaheen, M. (2018). Face recognition under varying expressions and illumination using particle swarm optimization. Journal of Computational Science, 28: 94-100. https://doi.org/10.1016/j.jocs.2018.08.005

[2] Naji, S.K., Hamad, M.H. (2021). Human identification based on face recognition system. Journal of Engineering and Sustainable Development, 25(1): 80-91. https://doi.org/10.31272/jeasd.25.1.7

[3] Malkauthekar, M.D. (2013). Analysis of Euclidean distance and Manhattan distance measure in Face recognition. In Third International Conference on Computational Intelligence and Information Technology (CIIT 2013), pp. 503-507. https://doi.org/10.1049/cp.2013.2636

[4] Tolentino, J.A., Gerardo, B.D., Medina, R.P. (2019). Enhanced manhattan-based clustering using fuzzy C-means algorithm. In Recent Advances in Information and Communication Technology 2018: Proceedings of the 14th International Conference on Computing and Information Technology (IC2IT 2018), pp. 126-134. https://doi.org/10.1007/978-3-319-93692-5_13

[5] Batra, A., Sharma, M. (2014). Analysis of distance measures in content based image retrieval. Global Journal of Computer Science and Technology, 14(G2): 11-16. 

[6] Belattar, K., Mostefai, S. (2015). Similarity measures for content-based dermoscopic image retrieval: A comparative study. In 2015 First International Conference on New Technologies of Information and Communication (NTIC), pp. 1-6. https://doi.org/10.1109/NTIC.2015.7368761

[7] William, I., Rachmawanto, E.H., Santoso, H.A., Sari, C.A. (2019). Face recognition using facenet (survey, performance test, and comparison). In 2019 Fourth International Conference on Informatics and Computing (ICIC), pp. 1-6. https://doi.org/10.1109/ICIC47613.2019.8985786

[8] Qiu, G., Mei, W. (2019). Fast face recognition algorithm based on collaborative representation classification and manhattan norm. In 2019 IEEE 3rd Information Technology, Networking, Electronic and Automation Control Conference (ITNEC), pp. 2662-2666. https://doi.org/10.1109/ITNEC.2019.8729177

[9] Asadi Amiri, S., Rajabinasab, M. (2021). Face recognition using color and edge orientation difference histogram. Journal of AI and Data Mining, 9(1): 31-38. https://doi.org/10.22044/jadm.2020.9376.2072

[10] Weitzner, D., Mendlovic, D., Giryes, R. (2020). Face authentication from grayscale coded light field. In 2020 IEEE International Conference on Image Processing (ICIP), pp. 2611-2615. https://doi.org/10.1109/ICIP40778.2020.9191048

[11] Veerashetty, S., Patil, N.B. (2021). Manhattan distance-based histogram of oriented gradients for content-based medical image retrieval. International Journal of Computers and Applications, 43(9): 924-930. https://doi.org/10.1080/1206212X.2019.1653011 

[12] Abdulrahman, A.A., Tahir, F.S. (2021). Face recognition using enhancement discrete wavelet transform based on MATLAB. Indonesian Journal of Electrical Engineering and Computer Science, 23(2): 1128-1136. http://dx.doi.org/10.11591/ijeecs.v23.i2.pp1128-1136

[13] Africa, A.D.M., Abello, A.J.A., Gacuya, Z.G., Naco, I. K.A., Valdes, V.A.R. (2019). Face recognition using MATLAB. International Journal of Advanced Trends in Computer Science and Engineering, 8(4): 1110-1116. https://doi.org/10.30534/ijatcse/2019/17842019

[14] Galib, S.L., Tahir, F.S., Abdulrahman, A.A. (2021). Detection face parts in image using neural network based on MATLAB. Engineering and Technology Journal, 39(1B): 159-164. https://doi.org/10.30684/etj.v39i1B.1944

[15] Kaur, N. (2016). Review of face recognition system using MATLAB. International Journal of Computer Science Trends and Technology (IJCST), 4. 

[16] Mantri, S., Bapat, K. (2011). Neural network based face recognition using MATLAB. International Journal of Computer Science Engineering and Technology, 1(1): 6-9. 

[17] Li, L., Mu, X., Li, S., Peng, H. (2020). A review of face recognition technology. IEEE Access, 8: 139110-139120. https://doi.org/10.1109/ACCESS.2020.3011028

[18] Putra, I.N.T.A. (2018). Face recognition based mobile using fisherface and distance classifier. JST (Jurnal Sains Dan Teknologi), 7(1): 135-145. https://doi.org/10.23887/jstundiksha.v7i1.13267

[19] Soltani, O., Benabdelkader, S. (2021). Euclidean distance versus Manhattan distance for new representative SFA skin samples for human skin segmentation. Traitement du Signal, 38(6): 1843-1851. https://doi.org/10.18280/ts.380629

[20] Sunardi, S., Yudhana, A., Saifullah, S. (2017). Identity analysis of egg based on digital and thermal imaging: Image processing and counting object concept. International Journal of Electrical and Computer Engineering, 7(1): 200. http://dx.doi.org/10.11591/ijece.v7i1.pp200-208