Skip to main content

Thank you for visiting You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

A machine learning approach to map crystal orientation by optical microscopy


Mapping grain orientation in crystalline solids is essential to investigate the relationships between local microstructure and crystallography and interpret materials properties. One of the main techniques used to perform these studies is electron backscatter diffraction (EBSD). Due to the limited measurement throughput, however, EBSD is not suitable for characterizing samples with long-range microstructure heterogeneity, nor for building large material libraries that include numerous specimens. We present a machine learning approach for high-throughput crystal orientation mapping, which relies on the optical technique called directional reflectance microscopy. We successfully apply our method on Inconel 718 specimens produced by additive manufacturing, which exhibit complex, spatially-varying microstructures. These results demonstrate that optical orientation mapping on a metal alloy is achievable. Since our method is data-driven, it can be easily extended to different alloy systems produced using different manufacturing processes.


Characterizing the microstructure of polycrystalline solids—including the size, morphology, and crystallographic orientation of the constituent crystal grains—is essential for understanding the relationships between process history, microstructure, and materials properties. This information enables predicting the behavior of structural and functional components and underpins the design of next-generation, high-performance materials1. The standard practice for crystallographic characterization involves diffraction-based methods, which rely on electron or X-ray microscopy techniques. One of the most utilized amongst these techniques is electron backscatter diffraction (EBSD). EBSD provides an accurate mapping of the material’s constituent phases and grains as a function of their crystallographic orientation by measuring and indexing the local diffraction patterns produced by the atomic lattice as the electron beam is scanned across the sample surface2,3. Being tied to an electron microscope, however, EBSD is limited in terms of measurement throughput, field of view, and maximum specimen dimensions. Therefore, orientation imaging by EBSD is generally carried out on small-area specimens (of the order of mm2), whose microstructure is representative of an entire component produced using a given manufacturing process. Due to these limitations, EBSD is inefficient at building materials libraries that are based on numerous specimens produced using different process parameters4, or at characterizing samples that exhibit large-scale microstructure heterogeneity. These limitations are particularly detrimental in the context of metal additive manufacturing (AM). Indeed, the complex and variable solidification pathways during fusion-based AM processes are known to yield microstructures that vary throughout the build and even across batches of nominally identical parts1,5. A high-throughput crystallographic characterization technique would significantly accelerate the development of additive processes as well as their adoption by the industry5.

One possible solution is to employ optical microscopy techniques, which provide significantly faster data acquisition and a larger field of view compared to EBSD. Since the atomic lattice cannot be resolved directly under visible light, however, optical orientation mapping may only be achieved indirectly, by analyzing optical signals that encode the underlying crystallographic orientation6,7. Based on this principle, techniques have been developed to quantify orientation-dependent changes in light intensity and polarization upon reflection from optically active materials8,9, or to reconstruct the topography of etch-pits10, which inherit their geometry and orientation from the underlying atomic lattice. Directional reflectance microscopy (DRM) falls in this second category10,11. The working principle of DRM is based on measuring and analyzing the reflection of light from the surface of the material as a function of the illumination direction10,11,12. When the material is chemically etched, the preferential dissolution of specific crystallographic planes13,14,15 or phases16 can generate topographical surface features which are linked to crystallographic orientation. These features reflect visible light preferentially at certain angles, producing a directional (i.e., anisotropic) reflectance effect. Once captured by DRM, directional reflectance data is analyzed by computational methods to enable spatial mapping of grain orientation10,11. Until now, however, orientation imaging by optical means has only been attained on pure crystalline solids, for which the measured optical signals could be indexed using material-specific, physics-based models. Expanding high-throughput optical orientation imaging to engineering metal alloys and other technologically relevant materials remains an open challenge, given that the complex, multi-phase microstructures of these materials give rise to optical signals that are difficult to decode using physics-based models.

Here, we present an optical method to perform grain orientation mapping in metal alloys. We use a convolutional neural network (CNN) to infer crystal orientation from the optical signal acquired by DRM. We name our model EulerNet because it predicts crystallographic orientation as represented by a set of Euler angles17. Our machine learning method circumvents some noteworthy limitations of physics-based approaches. Firstly, EulerNet learns the relationships between directional reflectance and crystal orientation autonomously, during training. That makes our workflow easier and faster by reducing the need for human intervention. No specialized studies are needed to build up knowledge about the morphology and crystallography of the microstructural constituents responsible for directional reflectance. Secondly, a machine learning model has the capacity of recognizing complex patterns in directional reflectance signals, which may otherwise go unnoticed by human analysis, or which may be difficult to outline using conventional digital signal processing. Finally, our data-driven framework is flexible. It can be easily templated and applied to other alloys with different microstructures, making it possible to extend optical orientation imaging to a variety of materials. In the following sections, we describe our machine learning workflow and demonstrate its effectiveness on Inconel 718 (I718) specimens produced by directed energy deposition (DED).

Results and discussion

Datasets, microstructure, and optical orientation maps

