*Article* **Application of Deep Learning in Petrographic Coal Images Segmentation**

**Sebastian Iwaszenko 1,\* and Leokadia Róg 2**


**Abstract:** The study of the petrographic structure of medium- and high-rank coals is important from both a cognitive and a utilitarian point of view. The petrographic constituents and their individual characteristics and features are responsible for the properties of coal and the way it behaves in various technological processes. This paper considers the application of convolutional neural networks for coal petrographic images segmentation. The U-Net-based model for segmentation was proposed. The network was trained to segment inertinite, liptinite, and vitrinite. The segmentations prepared manually by a domain expert were used as the ground truth. The results show that inertinite and vitrinite can be successfully segmented with minimal difference from the ground truth. The liptinite turned out to be much more difficult to segment. After usage of transfer learning, moderate results were obtained. Nevertheless, the application of the U-Net-based network for petrographic image segmentation was successful. The results are good enough to consider the method as a supporting tool for domain experts in everyday work.

**Keywords:** coal; petrographic analysis; macerals; image analysis; semantic segmentation; convolutional neural networks

#### **1. Introduction**

Coal petrography is a science that, despite the passage of many years, is developing and updating its knowledge with a view to new directions for use in the energy industry. Particular emphasis is placed on clean coal technologies as well as the recovery of critical elements from coal [1–6].

Coal is a heterogeneous substance in terms of its chemical composition. Its heterogeneity is due to the variation in the peat-forming plant material from which it was formed and the variation in the conditions, time, pressure, and temperature to which the organic material was subjected during both its biochemical and geochemical phases [7]. The basic units of the structure of coal, homogeneous in physical and chemical terms, are macerals. The study of the petrographic structure of coal is important from both a cognitive and a utilitarian point of view [7–11]. It is the petrographic constituents and their individual characteristics and features that are responsible for the property of coal and the way it behaves in various technological processes [7,8,12–15].

Knowledge of the percentage of individual petrographic constituents in coal is very important, as the petrographic constituents differ in terms of their physical and chemical properties, such as volatile matter content, elemental composition, vitrinite reflectance, and specific density, all of which affect the chemical, physical and technological properties of coal [7,13,16–18].

The knowledge of the petrographic and mineral composition of the coal deposit, and the properties resulting from this composition, should be the basis for optimizing the conditions in coal preparation plants [6,19,20]. Such an approach makes it possible to control the properties of the final product in order to obtain concentrates with precisely

**Citation:** Iwaszenko, S.; Róg, L. Application of Deep Learning in Petrographic Coal Images Segmentation. *Minerals* **2021**, *11*, 1265. https://doi.org/10.3390/ min11111265

Academic Editors: Rajive Ganguli, Sean Dessureault and Pratt Rogers

Received: 8 September 2021 Accepted: 10 November 2021 Published: 13 November 2021

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

defined parameters and properties, usable in clean coal technologies (CCT), especially in combustion, coking, and gasification processes [21–27].

Petrographic studies are also used to determine the composition of coke mixtures and to forecast coke quality. In addition, petrographic analyses of coal are used in research on the production of liquid fuels by means of the direct hydrogenation method [13]. Another important parameter in the selection of coal for various technologies is the degree of coalification of the organic matter in coal, a measure of which is the reflectance value determined on one of the most homogeneous macerals, namely vitrinite [16,28].

The petrographic composition of hard coals and their degree of coalification, determined by analyzing huminite reflectance for low-rank coals, and vitrinite reflectance for medium- and high-rank coals, have become an important element in the classification of coals, both according to the Polish classification PN-G-97002:2018:11 *Hard coal. Types* and the international classification ISO 11760:2005 *Classification of coals and international codification system for medium and high-rank coals*, ECE/COAL/115, United Nations Publication, New York, 1998. The international classification and codification are based on both the maceral content in coal and the degree of vitrinite carbonization, while the Polish classification by type is based on the vitrinite reflectance value. Although huminite reflectance could be a useful parameter for low-rank coal, the heterogeneous geochemical characteristics of huminite macerals might also be problematic [7,29–33]. Based on the above information, it can be concluded that petrographic studies of coal are very frequently used, and thus they are becoming more and more important.

