SR-CLD: spatially-resolved chord length distributions for statistical description, visualization, and alignment of non-uniform microstructures
Sheila E. Whitman Marat I. Latypov








[az-am]Graduate Interdisciplinary Program in Applied Mathematics, University of Arizona, Tucson, AZ 85721, USA
[az-mse]Department of Materials Science and Engineering, University of 
Arizona, Tucson, AZ 85721, USA

az-am]Sheila E. Whitman
az-am,az-mse]Marat I. Latypovcor1
[cor1]corresponding author
latmarat@arizona.edu


§ ABSTRACT 

This study introduces the calculation of spatially-resolved chord length distribution (SR-CLD) as an efficient approach for quantifying and visualizing non-uniform microstructures in heterogeneous materials. SR-CLD enables detailed analysis of spatial variation of microstructure constituent sizes in different directions that can be overlooked with traditional descriptions. We present the calculation of SR-CLD using efficient scan-line algorithm that counts pixels in constituents along pixel rows or columns of microstructure images for detailed, high-resolution SR-CLD maps. We demonstrate the application of SR-CLD in two case studies: one on synthetic polycrystalline microstructures with known and intentionally created uniform and gradient spatial distributions of grain size; and one on experimental images of two-phase microstructures of additively manufactured Ti alloys with significant spatially non-uniform distributions of laths of one of the phases. Additionally, we present how SR-CLDs can enable automated, computationally efficient, and robust alignment of large sets of images for merging into accurate composite images of large microstructure areas. 
 


Microstructure, Chord length distribution, Heterogeneous materials, Grain size. 






§ INTRODUCTION



Process–microstructure–property relationships of materials serve as the cornerstone of materials science and engineering. Efficient materials design requires not only qualitative but also quantitative understanding of these relationships. Quantitative process–microstructure–property relationships require rigorous description of the materials microstructure. Rigorous quantitative description of microstructures is not trivial, especially in structural metals and alloys that have a rich variety of microstructure constituents of interest at multiple length scales <cit.>. In many structural alloys, phases and grains are the constituents of special interest as they play a decisive role in a suite of engineering properties (e.g., stiffness, strength, fatigue, toughness) <cit.>. 

Microstructures are typically described by the statistics of size metrics of constituents such as areas, equivalent diameters, and intercepts (chords). Areas are often considered in microstructure maps where individual constituents can be clearly isolated: e.g., electron back-scattered diffraction (EBSD) maps <cit.> or segmented optical/electron microscopy images. It is common practice to convert areas of constituents (especially grains) into equivalent diameters, e.g., diameters of circles of the same area as the constituent <cit.>. The equivalent diameter is often a more preferred geometric descriptor than the area even for irregularly shaped grains because it is intuitive and compatible with widely used property models, e.g., the Hall–Petch model relating the yield strength to the average grain diameter of polycrystalline metals and alloys <cit.>. For significantly non-equiaxed microstructures (e.g., in rolled alloys with  elongated grains), equivalent ellipses can be considered instead of circles <cit.>. The ellipse representation allows analyzing distributions of major and minor diameters as well as aspect ratios and inclination angles of the major axes <cit.>, which provides insights into not only size but also, to some extent, morphology of the constituents and their geometric orientations.   

The intercept, or chord, is another size metric used in statistical microstructure analysis for both equiaxed and non-equiaxed constituents. A chord is a line segment completely contained within a microstructure constituent (see l_i in <Ref>a). The advantage of the chord is that it can be defined and measured for constituents with arbitrarily complex shapes without the underlying approximation to a circle, ellipse, or any other idealized shape. Chords are further advantageous in the context of microstructure–property relationships because chord lengths are directly relevant to transport properties in heterogeneous materials <cit.> and properties dictated by free paths in the microstructure, e.g., slip resistance related to the dislocation free path between grain boundaries <cit.>. 

In standardized practice, chords are sampled using test lines or other simple test objects (e.g., circles) <cit.>. To this end, one randomly overlays test lines (circles, or other objects) with the microstructure map and then identifies intersections with the boundaries of the constituents of interest. Chord lengths can be then estimated from the number of intersections per test line of a known length <cit.>. Upon sampling, the mean chord length value can be obtained and reported either directly or, in the case of grain size analysis, converted to an average size using standardized tables <cit.>. Some aspects of these standardized protocols of chord length analysis arise from the historical origins of manual measurements in non-digital micrographs.  