We produced a library of ten I718 specimens with rectangular geometry (24 mm × 24 mm × 12–18 mm) by DED. During the DED process, raw material in powder form (in this case, I718) is continuously fed into a melt pool through a nozzle, melted by a high-power laser source, and solidified upon cooling18. The material is deposited layer by layer on a build platform to create a three-dimensional shape. We produced our specimens using different combinations of laser powers, laser translating speeds, layer heights, and powder feed rates (Supplementary Table 1). These process parameters affect melt pool solidification and the thermal history of the material19,20. As a result, different specimens exhibit different microstructures. Some specimens display highly textured, columnar dendritic grains of the face-centered cubic (FCC) γ matrix phase, which grows along the build direction (BD). In other specimens, we observe portions of finer, randomly oriented grains interrupting the columnar growth, which produces a large-scale microstructure heterogeneity across the entire build. This heterogeneity is often found in DED-produced materials21. After deposition, we heat-treated the specimens following the ASTM standard for solutionizing and hardening I718 (see Methods). This heat treatment results in the formation of intermetallic precipitates in the microstructure, which are pivotal to our work. Among these precipitates, the orthorhombic phase δ (Ni3Nb) nucleates at the γ matrix grain boundaries and at dendrite boundaries through partial decomposition of the metastable, body-centered cubic (BCC) γ″ (Ni3Nb) phase22. δ precipitates appear in the microstructure as elongated, platelet-like structures22,23.

To enable optical orientation mapping, we etched the specimens using a chemical reagent that selectively dissolves the γ matrix, letting the corrosion-resistant δ platelets protrude from the surface (Fig. 1a, bottom). Because they are tilted with respect to the XY plane, these precipitates produce a directional reflectance signal which can be measured by DRM (Fig. 1a, top). Leveraging the crystallographic relationship between δ and γ, we use the directional reflectance signal to assess the orientation of the γ matrix grains. Indeed, δ and γ are oriented such that (111)γ//(010)δ and [\(\bar 101\)]γ//[100]δ22,24. Moreover, the habit plane of δ precipitates (i.e., the predominant platelet facet plane) is aligned parallel to {111}γ22.

Fig. 1: Illustration of the DRM technique.
figure 1

a In I718, chemical etching reveals δ phase precipitates in the form of elongated platelets protruding on the surface (here, seen under the scanning electron microscope). These platelets are in a specific crystallographic relationship with the γ matrix, causing surface reflectance to vary with grain orientation and the incident illumination angle. b The DRM apparatus (here, represented schematically) consists of a stereomicroscope focused on a fixed specimen and a moving white light source. A sequence of micrographs is captured while the light source rotates around the specimen.

We took a DRM measurement of each specimen using the setup shown schematically in Fig. 1b and following the procedure detailed in reference6. The local directional reflectance signal from any individual grain in the microstructure consists of the reflection intensity measured at that grain as a function of the light source elevation (θ) and azimuth (φ) angles. Peaks in reflection intensity may be observed at angles at which δ platelets reflect the incoming light directly into the optical microscope. Because the orientation of the platelets depends on the crystallographic orientation of the corresponding γ grain, different grain orientations produce distinct reflectance signals with different reflectance peaks.

Figure 2 illustrates the diversity of reflectance patterns encountered in I718. In this figure, we represent seven different crystal orientations in the inverse pole figure (IPF) map along the Z-axis as octahedra. The facets in each octahedron lay parallel to the {111}γ planes of the underlying grains, which coincide with the habit planes of the δ precipitates22. In general, we observe that the number and position of reflectance peaks in the reflectance patterns follow the underlying crystal symmetry. For instance, the reflectance pattern of the (100)γ grain contains four peaks separated by a 90° angle, which is consistent with the fourfold symmetry of the face-centered cubic (FCC) structure in this orientation. Similarly, the (110)γ grain pattern exhibits a two-fold symmetry. By contrast, we observe a six-fold symmetry in the pattern produced by (111)γ grains. The position of these reflectance peaks qualitatively matches the coordinates at which we would expect to observe specular reflections from {111}γ planes. This finding is a strong indication that reflectance peaks stem from specular reflections of the incoming light at the protruding δ platelets.

Fig. 2: Directional reflectance signals in I718.
figure 2

Directional reflectance signals measured from differently oriented grains exhibit different reflectance peaks. Each reflectance pattern is connected to its corresponding crystallographic orientation along the Z-axis (i.e., the sample surface normal) in the inverse pole figure (IPF) triangle. The peaks occur at illumination angles that coincide with specular reflections from {111}γ crystallographic planes.

Based on these observations, we speculate that grain orientation may be retrieved analytically, in principle, by devising a physics-based reflection model that relates peaks position and intensity to the etch-induced surface topography and to the underlying crystal orientation. In practice, however, developing such a model is challenging, time-consuming, and relies heavily on the input of human experts. It requires sophisticated digital signal analysis to accurately identify the key directional reflectance features in the optical signals, detailed characterization of the morphology, distribution, and crystallography of the microstructural constituents responsible for directional reflectance, and an in-depth understanding of how these constituents interact with visible light to produce the directional reflectance signal10. All these aspects make this approach difficult to template and hardly compatible with a high-throughput materials characterization paradigm.