The microscopic analysis of composition is based on the identification of individual petrographic constituents observed by the operator in the microscopic image. The method is standardized and based on ISO 7404-3:1994 *Methods for the petrographic analysis of bituminous coal and antaracite–Part 3: Method of determining maceral group composition*, as well as the maceral classification of the International Committee for Coal and Organic Petrology (ICCP) [9–11]. The determination is based on the identification of macerals at a minimum of 500 points. Even though several attempts have been made to design automated systems, this analysis is still commonly based on a manual method, which is very time consuming. It requires a lot of knowledge and skill on the part of the operator.

The application of image analysis and computer vision in minerals science has a long and successful history. The images were used for the identification of the minerals based on their color and textural features [34–36]. There were also attempts at the determination of grains sizes using the computer vision approach when the boundaries were used using color [37,38] as well as texture [39,40] features. Computer vision was also used to analyze the microscopic images of minerals. Martens et al. analyzed the microscopic pictures of mortars to assess the distribution of the sand grains sizes [41]. Kazak et al. successfully applied machine learning methods in the analysis of focused ion beam scanning electron microscopy (FIB SEM) images for void space characterization of tight reservoir rocks [42]. Zhou et al. investigated the possibility of segmenting mineral grains in petrographic images using various edge detection algorithms [43]. A similar problem, but with the application of the level set method [44], was also considered in [45]. The attempts were made to use image analysis in the petrography, macerals, cleat, and lithotypes of coal samples as early as in the 1980s [46–48]. The researchers investigated different possibilities to differentiate the organic and mineral matter. Hou et al. used the time-of-flight secondary ion mass spectrometry to obtained images of the macerals and selected mineral matter [49]. Alphana et al., based on scanning electron microscope images (SEM) [50], calculated a set of color and textural features for each image. The classification process is aimed at predicting the coal quality, namely as best, good and poor. The application of radial base functions neural networks (RBFNN) outperformed the other classification methods. However, there was no attempt to identify the macerals composing the sample, and the application of SEM complicated the image acquisition. The most interesting and desirable solution should address the automation of coal petrography using the simplest image acquisition procedure possible. In this direction, O'Braien et al. proposed the usage of full maceral

reflectograms for maceral identification [51]. The coal samples were submerged in resin and polished. After the resin regions were masked out in the image, the cumulative curve of reflectance was computed using the gray values of the remaining pixels. The shape of the curve reflects the composition of the coal. The method turned out to be successful, but it required appropriate preparation of sample and imaging protocol (e.g., usage of red dye for resin and green light for images acquisition). The gray level values had to be calibrated, so that the resulting curve could be interpreted in terms of maceral's containment. The idea was further enhanced by using simultaneous analysis of optic and SEM gathered images [52]. The idea of the usage of optical microscopy obtained images for automated macerals identification was also considered by other researchers [53–58]. Młynarczuk and Skiba proposed the usage of machine learning (ML) and artificial intelligence methods in maceral identification [59]. The maceral group identification is based on the color features vector computed for the square neighborhood of the selected pixel. The k nearest neighbors (kNN) and multilevel perceptron (MLP) were used as the classifier. The results were very promising, and the method was developed to identify the macerals within the inertinite group [60]. The features vector was extended to include both color and texture properties of the pixels. The results were satisfactory, but the effectiveness depended on the maceral. However, none of the methods tried to semantically segment the image. One of the attempts in this direction was made by Wang et al. [56]. In this attempt, the shapes of macerals groups were identified using a clustering procedure, namely a modified k-means algorithm. Then, the discovered objects were classified using morphological, color and texture features. It should be emphasized that in addition to the analysis of images from various types of microscopes, other methods were also used for carbon analysis, examples of which can be found in [61,62].