The emergence of modern tools of image processing, computational statistics, and visualization, as well as a shift towards digital microstructure data obtained by most of the current characterization instruments give rise to not only automation of measurements but also new, more detailed approaches to microstructure analysis. First of all, for digital microstructures, chord lengths can be calculated directly, rather than estimated from a number of intersection points. Second, automated and direct calculation allows obtaining chord lengths from a large number of test lines overlaid with the microstructure, as opposed to sampling with a few random test lines. The advantage is that systematic sampling with numerous parallel lines allows resolving the chord lengths and their  distributions in different directions. For example, Lehto et al. <cit.> presented a local grain size analysis method that calculates chord lengths in four directions (0, 45, 90, and 135) for each point in polycrystalline microstructures of welded steel. Latypov et al. <cit.> presented high-resolution angularly-resolved chord length distributions (CLDs) for EBSD grain maps of polycrystals . Turner et al. <cit.> developed a computational method of calculation of directional CLDs for 3D voxelized microstructures.  

Literature inspection shows that standardized and commonly used protocols of microstructure analysis focus on statistical summaries of size metrics (e.g., mean values) that assume idealized shapes (e.g., equivalent diameters) or calculated using methods grounded to originally manual measurements (e.g., number of intercepts with random test lines). A shift towards digital microstructure quantification shows the potential for more systematic and granular analyses with automated computational approaches, as seen in advances in resolving the chord lengths and their distributions in different directions <cit.>. Yet, even with recent advances, the existing approaches overlook spatial variation of size distributions of the constituents, which is only adequate for materials with spatially uniform microstructures. In this context, there is a growing need for new methods that can account for spatial variations. The need comes from the emergence of new classes of materials with intentionally designed non-uniform microstructures (e.g., heterostructured <cit.>, architectured <cit.>, gradient <cit.>, or lithomimetic <cit.> materials) and the corresponding new (as well as conventional) processing methods (friction stir welding <cit.>, additive manufacturing <cit.>, severe plastic deformation <cit.>). Related work in this direction includes the calculation of moving averages of the grain size <cit.> or the second-phase particle thickness <cit.> along principal directions in the microstructure. Building on the prior work of moving averages and directionally resolved CLDs, we present a method of the calculation and visualization of high-resolution spatially-resolved chord length distribution (SR-CLD). Our method is developed to capture spatial variations of the constituent size distributions along selected directions in diverse types of microstructures. In <Ref>, we describe the details of our SR-CLD method and then demonstrate its use in case studies in <Ref>. 





§ SPATIALLY-RESOLVED CHORD LENGTH DISTRIBUTIONS



For calculation of individual chord lengths, we adopt the scan-line method proposed by Turner et al. <cit.>. The method is suitable for digital microstructures defined on (pixel) grids, where microstructure constituents have pixel labels distinct from either boundaries or neighboring constituents. Given a grid of pixel values uniquely defining constituents of interest, we calculate horizontal (vertical) chord lengths by iterative pixel count for every row (column) of pixels on the microstructure grid. Consider the calculation of horizontal chord lengths in an example microstructure shown in <Ref>(a). For every row, starting from one end, we count pixels inside a microstructure constituent with the same label in a continuous stretch. While scanning pixels along the row, every time a new label or a boundary is encountered, we stop the pixel count, record the chord length (in pixels), and then restart the pixel count for the next constituent. We repeat the calculation for every row in the image and collect row-specific chord length datasets. For each dataset, we then bin the chord lengths and calculate row-specific (horizontal) distributions as shown with a couple of scan lines in <Ref>(b). If the microstructure map has K rows, the procedure would result in K sets of chord lengths and K CLDs. The calculation of chord lengths and their distributions in the vertical direction is identical to that for horizontal CLDs with the only difference being that pixels are scanned vertically along pixel columns instead of rows. 

We represent row- or column-specific distributions (SR-CLDs) by probabilities, P_i^(k), of finding a chord length within a small interval centered at a discrete value, l_i,  in a kth row or column of the microstructure calculated as follows:


    P_i^(k) = N_i^(k) l_i∑^B_i = 1N_i^(k) l_i,


