SOFTWARE FOR FOREST SPECIES RECOGNITION BASED ON DIGITAL IMAGES OF WOOD

Classifying forest species is an essential process for the correct management of wood and forest control. After cutting off the trunk of the tree, many of the characteristics of the species are lost and identifying them becomes a much more difficult task. In this context, an anatomical analysis of the wood becomes necessary, needing to be done by specialists who know very well the cellular structures of each species. However, such methodology approaches few automated techniques, making it a delayed and error-prone activity. These factors undermine environmental control and decision-making. The use of computer vision is an alternative to automatic recognition, since it allows the development of intelligent systems, in which, from images, are able to detect features and perform a final classification. One of the techniques of Computer Vision is the use of Convolutional Neural Networks, technique that represents the state of the art in this area, it is the construction of models capable of interpreting patterns in images. This research addresses experiments using convolutional neural networks for recognizing forest species from digital images. Two original datasets were used, one including macroscopic images and the other including microscopic images, for which three models were created: scale recognition, species recognition from macroscopic images and species recognition from microscopic. The best models provide 100% recognition rates for the scale dataset, 98.73% for the macroscopic and 99.11% for the microscopic which made possible to develop a software as a final product, using these three models.


INTRODUCTION
The classification of the different forest species is fundamental for the correct management of wood in the civil construction, timber, industrialization, export, among others. This classification makes it possible to identify the commercialization of endangered species and frauds in transactions involving wood, such as the sale of a lower value species as a species of higher commercial value (MOHAN et al., 2014).
Although there are a number of characteristics present in these species, such as, for example, leaves, fruits, seeds and odors, after cutting and removing the trunk from forests, many of these features are lost and, thus, identification becomes a much more difficult task. In this context, a detailed anatomical analysis of the wood performed by specialists who know very well the cellular structures present in each species is necessary (MARTINS et al., 2015;PAULA et al., 2014).
According to Correia (2009), the wood anatomical study contemplates the analysis of the morphological and tonal characteristics of the macro and microscopic layers of a trunk. Therefore, the recognition of patterns in the different layers of wood makes it possible to identify the respective species.
In turn, according to Lesk (2008), some activities involving pattern recognition can be very timeconsuming and stressful for humans, increasing the probability of errors. For problems like this, the use of intelligent computational systems can automate processes and provide even better results than expected for humans (LESK, 2008).
Systems that use Computational Vision techniques are examples of intelligent systems that seek to resemble human vision to solve complex problems such as image recognition. Hence, Computer Vision techniques have been used in the timber industry since the 1980s, assisting in problems such as identification of defects in logs, optimization of cuttings, among others (PEDRINI, SCHWARTZ, 2008). However, there are other problems to be explored, being one of them, for instance, the construction of software capable of performing species recognition from wood images.
Some approaches achieved the state of art in the Computational Vision area, being Convolutional Neural Networks, a technique that allows automating the recognition of patterns in images and other types of audible or visual data (GOODFELLOW et al., 2016), a good example.
Through the presented context, it is hypothesized that it is possible to classify forest species from wood images using Convolutional Neural Networks. Therefore, this research addresses the realization of experiments in order to evaluate such hypothesis with the purpose of obtaining intelligent computational models.
The general objective of the study was to develop a software capable of classifying forest species from macro and microscopic images of wood using Convolutional Neural Networks.
In order to achieve it, the following specific objectives have been defined: a) To adequate two existing image bases: on one hand, macroscopic images and, on the other hand, microscopic images of woods of different forest species; b) To test several models for scale recognition, macroscopic and microscopic images, varying the parameters of the convolutional neural networks; c) To choose the model with the best recognition rate for each phase of recognition (scale, macro and micro); d) To develop a software as a final product using the three models obtained. The wood anatomical study became such an important subject that in 1931 the International Association of Wood Anatomists (IAWA) was founded, an association whose main objectives are to facilitate the collection, storage and exchange of research materials related to anatomy of wood around the world, in addition to creating awareness about the importance of this subject for science, technology and conservation of natural resources. The IAWA headquarters is located in the Netherlands and is governed by an international board that standardizes the description of physical and mechanical tests already done for the identification of wood.
According to Martins et al. (2015) and Mohan et al. (2014), when a species is not found in the forest with its external characteristics, its classification consists of an anatomical analysis of wood. In this sense, this analysis is traditionally performed by experts who observe macro and microscopic aspects present in the wood in order to meet standards for recognition of the respective species.
According to Zenid & Ceccantini (2007), the macroscopic anatomical characteristics of wood are those observed in naked eye or with approximation up to 10 times using loupes or microscopes. Furthermore, according to Amabis & Martho (1995) and Correia (2009), the macroscopic structure of wood is composed of some morphological characteristics and differences in shades of colour. FLORESTA,Curitiba,PR,v. 49,n. 3,jul Medulla: the central part of the stem, consisting in a tissue with low thickness and little resistance, which makes it susceptible to rotting caused by fungi. It works as a function to store nutrients and perform the upward transport of liquids (MALIK et al., 2015).
Wood (Heartwood and Sapwood): interior layer that possesss a darker coloration (Heartwood) in the region next to Medulla and a coloration a little clearer in the region next to Cambium (Sapwood). On the one hand, the Heartwood is the layer with bigger density and resistance before biological degradation factors. On the other hand, the Sapwood is a more humid and less resistant layer that corresponds to the younger part of the wood with living cells, large amounts of water and nutrients that guarantee the conduct of raw sap from the root to the crown. Additionally, it is in this section that are located the growth rings (AMABIS; MARTHO, 1995;Belt, 2009).
Medullary Rays: rays that extend perpendicular to the axis of the stem from medulla to bark, being very important in the wood classification. Also, they transport nutrients to other parts of the trunk and contribute to the rigidity of the structure (AMABIS; MARTHO, 1995;Belt, 2009).
Growth Rings: Cambium activities vary according to climate changes according to seasons, creating rings that can be identified easily by means of a cross-section. These rings represent the annual cycles that characterize the age of the species, which represent the transition between initial and later wood formed annually due to the plants' physiological activities that increase during spring and autumn (ZENID; CECCANTINI, 2007).
Cambium: it has the function to generate new cells, because it consists of a changing cell tissue that is extremely important for the other layers (AMABIS; MARTHO, 1995;Belt, 2009).
Phloem: a bark sublayer which is responsible for protection of the trunk and conduction of the sap from the leaves to the tree growth (AMABIS; MARTHO, 1995;Belt, 2009).
Bark: it is the outer layer with irregular thickness that contains two parts: i. the Epidermal Layer, which is the external part and is composed by dead cells that protect the wood; and ii. the Phloem, formed by living cells, that leads the elaborate sap of leaves (AMABIS; MARTHO, 1995;Belt, 2009).
According to Zenid & Ceccantini (2007), the macroscopic anatomical characteristics of wood are those observed in naked eye or with approximation up to 10 times using loupes or microscopes. In this way, it is possible to see millions of microscopic cells of different sizes and shapes which, according to Koch et al. (2015), compose a trunk. These cells, in turn, are divided into the following groups: Tracheids, Vessels, Fibers and Spinal Rays.
Tracheoids: elongated cells oriented towards the longitudinal axis of the trunk. They have approximate dimensions of 5 mm in length and 0.6 mm in diameter, being possible to compose up to 95% of the wood. Moreover, they can function as a raw sap transport from one cell to another, storing polymerized substances and assigning mechanical resistance to the trunk (TIMAR et al., 2013).
Vases: long cells with approximate dimensions of 1 mm in length and 0.3 mm in diameter. They can compose up to 50% of the wood. And they have a rounded and leaked cross layer, fuctioning as a raw sap transport and storing polymerized substances (TIMAR et al., 2013).
Fibers: long cells with approximate length of 1.5 mm. They have a rounded and leaked cross layer, thick walls and can compose up to 50% of the wood. They have the function of assigning mechanical strength and rigidity to the trunk (TIMAR et al., 2013).
Medullary Rays (Radial Cells): long, flattened cells located horizontally from the bark to the Medulla. They work as a sap transport along the wood (TIMAR et al., 2013).
According to Mohan et al. (2014), the process of identification of wood is performed by experts who make observations of macro and microscopic anatomical aspects. These aspects are related to shape, size and distribution of elements in wood that can be compared to aid tools, as illustrated manuals, dichotomous keys, physical samples, electronic databases, among others. Furthermore, on the macroscopic level analysis, experts observe two groups of features: organoleptic and anatomical. The organoleptic characteristics include taste, density, odor, color, seed, texture, brightness, hardness and drawings on wood. In this way, the anatomical characteristics can be observed in three planes: traversal (perpendicular to the trunk axis), radial (parallel to the stem axis), and tangential (parallel to the trunk axis). In these planes can observe the growth layers, parenchyma types, vases and rays (KOCH et al., 2015).
On microscopic examination, experts observe the characteristics of the tissue and cellular structures, such as cell wall ornamentation, types of scores, cells composition in rays, dimensions of the cells, the presence of crystals, among others (ZENID; CECCANTINI, 2007 andKOCH et al., 2015).
This traditional approach of identification is a difficult task, not completely automated and requiring extreme concentration and specific knowledge.

