A Smartphone-Based of Wood Identification Using Image Feature Extraction

Each wood species has their special characteristics which can be differentiated based on their anatomical structures through wood identification. One of the methods is by detecting macroscopic wood image using computer vision. This method is more rapid and accurate to identify wood species compared to the conventional method. In previous work, we have developed a computer vision technique for wood identification by combining Histogram of Oriented Gradient (HOG) and Support Vector Machine (SVM). As smartphone usage is increasing worldwide, capturing wood structures using this smart device is very easy to do and can replace the use of digital microscopes. This paper proposes a technique for extraction the wood species on smartphone using combination of HOG method and SVM classifier on android smartphone. The SVM was used to classify the extracted wood textures from the HOG features. Our experiments, used seven wood images i.e Mimusops_elengi, Melanorrhoea wallichii, Acer niveum, Cratoxylon formosum, Agathis endertii, Dyera costulata and Knema glauca. Each species has a total of 100 training images and 100 testing images. The highest accuracy is obtained by Melanorrhoea wallichii and Agathis endertii species with 84 % score. The Agathis endertii species has the highest sensitivity and the value reaches 86%. Moreover, the Melanorrhoea wallichii species has a highest score for specificity and precision.


I. INTRODUCTION
Indonesia has more than 4,000 wood species grown in its tropical rainforest. As one of the main forest product, wood plays an important role to fulfil human needs so it is important to maintain its sustainability [1]. In previous work, we developed a computer vision technique for wood identification using Histogram of Oriented Gradient (HOG) to extract their features and Support Vector Machine (SVM) to classify the species of wood in computer process. The wood images have been captured using a digital microscope with various resolution. Those images were processed in the computer to extract the pattern of the woods. Another approach still need to be developed to make the identification process easier and faster. The use of smartphone is one of the best options, as it is increasing used in the world. By using a smartphone with additional lens, taking pictures of wood structure is very easy to do and can replace the use of digital microscopes. In addition, the smartphone is chosen because it is handy and can be used to take wood image anytime and anywhere in all region in Indonesia.

II. PREVIOUS WORKS
Aforementioned, it is expected that the wood species extraction process can be done on the smartphone. Besides the extraction process, the classification of the wood species also executed in smartphones. Several works have been undertaken with the use of smartphone for computer vision. Tapu et al. [2] introduced a real-time obstacle detection and classification system designed to assist visually impaired people to navigate safely by using a smartphone. By using an adaptation HOG descriptor and kmeans clustering algorithm, the detection of obstacle can be achieved with high accuracy rates. Khan et al. [3] showed the applicability and feasibility of different machine learning techniques on iris recognition from smartphone captured eye image. Through several steps and methods such as Daugman, canny edge detection and other methods, the result reached accuracy about 99.7% for training and 97% for testing. In [4], Sari et al proposed a new framework to preprocessing tomato image using combination of Linear Regression algorithm and V-Channel Otsu segmentation. This experiment used four types of smartphone devices and used a variance of Laplacian and produce a robust algorithm for blurred image. Finally, Shih et al [5] proposed the maximally stable external region (MSER) algorithm to accurately detected all traffic sign candidates in real time for automatic driving assistance system (ADAS). By using HOG detector and LSVM classifier, the achieved accuracy was about 96% precision rate for recognition on the German Traffic Sign Recognition Benchmark (GTSRB).
Above mentioned work strongly indicate that the extraction and classification process for computer vision can be done using a smartphone. In this paper, we propose a technique for extraction the wood species on smartphone using HOG method. For the classifier, we propose SVM to classify the wood species on smartphone. SVM was used to classify the extracted wood textures from the HOG features. Through a combination of these two processes, the species of wood could be obtained from the wood macroscopic image.

III. MATERIALS AND METHODS
In this paper, the extraction and classification will be the main topics in smartphone based. Figure 1 shows three main stage of the proposed method. At first stage, collected wood macroscopic image are ready for preprocessing stage. In the preprocessing stage, some wood image features were changed from RGB color image to grayscale on android smartphone for the next stage. The second step was a feature extraction process using HOG. In this process the cleaned wood image was extracted to generate a feature extraction for further processing. The last stage was classification process using SVM classifier to determine the wood species.

A. Wood Image Datasets
The dataset for extraction process is a macroscopic image of the cross section wood. The sample of wood obtained from the Xylarium of Bogoriense. Forest Product Research and Development Center, the Ministry of Environment and Forestry Republic of Indonesia. The size of this wood images were 1280 x 1024 pixels. Figure 2 shows the example of the cross section and texture image of the wood samples. In our experiments, wood image from seven wood species were used i.e. Mimusops_elengi, Melanorrhoea wallichii, Acer niveum, Cratoxylon formosum, Agathis endertii, Dyera costulata and Knema glauca. For collecting the training and testing images, the 1280 x 1024 pixel samples image were divided into two regions. The top part of this sample image provided for the training image and the bottom region for the testing image. Therefore, the training and testing process, each species must had 100 training images and 100 testing images. In order to collect this dataset, each part was captured randomly until they generated 100 images for each species. Each training or testing image has a size of 320 x 256 pixel. Figure 3 shows the data set of wood images for training and testing process in order to identify the wood species.