where the index i enumerates bins from 1 to B, N_i denotes the number of chords within the interval of the ith bin with its center corresponding to the chord length l_i.









The described calculation results in SR-CLDs numerically represented by two-dimensional probability arrays (matrices) of size K× B. For intuitive interpretation of SR-CLDs, we propose a visualization of SR-CLD arrays as heat maps, where one axis represents the spatial coordinate (along which the spatial variation of CLDs is captured), the other axis represents the chord length, and the color depicts the CLD probability. Such heat maps can be thought of as CLDs sequentially calculated across a microstructure, stacked together along a spatial axis with the probability axis represented by color (<Ref>(c)).
As seen in the simple example in <Ref> and in subsequent case studies, such visualization of SR-CLDs allows quick and intuitive visual assessment of the spatial uniformity (or lack thereof) in the microstructure in terms of constituent sizes. 





Note that, if the chord lengths are calculated and aggregated into a single dataset from all pixel rows or columns, the calculation would result in an overall CLD for a given direction, as considered in previous studies <cit.>. <Ref> illustrates advantages of SR-CLDs compared to overall CLDs. Overall CLDs calculated in the horizontal direction for two synthetic microstructures are identical although the microstructures are clearly different with one being non-uniform (<Ref>(a)). It is the consideration of chord lengths along individual rows/columns followed by row-/column-wise calculation of distributions that spatially resolves the CLD to capture the spatial variation of microstructure constituents as seen in <Ref>(c). Mathematically, the spatial resolution of CLDs is signified by the index k that enumerates rows for horizontal CLDs or columns for vertical CLDs. In this study, we discuss the calculation and analysis of SR-CLDs along two principal directions (horizontal and vertical), however, this method can be generalized to any direction in a microstructure.

The SR-CLD values in the numerical arrays and their corresponding heat map visualizations depend on the binning of chord lengths selected in the CLD calculation (<Ref>). The choice of the binning, and specifically the number of bins for calculating a distribution is not trivial; and much research has been dedicated on determining the optimal number of bins that convey a representative distribution of a given dataset <cit.>. Some common methods of determining the number of bins include the square root rule, Sturges' formula <cit.>, Scott's normal reference rule <cit.>, Freedman–Diaconis Rule <cit.>, Rice's rule <cit.>, and Doane's formula <cit.>. In this work, we explored all these methods and chose Doane's formula for SR-CLD calculations due to the large number of chords and skewness of the distribution present in most considered cases. 
 


§ CASE STUDIES
 


We demonstrate the application of our methodology in two case studies: (i) synthetic polycrystalline microstructures and (ii) experimental two-phase microstructures. The first case study serves as a proof of concept in which SR-CLD describes a known and intentionally created gradient in the grain size in synthetically generated polycrystals. The second case study analyzes non-uniform microstructures experimentally obtained in additively manufactured Ti alloys. Beyond these case studies, we present an additional application of SR-CLD for efficient and effective automated alignment of a large number of microstructure images. 



 §.§ Synthetic polycrystalline microstructures
 


To evaluate the SR-CLD approach on a microstructure with known non-uniform spatial distributions of the constituent size, we generated synthetic 2D polycrystals using the open-source software Neper <cit.>. We generated two representative polycrystals (<Ref>(a)): (i) a polycrystal with uniform grain size and (ii) a polycrystal with a monotonically decreasing grain size along the vertical direction (the y axis in <Ref>). To this end, we used different settings of grain seeding available in Neper: random for the uniform polycrystal and biased for the polycrystal with a grain size gradient. The biased seeding aimed for a 300 increase in grain size from top to bottom ends of the microstructure. Both polycrystals contained 1108 grains and similar overall grain size distribution and mean grain size (<Ref>(c,d)).



To quantitatively compare spatial variations in these polycrystals using the SR-CLD approach, we worked with binary images of the polycrystals exported from Neper. In the binary images of pixel size 284×786, grain interiors were represented with white and grain boundaries with black pixels. By counting uninterrupted stretches of white pixels in each row, we digitally measured horizontal chords and computed K=284 chord length distributions (CLDs) for all of 284 pixel rows using <Ref> with B=39 bins, as determined from Doane's formula. <Ref>(b) displays the results of this SR-CLD calculation visualized as heat maps. 


