Keywords

1 Introduction

The use of computer tools to aid in the analysis and recognition of images is a matter of interest for the most renowned research centers in the world. The use of computing for image analysis and recognition is in constant development, generating many benefits to society in the most diverse areas of knowledge. Concerning the recognition of cattle branding in particular, a very traditional activity and of great social-economic relevance for Latin American countries, including Brazil, there is no specific and appropriately consolidated tool for this end.

The use of brands or symbols on cattle presupposes the public recognition of its property by an individual or group. Livestock has a relevant role in social formation, which is still today an activity of great importance in cultural expressions associated to it, as it is linked to the culture and the countryside way of life, and it also has a role in the affirmation and building of individual and group identities [1]. Generally, cattle brand records involve books with the drawings of the brands and the identification of their owner. Currently, brand recording in Brazil is performed by town offices, generally without a more effective systematization and without instituted renewals.

In face of the presented scenario, this work intends to present and assess a tool that performs automatic cattle brand recognition, with the goal of replacing the manual control of cattle branding performed today, in order to potentially decrease the possibility of duplicate records, reducing waiting times for the recording of new brands, improving governmental administration regarding the brand archive under its care and aid security officials in preventing cattle raiding crimes.

Our work focused on the development of algorithms for the recognition of cattle branding for the São Francisco de Assis City Hall, in Rio Grande do Sul, Brazil. Therefore, the employees in the Cattle Branding Record Section and in the Data Processing Center of this township validated the suggested tool.

The remaining work is organized as follows: in Sect. 2, we describe related works. In Sect. 3, we present the materials and methods used in the article. Section 4 describes the results and discussions obtained by the application of the recommended methods. Lastly, in Sect. 5, final considerations are described.

2 Related Work

In general, we could not find any works in the literature review that report the use of convolutional neural networks for the recognition of cattle branding images.

Sanchez et al. [2] present a tool for recognition of cattle branding that use Hu and Legendre moments for extracting features of images in a grey scale, and also a classifier of k-nearest neighbors (k-NN). The authors used Hu and Legendre moments to source features that were not prone to rotation, translation, and scale transformations. The peak percentage of correct classification presented by the authors was 99.3%, with a significant decrease in accuracy as the number of classified images increased, however. No classification model is created. Instead, for each new object to be classified, training data are scanned, and the suggested classifier becomes computationally expensive.

Convolutional neural networks have been used for many years in image recognition, and they have obtained great success in recognizing characters in the research made by LeCun et al. [3] Recent studies using convolutional neural networks known as Deep Convolutional Neural Networks (CNN) obtained the new state of the art in object recognition based in CIFAR-10 and NORB [4]. Generally, CNNs are trained under supervision, but some research revealed that pre-training CNNs with filters obtained in a non-supervised way yields better results [5]. In the research conducted by Sermanet et al. [6] they present a framework using CNNs to perform recognition, localization, and detection of images. An important feature of CNNs is their ability to be reused and refined for different image bases. In the research conducted by Razavian et al. [7] a pre-trained CNN named Overfeat [6] was used to perform the extraction of a descriptor from different image bases whose CNN was not originally trained. In this case, the descriptors are then sorted by an SVM linear classifier. These results indicate a performance compatible with the state of the art, even when compared with algorithms that use manually-segmented images, a procedure that is unnecessary when CNNs are used and trained specifically in the analyzed basis. Usage of deep learning is also described in the research made by Constante et al. [8]. In this paper, the method was used to sort strawberries and obtained Overall Accuracy results of 92.5% in the “Extra” category; 90% in the “Consumption” category; 90% in the “Raw material” category; and 100% in the “Alien objects” category.

Differently from the research presented by Sanchez et al. [2], the work we propose here intends to show results that can be generalized or reproduced, deploying state-of-the-art techniques for feature extraction and statistical classification of digital images, such as Convolutional Neural Networks (CNN) and Support Vector Machines (SVM) to achieve superior performances in image recognition in databases with a greater number of records, but with a lower computational cost and processing time.