B. Image Preprocessing
In the preprocessing stage, color normalization is a main topic. It was applied to the wood images to enhance the clearness of the texture property in smartphone. It changed the RGB (Red-Green-Blue) color image to grayscale using a weighted method. The formula can be changed with different weights for each RGB color as follows [6]: I is the intensity of the image and the non-negative coefficients  r ,  g ,  b with a condition: In this research, the conversion color image to grayscale used weighted method. The proportion of  r ,  g ,  b in RGB color followed Equation (3): The red, green and blue colors contributed 29.9%, 58.7% and 11.4% respectively. Figure 4 shows an example of the RGB to grayscale conversion image.

C. Features Extraction using HOG Descriptor
HOG is a popular features descriptor for object detection. A feature descriptors is a representation of image that simplifies the image by extracting useful information. HOG features descriptor can be described by the distribution of density distribution of gradients [7][8] [9]. In this case, the useful information can be achieved by dividing the image into small regions called a cell. Each cell compiles a histogram of gradient direction for the pixel within the cell. HOG features descriptor has four steps to extract the object [10]. First, a 64 x 48 pixel windows is divided by 8 x 8 pixel cell as shown in Figure 5. The next step is calculating the gradient component of each pixel from wood image horizontally by formula (4) and vertically by formula (5).
The gradient magnitude of each pixel is calculated by: The gradient direction of each pixel of wood image is calculated following Equation (7): The second step is spatial orientation binning. In this step, the HOG descriptor functions to give a result of cell histogram by a voting process. Each pixel of the wood image within the casts is a weighted vote for orientation in accordance with the closest bin in the range of 0 to 180 degrees. In the third step, the normalization of cell occurs in this descriptor and the histogram from entire block region is converted to a vector form. The normalization of each block is needed in the fourth step and performed by the L2 norm. The L2 norm is derived in Equation (8): After process HOG normalization, the windows descriptor collects descriptor from all the block and is changed into vector form. Figure 6 shows the result of the HOG extraction process with the histogram of 9 gradient for each cell.

D. Support Vector Machine (SVM) Classifier
Support Vector Machine (SVM) is a supervised models associated with respect to learning algorithm and mainly used for analyzing the data for regression and classification [11]. The advantages of SVM are effective in high dimension spaces and in cases where the number of dimension is greater than the number of samples. Moreover, SVM provides efficiency of the memory because it use a support vector. SVM works by mapping data training to a high dimensional feature space and looks the best decision hyperplane located between the two classes boundary.
The distance between the hyperplane and data training from either data is known as the margin. The SVM looks for the hyperplane with the greatest possible margin between the hyperplane and any point within the data training. In this research, SVM was used to classify the wood species based on the result of HOG Features on the smartphone. By linear kernel of SVM, the result of wood species produced the value of 1 for the correct data and -1 for incorrect data. Figure 8 shows the SVM classifier illustration for classifying the positive and negative wood image. The positive and negative training image data were taken from the seven types of wood described above. For each wood species type, we took positive training images from one wood species and the negative training images from other wood species.

E. Android Architecture
Android is the operating system software used in this smartphone-based wood identification. This operating system is widely used today. Android operating system is a stack of software component. The Architectures of Android divided into five layers [12]. The first layer is a Linux Kernel that provides basic system functionalities. This function is usually used for management of all devices in a smartphone like memory, camera, display, keypad, etc. The second layer is Android Runtime that have a task to execute Android Application using Dalvik Virtual Machine. The third layer is Libraries that contains of libraries of including open-source web browser WebKit, SQLite Database, libraries to play and record audio and video, SSL libraries for Internet security etc. The Application Framework layer becomes the fourth layer that provides many higher-level services to applications in the form of Java classes. This services is used by application developer to create their own android application. The last layer is Application at the top of the layers. This layer functions to write the application to be installed on this layer like contact, browser, games, etc. Figure 9 shows layer of the Android architecture. Fig. 9. The layer of Android architecture [12] The algorithms of HOG feature extraction and SVM classifier are implemented on android smartphone using java programming with Android Studio 3.0 and OpenCV libraries.
OpenCV is an open source computer vision and machine learning software library. OpenCV is built to have a common framework for computer vision application and help developers to modify and utilize the code programming in order to build the android application [13]. OpenCV has a lot of computer vision and machine learning algorithms. These algorithms can be used to establish the extraction and classification process for wood identification. With the OpenCV library the implementation of HOG feature and SVM classifier procedures can be adopted in android java programming