The SR-CLD clearly captures the gradient in the grain size when it is present: the SR-CLD  for the gradient polycrystal shows a shift of the prevalent chord length from about 4 to 18 (<Ref>(b)). This trend is confirmed with the moving average chord length also shown in <Ref>(c) alongside the SR-CLD maps. Unlike the mean chord length however, the SR-CLD map additionally shows the variance in the chord lengths for each vertical location. The top part of the microstructure has small grains of consistent size, as seen from a high probability in the narrow range of chord lengths (red bands in the SR-CLD map, <Ref>(b)). On the other hand, the probability is lower and spread over a wider range of chord lengths for the bottom part of the gradient microstructure containing large grains with a greater variety of horizontal chord lengths. In contrast to the gradient polycrystal, the microstructure generated with random seeding is characterized by a consistent mean chord length (<Ref>(c)) and a SR-CLD with no trend: the chord length probability is in a consistent range centered around 9 (<Ref>(b)).



 §.§ Two-phase microstructures of titanium alloys
 


The second case study demonstrates the application of SR-CLD on real microstructures to describe spatial variation of phase sizes. Specifically, we quantify the spatial variation of the α phase in two-phase microstructures of two dissimilar titanium alloys additively manufactured and experimentally characterized by Kennedy et al. <cit.>. The authors co-deposited Ti5553 and Ti64 alloys using a wire-arc additive manufacturing process, which results in spatial variations of the composition, microstructure, and thus properties (e.g., strength and damage tolerance). The spatial microstructure variation is primarily manifested in a variation of the lath size of the α phase. To demonstrate our approach for these materials, we processed the raw experimental images of the phases into the binary format consistent with the pixel count method, aligned the individual images into large composite images and calculated SR-CLD for the entire composite images. 

Raw data and image pre-processing. Raw data published by Kennedy et al. <cit.> contain over 900 high-resolution scanning electron microscope images for two additively manufactured materials: Ti5553-on-Ti64 and Ti64-on-Ti5553. To segment the raw images, we first applied a Gaussian filter (with radius of 5px) and then applied a threshold optimally selected using Yen's method <cit.> to obtain binary images whose white pixels represent the α phase (laths) of interest. The binary images were passed through erosion and dilation filters to clean up the remaining segmentation noise <cit.>. Hundreds of the individual segmented images were then aligned and merged into large composite images: one for Ti5553-on-Ti64 and one for Ti64-on-Ti5553 samples (except a couple of stained images at the top of the analyzed regions). 

SR-CLD calculation. We calculated SR-CLDs for both composite images despite their very large size (288688×3897 each) following merging. Horizontal chord lengths were measured for the α phase by counting the corresponding white pixels at each pixel row. From the measured chord lengths, we estimated 288688 CLDs using <Ref> with B=55 bins, also for all 288688 pixel rows. While we obtained the SR-CLD maps for the entire composite images, they are so large that we can practically present the results only for microstructure subregions of approximately 70 along the y axis – the direction of the microstructure variation (<Ref>). 
<Ref> shows two subregions of each processed microstructure and their corresponding SR-CLD maps and moving average chord length curves for the two studied materials.



These subregions were selected to represent a variety of microstructure transitions that were present in the samples. The first two subregions include monotonic transitions from fine to coarse α laths (<Ref>(a,b)), while the other two subregions feature zones of coarse  α laths surrounded by fine α-lath microstructures (<Ref>(c,d)). Some of these microstructure transitions are captured by the moving average chord length: e.g., coarse zone in <Ref>(c,d). At the same time, the mean chord length curve has spurious peaks for the subregion shown in <Ref>(a), which can mislead to a conclusion of the presence of much larger α laths compared to the rest of the microstructure. SR-CLD maps present a richer description of these non-uniform microstructures. Serving as visual representations of the distributions rather than only the mean values, SR-CLD maps show not only most probable chord lengths for each zone but also their consistency and variance in chord lengths. The high probability of short chord lengths in the zones of fine α laths highlights the consistency of chords in a narrow range of lengths (<Ref>(a,b,d)). At the same time, the probability is distributed over a wide range of lengths for the zones with coarse laths (<Ref>(a,c,d)). Partially, the lack of clear SR-CLD peaks in zones with coarse α laths is associated with the fewer chords present in those zones. This is because the image of (approximately) constant width captures many fine laths and relatively few coarse laths. The SR-CLD maps conveniently indicate the insufficient number of chords for conclusive statistics with low probability spread over the entire range of chord lengths analyzed for these microstructure regions. 



 §.§ Alignment of experimental images for large microstructures