3 Materials and Methods

The images from cattle branding presented in this research were provided by the São Francisco de Assis City Hall, in Rio Grande do Sul. We used 30 cattle branding images, each one of them composed by 45 sub-images (samples), totaling 1,350 samples from original images, but with size and orientation variations. We intended to identify patterns with the greatest independence possible from these variable factors. The images were provided in high resolution in the Portable Network Graphics format at a size of 600 × 600 pixels.

For the implementation of the proposed tool, as well as image database storage, algorithm processing and viewing of the results we used a personal computer with a video card that supports CUDA parallel computing platform with a 5.0 compute capability version. Furthermore, we used the MATLAB software with the Neural Network, Parallel Computing and Statistics and Machine Learning libraries and the pre-trained convolutional network model obtained from the open source library VLFeat.org [9].

The proposed method consists of six steps, which are: image database selection; selection of pre-trained CNN model; pre-image processing and application of CNN; extraction of features of the images; training and classification of images by Support Vector Machines; and, finally, evaluation of the classification results. Figure 1 shows a summarized flowchart of the proposed method.

Fig. 1.
figure 1

Summarized flowchart of the proposed method

3.1 Image Database Selection

The brands, and brand codes used are presents in Fig. 2.

Fig. 2.
figure 2

Images of cattle branding used in this article

3.2 Model Selection of a Pre-trained CNN

Convolutional neural networks exhibit a relatively unexploited property known as knowledge transfer. By applying this concept, we selected the CNN model of the open source VLFeat library. The option for a pre-trained model was made due to the fact that the dataset is not large enough to effectively train the CNN. Moreover, the time needed to train a model from scratch would preclude the use of the proposed tool, since it needs speed regarding the task of recognizing cattle brandings. The use of the above mentioned pre-trained CNN model did not directly influence the Overall Accuracy of the cattle branding images.

3.3 Image Pre-processing and CNN Application

The adopted method is a neural network with five convolutional layers. Pre-processing is performed for grey-shaded images, which conducted by replicating images 3 times in order to create a RGB image. The 1st convolutional layer has as its input the 3 color channels (RGB). Each convolution performs an application of the non-linear activation function ReLU and a reduction by the Maxpooling. The last layers are composed of totally-connected neurons. Figure 3 shows the proposed convolutional neural network architecture.

Fig. 3.
figure 3

Proposed convolutional neural network architecture

3.4 Image Feature Extraction

The set of filters learned by the CNN during training is responsible for the sensing of features in the new image at the moment of a query. In the first filter level, we can observe some lines and orientations used for that sensing. Figure 4 shows the learned filters in the first convolutional layer using the RGB color space. There are 96 individual sets that represent the 96 filters used in that layer. It is possible to observe how the areas with horizontal, vertical and diagonal bulges are highlighted after the first convolution.

Fig. 4.
figure 4

Convolutional 1st layer filters from the executed experiment

After the first convolutions, it was possible to perform the extraction of image features for training the classifier.

3.5 Training and Classification of Images with Support Vector Machines

The model for automatic learning adopted in the presented work was the Support Vector Machine (SVM) supervised classifier. Support Vector Machine is a classification algorithm known for its success in a wide range of applications. SVMs are one of the most popular approaches for data modeling and classification. Its advantages include their outstanding capacity for generalization, concerning the ability to correctly sort the samples that are not in the feature space used for training. SVMs are used to classify and recognize patterns in several types of data; they are also employed in a wide range of applications, such as face recognition, clinical diagnosis, industrial process monitoring, and image processing and analysis [10].

In the proposed research, we randomly separated the set of images in two parts, where one of these parts was used for the training stage and the other for the test stage, thus eliminating polarization in the results. The final result is the average of the result obtained in the test stage. The percentage division used here was 30% for training and 70% for test.

3.6 Assessment of Classification Results – Confusion Matrix