For the experiments with macroscopic images, the basis elaborated and made available by Paula et al.
(2012) 1 , composed of 2942 wood macroscopic images of 41 species with resolutions of 3264x2448 pixels.
For the construction of this base, Paula et al. (2014) captured the images in transverse plane from wood blocks of 2 cm 3 pre-sanded for the standardization of the samples. A structure was built with two halogen lamps with sulphite paper filters for standardization of illumination and a SONY camera model DSC T20. For the acquisition of the images, the samples were positioned approximately 1cm from the lens.
For the experiments with microscopic images, the basis elaborated and made available by Martins et al. (2012) 2 was used. This base consists of 2240 images of woods of 112 different forest species (20 samples of each species) with resolutions of 1024x768 pixels.
For the construction of this base, Martins et al. (2015) made blocks of wood, initially 2 cm 3 , which passed through a baking process and histological cuts in transverse plane using an equipment called sliding microtome to improve the anatomical aspects. It was carried out the triple wood cuts coloration to the dehydration in ascending alcoholic series. After that, the images were then collected by means of an Olympus-branded microscope model CX40, configured with a 100x optical approximation.
The images of the three bases were divided in 70% for training and 30% for tests. Such division resulted in the following quantities: a) Scale base (2 classes): 3641 images for the training set and 1541 for tests; b) Macrocospic base (41 classes): 2073 images for the training set and 869 for tests; c) Scale base (112 classes): 1568 images for the training set and 672 for tests; Training refers to the group of images to be presented for intelligent models in order to the same ones learn to generalize and to classify unknown images, as for example, the test images.