Composite images of large microstructure regions consist of multiple images of adjacent fields of view taken individually with a characterization instrument. In practice, seldom are images of the adjacent fields of view perfectly aligned. Analyses of large microstructures thus require an additional step of digital alignment followed by merging into large composite images, as was the case for the Ti images discussed in <Ref>. Manual and semi-manual methods (e.g., <cit.>) are impractical for alignment of more than a few individual images. For example, methods that require any manual input would be challenging and extremely time-consuming to align and merge more than 900 images into the two composite microstructure images that were part of the Ti dataset. In this study, we found that SR-CLDs can be used for efficient, fully-automated, and effective alignment of numerous microstructure images.  

We propose an SR-CLD-based method that aligns a pair of images by minimizing the difference between SR-CLDs calculated in the two images in horizontal or vertical direction in their overlapping region. We introduce scaled Euclidean distance as a quantitative metric of the difference between two SR-CLDs. For SR-CLDs, P_a and P_b, calculated for two images a and b with a vertical/horizontal overlap of K pixel rows/columns, our scaled Euclidean distance is expressed as:


    d_K(P_a,P_b) = 1/K√(∑_k=0^K  (P^(k)_a - P^(k)_b)^2),


Note that, compared to the conventional Euclidean distance between two high-dimensional vectors, d_K quantity has an additional factor of 1/K, which normalizes the difference in two SR-CLDs by the amount of overlap between the two images, K. We introduce this factor because minimizing just the absolute value of the Euclidean distance would always favor a minimal overlap of two images, which does not necessarily correspond to the best alignment. Thus defined, scaled Euclidean distance serves as a quantitative alignment “error” between two images in a given direction. The process of alignment can be then formulated as an optimization problem that seeks the optimal overlap, K_opt, that minimizes the alignment error, d_K: 


    K_opt = min_K d_K(P_a,P_b)


Since the SR-CLD calculation is computationally efficient (see <Ref>), K_opt can be found by iteratively adjusting the relative position of images by single-pixel shifts. Starting with an exaggerated overlap such that K ≫ K_opt, one of the images is shifted (pixel-wise) in the direction of separation (no overlap) of the two images (<Ref>(a)). The analysis of the alignment error calculated at different overlaps K during iterative shifting (<Ref>(c)) provides K_opt that minimizes d_K(P_a,P_b). This procedure of minimizing the alignment error is suitable for vertical, horizontal, and combined alignment. For combined alignment in both directions, the images can be aligned first in one direction followed by alignment in the other direction. 



The alignment procedure described above can be used for alignment of very large series of images by repeating the steps of pairwise alignment and merging. We tested this methodology for automated alignment and merging of more than 900 images from the Ti dataset discussed above. First, the SR-CLDs were calculated for two images at a time in the vertical direction. Using these SR-CLDs, the images were aligned vertically by finding the optimal vertical overlap that minimizes the alignment error (<Ref>). Then the SR-CLDs in horizontal direction were calculated only for the overlapping rows of the two images, followed by minimizing their difference, d_K. 
Once two images were aligned in both directions, they were merged into a single image. The procedure was repeated for the pairwise alignment of the merged image with a next individual image. We compared this SR-CLD approach with alignment by minimizing the Euclidean distance between pixel values previously considered in literature <cit.>. We found that the SR-CLD approach leads to better alignment (<Ref>(b,d)) because the experimental images had significant differences in image contrast, which results in noise in pixel values in the overlapped regions, whether raw or after processing and segmentation (<Ref>(b–d)). Since SR-CLDs are statistical descriptions, they are less sensitive to raw image imperfections, differences in contrast due to surface lightning, and noise or errors in segmentation <cit.>, which results in more robust alignment (<Ref>(d)). 



§ DISCUSSION



