Rock images classification by using deep convolution neural network

Granularity analysis is one of the most essential issues in authenticate under microscope. To improve the efficiency and accuracy of traditional manual work, an convolutional neural network based method is proposed for granularity analysis from thin section image, which chooses and extracts features from image samples while build classifier to recognize granularity of input image samples. 4800 samples from Ordos basin are used for experiments under colour spaces of HSV, YCbCr and RGB respectively. On the test dataset, the correct rate in RGB colour space is 98.5%, and it is believable in HSV and YCbCr colour space. The results show that the convolution neural network can classify the rock images with high reliability.


Introduction
For the effective development of reservoirs, it is necessary to provide a comprehensive reservoir description and characterization to determine the underground gas content. Granularity analysis is an important work of it [1]. The traditional method for rock classification is a manual work with many problems such as time-consuming and low accuracy. With the development of science and technology, Artificial intelligence is successfully applied in all walks of life. Many domestic and foreign scholars have done researches in the automatic classification of rock images, such as, Cheng Guojian and Liu Ye [2][3] used shallow neural network and SVM to classify rock images. Mariusz Młynarczuk et al. [4] performed the Classification of thin rock images respectively in RGB, CIELab, YIQ and HSV colour spaces using the nearest neighbour algorithm, K-nearest neighbour, the nearest pattern algorithm, and the optimized spherical neighbourhood; Hossein Izadi et al. [5] established a neural network to identify the rock mineral, whose accuracy was 93.81%. The above methods show that the application of machine learning in rock classification can improve its efficiency and accuracy.
However, using machine learning to classify rock images still has the following shortcomings. Firstly, to classify rock images by machine learning is based on the premise of artificial extraction of image features. Secondly, if the images are large, training a shallow neural network is almost impossible.
Convolution neural network (CNN) is an important deep learning architecture. It can extract the image features automatically and has a high classify accuracy. CNN has achieved a wide range of applications such as plant classification, face recognition, handwritten Chinese character recognition and so on [6][7][8]. In this paper, we construct a new convolution neural network for rock classification, rock images respectively in RGB, HSV, YCbCr colour spaces are used to train it, then contrasted the results and choose the best one.

The Rock Images
It is usually determined by professional geological researchers for types and structural parameters of rocks after identifying rock thin section under polarized light microscopy. The rock images used in Discrete convolution: There are some challenges in using CNN such as how many convolutional layers, how large the size of convolutional kernel and the learning rate of the network should be set are all worth to study carefully.

Data Sources
In this paper, 4800 rock images in RGB colour space are selected as experimental samples, normalize the size of them to 224*224. There are 1600 coarse-grained rock images, 1600 medium-grained rock images and 1600 fine-grained rock images. And 1200 rock images of each type are used as the training set, the remaining 400 are used as the test set. Then converting the 4800 rock images to YCbCr colour space and HSV colour space respectively, whose training set and test set distribution remains unchanged.

The Architecture
The convolution neural network structure designed in this paper is shown in figure 2, which is a 6-layer structure, 4 layers are convoluted and 2 layers are fully connected. The convolution layers use ReLU [10] as the activation function and the fully connected layers do classification by the Softmax classifier. The original image is in RGB colour space, convert it to an RGB three-channel grayscale image as input. As is shown in figure 2 (The marks of the pooling layers S1, S2 and S3 are omitted in the figure), the size of the input image is 224*224. The first convolution layer C1 uses 48 convolution kernels of 11*11 (convolution step is 4 pixels) to obtain 48 feature maps of 56*56 by convolution operation, and then let the 48 feature maps go through a pooling layer with a window whose size is 3*3 (moving step is 2 pixels) obtaining 48 feature maps of 27*27(S1). The second convolution layer C2 takes S1 as input and convolves them with 64 convolution kernels of 5*5 (convolution step is 1 pixel) to obtain 64 slices of 27*27 feature map, then let the 64 feature maps go through a pooling layer with a window whose size is 3*3 (moving step size of 2 pixels) to get 64 feature maps S2 whose size are 13*13(S2).The third convolution layer C3 takes S2 as input and convolves them with 128 convolution kernels of 3*3 (convolution step size of 1 pixel) to obtain 128 slices of 13*13 feature map. The fourth convolution layer C4 takes the 128 slices feature map as input and convolves them with 64 convolution cores of 3*3 (convolution step size of 1 pixel) to obtain 64 feature maps whose size are 13*13. Then let these 64 feature maps go through a pooling layer with a window size of 3*3 (moving in steps of 2 pixels) to obtain 64 feature maps whose size are 6*6(S3). Finally, transforming the result into a one-dimensional vector and use it as the input of the fully connected layer, which is connected with the fully connected layer f1 which has 512 neurons and classifies the rock images according to its granularity size by the Softmax classifier.