By contrast, our machine learning model, EulerNet, can recognize complex patterns in directional reflectance signals autonomously and predict orientation with high accuracy and throughput. As the relationships between the input and output are learned in a fundamentally unguided way during training, the model requires minimal human supervision. In particular, no specialized microstructural studies are required to build up prior knowledge of the linkage between surface topography, directional reflectance, and crystal orientation. When used on a test specimen, EulerNet predicts a crystallographic orientation for each pixel in the DRM dataset, enabling grain orientation to be mapped spatially over the specimen’s surface in a similar fashion as EBSD. Figure 3 compares the EulerNet and EBSD IPF grain maps (831 × 1102 pixels) from one of our I718 specimens. From visual inspection of these maps, it appears that the crystal orientation predictions by EulerNet based on DRM generally match the results obtained by EBSD. Acquiring a DRM measurement on our samples took about 20 min while generating the orientation maps using EulerNet took only a few minutes when running on a modern laptop computer. By contrast, acquiring the EBSD measurement took several hours. Furthermore, different instances of the EulerNet model can be trained on different material datasets. Therefore, the methodology can be easily templated and reapplied to different alloys, regardless of their microstructural complexity. All these characteristics make our machine learning approach suited to deliver high-throughput optical orientation imaging while minimizing development time and effort.

Fig. 3: Orientation maps produced by EulerNet (DRM) and EBSD.
figure 3

The IPF maps produced by our EulerNet model from directional reflectance are visually almost identical to the ground truth EBSD maps, both in-plane (along the X and Y reference directions) and out-of-plane (along the Z direction). The specimen shown in the figure was not used for training the model. The scale bar represents 5 mm.

Machine learning model

The CNN architecture of our EulerNet model is shown schematically in Fig. 4. CNNs are state-of-the-art machine vision algorithms that have proven effective at processing image-like data and have gained significant attention in computer vision25,26. Our model takes as input a directional reflectance signal in the form of a two-dimensional numerical array of 6 × 72 continuous values, which represent the local surface reflection intensity across the array of illumination angles measured during DRM.

Fig. 4: Convolutional neural network model architecture.
figure 4

Our CNN model, EulerNet, connects the input directional reflectance signal to crystal orientation, which is represented as a set of three Euler angles. The input is first passed through convolutional layers and max-pooling layers to extract visual patterns, and then through fully connected regression layers, leading to the Euler angles prediction.

To predict crystal orientation from this input, the directional reflectance signal is passed through two convolutional and max-pooling layers followed by two fully connected regression layers. The role of the convolutional and max-pooling layers is to extract visual patterns in the reflectance signal which are informative about crystal orientation. In the first convolutional layer, simple visual patterns are detected. These so-called low-level features could be, for instance, edges and blobs. In the second convolutional layer, these patterns are assembled into more complex visual patterns representing, presumably, characteristics of the reflectance peaks, such as their position, number, and intensity. These high-level features are then flattened (i.e., reduced to a single dimension) and further passed through the fully connected regression layers. The resulting output prediction takes the form of three continuous values: the Euler angles used to represent crystal orientation. Euler angles parameterize an ordered sequence of three rotations that bring the (right-handed) Cartesian coordinate system attached to the specimen onto that of the crystal.

The convolutional layers and the fully connected layers comprise several tunable parameters—such as weights and biases—that must be learned during a training phase. Training is performed iteratively by comparing model predictions to the ground truth, computing prediction error, and readjusting the trainable parameters through backpropagation to minimize the error and improve prediction accuracy27. Here, we use EBSD measurements as ground truth labels and design our EulerNet model to minimize the mean disorientation angle between the predicted crystal orientation and the ground truth. The disorientation angle represents the minimum angle of rotation about a given axis to bring the two crystal orientations into coincidence28. Once trained, we test the model on previously unseen specimens; namely data which we did not use for training. This approach is representative of a real application scenario, in which a newly produced part with an unknown microstructure must be characterized. To test our model, we apply cross-validation over ten splits to our set of specimens. We use data from nine specimens for training and hold one out for testing, switching the test specimen in-between each split. We further detail the process of selecting data for training and testing in the Methods section.

Performance evaluation

We evaluate the performance of our EulerNet model by comparing the predicted and ground truth (EBSD) orientations at selected locations (i.e., pixels in the dataset) at the center of grains to avoid including data that might be misregistered in the test set (see Methods). For completion, we also include a comparative analysis on a pixel-level without filtering the data in the supplementary materials (Supplementary Fig. 2). In Fig. 5a, we show the distribution of disorientation angles in the combined tests from all cross-validation splits. The median disorientation angle between the predicted and true orientations averaged across the ten cross-validation splits is 6.7° ± 0.8°. While this value is a useful performance indicator, we believe it overestimates the real error because of two existing and hardly avoidable limitations in our evaluation method. Firstly, registration of the EBSD and DRM datasets is challenging because of the substantial differences in spatial distortion resulting from the two types of measurement, which require nonlinear methods to bring the two fields of view into coincidence. In this work, we employed an image registration algorithm based on optical flow estimation. We anticipate that, despite selecting pixels at the center of grains for the error evaluation, imperfections in the registration process may still lead to mislabeling of a fraction of the test data (see Supplementary Fig. 2c). The tail of the distribution at high disorientation angles in Fig. 5a likely contains this mislabeled data. Secondly, mounting the specimen for DRM such that the transverse and build directions are aligned parallel to the corresponding directions in the EBSD dataset is also a process that is subject to manual error, which is difficult to correct given the differences in spatial distortion between the two datasets.

Fig. 5: Evaluation of EulerNet performance.
figure 5

a The disorientation angle between the predicted orientation and the EBSD ground truth is centered around 5-8°. b The disorientation angle is marginally higher in the vicinity of the {111}γ orientation out-of-plane (Z) and is otherwise mostly uniform across the other orientations.