IV. RESULTS AND DISCUSSION
We have tested experiments extraction and classification process of wood species using the HOG feature and SVM classifier on android smartphone. For the first time, all of wood image in dataset, both of training positive or negative images were put into HOG descriptor to generate the features extraction. Figure 10 shows the training procedure to obtain the result of classification. In accordance with Figure 10, we trained 100 positive training images and 100 negative training images for each wood species. This training process generate the features extraction of positive or negative training images for each wood species using HOG descriptor. This extraction saved into xml database on android smartphone storage. From this two xml form, the SVM classifier computed this feature extraction to determine a decision boundary of a support vector form. This support vector was used for determining the wood species of testing process In the testing experiment, 100 training images were prepared for the test on android smartphone. The testing images were also extracted with HOG feature for determining a final vector at the end of the extraction process. This extraction were compared with the decision boundary of a support vector form in the training process and gave the result of decision. Figure 11 shows the testing procedure of the wood image input to identify the wood species and then determine the wood species. Fig. 11. The testing procedure of extraction and classification for wood image input All of this testing used android smartphone. We used some android smartphone like Samsung, Acer and Xiomi that have 1.4 GHz core Max for the CPU clock and 2 GB RAM. The testing results indicated that the features extraction and classification processes was possible to be done on the android smartphone. For each species it took about 2.19 seconds to provide the classifier output. Conversely, the previous works indicated that the features extraction and classification processes in the computer was faster than ones in the android smartphone. It takes about 1.09 second.
Beside the speed of the features extraction and classification processes, the confusion matrix is interesting to be evaluated. The confusion matrix is useful to analyze how good a classifier model is. Confusion matrix contains information about actual and prediction generated by classifier [14].  Figure 12 shows the confusion matrix which contain information about actual and predicted classification.  [14] To evaluate the SVM classifier in this research, we used four standard terms to be calculated from the confusion matrix. These four things are accuracy, sensitivity, precision, and specificity. Accuracy is the percentage of test set tuples that are correctly classified by the classifier. Sensitivity is the proportion of the positive tuples that are correctly identified and can be referred to as the true positive (recognition) rate. Specificity is the proportion of negative tuples that are correctly identified and can be defined as the true negative rate. The last is the precision that referred to the measurement of exactness and defined as percentage of tuples labeled as positive are actually such [15]. Table I shows the confusion matrix of the experiment result of 100 wood test images for seven species on android smartphone Table I presents the performance of the SVM classifier on the smartphone. Table II shows the four standard terms of each testing wood image and describes that the testing result has different value of accuracy, sensitivity, specificity and precision. The highest accuracy is obtained by Melanorrhoea wallichii and Agathis endertii species. It means that both wood species have more correct testing images than other species. The Cratoxylon formosum species is the wood species that has the lowest accuracy. This is because it has many wooden vessels and has a longer vessel diameter compared to ther species. This is inversely proportional to Melanorrhoea wallichii and Agathis endertii species which have rare wooden vessels and have a short vessel diameter. In order to verify the sensitivity, the proportion of positive testing wood images that are correctly identified in this wood identification are evaluated. The Agathis endertii species has the highest sensitivity and the value reaches 86%. For the specificity, the Melanorrhoea wallichii species has the highest score. It means that specificity answers the question: "What percentage of wood species is correctly predicted from negative wood image data compared to overall negative wood image data". The last is the precision. it is a true positive prediction ratio compared to overall positive predicted results. Melanorrhoea wallichii is a species that has a high precision. If we see the image of this wood species in Figure 3, its pattern is unclear compared to Agathis endertii species even though it has the same score of accuracy.
From the confusion matrix discussed above, it appears that the SVM classifier was implemented correctly and successfully to classify the testing wood image extracted using HOG descriptor.

V. CONCLUSION
In this paper, the features extraction process on the android smartphone is proposed for wood identification. This paper successfully shows that in the case of smartphone process, the features extraction and classification process have similar good quality to the PC based processing. In this research, HOG descriptor works properly to generate the features extraction and the SVM classifier. It classifies the wood species with the various accuracy, sensitivity, specificity and precision. The highest accuracy (84%) is obtained by Melanorrhoea wallichii and Agathis endertii species. The Agathis endertii species has the highest sensitivity of 86%. Moreover, the Melanorrhoea wallichii species has a highest score for specificity and precision. The different score of the confusion matrix is caused by the number of wooden vessels and the length of its diameter. The pattern of wood texture also affects the HOG extraction process and it produced a different score in confusion matrix.