In this work, we introduced a new approach to analyzing and quantifying non-uniform microstructures. With two case studies, we demonstrated that SR-CLDs provide insights into spatial microstructure variations inaccessible with traditional methods of microstructure descriptions. For example, two clearly different polycrystalline microstructures studied in <Ref> had similar overall grain size distributions and mean grain sizes (<Ref>(a,d)). SR-CLD captured the differences in those microstructure both numerically and visually via SR-CLD maps (<Ref>(b)). Capturing spatial differences is important because microstructure description is a foundation for establishing process–microstructure–property relationships. We can expect that a microstructure with a significant gradient is a result of a particular process and will have properties different from those of a uniform microstructure. Yet, microstructure descriptions that focus on overall size distributions or mean values without spatial sensitivity will fail to reflect such differences. The SR-CLD approach that resolves spatial microstructure variations can therefore serve as a statistically rigorous microstructure description for quantitative process–microstructure–property relationships in materials with significantly non-uniform microstructures. For example, SR-CLDs or their reduced-order representations (e.g., from principal component analysis <cit.>) could be used as microstructure “features” for machine learning, as previously shown with traditional (non-spatially-resolved) CLDs <cit.>. 

While our case studies demonstrated SR-CLDs for describing grains and phases, the presented approach is flexible for analyzing any other microstructure constituents in a wide variety of materials and data modalities. Since our chord length calculation is based on simple pixel counting, any microstructure map that contains constituent labels at pixels could be used for SR-CLD calculations. This includes electron back-scattered diffraction (EBSD) maps that contain phase IDs (for multiphase microstructures) and grain IDs at each EBSD “pixel”, which can be used for digital chord measurements for the SR-CLD approach. Segmented microstructure images are another wide class of microstructure data that can benefit from the presented SR-CLD calculations. An advantage of leveraging SR-CLDs for segmented images is that, CLDs are tolerant to segmentation errors inevitable in experimentally obtained microstructures <cit.>. 

In addition to the description of non-uniform microstructures, we demonstrated the application of SR-CLD for image alignment (<Ref>). Using Euclidean distance between SR-CLD in the overlapped regions of image pairs, we successfully aligned and merged over 900 images into two large composite images. Similar to the microstructure description, this SR-CLD-based alignment is robust even in the presence of contrast and segmentation differences in the images (<Ref>(d)). Like microstructure description, alignment based on SR-CLD can be used for a rich variety of microstructures, microstructure constituents, and data modalities, not limited to images of phases from the scanning electron microscope considered in <Ref>.

Based on simple pixel counting, the presented approach of SR-CLD calculations is computationally efficient with minimum CPU and memory requirements. Calculation of SR-CLD for a typical high-resolution 12000×4000 image (shown in <Ref>) takes only about 23, and 6.3 for a very large (288688×3897) composite image  on an average consumer-grade laptop (MacBook Air M1 with 16 RAM). Since the calculation of individual location-specific CLD for a pixel row/column is independent, the SR-CLD calculation can be easily parallelized if needed, e.g., for extremely large microstructure maps. To facilitate adoption of the approach by the community, we made a Python code for SR-CLD calculations available on GitHub (link below).




§ CONCLUSION



In this paper, we presented calculation of spatially-resolved chord length distribution (SR-CLD) for statistical description of non-uniform microstructures. With two case studies, we demonstrated the application of our SR-CLD approach to different microstructures with grains and phases as microstructure constituents of interest. The results show that SR-CLDs capture spatial variations of constituent sizes that would be inaccessible with traditional microstructure descriptions focusing on overall size distributions or their moments. SR-CLD captures microstructure uniformity (or lack thereof) both visually (via proposed SR-CLD maps) and numerically and are therefore suitable both for intuitive visual assessment of the microstructure and for quantitative relationships between microstructure, properties, and processing. We further demonstrated that SR-CLDs can be used for robust alignment of numerous microstructure images into large composite images even in the presence of contrast and other differences in images that need to be aligned. With a simple pixel counting algorithm as a basis, SR-CLD calculations require very modest computational resources and can be therefore calculated for description or alignment of very large images on a typical laptop.   



§ ACKNOWLEDGEMENTS


SEW acknowledges the support by the National Science Foundation (NSF) Graduate Research Fellowship Program under Grant No. DGE-2137419. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of the NSF.



§ DATA AVAILABILITY


The codes for SR-CLD calculations and SR-CLD-based alignment are available at <https://github.com/materials-informatics-az/SR-CLD>.