The confusion matrix of a classifier indicates the number of correct classifications versus the predictions made in each case over a group of examples. In this matrix, the lines depict the actual cases and the columns depict the predictions made by the model. Through the confusion matrix, it is possible to find information related to the number of correctly and incorrectly classified images for each group of samples. This is an A × A matrix, where A is the amount of categories to which we apply the classifier. In our case, the experiment conducted included 30 brands, so we have a 30 × 30 confusion matrix in this situation.

4 Results and Discussions

Through the results found we were able to assess the proposed method. The assessment of experiment results was performed based on the recognition rate obtained in the confusion matrix rendered from the classification attained in the test stage. Furthermore, the total processing time of the proposed method was also checked.

Figure 5 presents the confusion matrix for the best result obtained in the experiments, whose recognition rate was up to 91.94%. Through the analysis of the main diagonal we can observe that the correct classification rate is emphasized in three brandings “864”, “1085”, and “2542”, in which the percentage of correctness reached 100%, or 31 correct hits. We can also observe that the brandings with the lowest correct classification rates were “2516” and “1083”, with a percentage of 77.42% and 80.64%, in this order.

Fig. 5.
figure 5

Confusion matrix obtained in the test stage

The hypothesis of wrong classification of cattle branding as shown in the confusion matrix may also be associated to the complexity of the samples, since some of the images present similar features among themselves. In general, the image samples of brandings with a better descriptive power and better quality correctly classified more images, since they encompass more characteristics when compared to brandings with worse sample quality, and, consequently, less extracted features. The capacity of recognizing patterns in an image over a set of images depends on the amount of a priori information available about the object in question.

Taking into account the confusion matrix shown in Fig. 5, we can observe that, through the sum of main diagonal, we can find the total number of correctly classified cattle branding, more precisely, 855, while the sum of the other values points to incorrectly classified brandings, that is, 75.

The processing time of the algorithm based on the number of cattle branding samples is shown in Fig. 6. The processing times of the proposed method were measured for the classification of five sample groups, respectively. Each group contained 270; 540; 810; 1,080, and 1,350 images. The processing times for the classification of the images in each group was 9.616 s; 14.162 s; 18.114 s; 22.320 s, and 26.766 s, in this order. When analyzing the graphic in Fig. 6, we can understand that the processing time observed in the Y-axis, varies in direct proportion to the increase of samples of cattle branding classified in the X-axis, i.e., a pattern of linear growth of the function is observed, even if the growth rate is not exactly a constant number.

Fig. 6.
figure 6

Processing time of the algorithm according to number of samples

The results obtained with the experiments performed with 30 cattle brandings and 1,350 image samples, used both for training and test, obtained an Overall Accuracy of 91.94%, an error rate of 8.06%, and a total processing time of 26.766 s. The Overall Accuracy rate was obtained through the calculation of the arithmetic average of brands properly classified from the confusion matrix, and the total processing time was obtained with the use of the MATLAB software which, at the end of code processing, performs the breakdown of the algorithm processing speed.

5 Conclusion

In this research, we presented an automated method for the recognition of cattle branding. The experiments performed in this project used a Deep Learning technique of Convolutional Neural Network (CNN) to extract features and an SVM supervised classifier.

The usage of the suggested method delivered an Overall Accuracy of 91.94% and an algorithm processing time of 26.766 s for the 30 assessed brands, in a total of 1,350 samples used for training and test. The deployed method has effectively and efficiently performed the recognition of different cattle brands, although it used a pre-trained CNN. Its main limitation, however, was the need for a high number of sample images to train the classifier, as CNN needs these images in order to extract the features from convolutional layers.

As future researches, we strive for the expansion of the image base used for training and test, with a main goal of obtaining new accuracy and performance measurements of the proposed method. In time, we intend to conduct new experiments through the use of an untrained model for the implemented CNN to extract features, in order to compare with results obtained by the pre-trained model. Finally, we will use a Sofmax layer at the output of the CNN to sort cattle brandings to compare the results of this new model with the ones that were obtained by using SVM.