We also examine the orientation dependence of the prediction error by evaluating it along each of the specimen’s reference directions. To evaluate the error along these axes, we consider the two 3 × 3 rotation matrices associated with the Euler angles predicted by EulerNet, g1, and the EBSD measurement, g2. We compute eX, eY, and eZ, which represent the angles between the predicted and true normal vectors of the plane facing the specimen’s reference directions, as:

$${\it{e}}_{{{\mathrm{X}}}} = \mathop {\sum}\limits_{{\it{j}} = 1}^3 {{{{\mathrm{arccos}}}}} \left( {{{{\mathbf{g}}}}_{1\,j,1}^{ - 1} \cdot {{{\mathbf{g}}}}_{2\,j,1}^{ - 1}} \right)$$
$$e_{{{\mathrm{Y}}}} = \mathop {\sum}\limits_{j = 1}^3 {{{{\mathrm{arccos}}}}} \left( {{{{\mathbf{g}}}}_{1\,j,2}^{ - 1} \cdot {{{\mathbf{g}}}}_{2\,j,2}^{ - 1}} \right)$$
$$e_{{{\mathrm{Z}}}} = \mathop {\sum}\limits_{j = 1}^3 {{{{\mathrm{arccos}}}}} \left( {{{{\mathbf{g}}}}_{1\,j,3}^{ - 1} \cdot {{{\mathbf{g}}}}_{2\,j,3}^{ - 1}} \right)$$

We compute the mean values of eX, eY, and eZ, in the test set and name these metrics DX, DY, and DZ. The values of DX, DY, and DZ, averaged across all cross-validation splits, are respectively 6.5° ± 0.6°, 6.4° ± 0.6° and 5.8° ± 0.6°. This result indicates a slightly lower prediction error along the out-of-plane direction (DZ) compared to the in-plane directions (DX, DY). This difference may come from the greater potential for misalignment of the specimens in-plane compared to out-of-plane when mounting them to carry out DRM measurements. Finally, in Fig. 5b, we plot the disorientation angle as a function of crystal orientation in the principal axes of the specimen’s coordinate system. The error distribution is mostly uniform, except for the slight increase near the {111}γ orientation in the out-of-plane direction (Z). We believe that this minor inhomogeneity could be related to the peculiar six-fold symmetry seen in the directional reflectance signal corresponding to this crystal orientation (Fig. 2).

Our EulerNet model provides reliable orientation mapping in all our I718 specimens (Supplementary Fig. 1) despite the marked differences in their microstructure, which stem from the different DED parameters we used to produce them. This result suggests that EulerNet is robust to variations induced by the manufacturing process and can be used to characterize a wide range of I718 microstructures. Nevertheless, we note that our reported accuracy of 6.7°—even though overestimated by dataset misregistration—is substantially higher than the typical accuracy attainable by EBSD (~0.6°)17. We speculate that the error rate of our optical technique may also be affected by the inherent tolerance found in the elements that make DRM, including the level of light collimation, the quality of the optical lens of the camera, the accuracy of the motors which move the light source around the specimen, and the variability of the etch-induced surface structures. Thus, it is likely that increasing equipment accuracy would enhance the measurement accuracy significantly. In addition, given the vast design space of neural networks and the rapid developments in this field, it is possible that future improvements in the design or in the implementation of our CNN model could further contribute to improve performance.

Finally, we believe that DRM should not be considered as a direct substitute for EBSD, which remains the main technique for detailed analysis of crystallographic features, especially at the small scale. Instead, we believe that DRM combined with our machine learning technique can be an invaluable tool in supporting materials development efforts that require the application of orientation mapping to large specimens or vast databases. It may also be particularly suitable for applications that tolerate a modest trade-off in accuracy for a considerably increased measurement throughput. Many of such applications already exist. A notable example is the identification of relationships between crystallographic texture, process parameters, and part geometry in metal AM.

Handling anomalous data

Once an EulerNet is trained and validated, it becomes permanently available for future characterization of a specific material. The model used in this study, for instance, is available online (see Data Availability) and is suitable for the characterization of I718 specimens produced by DED. We believe that our model would yield reliable results on any such specimen as long as the δ phase precipitates—which generate the directional reflectance signal—are well-developed in the alloy and visible after etching. These conditions should be met when carrying out ASTM standard heat treatments on I718 and when the specimen surface preparation (including polishing and chemical etching) is performed following the same steps as those used to prepare the training dataset. We note that using DRM apparatuses that consist of equipment different from that used to produce the training set (e.g., the optical microscope, the camera sensor, the light source, etc.) could potentially introduce systematic bias into the data and affect the error rate. To minimize equipment bias and ensure model transferability across the community, we advise for equipment calibration, which we detail in the Methods section. If systematic equipment bias persisted despite the calibration, we foresee that applying transfer learning29,30 to fine-tune neural networks to a specific set of hardware might be a suitable solution to explore.

