Page 26 - Read Online
P. 26
Page 4 of 17 Hansen et al. Microstructures 2023;3:2023029 https://dx.doi.org/10.20517/microstructures.2023.17
Regarding crystallographic variant mapping, three methods were developed. Both the first and second
methods rely on comparing the diffraction patterns of each pixel to the reference patterns from the same
PED dataset. The first method is more manual in that it requires the user to first choose the reference
patterns. For each diffraction pattern in the dataset, the highest similarity value between all the reference
patterns is used to determine which crystallographic variant it is most similar to. A crystallographic variant
map is then generated based on the highest similarity values at each location in the data. The second
method is more automatic, in which the algorithm will create new references when the similarity values
between the test pattern and the existing reference patterns are lower than a threshold. In the first two
methods, the Euclidean distance, Cosine, and Structural Similarity (SSIM) algorithms were used to quantify
the similarity values between the diffraction patterns of each pixel to references.
[30]
The Euclidean distance algorithm flattens the 2D image arrays to create 1D number arrays. The 1D
number arrays can be viewed as vectors. For 144 × 144 pixel resolution diffraction patterns, the i value is
2
20,736 (i.e., 144 ). Hence the 1D number arrays correspond to vectors in 20,736 dimensions. The Euclidean
distance, d(u, v), between the test diffraction pattern and the reference pattern is calculated as the distance
between the two vectors in 20,736 dimensions, which is expressed as d(u, v) = , where u and v
are intensity values of each pixel in the test and reference diffraction patterns, respectively. In PED, the
diffraction patterns are stored as 8-bit images with the values of u and v ranging from 0 to 255. To turn the
Euclidean distances into similarity values that range from 0 to 1, we describe Euclidean similarity (S Euclidean ) as
S Euclidean = , where |u| and |v| are the magnitudes of the vectors corresponding to the test and reference
patterns, respectively. The magnitude is calculated as |u| = . The same applies to v in the reference
pattern. A S Euclidean value of 1 indicates that the test and reference diffraction patterns are identical. For
2
diffraction patterns acquired with 580 × 580 pixel resolution, the i value is 336,400 (i.e., 580 ), and the
vectors are 336,400 dimensional. The Euclidean distances and the similarities are calculated in the same way
as described above.
The Cosine image comparison method is similar to the Euclidean distance algorithm. The 2D image
[31]
arrays are also transformed into 1D arrays (i.e., vectors at high dimensions). The Cosine method uses the
angle between the two high-dimensional vectors describing the test and reference patterns. If the cosine
angle between the arrays is low, the two images are similar. The Cosine similarity (S Cosine ) is calculated as
S Cosine = , where u·v is the dot product between the test (u) and reference (v) diffraction patterns.
The S Cosine value also ranges between 0 and 1, and a value of 1 means that the two images are the same and
the angle between the corresponding two vectors is 0.
The SSIM image comparison method measures the structural similarity between two images (the reference
and test diffraction patterns in this work), taking into account luminance, contrast, and structure .
[32]
Luminance (l) measures the brightness difference between the two images and is defined as l(x,y) = ,
where µ and µ are the pixel intensity means of two images x and y, and c is a constant. Contrast (c)
1
y
x
captures the variation of brightness in the images and is defined as c(x,y) = , where σ and σ are the
x
y
pixel intensity variances of two images x and y, and c is also a constant. The structure (s) captures the
2
patterns and texture in the image and is defined as s(x,y) = , where σ is the pixel intensity covariance
xy
of images x and y, and c is also a constant. The SSIM similarity combines the above measurements and is
3
defined as SSIM(x,y) = l(x,y)·c(x,y)·s(x,y). Similar to S Euclidean and S Cosine , SSIM(x,y) also ranges from 0 to 1, and