Semantic segmentation is a topic of much research interest nowadays [63,64]. The application of deep learning (DL) and convolutional neural networks (CNN) allowed for achieving stunning results. The DL was used as a tool for microfossils, core images, petrographic and rock images classification [65]. Attempts are being made to apply these approaches to the analysis of coal characteristics and particularly its petrography using visual information. The most fundamental characteristic of coal's run-of-mine (ROM) distinguishes between coal rocks and the accompanying gangue. Pu et al. used the VGG16 CNN for the classification of images presenting coal or gangue in different configurations (as stockpiles, during transportation, photographed in laboratory conditions, etc.) with satisfactory results [66]. Li et al. developed a solution for the identification of coal and gangue rocks on images [67]. The proposed framework processed the Gaussian pyramid of the input image. The rock grains were detected and classified as coal or gangue. The authors reported impressive accuracy, exceeding 98%, in rock type recognition. The application of semantic segmentation to maceral group identification was developed by Lei et al. [68]. The proposed network utilizes the U-Net [69] network enhanced with the attention gates. The authors used the multi-class form of the output layer of the network. The segmentation results were very good and proved the robustness of DL methods.

The identification of the macerals directly on the image by means of the direct assignment of the maceral label to every pixel would be beneficial in many ways. First of all, it will allow the determination of maceral composition. Secondly, it would provide the scientist with information allowing them to judge whether the individual parts of the image have been correctly identified. Third, the calibration should not be critical in maceral identification, because not only are the color statistics considered, but also the spatial arrangement of pixels constituting the maceral groups (for medium- and high-rank coals). Therefore, attempts were made to develop a method suitable for such coal petrographic images analysis. The presented paper provides a proposition of such a method using the deep learning approach. The highlights of the presented results include the development of the coal petrographic images database, the method of image preparation and augmentation, and the development of a U-Net [69]-based convolutional neural network for the semantic segmentation of coal petrographic images. The proposed approach is based on using

single-class classification—a separate model of the same architecture was trained for each of the macerals. architecture was trained for each of the macerals. **2. Materials and Methods**

the development of the coal petrographic images database, the method of image preparation and augmentation, and the development of a U-Net [69]-based convolutional neural network for the semantic segmentation of coal petrographic images. The proposed approach is based on using single-class classification**—**a separate model of the same

*Minerals* **2021**, *11*, x 4 of 17

#### **2. Materials and Methods** The identification of macerals is based on the microscopic evaluation of grain

The identification of macerals is based on the microscopic evaluation of grain morphology and color. On this basis, three groups of macerals were distinguished: liptinite, vitrinite, and inertinite (Figure 1) [9–11]. The color of liptinite changes from brown through dark grey to light grey in the microscopic image. Under incident light, depending on coal rank, the color of vitrinite changes from dark grey through light grey to almost white. On the other hand, in the same light conditions, the color of inertinite in coal is always the brightest and changes from light grey to white and bright white. The reflectance of all macerals increases with the increasing carbonization of the organic matter of the coal (Figure 2). At the vitrinite reflectance (%Rr) level of about 1.5%, the simultaneous differences in reflectance and in color between liptinite and vitrinite disappear, and with a %Rr about 2.4%, the differences between vitrinite and inertinite also disappear. morphology and color. On this basis, three groups of macerals were distinguished: liptinite, vitrinite, and inertinite (Figure 1) [9**–**11]. The color of liptinite changes from brown through dark grey to light grey in the microscopic image. Under incident light, depending on coal rank, the color of vitrinite changes from dark grey through light grey to almost white. On the other hand, in the same light conditions, the color of inertinite in coal is always the brightest and changes from light grey to white and bright white. The reflectance of all macerals increases with the increasing carbonization of the organic matter of the coal (Figure 2). At the vitrinite reflectance (%Rr) level of about 1.5%, the simultaneous differences in reflectance and in color between liptinite and vitrinite disappear, and with a %Rr about 2.4%, the differences between vitrinite and inertinite also disappear.

**Figure 1.** Maceral groups: (**a**) vitrinite; (**b**) liptinite and inertinite; (**c**) liptinite; (**d**) inertinite and vitrinite. Oil immersion, magnification 500×.

Upper Silesian Coal

**Figure 2.** Variability of macerals' groups reflectivity in coals of different carbonization degree [70]. **Figure 2.** Variability of macerals' groups reflectivity in coals of different carbonization degree [70].