Regardless of its origins, it is important to be able to detect and exclude biased data to prevent fundamentally wrong microstructure characterization output. Indeed, machine learning models make predictions without any judgment on the quality of the input data or without any capacity to assess the uncertainty associated with the predictions31. If a test specimen is markedly different from the training specimens—which may occur, for example, as a result of failed specimen preparation, or when using a new DRM apparatus—the input data may be out-of-distribution (i.e., unrepresentative) and the associated predictions by the machine learning model may be flawed32. To detect out-of-distribution data, we propose an anomaly detection model based on dimensionality reduction of the DRM dataset by principal component analysis (PCA)33. We compute the two first principal components of the directional reflectance signals in the training set and project the data in this manifold. By construction, PCA components represent axes along which variance in the data is maximized. Along the PCA axes, training data is scattered following a distribution close to normal. We standardize these distributions by centering them around 0, with a standard deviation of 1, to ensure that they are in the same relative range. Then, we define the average of both variables as a single out-of-distribution indicator, z. This indicator is unitless. It reflects how far the data is from the mean of the training set distribution.

This z-score model is both simple to implement and efficient in detecting biased data. We illustrate its effectiveness by comparing two separate I718 specimens produced by DED. The first one (in Fig. 6a) is a specimen whose microstructure contains a few lack-of-fusion defects (see Fig. 6c) resulting from an excessive layer height setting during the DED process. The other (in Fig. 6d) is a specimen that, despite being heat-treated and etched according to standards, shows underdeveloped crystallographic surface features, and even a complete absence of them (see Fig. 6f) in the region near the baseplate. This anomaly is due to the variable cooling rates established within the alloy during processing, which led to high Nb retention in solid solution (and, correspondingly, depletion of δ phase precipitates) in the first portion of the build34. The corresponding z-maps successfully identify both anomalies. In the specimen in Fig. 6a, the distribution of the z value (in Fig. 6b) approximately follows that of the training dataset, indicating that directional reflectance in this specimen and in the training set are globally alike. However, lack-of-fusion defects get highlighted by the anomaly detection model. The uniformly bright appearance of the lack-of-fusion defects in the bright-field optical micrograph in Fig. 6c suggests that the surface remained locally flat (i.e., mirror-like) and that it did not react to the chemical etchant. In the specimen in Fig. 6d, it is apparent that z is generally higher compared to the training set (see Fig. 6e), and increases progressively towards the bottom of the sample, where there are no δ phase precipitates.

Fig. 6: Detection of anomalies and systematic bias in DRM datasets.
figure 6

Applying anomaly detection to new directional reflectance datasets enables to preemptively detect and discard unrepresentative data, which is not suitable for orientation imaging by the EulerNet model. a Anomaly detection in a regular specimen containing lack-of-fusion defects. When mapping z across the surface, the defects get highlighted by the anomaly detection model. b The distribution of z in this specimen is otherwise close to that of the training set distribution. c An example of lack-of-fusion defect seen under the optical microscope. d In a specimen with underdeveloped or absent δ phase precipitates exhibiting a globally high z-score. e The distribution of z is shifted compared to that of the training set. f Under SEM, no δ phase precipitates are visible on the specimen’s surface in the area close to the baseplate. The scale bars in (a, d) represent 5 mm and the scale bar in (f) represents 5 µm.

These examples illustrate that applying anomaly detection to new specimens of interest can be effective at detecting unrepresentative data, enabling preemptively verifying its suitability for orientation imaging by the EulerNet model. As the meaning of a high z-score can vary, the final decision to keep or discard data based on this indicator should be left to the operator based on his/her domain expertise and interpretation of the data.

Future outlook

Our results underpin the tremendous potential of machine learning algorithms for the automated decoding of directional reflectance signals and their application to crystallographic orientation mapping. In this paper, we decided to focus on Inconel 718 owing to the technological relevance of this alloy, which is used for many components in aircraft, rocket engines, turbines, and combustion chambers. In principle, however, our method would be applicable to any other alloy for which a reliable crystallographic etching method can be identified. Fortunately, the identification of etchants that are amenable to producing crystallographic features on the specimen surface is facilitated by the large body of literature produced by metallographers, who have perfected the chemical etching of metals and metal alloys over the past several decades14.

Once a suitable etchant is identified for a given material, our machine learning approach can be applied without the need for detailed microstructural studies or for deriving and manually tuning a physics-based orientation indexing model. The only requirement is to gather an initial set of specimens of the material to be characterized, assess their microstructure by means of DRM and EBSD, and train and validate the corresponding EulerNet model. Because of the relatively high cost of initially gathering data to perform training, validation, and optimization of a new model, there is great benefit in sharing trained models across the materials science community at large for a variety of different materials, alongside detailed information about surface preparation of the specimens, DRM equipment used (and the corresponding calibration), and the attainable performance. This endeavor could be achieved, for example, through e-collaborations.

The low cost and availability of the equipment required to carry out DRM measurements hold the promise to spread optical orientation mapping capabilities across both academia and the industry. We believe that our method would find immediate application in the research and development of metal AM processes, where there is high interest in expanding orientation imaging to entire, large-scale components. Moreover, our machine learning approach is the first to demonstrate orientation imaging of a complex alloy by optical means. As such, it could be pivotal in establishing a solid foundation for high-throughput optical orientation microscopy, leading to faster discovery of process-structure-property relationships and accelerated materials discovery.