RESULTS
From the training of models to scale recognition, the best model achieved 100% recognition rate. For recognition from macroscopic images, the best model achieved a recognition rate of 98.73%. For recognition from microscopic images, the best model achieved a recognition rate of 99.11%. Table 1 shows the relationship between models, hits and errors, in which there is no error for the Scale Model, 1.27% for the Macro Model (11 images) and 0.89% (06 images) for the Micro model. After obtaining the three best models, the construction of the final product was carried out. Such product consists of software web that can be accessed through the following electronic address: http://reconhecimentoflorestal.md.utfpr.edu.br. It is available in Portuguese (Brazil) and English (US). Figure 1 shows the main screen, which has an area for upload of images and another one for image processing. FLORESTA,Curitiba,PR,v. 49,n. 3,jul In order to improve the interpretation of the classifications performed by the software, a rule has been included, behaving as an alert threshold. In other words, if there is low accuracy in the scaling or sorting of the species, the software displays an alert with the following message: "This image may not be of a species known by this system". 548 FLORESTA,Curitiba,PR,v. 49,n. 3,jul The intention of this rule is to identify possible classifications of images containing species that are not yet known by the models or even images that are not of forest species, as can be observed in the example shown in Figure 3. When performing tests with images of species not known and random images (dogs, cars, houses, etc.), the alert level was set as below 85% for the Scale Model or below 15% for Macro and Micro Models.

DISCUSSION
Since the classifier presents the average probability for each class of the model, each confounded image was analyzed to see if the second or third prediction referred to the correct class. Table 2 presents this relation for the 11 errors made by the Macro Model. Note that of the 11 confounded images, 8 were correctly classified as second prediction and 2 were correctly classified as third prediction. Therefore, only 1 of the images was not correctly classified in 1st, 2nd or 3rd instance.

-Classification erros of Macroscopic Model
In order to evaluate the similarity between some of the images confounded by models, visual analysis was performed between examples of the expected class and examples of the predicted classes such as 1st, 2nd and 3rd predictions (three higher probabilities).  Table 5 presents the confusion committed by the Micro Model, which classified a label image "016 -Pinales articulata" as being of class "035 -Pinales baccata". Note that the visual characteristics present in expected and predicted class examples are very similar.
Tabela 5 -Visualização de Erro de Classificação do Modelo Microscópico Table 5  • 15 of these 17 errors correspond to images that were correctly classified when considering the second and third major probability; Using the mentioned computational models, the final product (web software) was constructed, which is located in: http://reconhecimentoflorestal.md.utfpr.edu.br.