Architecture Adjustment
The experimental data is loaded into memory by batch whose size is 100. An iteration is performed while a batch of data is loaded, where the dropout is set to 0.5.

Number of layers.
Setting an appropriate number of convolution layers is one of the key steps in constructing a CNN. If the convolution layers are too less, the network will be not able to learn the essential features of the original image, if there are too many convolution layers, it may lead the network over-fitting. In this paper, the number of convolution layers of 5, 4 and 3 are studied respectively. Compared the convergence and error rate while each network has been subjected to 400 iterations, the results are shown in table 1 and figure 3.

Figure 3. Network loss function for different convolution layers
It can be seen from figure.3 and table 1 that whenever the number of convolution layers is 3, 4 or 5, the network can converge quickly. However, when the 4-layer convolution structure is used, the loss function and the error rate are the lowest.

Convolution kernel.
Convolution kernel size is another important factor affecting the efficiency of CNN. When using a 4-layer CNN, the convolution kernel size of it is set to 11-7-5-3, 11-5-3-3 and 11-3-3-3 respectively for experiment in this paper. After 400 iterations, the error rate is shown in Table 2 and the loss function curve is shown in Figure. figure.4, we can see that setting the convolution kernel size to 11-7-5-3, 11-5-3-3, 11-3-3-3 respectively, the network all can get convergence fast. However, when it is 11-7-5-3, the network convergence fluctuates greatly than the other two. But, the network with convolution kernel of 11-5-3-3 has the lowest error rate. Therefore, a 4-layer CNN whose convolution kernel is 11-5-3-3 is used in this paper.

Learning rate.
Learning rate is a key factor influencing the convergence rate and classification accuracy. When a 4-layer CNN whose convolution kernel size is 11-5-3-3 by setting the initial learning rate as 0.01, 0.001, 0.0005, 0.0001 respectively, the error rate and iterations times are shown in Table 3.  It can be seen from table 3 that when the initial learning rate is 0.01 the network does not converge because of the gradient step is too large and deviates from the optimal point. When the initial learning rate is 0.001, the gradient step is larger and the convergence speed of the network is slower and the error classification rate is lower. When the initial learning rate is 0.0005, the network convergences fast and the error classification rate is the lowest. When the initial learning rate is 0.0001, the network can convergence and finds the best point, but needs to iterate more times and the classification accuracy is lower. In summary, setting the initial learning rate as 0.0005 is the most appropriate.

Validation
In order to prevent the network from over-fitting, this paper use cross-validation. Each type of rock image data set is randomly divided into ten subsets, which is 160 per subset for cross-validation. The production of data set and experimental process in YCbCr colour space and HSV colour space are consistent with that in RGB colour space. Table 4 shows the cross-validation results for RGB, YCbCr and HSV colour spaces. It can be seen from table 4 that the error rates of cross-validation in HSV, YCbCr and HSV colour spaces are all small. So the network does not appear the over-fitting phenomenon in the three colour spaces.
Granularity analysis can provide authenticate researchers essential basis for determining types and structural parameters of rocks, but it is a manual work with low reliability in traditional. However, the experiment results above shows that do the rock granularity analysis using CNN is with high accuracy which could improve the reliability and efficiency.

Conclusion
In this paper, CNN is used to identify the rock granularity. The experiments show that it has high reliability whether in HSV, YCbCr or RGB colour space. In RGB colour space, the classification accuracy achieves 98.5% with high efficiency. However, the experimental results still have deviation may be caused by the use of single polarized images. The next step of study can be committed to multi-polarized light in the rock image. In view of the high reliability of the application of CNN in rock image classification based on rock granularity, it can be considered to apply to the classification of rock components.

Acknowledgments
The main project is supported by the National Science and Technology (No.2011ZX05044) and Shaanxi Province industrial science and technology (No.2015GY104).