The nominal composition of the I718 specimens was 54% Ni, 18% Cr, 20% Fe, 5% Mo, 2% Nb, and 1% Ti. We produced them using a commercial-directed energy deposition machine (by BeAM) equipped with a 24Vx nozzle. We set the hatch spacing to 1.5 mm with 33% overlap, the working distance to 13 mm, and the central and secondary gas flow rates to 6 and 10 L/min. After deposition, we heat-treated the I718 specimens in a vacuum furnace using a three-stage process including a 60-min hold at 950 °C, an 8-h hold at 750 °C (for age hardening), and another 8-h hold at 690 °C (following standard AMS5663 for I718). We cut the heat-treated specimens along the XY plane perpendicular to the build direction (Z), and mechanically ground them according to standard metallographic sample preparation techniques to reveal the microstructure. To grind the specimens, we used a sequence of silicon carbide paper from 320 grit to 4000 grit. We then polished them to a mirror-like finish using a colloidal suspension of silica particles. Finally, we etched the specimens by immersion in a bath of Kalling’s 2 reagent (5 g cupric chloride, 100 mL hydrochloric acid, and 100 mL ethanol) at room temperature for 10 min.

For all specimens, we measured crystal orientation by EBSD and registered the EBSD and DRM fields of view so that each reflectance pattern could be associated to a reference orientation, which we regard as a ground truth. We performed EBSD measurements in a JEOL 7600 F field emission scanning electron microscope equipped with an Oxford instruments Nordlys 2 S EBSD detector. We used a 15 mA emission current, 20 kV accelerating voltage, and a 15 μm step size. To perform DRM measurements, we used an apparatus consisting of an Olympus SZ6145 stereomicroscope equipped with a 3X objective lens, an industrial monochrome CMOS camera, and a white LED light source. We varied the light source elevation angle (θ) from 15° to 65° in steps of 10° and the azimuth angle (φ) from 0° to 355° in steps of 5° and captured an image for each (θ, φ) combination. As a result, each DRM dataset contained a stack of 6 × 72 = 432 images. The original resolution of the images captured was 2448 × 2048 pixels. The images were downscaled to 1224 × 1024 pixels in the DRM datasets to reduce memory transfer during data processing. We normalized the measured reflectance against a uniform white reflector6 to compensate for uneven light intensity. We registered the DRM and EBSD datasets using the Python Scikit-image implementation of the TV-L1 solver for coarse to fine optical flow estimation35.

Model implementation

We implemented our EulerNet model in the Python Tensorflow library36 using the Keras Functional API37. In Table 1, we report the specifications of all constitutive layers. Our model leveraged a total of 1’219’523 trainable parameters.

Table 1 EulerNet model layer specifications.

Objective function

The aim of our EulerNet model was to minimize the disorientation angle between the predicted output and the ground truth EBSD orientation28. In face-centered cubic (FCC) crystal structures (the structure of the γ phase in I718), 24 different symmetry operations can be applied to the crystal and result in equivalent orientations. Owing to this crystal symmetry, the disorientation angle is derived as the minimum among the 24 different angles computed between the ground truth and all orientations equivalent to the predicted orientation. Considering two 3 × 3 rotation matrices g1 and g2, associated with the Euler angles of the predicted and ground truth orientations, respectively, and Si=1:24 the ensemble of the 24 symmetry operators for the FCC crystal structure, the disorientation angle is given by:

$$D\left( {{{{\mathbf{g}}}}_1,{{{\mathbf{g}}}}_2} \right) = \mathop {{{{{\mathrm{min}}}}}}\limits_{i \in [1,24]} \left\{ {arccos\left( {\frac{{tr\left[ {{{{\mathbf{g}}}}_1S_i{{{\mathbf{g}}}}_2^{ - 1}} \right] - 1}}{2}} \right)} \right\}$$

During training, the input data was passed into the model iteratively in mini-batches of 50 examples. At each mini-batch iteration, the weights and biases of the fully connected components and the filters of the convolutional layers were progressively updated by backpropagating the error given by the objective function28 using an optimizer algorithm. As an optimizer, we used the Adam algorithm38 which requires the objective function to be differentiable with respect to its inputs to enable computation of the gradients. This is not the case of the disorientation expression above because the arccos(x) function is only defined in the domain of [−1, 1], which induces discontinuities in the gradient of the disorientation metric with respect to the input orientations. Therefore, this expression cannot be used directly as an objective function17. Instead, we implemented an approximation to the disorientation function as:

$$L\left( {{{{\mathbf{g}}}}_1,{{{\mathbf{g}}}}_2} \right) = \mathop {{\min }}\limits_{i \in [1,24]} \left\{ {\sqrt {3 - tr\left[ {{{{\mathbf{g}}}}_1S_i{{{\mathbf{g}}}}_2^{ - 1}} \right]} } \right\}$$

This function takes as input two rotation matrices defining the orientations and returns a value approximating the disorientation angle in the vicinity of tr(x) = 3, which corresponds to small disorientations. The function otherwise monotonically decreases with tr(x), thus following the disorientation function. These properties make it a suitable choice of objective function because its minimization conjointly minimizes the disorientation function while it is also differentiable with respect to the input orientations.