For the purposes of this study, medium-sized samples were prepared for petrographic analyses, according to the PN-ISO 7404-2:2005 *Methods for the petrographic analysis of bituminous coal and anthracite–Part 2: Method of preparing coal samples,* from selected coal samples in which vitrinite reflectance did not exceed 0.8%. Coal samples were taken from coals originating from Polish coal basins: the Upper Silesian Coal Basin and the Lublin Coal Basin. Data on the tested coal samples (rank, the origin of the samples, and maceral compositions are presented in Table 1. The microscopic specimens were prepared by the immersion of coal dust in a mixture of epoxy resin and hardener, obtained by mixing the components at a ratio of 8:1. The immersed microscopic specimens were left for at least 24 h until solidification. The solidified specimens were ground and polished using a Struers LaboForce-3 grinding/polishing machine (Struers Inc., Cleveland, OH, USA). A Zeiss Axio Imager Z 2m microscope (Carl Zeiss AG, Oberkochen, Germany) (Figure 3) was used for the study. A magnification of 500 times and white light reflected in oil immersion were used. Surfaces were selected for which photographs were taken using an Axiocam 506 color camera. The set of microscope photographs obtained showed different macerals for which a mask set was developed. In the petrographic analysis, the participation of maceral groups was most important. The results of the determination of the mineral substance are rarely used. Therefore, they were omitted in the first stage of the research. We plan to take For the purposes of this study, medium-sized samples were prepared for petrographic analyses, according to the PN-ISO 7404-2:2005 *Methods for the petrographic analysis of bituminous coal and anthracite–Part 2: Method of preparing coal samples,* from selected coal samples in which vitrinite reflectance did not exceed 0.8%. Coal samples were taken from coals originating from Polish coal basins: the Upper Silesian Coal Basin and the Lublin Coal Basin. Data on the tested coal samples (rank, the origin of the samples, and maceral compositions are presented in Table 1. The microscopic specimens were prepared by the immersion of coal dust in a mixture of epoxy resin and hardener, obtained by mixing the components at a ratio of 8:1. The immersed microscopic specimens were left for at least 24 h until solidification. The solidified specimens were ground and polished using a Struers LaboForce-3 grinding/polishing machine (Struers Inc., Cleveland, OH, USA). A Zeiss Axio Imager Z 2m microscope (Carl Zeiss AG, Oberkochen, Germany) (Figure 3) was used for the study. A magnification of 500 times and white light reflected in oil immersion were used. Surfaces were selected for which photographs were taken using an Axiocam 506 color camera. The set of microscope photographs obtained showed different macerals for which a mask set was developed. In the petrographic analysis, the participation of maceral groups was most important. The results of the determination of the mineral substance are rarely used. Therefore, they were omitted in the first stage of the research. We plan to take care of this problem in the future.

care of this problem in the future. **Table 1.** Data on the tested coal samples. **Origin Samples Numer of Samples Maceral Groups (% vol.) Vitrinite Reflec-Vitrinite Liptinite Inertinite tance (%)** Basin <sup>12</sup> <sup>45</sup>–79 7–12 17–31 0.51–0.80 The images were captured with the resolution 3072 × 2304 pixels with 8-bit RGB color space. For further processing, the images were cut into 512 × 512 parts. Then, the manual segmentation of the vitrinite, inertinite, and liptinite was performed by a domain expert. The segmentation was used as the ground truth for further processing. There were separate masks created for each of the macerals. The completed database consisted of 162 images for which the masks were created (three masks were created for each input image). The example image and masks are presented in Figure 4.


Lublin Coal Basin 10 58–72 6–15 18–35 0.58–0.75 **Table 1.** Data on the tested coal samples.

*Minerals* **2021**, *11*, x 6 of 17

**Figure 3.** Microscope Zeiss Axio Imager Z 2m. **Figure 3.** Microscope Zeiss Axio Imager Z 2m. The example image and masks are presented in Figure 4.

**Figure 4.** Example of the input image and accompanying masks: (**a**) the input image; (**b**) mask for the inertinite; (**c**) mask for the liptinite; (**d**) mask for the vitrinite. **Figure 4.** Example of the input image and accompanying masks: (**a**) the input image; (**b**) mask for the inertinite; (**c**) mask for the liptinite; (**d**) mask for the vitrinite.

(**c**) (**d**) **Figure 4.** Example of the input image and accompanying masks: (**a**) the input image; (**b**) mask for the inertinite; (**c**) mask for the liptinite; (**d**) mask for the vitrinite. It was decided to use a separately trained single-class model for the maceral identification. This approach has its advantages, dictated by both practical and computational considerations. In petrographic practice, the identification of macerals is used in various variants. For example, as far as the analysis of the vitrinite reflectance index is concerned, the recognition of only one maceral—collotelinite—is required. Similarly, the research carried out in order to determine the coke-forming properties requires the recognition of

two types of petrographic components, namely reactive ones, which include macerals from the vitrinite and liptinite groups, and inert ones, which include macerals from the inertinite group. Using a single-class approach gives the opportunity to make it possible to obtain a network that is particularly sensitive to a specific group of macerals. Such a network is expected to be easier to train than a multiclass network and will allow for the usage of a simpler architecture without sacrificing the performance. The above is also true with respect to the preparation of a set of training images. It also provides the possibility to optimize the network architecture for each group of macerals. The usage of single-class models does not limit the common analysis of all of the maceral groups simultaneously. The outputs of the models can be combined into the result, showing all classes on a single image using for example argmax function (argmax function returns the argument for which the maximum value of output was achieved). types of petrographic components, namely reactive ones, which include macerals from the vitrinite and liptinite groups, and inert ones, which include macerals from the inertinite group. Using a single-class approach gives the opportunity to make it possible to obtain a network that is particularly sensitive to a specific group of macerals. Such a network is expected to be easier to train than a multiclass network and will allow for the usage of a simpler architecture without sacrificing the performance. The above is also true with respect to the preparation of a set of training images. It also provides the possibility to optimize the network architecture for each group of macerals. The usage of single-class models does not limit the common analysis of all of the maceral groups simultaneously. The outputs of the models can be combined into the result, showing all classes on a single image using for example argmax function (argmax function returns the argument for which the maximum value of output was achieved).

It was decided to use a separately trained single-class model for the maceral identification. This approach has its advantages, dictated by both practical and computational considerations. In petrographic practice, the identification of macerals is used in various variants. For example, as far as the analysis of the vitrinite reflectance index is concerned, the recognition of only one maceral—collotelinite—is required. Similarly, the research carried out in order to determine the coke-forming properties requires the recognition of two

For the segmentation experiments, the U-Net convolutional semantic segmentation network was used [71]. The architecture of the network is presented in Figure 5. For the segmentation experiments, the U-Net convolutional semantic segmentation network was used [71]. The architecture of the network is presented in Figure 5.

*Minerals* **2021**, *11*, x 7 of 17

**Figure 5.** The architecture of U-Net network [71]. **Figure 5.** The architecture of U-Net network [71].

The U-Net is an example of an autoencoder network. It can be divided into three parts: the contraction part (4 blocks composed of two convolutional steps and pulling The U-Net is an example of an autoencoder network. It can be divided into three parts: the contraction part (4 blocks composed of two convolutional steps and pulling step), the bottleneck (the convolutional layer with 1024 channels), and the expansion part (4 blocks composed of two convolutional layers followed by upscaling layer). All convolutional layers use the rectified linear unit (ReLU) as the activation function. The input layer in the constructed U-Net-based network has a 512 × 512 resolution, which is in accordance with the input image size. The output layer was constructed with a 1 × 1 convolutional layer with a sigmoid activation function. The list of layers along with their shapes is presented

in Table 2. The network architecture was implemented using the Tensorflow deep learning framework library.


**Table 2.** The shapes of layers used for the U-Net-based maceral segmentation network.

The input images were split randomly into training and validation sets. The validation set was formed with 10% of all images. The binary cross-entropy function was used as a loss function during the network training process. During the training, the pixel-wise accuracy (PA), intersection-over-union (IoU), and mean intersection-over-union (MIoU) were also monitored as effectiveness measures. The ADAM optimizer was chosen for model learning [72]. The training of the network was performed in two stages. In the first stage, the batch size and the learning rate range were estimated. The model training was stopped after just a few epochs and the training results were analyzed. The upper limit for learning rate was established by choosing the value at which the model improved the performance in at least 4 consecutive epochs. The batch size was limited by the size of the input dataset. The bigger the batch size, the fewer steps per epoch the training procedure can make. It was assumed that the biggest batch size allowed for at least several dozen steps for the epoch. The second stage was devoted to model training. During the training, the decreasing learning rate was used. The model was trained for 50 epochs with a constant rate. If no improvement to the loss function was observed, the learning rate was decreased by 10 and the training process was repeated. The accuracy for the validation set was observed as an indicator for possible overtraining. The training was stopped once the validation set accuracy start to decrease. The presented learning procedure was used for each of the macerals. During the training process, two kinds of data modifications were performed:


The order of the images during each epoch was randomized. All input images were in RGB color space. All masks were binary. No image preprocessing except for the described augmentation was performed.

All the calculations were performed on an MS Windows workstation equipped with an Intel i7 processor running at 3.6 GHz (maximum), 32 GB RAM, and an NVIDIA GeForce GTX 1080 graphic card. All software necessary for computation was prepared with the Python programming language using the TensorFlow framework [73].

#### **3. Results and Discussion**

The learning rate during the first stage of experiments was changed from 10−<sup>1</sup> to 10−<sup>6</sup> . It was observed that learning rates greater than 10−<sup>4</sup> caused huge changes in the loss function for consecutive epochs. The loss hardly shows any improvement. Therefore, the rate of 10−<sup>4</sup> was chosen as the largest learning rate used in the calculation. After every 50 epochs during the training, the results were examined and the learning rate decreased once the loss function values started to oscillate from one epoch to another. The calculations were stopped once the validation test accuracy started to increase. At this moment, the learning rate was as low as 10−<sup>7</sup> .

The training for the inertinite started from the randomly initialized network, using Xavier initializer [74]. During the 250 epochs of the training process, the learning rate was changed from 10−<sup>4</sup> to 10−<sup>6</sup> . The final accuracy computed for the validation set was equal to 0.9385. The values of IoU and MIoU were equal 0.79 and 0.85, respectively. The segmentation results compared with the input image and the ground truth for selected images are presented in Figure 6.

The presented results of segmentation are indeed the output values from the last layer in the used U-Net based network. The values, being the values of the sigmoid function, vary from 0 to one, which is reflected by the grayscale level in the picture. The segmentation quality can be assessed as very good, though not perfect. It may be noticed that some minor artifacts are visible on each of the presented images. The network has difficulties in recognizing the tiny structures of inertinite visible among other macerals of similar greyscale and textures. In addition to that, vast structures were correctly noticed by U-Net and marked.

The training procedure and the results obtained for vitrinite were similar to those for inertinite. The learning process also lasted 250 epochs, though the learning rate was changed in a wider range. It started at 10−<sup>4</sup> , but ended with 10−<sup>7</sup> . The selected results of the segmentation are presented in Figure 8. The obtained accuracy computed for the validation set was equal to 0.9176. The IoU was equal to 0.78 and the MIoU was equal to 0.75.

The analysis of the results shows that the quality of segmentation is similar to that for inertinite; however, a slightly higher level of artifacts was observed, which is also visible in the presented images (see Figure 7). The results can be considered very good and suitable for practical applications.

*Minerals* **2021**, *11*, x 10 of 17

**Figure 6.** The results of inertinite segmentation. (**a**), (**d**), (**g**) Input images; (**b**), (**e**), (**h**) segmentation results; (**c**), (**f**), (**i**) ground truth. **Figure 6.** The results of inertinite segmentation. (**a**,**d**,**g**) Input images; (**b**,**e**,**h**) segmentation results; (**c**,**f**,**i**) ground truth.

The presented results of segmentation are indeed the output values from the last layer in the used U-Net based network. The values, being the values of the sigmoid function, vary from 0 to one, which is reflected by the grayscale level in the picture. The segmentation quality can be assessed as very good, though not perfect. It may be noticed that some minor artifacts are visible on each of the presented images. The network has difficulties in recognizing the tiny structures of inertinite visible among other macerals of similar greyscale and textures. In addition to that, vast structures were correctly noticed by

The training procedure and the results obtained for vitrinite were similar to those for inertinite. The learning process also lasted 250 epochs, though the learning rate was

U-Net and marked.

suitable for practical applications.

changed in a wider range. It started at 10−4, but ended with 10−7. The selected results of the segmentation are presented in Fxxigure 8. The obtained accuracy computed for the validation set was equal to 0.9176. The IoU was equal to 0.78 and the MIoU was equal to 0.75. The analysis of the results shows that the quality of segmentation is similar to that for inertinite; however, a slightly higher level of artifacts was observed, which is also visible in the presented images (see Figure 7). The results can be considered very good and

**Figure 7.** The results of vitrinite segmentation. (**a**), (**d**), (**g**) Input images; (**b**), (**e**), (**h**) segmentation results; (**c**), (**f**), (**i**) ground truth. **Figure 7.** The results of vitrinite segmentation. (**a**,**d**,**g**) Input images; (**b**,**e**,**h**) segmentation results; (**c**,**f**,**i**) ground truth.

> As expected for medium- and high-rank coals, the segmentation of liptinite turned out to be the most difficult. There was no success with the training network beginning with the As expected for medium- and high-rank coals, the segmentation of liptinite turned out to be the most difficult. There was no success with the training network beginning with the randomly initialized weights. Moderately satisfactory results were obtained when the training process for liptinite used the weights from the trained model for inertinite segmentation. The application of such performed transfer learning made it possible to obtain acceptable liptinite segmentation, but the errors and artifacts are clearly visible in the resulting images. The accuracy value for the validation set was 0.9791. Such a large value, with a relatively low quality of segmentation, results from the small area covered by the liptinite on the analyzed images. The calculated values for the IoU (0.18) and the

truth.

*Minerals* **2021**, *11*, x 12 of 17

MIoU (0.58) show that the segmentation is indeed poor, and can be treated as a rough identification of liptinite's presence. The results of segmentation are presented in Figure 8. lyzed images. The calculated values for the IoU (0.18) and the MIoU (0.58) show that the segmentation is indeed poor, and can be treated as a rough identification of liptinite's presence. The results of segmentation are presented in Figure 8.

randomly initialized weights. Moderately satisfactory results were obtained when the training process for liptinite used the weights from the trained model for inertinite segmentation. The application of such performed transfer learning made it possible to obtain acceptable liptinite segmentation, but the errors and artifacts are clearly visible in the resulting images. The accuracy value for the validation set was 0.9791. Such a large value, with a relatively low quality of segmentation, results from the small area covered by the liptinite on the ana-

**Figure 8.** The results of liptinite segmentation. (**a**), (**d**), (**g**) Input images; (**b**), (**e**), (**h**) segmentation results; (**c**), (**f**), (**i**) ground **Figure 8.** The results of liptinite segmentation. (**a**,**d**,**g**) Input images; (**b**,**e**,**h**) segmentation results; (**c**,**f**,**i**) ground truth.

A summary of the obtained values of accuracy, IoU, and MIoU is presented in Table 3. The quality of segmentation obtained for inertinite and vitrinite was good enough to be used as the basis for the development of an autonomous maceral identification method. The imperfections were small, not differing much from the ground truth. Moreover, during the analysis of the results, it turned out that the network was able to identify the small inertinite structures overlooked during manual segmentation. It seems reasonable to use the U-Net-based convolutional network for the segmentation of the mentioned macerals

with only a little attention from a domain expert. Unfortunately, this is definitely not true for liptinite. The network was able to identify the liptinite only roughly. The result should instead be treated as approximate, possible locations of liptinite structures which have to be verified and corrected by a domain expert. The training for liptinite was also more difficult than for other macerals. It is probably caused by its more varied appearance. In addition, liptinite covered small areas in the images and was present only on relatively small numbers of them. Nevertheless, such support in assessing the maceral can be useful in practice. The obtained results can be related to others reported in the literature [56,68]; however, the comparison is not obvious as the mentioned papers do not provide the measures for the macerals' groups separately. Therefore, it is reasonable to use the mean values for the IoU and MIoU presented in Table 3 and the values of the same measures presented in [68]. The presented U-Net-based network gives better results than the non-DL methods. The results obtained by the improved U-Net (enhanced with the use of attention gates) are better than presented in the paper, though the difference is small (IoU ~ 0.8554 and MIoU ~ 0.631 for best enhanced network presented in [68]). However, it is impossible to assess how it is divided into individual macerals groups. When the liptinite, with the worst results, is omitted, the mean IoU and MIoU for inertinite and vitrinite are much greater. As the proposed models address the segmentation of each of the macerals individually, they should be treated as complementary to the model presented in [68]. Wang et al. presents the results obtained using different deep learning networks architectures, such as U-Net (standard multi-class architecture), SegNet, and DeepLab V3+ [57]. The results are provided for each of the macerals separately. The comparison is presented in Table 4.


**Table 3.** The values of accuracy, IoU and MIoU obtained for validation images set.

**Table 4.** The IoU values obtained for various deep networks architectures.


The proposed simplified U-Net-based network did very well in segmenting the inertinite, achieving a better result than much more sophisticated DeepLab V3+ network (the best from architectures compared in [57]). The results obtained for vitrinite are slightly worse than for the other two networks. There are very large differences in the case of liptinite. The network architecture was probably too simple to successfully cope with the most difficult to recognize maceral groups. The results obtained for two other maceral groups are optimistic. In particular, the IoU measure for the inertinite is good enough to contribute to the assumptions made and present the network's robustness. The proposed network can be efficiently used for inertinite and vitrinite identification in the petrographic images.

The discussed approaches present different means to provide the solution for maceral groups identification. The usage of different models trained for each maceral group separately gives the opportunity for finetuning. This also allows the architecture of the net to be kept relatively simple (e.g., simpler than in the original U-Net) while still providing good performance, at least for inertinite and vitrinite. The results are also encouraging in research targeted at discovering the simplest and most robust neural network structure for the efficient analysis of petrographic images.

#### **4. Conclusions**

The application of a U-Net-based CNN network for macerals segmentation on the coal petrographic optical microscope images has been presented. The set of images was manually segmented by experts and used further as the ground truth. The network was trained to segment inertinite, liptinite, and vitrinite. During the training, basic image augmentation was used (horizontal and vertical flipping, rotation by multiplicity of π/2 angle). The result show that very good results can be achieved for inertinite segmentation. The vitrinite was segmented slightly worse, but also at a very good level. The liptinite was most difficult to process. Moderately good results were obtained after the transfer learning usage. Even so, the segmentation was noticeably worse than for inertinite and vitrinite.

The obtained results show that the proposed convolutional autoencoder could effectively be used for maceral segmentation. Although the results for the liptinite were worse than those for other macerals, due to the advanced rank of analyzed coal samples, the network in most cases was able to locate the estimated maceral location. The inertinite and vitrinite segmentation are good enough to be considered as a base for autonomous petrographic processing. Although the results do not justify such a sentence in the case of liptinite, it still can be a valuable tool supporting the expert during petrographic image analysis. Data augmentation and transfer learning in particular proved their effectiveness in at least partially solving the problems in difficult cases. The comparison of the results with similar research showed that the obtained values of IoU and MIoU are better than those reported in the literature for the ML models, and are similar to those achieved by using the DL models (for inertinite and vitrinite). The segmentation of liptinite with the simplified, U-Net-based network is still a challenge and requires further research. The ML methods as well as image analysis methods are very promising, and have been utilized for coal analysis by many scientists with satisfactory results. The approach proposed here, though encouraging, fulfills only a tiny portion of the scientific challenges related to coal petrography. Further research work in this field is required.

**Author Contributions:** Conceptualization, S.I. and L.R.; methodology, S.I. and L.R.; software, S.I.; validation, L.R.; formal analysis, S.I.; investigation, S.I.; resources, L.R.; data curation, S.I. and L.R.; writing—original draft preparation, S.I. and L.R.; writing—review and editing, S.I. and L.R.; visualization, S.I.; supervision, L.R.; project administration, L.R.; funding acquisition, L.R. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by Ministry of Science and Higher Education (Poland), grant number 11185011.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

#### **References**