For all specimens, we registered the DRM and EBSD fields of view so that each reflectance pattern could be associated to the corresponding reference orientation. Instead of using all the pixels in the datasets for training and evaluating the models—which would be inefficient due to the redundancy of pixels belonging to the same grain—we selected a single reflectance pattern and its associated orientation from each grain to form both training and test sets. We first segmented the microstructures into grains using the LRC-MRM algorithm detailed in reference39. Then, we excluded grains smaller than six pixels in diameter, for which registration between the DRM and EBSD datasets might be inaccurate. In all remaining grains, we selected the pixel furthest from any grain boundaries as a training data point, based on the maximum of the Euclidean distance transform of the grain40. Following this strategy, we included on average 68’850 data points for training. The size of the training set varied slightly depending on the cross-validation split. Moreover, we used data augmentation to increase the variety of the training data, which can reduce potential overfitting41. We augmented the training set by randomly rotating of the reflectance signals around the azimuth and multiplying the reflectance signals by a random factor sampled from a normal distribution, with an average of 1 and a standard deviation of 0.2 (we clipped the resulting values in the range 0–1). We performed these augmentations based on the assumption that the model should be able to recover the correct crystal orientation regardless of the origin of the azimuth and of variations in reflection intensity, as neither alteration is expected to change the structure of the reflectance patterns.

We trained the neural network for 100 epochs (an epoch corresponds to one full cycle through the training dataset) starting from a random initialization of the trainable parameters. We tuned the learning rate by searching over a logarithmic grid of values between 10−6 and 10−2. We found that the value leading to the lowest error was 3.1 × 10−3. With these parameters, it took 1 h and 32 min to train the EulerNet model on a commercial laptop computer equipped with an Intel i7-9750 CPU.

Data availability

The data required to reproduce these findings are available to download from

Code availability

The code required to reproduce these findings are available to download from


  1. Sofinowski, K. A., Raman, S., Wang, X., Gaskey, B. & Seita, M. Layer-wise engineering of grain orientation (LEGO) in laser powder bed fusion of stainless steel 316L. Addit. Manuf. 38, 101809 (2021).

    CAS  Google Scholar 

  2. Manninen, T. et al. EBSD. Mater. Sci. 86, 1689–1699 (2011).

    Google Scholar 

  3. Humphreys, F. J. Quantitative metallography by electron backscattered diffraction. J. Microsc. 195, 170–185 (1999).

    CAS  Article  Google Scholar 

  4. Potyrailo, R. et al. Combinatorial and high-throughput screening of materials libraries: review of state of the art. ACS Combinatorial Sci. 13, 579–633 (2011).

    CAS  Article  Google Scholar 

  5. Seita, M., Wittwer, M. & Wang, X. Optical metallography of fusion-based additively manufactured metals. Encyclopedia of Materials: Metals and Alloys 3, 193–202 (2022).

    Google Scholar 

  6. Seita, M., Nimerfroh, M. M. & Demkowicz, M. J. Acquisition of partial grain orientation information using optical microscopy. Acta Materialia 123, 70–81 (2017).

    CAS  Article  Google Scholar 

  7. Seita, M. et al. A high-throughput technique for determining grain boundary character non-destructively in microstructures with through-thickness grains. npj Comput. Mater 2, 16016 (2016).

    Article  Google Scholar 

  8. Jin, K. W. & De Graef, M. c-Axis orientation determination of α-titanium using computational polarized light microscopy. Mater. Charact. 167, 110503 (2020).

    CAS  Article  Google Scholar 

  9. Ilchenko, O. et al. Fast and quantitative 2D and 3D orientation mapping using Raman microscopy. Nat. Commun. 10, 1–10 (2019).

    Article  Google Scholar 

  10. Wang, X., Gao, S., Jain, E., Gaskey, B. & Seita, M. Measuring crystal orientation from etched surfaces via directional reflectance microscopy. J. Mater. Sci. 55, 11669–11678 (2020).

    CAS  Article  Google Scholar 

  11. Gaskey, B., Hendl, L., Wang, X. & Seita, M. Optical characterization of grain orientation in crystalline materials. Acta Materialia 194, 558–564 (2020).

    CAS  Article  Google Scholar 

  12. Zhou, S. & Seita, M. Large-area surface topography analysis of additively manufactured metallic materials using directional reflectance microscopy. Mater. Sci. Eng. A 760, 489–497 (2019).

    CAS  Article  Google Scholar 

  13. Sangwal, K. (ed) in Etching of Crystals Ch. 3, Elsevier (1987).

  14. Sangwal, K. (ed) in Etching of Crystals Ch. 11, Elsevier (1987).

  15. Sangwal, K. (ed) in Etching of Crystals Ch. 8, Elsevier (1987).

  16. Szczotok, A. & Reichel, H. Methodology for revealing the phases and microstructural constituents of the CMSX-4 Nickel-based superalloy implicating their computer-aided detection for image analysis. Materials 13, 341 (2020).

    CAS  Article  Google Scholar 

  17. Jha, D. et al. Extracting grain orientations from EBSD patterns of polycrystalline materials using convolutional neural networks. Microsc. Microanalysis 24, 497–502 (2018).

    CAS  Article  Google Scholar 

  18. Dass, A. & Moridi, A. State of the art in directed energy deposition: from additive manufacturing to materials design. Coatings 9, 418 (2019).

    CAS  Article  Google Scholar 

  19. Polonsky, A. T. et al. 3D characterization of the columnar-to-equiaxed transition in additively manufactured Inconel 718. Superalloys 2020, 990–1002 (2020).

    Google Scholar 

  20. Chadwick, A. F. & Voorhees, P. W. The development of grain structure during additive manufacturing. Acta Materialia 211, 116862 (2021).

    CAS  Article  Google Scholar 

  21. Chen, B. & Mazumder, J. Role of process parameters during additive manufacturing by direct metal deposition of Inconel 718. Rapid Prototyp. J. 23, 919–929 (2017).

    Article  Google Scholar 

  22. Dehmas, M., Lacaze, J., Niang, A. & Viguier, B. TEM study of high-temperature precipitation of delta phase in Inconel 718 alloy. Adv. Mater. Sci. Eng. 2011, 940634 (2011).

    Article  Google Scholar 

  23. Mahadevan, S. et al. Evolution of delta phase microstructure in alloy 718. In Proc. 7th International Symposium on Superalloy 718 and Derivatives. TMS, Pittsburg, PA, USA, 737–750 (2010).

  24. Nunes, R. M., Pereira, D., Clarke, T. & Hirsch, T. K. Delta phase characterization in inconel 718 alloys through x-ray diffraction. ISIJ Int. 55, 2450–2454 (2015).

    CAS  Article  Google Scholar 

  25. Krizhevsky, A. & Hinton, G. E. ImageNet classification with deep convolutional neural networks. Adv. Neural Inf. Process. Syst. 25, 1–9 (2012).

    Google Scholar 

  26. Szegedy, C., Ioffe, S., Vanhoucke, V. & Alemi, A. Inception-v4, inception-ResNet and the impact of residual connections on learning. CoRR abs/1602.07261 (2016).

  27. Kelley, H. J. Gradient theory of optimal flight paths. Ars. J. 30, 947–954 (1960).

    Article  Google Scholar 

  28. Bottou, L. Stochastic gradient learning. Proceedings of Neuro-Nımes, 91, 1991.

  29. Weiss, K., Khoshgoftaar, T. M. & Wang, D. D. A Survey of Transfer Learning (Springer, 2016).

  30. Mishra, P. & Passos, D. Deep calibration transfer: transferring deep learning models between infrared spectroscopy instruments. Infrared Phys. Technol. 117, 1–10 (2021).

    Article  Google Scholar 

  31. Holm, E. A. et al. Overview: computer vision and machine learning for microstructural characterization and analysis. Metall. Mater. Trans. A Phys. Metall. Mater. Sci. 51, 5985–5999 (2020).

    CAS  Article  Google Scholar 

  32. Martin, J. & Elster, C. Detecting unusual input to neural networks. Appl Intell 51, 2198–2209 (2021).

    Article  Google Scholar 

  33. Jolliffe, I. T. & Cadima, J. Principal component analysis: a review and recent developments. Philos. Trans. R. Soc. A 374, 20150202 (2016).

    Article  Google Scholar 

  34. Chen, Y. Y. et al. Multiscale microstructural heterogeneity and mechanical property scatter in Inconel 718 produced by directed energy deposition. J. Alloy. Compd. 887, 161426 (2021).

    Article  Google Scholar 

  35. Sánchez Pérez, J., Meinhardt-Llopis, E. & Facciolo, G. TV-L1 optical flow estimation. Image Process. Line 3, 137–150 (2013).

    Article  Google Scholar 

  36. Abadi, M. et al. TensorFlow: a system for large-scale machine learning. In Proc. 12th USENIX Symposium on Operating Systems Design and Implementation, USENIX Association, OSDI. 265–283 (2016).

  37. Chollet, F. Keras. Github. (2015).

  38. Kingma, D. P. & Ba, J. Adam: a method for stochastic optimization. In Proc. 3rd International Conference for Learning Representations. ICLR, 1–15 (2015).

  39. Wittwer, M., Gaskey, B. & Seita, M. An automated and unbiased grain segmentation method based on directional reflectance microscopy. Mater. Charact. 174, 110978 (2021).

    CAS  Article  Google Scholar 

  40. Dong, X. & Hua, L. Euclidean distance transform of digital images in arbitrary dimensions. Lect. Notes Computer Sci. (including Subser. Lect. Notes Artif. Intell. Lect. Notes Bioinforma.) 4261, 72–79 (2006).

    Google Scholar 

  41. Shorten, C. & Khoshgoftaar, T. M. A survey on image data augmentation for deep learning. J. Big Data 6, 60 (2019).

    Article  Google Scholar 

Download references


The authors would like to thank Yong Chen Yeoh for producing all the specimens and carrying the EBSD measurements, Ekta Jain for carrying the SEM measurements, and Le Tan Phuc and Wang Yulai for designing and manufacturing the motorized DRM stage. This research was funded by the Ministry of Education of Singapore, Official Number: MOE2017-T2-2-119. Access to shared experimental facilities used for the experiments described in this work was provided by the School of Mechanical and Aerospace Engineering at NTU.

Author information

Authors and Affiliations



M.W.: Conceptualization (equal); Data curation; Formal analysis; Investigation; Methodology; Software; Validation; Visualization; Writing—original draft preparation; Writing—review and editing (equal). M.S.: Conceptualization (equal); Funding acquisition; Project administration; Resources; Supervision; Writing—review and editing (equal).

Corresponding author

Correspondence to Matteo Seita.

Ethics declarations

Competing interests

The authors declare no competing interests.

Additional information

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary information

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Wittwer, M., Seita, M. A machine learning approach to map crystal orientation by optical microscopy. npj Comput Mater 8, 8 (2022).

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI:


Quick links

Nature Briefing

Sign up for the Nature Briefing newsletter — what matters in science, free to your inbox daily.

Get the most important science stories of the day, free in your inbox. Sign up for Nature Briefing