# Diffraction Enhanced Imaging Analysis with Pseudo-Voigt Fit Function

Deepak Mani, Andreas Kupsch, Bernd R. Müller, Giovanni Bruno

► To cite this version:

Deepak Mani, Andreas Kupsch, Bernd R. Müller, Giovanni Bruno. Diffraction Enhanced Imaging Analysis with Pseudo-Voigt Fit Function. Journal of Imaging, 2022, 8 (8), pp.206. 10.3390/jimag-ing8080206. hal-05075961

HAL Id: hal-05075961

https://hal.science/hal-05075961v1

Submitted on 20 May 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
<figure><img src="image_2.png" /></figure>

Article

# Diffraction Enhanced Imaging Analysis with Pseudo-Voigt Fit Function

Deepak Mani<fnref n="1" />,<fnref n="2" />,<fnref n="3" />,* ID, Andreas Kupsch ¹ID, Bernd R. Müller ¹ID and Giovanni Bruno <fnref n="1" />,<fnref n="4" /> ID

**Abstract:** Diffraction enhanced imaging (DEI) is an advanced digital radiographic imaging technique employing the refraction of X-rays to contrast internal interfaces. This study aims to qualitatively and quantitatively evaluate images acquired using this technique and to assess how different fitting functions to the typical rocking curves (RCs) influence the quality of the images. RCs are obtained for every image pixel. This allows the separate determination of the absorption and the refraction properties of the material in a position-sensitive manner. Comparison of various types of fitting functions reveals that the Pseudo-Voigt (PsdV) function is best suited to fit typical RCs. A robust algorithm was developed in the Python programming language, which reliably extracts the physically meaningful information from each pixel of the image. We demonstrate the potential of the algorithm with two specimens: a silicone gel specimen that has well-defined interfaces, and an additively manufactured polycarbonate specimen.

**Keywords:** diffraction enhanced imaging; analyzer-based imaging; X-ray refraction; non-destructive evaluation; Pseudo-Voigt fit function; Python

## 1. Introduction

The use of lightweight materials for various applications has rapidly increased in recent years. To utilize these materials in practice, a comprehensive investigation is required to validate their different properties. Since the introduction of digital detector arrays for non-destructive testing, novel possibilities to analyze and characterize materials have been available for the user. Nevertheless, hard X-rays are not suitable to analyze lightweight materials due to their poor absorption contrast. As an alternative to absorption, other interactions of X-rays with matter, such as X-ray refraction (XR) [1], can be used to obtain contrast-enhanced images of internal interfaces. This allows not only characterization, but also non-destructive evaluation (damage analysis) of these materials. Generally, XR imaging is based on the assumption that when X-rays pass through a specimen with interfaces, they are mainly absorbed and refracted at the interfaces [2], with negligible diffraction or Compton scattering. Several XR imaging techniques have been developed in recent decades. They employ devices such as gratings [3,4] or crystals [5-7] to separate the deflected (refracted) beam portions from the primary radiation, or use large distances between the specimen and the detector [8-10]. One such imaging technique is the diffraction enhanced imaging technique [6] (also known as analyzer-based imaging, ABI). It is based on the concept that an analyzer crystal acts as angular filter to obtain different images corresponding to different refraction angles.

While the XR techniques listed above are mainly synchrotron based, the roots of XR imaging date back to the 1980s and 1990s [1,11] when access to synchrotron sources was

<figure><img src="image_3.png" /></figure>

### check for updates

**Citation:** Mani, D.; Kupsch, A.; Müller, B.R.; Bruno, G. Diffraction Enhanced Imaging Analysis with Pseudo-Voigt Fit Function. *J. Imaging* **2022**, *8*, 206. https://doi.org/10.3390/jimaging8080206

Academic Editors: Bin Fan and Wenqi Ren

Received: 29 June 2022

Accepted: 21 July 2022

Published: 23 July 2022

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

<figure><img src="image_4.png" /></figure>

**Copyright:** © 2022 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/).

<footnote n="1">¹ Bundesanstalt für Materialforschung und -Prüfung (BAM), Unter den Eichen 87, 12205 Berlin, Germany; andreas.kupsch@bam.de (A.K.); bernd.mueller@bam.de (B.R.M.); giovanni.bruno@bam.de (G.B.)</footnote>

<footnote n="2">² Non-Destructive Testing Int., Engineering Department, Dresden International University (DIU), Freiberger Str. 37, 01067 Dresden, Germany</footnote>

<footnote n="3">³ European Synchrotron Radiation Facility (ESRF), 71, Avenue des Martyrs, 38043 Grenoble, France</footnote>

<footnote n="4">⁴ Institute of Physics and Astronomy, University of Potsdam, Karl-Liebknecht-Str. 24-25, 14476 Potsdam, Germany</footnote>

<footnote>* Correspondence: deepak.mani@esrf.fr</footnote>
rather limited. Laboratory XR imaging techniques are based on scanning the specimen through a finely collimated beam and detecting refracted beam portions. A so-called refraction value (see Section 2) has been introduced to correlate the measured (refracted) intensity with the specific surface inside the specimen (internal surface per unit volume). When transferring the concept of the refraction value to the DEI set-up, parameters of the so-called rocking curves (RCs) are needed. It turned out that fitting conventional Gaussian peak functions did not sufficiently simulate the measured RCs and sometimes even failed completely, thereby yielding wrong values of the above-mentioned parameters. In this study, we introduce a novel robust fitting routine based on Pseudo-Voigt functions. We also demonstrate how this routine allows the extraction of the RCs parameters and, therefore, of the microstructural properties of specimens.

## 2. Diffraction Enhanced Imaging

The DEI technique uses an intense and parallel monochromatic X-ray beam from a synchrotron source and an analyzer crystal (AC) positioned downstream of the specimen (see Figure 1). The AC is tilted in the (angular) vicinity of a Bragg reflection at $\theta_B$, collecting a rocking curve (RC) for each image pixel. If a (refracting) object is placed upstream of the AC, the RC is damped, broadened, and shifted. The AC separates the beam portions according to the deflection angle, $\theta' = \theta - \theta_B$ (see Figure 2), by accepting only rays that meet the Bragg condition for the actual tilt angle. However, the series of images obtained using this technique need to be processed to retrieve maximum information from the RCs. The reciprocal lattice vector **H** of a certain AC Bragg reflection predefines the directional sensitivity of DEI experiments as follows: only features laying nearly perpendicular to the scattering plane (the plane spanned by the incident beam direction and **H**) are detectable, i.e., not all interfaces are contrasted at once for one specimen orientation. One needs at least two perpendicular specimen orientations to detect all interfaces contained in the specimen. This, on the other hand, turns to great advantage, since it implies an orientation sensitivity of the technique: a specimen can be purposely mounted in such a way that only interfaces of a certain orientation are contrasted.

<figure><img src="image_5.png" /><figcaption>**Figure 1.** The main components of diffraction enhanced imaging technique; sketch and photograph of the actual set-up at BAMline (hard X-ray beamline at the electron storage ring BESSY II, at Helmholtz-Zentrum Berlin, Germany).</figcaption></figure>
<figure><img src="image_6.png" /><figcaption>**Figure 2.** Typical RC recorded for a pixel: intensity as a function of the angular position ($\theta - \theta_B$) of the AC. Black line: the primary beam, flat field, measured; red line: a purely absorbing specimen without any internal surfaces, calculated; blue line: an absorbing specimen containing internal surfaces, measured. The loss of (peak) intensity due to refraction can be used to quantify the scattering.</figcaption></figure>

DEI has been used to detect and quantify the microcrack density and orientation in porous ceramics [12,13] or damage after cyclic loading in all-oxide ceramic matrix composites [14]. In-situ experiments revealed the formation of cracks in fiber-reinforced plastics [15], the damage evolution in metal matrix composites under tensile load [16], or the evolution of different types of porosity in additively manufactured AlSi10Mg during heat treatment [17]. Recently, a synchrotron X-ray refraction tomography study quantified the hydrogen-assisted microcracking in duplex stainless steel [18] by 3D XR imaging.

In this study, we show that the Pseudo-Voigt function (PsdV) is suited to fit the typical RC at each pixel separately, thereby allowing the extraction of relevant microstructural features. Furthermore, the comparison of feature extraction with algorithms in ImageJ and Python elucidates the advantages of using the latter to obtain improved results with shorter computation times. Using our algorithm, we can extract and compute different parameters from the RCs; their corresponding physical information is listed in Table 1.

<table><caption>**Table 1.** Extracted rocking curve parameters and their physical equivalent. FWHM is the full width at half maximum.</caption><thead><tr><th>RC Parameter</th><th></th><th>Physical Phenomenon</th><th>Structural Information</th></tr></thead><tbody><tr><td>peak integral</td><td>∫ I(θ) dθ</td><td>transmission</td><td>absorbing mass</td></tr><tr><td>peak height</td><td>I<sub>max</sub> = max (I(θ))</td><td>apparent transmission</td><td>absorbing mass<br>+ specific surface</td></tr><tr><td>peak position</td><td>mode (I(θ))</td><td>refraction angle</td><td>structure gradient<sup>1</sup></td></tr><tr><td>peak width (FWHM)</td><td>w (I(θ))</td><td>scattering</td><td>specific surface</td></tr></tbody></table>

The RC, i.e., $I(\theta)$, measured with a specimen, corresponds to the convolution product of a reference RC, $I_0(\theta)$, of the empty beam (the so-called flat field) and the scattering function of the specimen, $s(\theta)$:

$$I(\theta) = s(\theta) \otimes I_0(\theta), \qquad (1)$$

where $\otimes$ denotes the convolution operator.

<footnote n="1">¹ Gradient of the transmission length of the local scattering macro-structures, i.e., gradient of the objects' phase shift.</footnote>
Therefore, the RC parameters of Table 1 must be determined separately for the two-image series: with and without the specimen. To extract the parameters of $s(\theta)$ (i.e., the specimen properties) we use the following equations:

$$T = \int s(\theta) \, d\theta = \int I(\theta) \, d\theta / \int I_0(\theta) \, d\theta, \qquad (2)$$

$$AT = \max(I(\theta))/\max(I_0(\theta)), \qquad (3)$$

$$\Delta\theta(s_{\max}) = \theta(I_{\max}) - \theta(I_{0,\max}), \qquad (4)$$

$$w(s(\theta)) = \left( w^2(I(\theta)) - w^2(I_0(\theta)) \right)^{1/2} \qquad (5)$$

where Equation (2) represents the transmission $T$, Equation (3) the so-called apparent transmission $AT$, Equation (4) the refraction angle, and Equation (5) the scattering. The transmission accounts for the absorption effects only, whereas the apparent transmission accounts for absorption and extinction (due to scattering) effects.

In the first DEI paper [6], the authors suggest an algorithm to extract images of the “apparent absorption” and “refraction angle”. Since, from a medical point of view it is desirable to minimize the radiation dose, the authors in [6] acquired just two images (at roughly half the maximum peak intensity on each side of the RC) and used relative changes of intensity and the slope to compute the two parameters. Assuming a Gaussian RC shape, Arfelli et al. [19] introduced the $G^2$DEI algorithm to additionally extract the scattering width from three images on the RC. Chen et al. [20] indicated how to retrieve different types of information from the analysis of the moments of RCs, in particular the skewness (3rd moment) and the kurtosis (4th moment), revealing the asymmetry (caused by the local curvature of interfaces) and the strength of the tails relative to the peak, respectively. Interestingly, the straightforward approach of Chen et al. does not require any fitting procedure or any assumption about the type of peak function.

In former studies, we quantified the results obtained from DEI in terms of the refraction value $C_m$. Such quantity has been introduced by Fensch-Kleemann et al. [21] to quantify laboratory-based XR topography [11] results (i.e., 2D scans of the specimen). In this laboratory set-up, the refracted beam portions (see e.g., [22–25]) deviating from a well-collimated primary beam (collimation of the Kratky type [26]) are collected in a fixed angular range. The $C_m$ can be calculated by normalizing the intensity of the refracted X-rays with the corresponding absorption effects. This formalism has been transferred to the quantities obtained from DEI experiments [16], assuming that $C_m$ can be considered as an additional attenuation coefficient; see Figure 2 (for details see [16]). In terms of RC parameters, the sample transmission corresponds to the ratio of peak integrals of $I(\theta)$ and $I_0(\theta)$ ($I_T$ and $I_{T0}$ in Equations (6) and (7)). A purely absorbing specimen would just dampen the RC without the specimen, $I_0(\theta)$, by a constant factor, leaving the width unchanged (see Figure 2). Since refraction corresponds to a pure redistribution of beam portions (i.e., it leaves the integral unchanged), a specimen with internal interfaces causes broadening of the RC at the expense of peak height (extinction). Therefore, the refraction value represents an equivalent to the scattering as follows:

$$C_m \cdot d = 1 - \frac{I_R}{I_{R0}} \frac{I_{T0}}{I_T}, \qquad (6)$$

where $d$ is the specimen thickness, $I_R = \max(I(\theta))$ and $I_{R0} = \max(I_0(\theta))$ are the RC peak heights with and without the specimen, respectively. In other words, $C_m$ is the apparent transmission normalized to the true transmission. In order to eliminate the dependence on the specimen thickness, Equation (6) is normalized by $\mu \cdot d = -\ln(I_T/I_{T0}) = -\ln(T)$, $\mu$ being the attenuation coefficient as follows:

$$C_m / \mu = \left( 1 - \frac{I_R}{I_{R0}} \frac{I_{T0}}{I_T} \right) / \ln \left( \frac{I_{T0}}{I_T} \right). \qquad (7)$$
This approach waives one recording full RCs, when such measurements are exceed-
ingly time consuming, e.g., in the case of X-ray refraction computed tomography (XRCT)
experiments [18,27]. Instead of sampling the full RC, one can record images with the AC at
$\theta_B$ (i.e., in the RC center of the flatfield, without the specimen). At this setting, all X-rays
deflected by refraction events within the specimen are rejected by the analyzer crystal, caus-
ing an additional attenuation of the X-rays; assuming negligible peak shifts one could write:
$I_R = I(\theta_B)$ and $I_{R0} = I_0(\theta_B)$). Transmission images are recorded as conventional radiographs,
i.e., without the AC in the beam and with the detector lowered into the (incident) beam.
This set-up yields $I_T$ and $I_{T0}$. In this study, however, $I_R(\theta_C)$ is the maximum of the fitted
RCs (i.e., $\theta_C$ being $\theta(I_{max})$).

3. Experimental Section

The DEI experiments were carried out at the beamline BAMline, using synchrotron radiation of the electron storage ring BESSY II, at Helmholtz-Zentrum Berlin, Germany [28,29]. Using a double crystal monochromator (Si (111)), the beam energy was set to 17.5 keV. A flat panel detector (1600 × 1200 pixels) in combination with a lens system and a 50 µm thick CWO scintillator screen provided a pixel size of 4.08 µm, capturing a field-of-view (FoV) of approximately 6.5 × 4.9 mm². The incident beam was narrowed to the FoV by a slit system, to avoid detector backlighting [30,31]. The exposure time for each image of the series was 1 s. The AC was adjusted to $\theta_B = 6.488^{\circ}$. The RC was sampled in 61 steps of $2 \times 10^{-4}^{\circ}$ (~3.5 µrad) symmetrical to $\theta_B$. Two such image series were recorded with and without (the so-called flat field) the specimen in the beam path. Beyond numerical normalization, the flat field images enable one to remove strong artefacts of the imaging system (composed by the monochromator, the AC, and the scintillator screen). Examples of raw images obtained from different tilt positions of the AC are shown in Figure 7 below.

In our set-up, the scattering vector pointed upwards. In the images shown below, refraction
contrast was obtained only from interfaces, the normal of which has a vertical component.

In Figure 2, the changes in the RC due to a purely absorbing specimen (without any interfaces) is a pure reduction of the RC (i.e., the width remains a constant red line), while an absorbing and refracting specimen (i.e., with internal surfaces) broadens the curve (blue line). The integral of the two RCs is the same. In some cases, we additionally observe a shift of the peak position (also depicted in Figure 2). The RCs are recorded for each individual pixel of the entire image of 1600 × 1200 pixels.

The total number of RCs per image (~2 million) demands the use of an automated and robust algorithm to extract the RC parameters by using appropriate computer programming languages.

A silicone gel specimen containing air bubbles serves as a demonstration to highlight
the properties that can be extracted (here, very well-defined and separated interfaces).

Additionally, an additively manufactured (AM) polycarbonate specimen [32] displays different features (i.e., elongated pores at the interface of consecutive layers).

4. Image Analysis Algorithm

4.1. *Selection of Fitting Functions*

As a reference, we implemented a fitting procedure based on Gaussian functions (Equation (8)), as suggested, e.g., by Arfelli et al. [19]:

$$
I(\theta) = I_B + \frac{Ae^{\frac{-4 \ln(2)(\theta - \theta_c)^2}{w^2}}}{w \sqrt{\pi / 4 \ln(2)}}, \quad (8)
$$

where $I_B$ is the baseline level (offset), $\theta_c$ is the center, $A$ is the integral, and $w$ the FWHM of the RC for each pixel. The FWHM is linked to the standard deviation $\sigma$ by the factor $(8 \ln(2))^{1/2}$. It should be noted that $\theta_c$ is not necessarily equal to $\theta_B$, in particular in the presence of macroscopic structures which cause a peak shift. It turned out that fitting with Gaussians could not properly reproduce the RCs at the maximum and at the tails at the same time (Figure 3).
<figure><img src="image_7.png" /><figcaption>**Figure 3.** Comparison of the two fitting functions to the experimental RC of a single pixel. The gray value (intensity of the pixel at that angular position of the analyzer crystal) is plotted as a function of the number of slice (proportional to the angular position of the analyzer crystal).</figcaption></figure>

Among different alternative peak fitting functions, such as Pearson VII or Inverse Polynomial, the Pseudo-Voigt (PsdV) fit function proved to be best suited to fit the experimental RCs and extract the targeted quantities. The Voigt function is a convolution of Gaussian and Lorentzian functions, whereas the PsdV function (Equation (9)) is a simpler weighted sum of these two functions, as a close approximation to the Voigt function.

The Pseudo-Voigt Function reads as follows:

$$I(\theta) = I_B + A \left[ m_u \frac{2}{\pi} \frac{w}{4(\theta - \theta_c)^2 + w^2} + (1 - m_u) \frac{\sqrt{4 \ln 2}}{\sqrt{\pi} w} e^{-\frac{4 \ln(2)}{w^2} (\theta - \theta_c)^2} \right], \quad (9)$$

where $m_u$ is the (linear) weighting factor of Lorentzian and Gaussian functions.

Only three out of five different coefficients obtained from the PsdV function proved to be useful for further evaluation, namely, $A$, $w$, and $\theta_c$ (Figure 4). They resulted in different image modalities (Table 1). The height of the RC gives the information about the reduction of intensity due to refraction, and also needs to be extracted. As the PsdV function does not contain a parameter to directly extract this value, we coded the algorithm to calculate $I_{max}$ from the fitting parameters (see Section 4.3) using the following equation:

$$I_{\max} = I_B + 2A/\pi w \left( (1 - m_u) \sqrt{\pi \ln 2} + m_u \right). \quad (10)$$

It is obvious that the PsdV function results in much better fit of the tails and of the peak of a typical experimental RC, compared to the Gaussian function. This is supported by the calculated $R^2$ values, serving as a figure of merit: 0.9917 for the Gaussian and 0.9988 for the PsdV.
<figure><img src="image_8.png" /><figcaption>**Figure 4.** Experimental RC of a single pixel (black dots) and the PsdV function (blue line). The letters indicate the quantities to be extracted.</figcaption></figure>

## 4.2. ImageJ Macro Language

The PsdV fitting procedure was first implemented using ImageJ Macro to validate the accuracy of the fit, as it can be computed with simple codes. Although ImageJ [33] offers a variety of inbuilt peak fitting functions, the PsdV function had to be implemented as a user-defined plugin. By fitting and analyzing the RC of every pixel of the image and flat field stacks with the PsdV function, the extracted quantities (the parameters of the function) were then assigned as gray values to the respective pixel of the different image modalities.

The PsdV function requires initial guesses for each of its parameters. These initial guesses were tested using Origin 2019 software, such that the fitting procedure could converge with the minimum number of iterations, in the minimum time, and with optimal quality for each pixel. Changes and manipulation of these guesses had a drastic impact on the fitting of the curve. Based on numerous trials using Origin 2019, the accuracy of the initial guesses for the fitting were checked and were also validated for use in ImageJ. Since the RC height is needed for the evaluation, it was derived from a numerical fine sampling of the obtained fit function (i.e, with a step five times finer than the experimental angular steps).

The four images (see Table 1) of the specimen and the flat field were used to calculate images of: the transmission (peak integral), the apparent transmission (peak height), the refraction angle (peak position) (according to Equations (2)–(5)), the refraction value $C_m \cdot d$, the attenuation $\mu \cdot d$, and the specific surface $C_m/(\mu \cdot d)$, according to Equations (6) and (7). It should be noted that the negative logarithm of the apparent transmission image is named the apparent absorption in some studies (e.g., [6,19]).

Figure 5 shows refraction angle images computed using the ImageJ Macro Language, using the two types of fit functions in the case of the silicone gel specimen.
<figure><img src="image_9.png" /><figcaption>**Figure 5.** Refraction angle images of the silicone gel specimen obtained from (a) the Gaussian function and (b) the PsdV function. Note the substantial improvement in the quality of image (b), which was computed using the PsdV function.</figcaption></figure>

For larger datasets (number of images in a stack), the computing time per iteration increased, and some erroneous fit results occurred. Figure 4 shows that the peak region of the experimental RC is not exactly fitted at the peak. This phenomenon occurred for the AM specimen; in that case, the different images modalities displayed some erroneous pixels (see Figure 6a).

<figure><img src="image_10.png" /><figcaption>**Figure 6.** Comparison of transmission (integral) images of an additively manufactured polymer specimen obtained from fitting PsdV functions in (a) ImageJ and (b) Python. The black pixels in Figure (a) are due to ill-fitting of the experimental RC. Figure (b) demonstrates the improved quality of images with no ill-fitted pixels using the Python module.</figcaption></figure>

The reason for this failure of the fitting procedure was the ad-hoc implementation of the user-defined macro.

Instead of using Equation (9) for each actual AC tilt angle, it proved advantageous to compute the fitting as a function of the slice number (i.e., the integer image number in the stack). Each image was read as the number of the slice, which is proportional to the angle of the analyzer crystal. The fitting function used this number to calculate the variables of the function, rather than reading the angle itself.

As the number of images in a stack are increased, computation times become longer. Therefore, after the accuracy of the fitting procedure was validated by means of $R^2$ values, the task of reducing the computing time had to be addressed. In fact, even though the im-
ages evaluated with the PsdV function were of better quality as compared to the Gaussian, the use of the PsdV led to an approximately 25 times large computing time for each pixel than the Gaussian function. This factor increased even further with the image size and with the number of images in the stack in ImageJ. Table 2 lists the iteration parameters for both types of peak functions for one pixel.

<table><caption>**Table 2.** Number of cycles (iterations) needed for the best fitting for individual RC and the average time required for each cycle in ImageJ.</caption><thead><tr><th></th><th>Gaussian Fit</th><th>PsdV Fit</th></tr></thead><tbody><tr><td>Number of iterations</td><td>106</td><td>936</td></tr><tr><td>Time consumption/RC</td><td>2 ms</td><td>49 ms</td></tr></tbody></table>

The total time required to evaluate the whole specimen and the flat field stack reached 2–3 days (depending on the number of images in the stack). Table 3 lists the influence of the number of images in the stack on the time required for computation. It is to be noted that all times reported are intended as average values. Every fit of an individual RC of a pixel in a stack may require a different number of iterations. To overcome these shortcomings and optimize the time performance of the algorithm, this approach was programmed in the Python language.

<table><caption>**Table 3.** Number of iterations needed and time consumption per RC of fitting PsdV functions in ImageJ as a function of the number of images of DEI measurements.</caption><thead><tr><th>Number of Images/RC</th><th>Iterations (Average)</th><th>Time/RC (Average)</th></tr></thead><tbody><tr><td>41</td><td>936</td><td>49 ms</td></tr><tr><td>61</td><td>967</td><td>60 ms</td></tr><tr><td>81</td><td>969</td><td>96 ms</td></tr><tr><td>121</td><td>1305</td><td>124 ms</td></tr></tbody></table>

### 4.3. Python Code

Python 3.0 (released in 2008) is a multi-paradigm programming language that fully supports both object-oriented programming and structured programming. The vast array of standard libraries in Python could provide a better solution to both problems: increase the quality of images and reduce the computing time. The *lmfit* module package contains fitting procedures of peak functions such as Gaussian, Lorentzian, Voigt, PsdV, etc. [34]. This Python module allowed the algorithm to yield images of superior quality in substantially reduced computing times.

The algorithm in Python was coded to follow the same procedure of creating blank images and assigning the parameters as gray values to the respective pixels of the image. The main part of the Python code is given in the Supplementary Material. Irrespective of the number of images in the stack, the internal features or the deviations of the RC from the ideal curve, optimal convergence of the fitting procedure (see Figure 6b) could be obtained in approximately 8 h. This represented a time reduction of a factor of 10, compared to ImageJ. Moreover, the image quality was significantly improved.

It is to be noted that the time required for the computation depends on the specifications of the computer. The computer used for this computation possesses an Intel(R) Core (TM) i5-8500 CPU at 3.00 GHz, 32 GB RAM and a 64-bit operating system. The Python program also allows simultaneous work with different sets of images, with each set working in dedicated consoles. This represents an enormous improvement as compared to ImageJ (even if several instances of ImageJ are opened simultaneously). Simultaneously working with different sets of image stacks is limited only by the specifications of the computer. In the case where eight different pairs of image stacks (object and flat field stack) were processed simultaneously, the fit converged to its optimum in 14 h (total for all of the eight pairs of images).
## 5. Results and Discussion

The silicone gel specimen (Figure 7a,b) with microscopic air bubbles ranging from approximately 100–400 µm in diameter, served as an example of a material meso-structure containing separated and geometrically well-defined interfaces. The images were computed with the algorithm programmed in Python, and all modalities could be extracted from the RC (Figure 8).

<figure><img src="image_11.png" /><figcaption>**Figure 7.** (a) Photograph of the silicone gel specimen with microscopic air bubbles, (b) raw image (corrected for the flat field) recorded in the center of the rocking curve. The marked region shows a concentration of air bubbles. (c) Sketch of the principal paths of X-rays traversing a spherical object, acting as an imperfect converging lens. The RC sample's intensity accumulations from the top and bottom cap of the bubbles at different off-center AC positions and the extinction at edges in the RC center (images on the right).</figcaption></figure>

<figure><img src="image_12.png" /><figcaption>**Figure 8.** Image details computed from fitting each pixel of the specimen with the PsdV function, showing (a) transmission, (b) apparent transmission, (c) refraction angle (d) scattering (width), and (e) $C_m \cdot d$. The latter two quantities highlight the same features at different scales, proving the analogy derived in Section 2. Note that the scattering vector is pointing upwards, so that crescents appear above and below each bubble.</figcaption></figure>
The principle of deflection of monochromatic X-rays at spherical shapes inside a specimen is shown in Figure 7c. The edges of an air bubble, i.e., its concave boundaries, cause the X-rays to be refracted convergently [35].

At the lower angular position, we observe the X-rays concentrated at the lower edge inside the air bubble, and at the higher angle, concentration at the upper edge. (Figure 7c). In Figure 8, a 250 × 250-pixel (1 × 1 mm²) detail of the full image (Figure 7b) is shown, highlighting a cluster of air bubbles. The improved quality of images obtained using the PsdV function compared to the Gaussian function is shown Figure 8 for all of the extracted features.

The $C_m \cdot d$ value is computed for each pixel according to Equation (5) (basically the ratio of height and integral of the RCs normalized to the flat field). In other words, the loss of peak intensity is an indirect measure of the increase of the peak width. Thus, the image of $C_m \cdot d$ and the scattering (width) carry the same information; this can be seen from a comparison of Figure 8d, e (see also Table 1).

The DEI or analyzer-based imaging technique is sensitive to the interfaces that are parallel to the plane of the analyzer crystal. (To observe the interfaces perpendicular to such plane we would have to rotate the specimen.) In the $C_m \cdot d$ images, it was observed that at the top and the bottom edges of each air bubble (i.e., surface nearly parallel to the plane of the analyzer crystal) crescent shape signals appear, whereas the perpendicular interfaces (at the equator line of each air bubble) display no noticeable intensity. An advantage of the DEI technique is that the scattering vector is predefined by the analyzer crystal, therefore surfaces with different orientation (e.g., cracks and pores) can easily be distinguished and quantitatively separated. In fact, if a further measurement was performed with the orientation of the specimen changed by 90°, pores would yield the same signal (i.e., the same images as in Figure 8), while cracks would not be detected if they were visible in the previous set-up (and vice-versa, they would be detected if they were previously invisible).

## 6. Conclusions

We have shown that the physical information content of image series collected according to the DEI principle can be more precisely exploited when using PsdV functions (instead of Gaussians) to fit experimental RCs. Using the ImageJ macro code, the fitting routines were optimized with respect to accuracy, robustness, and speed. However, it turned out that, locally, some RCs could not be fitted (especially if one of the parameters of the fitting function was far from the average values in the image). Using an optimized tool (lmfit) in a Python programming environment, the ill-behaved RCs of such pixels could be properly fitted, and a significant reduction in the computation time (by a factor of seven compared to ImageJ) was achieved. The added advantage of working in dedicated consoles for simultaneously processing different image datasets assured the practicality and versatility of the developed Python algorithm.

Beyond the modalities (transmission, refraction angle, scattering), which have been shown to be extracted from Gaussian type RCs, we showed the analogy between scattering and the so-called refraction value ($C_m$) images. Since the latter quantity is accessible with lower experimental effort, the use of our Python routine paves the road to an even faster access to X-ray refraction data analysis.

**Supplementary Materials:** Supporting information on the main part of the Python code can be downloaded at: https://www.mdpi.com/article/10.3390/jimaging8080206/s1.

**Author Contributions:** Conceptualization, D.M. and A.K.; methodology, D.M., A.K. and B.R.M.; software, D.M.; validation, D.M., A.K. and B.R.M.; formal analysis, D.M.; investigation, D.M. and A.K.; resources, A.K. and G.B.; data curation, D.M.; writing—original draft preparation, D.M. and A.K.; writing—review and editing, D.M., A.K., G.B. and B.R.M.; visualization, D.M. and A.K.; supervision, A.K. and G.B. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research received no external funding.

**Institutional Review Board Statement:** Not applicable.
**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Any data and code used in this paper is available from the authors on reasonable request.

**Acknowledgments:** The authors acknowledge M. Sintschuk and R. Britzke (BAM) for their assistance with the measurements at BAMline. L. Brambol, F. Arfelli, R. Menk, L. Rigon, and L. Mancini of the SYRMEP group at Elettra, Trieste, Italy, are acknowledged for vivid and fruitful discussions on several aspects of XR imaging. D.M. acknowledges the late S. Evsevleev and S. Magkos (BAM) for introducing him to the basics of ImageJ Macro language and Python programming.

**Conflicts of Interest:** The authors declare no conflict of interest.

## References

1. Hentschel, M.P.; Hosemann, R.; Lange, A.; Uther, B.; Brückner, R. Small-angle X-ray refraction in metal wires, glass-fibers and hard-elastic propylenes. *Acta Crystallogr. Sect. A* **1987**, *43*, 506–513. [CrossRef]

2. Zhu, P.; Yuan, Q.; Huang, W.; Wang, J.; Shu, H.; Chen, B.; Liu, Y.; Li, E.; Wu, Z. Diffraction enhanced imaging: A simple model. *J. Phys. D Appl. Phys.* **2006**, *39*, 4142–4147. [CrossRef]

3. Pfeiffer, F.; Weitkamp, T.; Bunk, O.; David, C. Phase retrieval and differential phase-contrast imaging with low-brilliance X-ray sources. *Nat. Phys.* **2006**, *2*, 258–261. [CrossRef]

4. Olivo, A.; Arfelli, F.; Cantatore, G.; Longo, R.; Menk, R.H.; Pani, S.; Prest, M.; Poropat, P.; Rigon, L.; Tromba, G.; et al. An innovative digital imaging set-up allowing a low-dose approach to phase contrast applications in the medical field. *Med. Phys.* **2001**, *28*, 1610–1619. [CrossRef]

5. Ingal, V.N.; Beliaevskaya, E.A. X-ray plane-wave topography observation in the phase contrast from a non-crystalline object. *J. Phys. D Appl. Phys.* **1995**, *28*, 2314–2317. [CrossRef]

6. Chapman, D.; Thomlinson, W.; Johnston, R.E.; Washburn, D.; Pisano, E.; Gmur, N.; Zhong, Z.; Menk, R.; Arfelli, F.; Sayers, D. Diffraction enhanced x-ray imaging. *Phys. Med. Biol.* **1997**, *42*, 2015–2025. [CrossRef]

7. Ando, M.; Maksimenko, A.; Sugiyama, H.; Pattanasiriwisawa, W.; Hyodo, K.; Uyama, C. Simple X-ray dark- and bright-field imaging using achromatic lane optics. *Jpn. J. Appl. Phys. Part 2 Lett.* **2002**, *41*, L1016–L1018. [CrossRef]

8. Wilkins, S.W.; Gureyev, T.E.; Gao, D.; Pogany, A.; Stevenson, A.W. Phase-contrast imaging using polychromatic hard X-rays. *Nature* **1996**, *384*, 335–338. [CrossRef]

9. Paganin, D.; Mayo, S.C.; Gureyev, T.E.; Miller, P.R.; Wilkins, S.W. Simultaneous phase and amplitude extraction from a single defocused image of a homogeneous object. *J. Microsc.* **2002**, *206*, 33–40. [CrossRef]

10. Weitkamp, T.; Haas, D.; Wegrzynek, D.; Rack, A. ANK Aphase: Software for single-distance phase retrieval from inline X-ray phase-contrast radiographs. *J. Synchrotron Radiat.* **2011**, *18*, 617–629. [CrossRef]

11. Hentschel, M.P.; Harbich, K.-W.; Lange, A. Nondestructive evaluation of single fibre debonding in composites by X-ray refraction. *NDT E Int.* **1994**, *27*, 275–280. [CrossRef]

12. Kupsch, A.; Lange, A.; Hentschel, M.P.; Onel, Y.; Wolk, T.; Staude, A.; Ehrig, K.; Müller, B.R.; Bruno, G. Evaluating porosity in cordierite diesel particulate filter materials, part 1 X-ray refraction. *J. Ceram. Sci. Technol.* **2013**, *4*, 169–176.

13. Müller, B.R.; Cooper, R.C.; Lange, A.; Kupsch, A.; Wheeler, M.; Hentschel, M.P.; Staude, A.; Pandey, A.; Shyam, A.; Bruno, G. Stress-induced microcrack density evolution in β-eucryptite ceramics: Experimental observations and possible route to strain hardening. *Acta Mater.* **2018**, *144*, 627–641. [CrossRef]

14. Kupsch, A.; Laquai, R.; Müller, B.R.; Paciornik, S.; Horvath, J.; Tushtev, K.; Rezwan, K.; Bruno, G. Evolution of Damage in All-Oxide Ceramic Matrix Composite After Cyclic Loading. *Adv. Eng. Mater.* **2022**, *24*, 2100763. [CrossRef]

15. Kupsch, A.; Trappe, V.; Müller, B.R.; Bruno, G. Evolution of CFRP stress cracks observed by in-situ X-ray refractive imaging. In Proceedings of the IOP Conference Series: Materials Science and Engineering, Roskilde, Denmark, 7–10 September 2020; Volume 942, p. 012035. [CrossRef]

16. Nellesen, J.; Laquai, R.; Müller, B.R.; Kupsch, A.; Hentschel, M.P.; Anar, N.B.; Soppa, E.; Tillmann, W.; Bruno, G. In situ analysis of damage evolution in an Al/Al₂O₃ MMC under tensile load by synchrotron X-ray refraction imaging. *J. Mater. Sci.* **2018**, *53*, 6021–6032. [CrossRef]

17. Serrano-Munoz, I.; Roveda, I.; Kupsch, A.; Müller, B.R.; Bruno, G. Synchrotron X-ray refraction detects microstructure and porosity evolution during in-situ heat treatments. *Mater. Sci. Eng. A* **2022**, *838*, 142732. [CrossRef]

18. Laquai, R.; Schaupp, T.; Griesche, A.; Müller, B.R.; Kupsch, A.; Hannemann, A.; Kannengiesser, T.; Bruno, G. Quantitative analysis of hydrogen-assisted microcracking in duplex stainless steel through X-ray refraction 3D imaging. *Adv. Eng. Mater.* **2022**, *24*, 2101287. [CrossRef]

19. Arfelli, F.; Astolfo, A.; Rigon, L.; Menk, R.H. A Gaussian extension for Diffraction Enhanced Imaging. *Sci. Rep.* **2018**, *8*, 362. [CrossRef]

20. Chen, H.; Liu, B.; Zhao, L.M.; Ren, K.; Wang, Z.L. Retrieval of multiple scattering contrast from x-ray analyzer-based imaging. *Chin. Phys. B* **2021**, *30*, 018701. [CrossRef]
21. Fensch-Kleemann, E.; Harbich, K.-W.; Hentschel, M.P. Microstructural Characterisation of Porous Ceramics by X-Ray Refraction Topography. *Ceram. Forum Int. CFI* **2002**, *79*, E35-E38.

22. Kupsch, A.; Müller, B.R.; Lange, A.; Bruno, G. Microstructure characterisation of ceramics via 2D and 3D X-ray refraction techniques. *J. Eur. Ceram. Soc.* **2017**, *37*, 1879–1889. [CrossRef]

23. Schob, D.; Roszak, R.; Sagradov, I.; Sparr, H.; Ziegenhorn, M.; Kupsch, A.; Léonard, F.; Müller, B.R.; Bruno, G. Experimental determination and numerical simulation of material and damage behaviour of 3D printed polyamide 12 under quasi-static loading. *Arch. Mech.* **2019**, *71*, 507–526. [CrossRef]

24. Schob, D.; Sagradov, I.; Roszak, R.; Sparr, H.; Franke, R.; Ziegenhorn, M.; Kupsch, A.; Léonard, F.; Müller, B.R.; Bruno, G. Experimental determination and numerical simulation of material and damage behaviour of 3D printed polyamide 12 under cyclic loading. *Eng. Fract. Mech.* **2020**, *229*, 106841. [CrossRef]

25. Erdmann, M.; Kupsch, A.; Müller, B.R.; Hentschel, M.P.; Niebergall, U.; Böhning, M.; Bruno, G. Diesel-induced transparency of plastically deformed high-density polyethylene. *J. Mater. Sci.* **2019**, *54*, 11739–11755. [CrossRef]

26. Glatter, O.; Kratky, O. *Small Angle X-ray Scattering*; Academic Press: London, UK, 1982.

27. Zocca, A.; Müller, B.R.; Laquai, R.; Kupsch, A.; Wieder, F.; Wilbig, J.; Günster, J.; Bruno, G. Microstructural characterization of an AP40 apatite-wollastonite glass-ceramic. *Ceram. Int.* **2022. to be submitted**.

28. Görner, W.; Hentschel, M.P.; Müller, B.R.; Riesemeier, H.; Krumrey, M.; Ulm, G.; Diete, W.; Klein, U.; Frahm, R. BAMline: The first hard X-ray beamline at BESSY II. *Nucl. Instrum. Methods Phys. Res. Sect. A Accel. Spectrometers Detect. Assoc. Equip.* **2001**, *467*, 703–706. [CrossRef]

29. Rack, A.; Zabler, S.; Müller, B.R.; Riesemeier, H.; Weidemann, G.; Lange, A.; Goebbels, J.; Hentschel, M.; Görner, W. High resolution synchrotron-based radiography and tomography using hard X-rays at the BAMline (BESSY II). *Nucl. Instrum. Methods Phys. Res. Sect. A Accel. Spectrometers Detect. Assoc. Equip.* **2008**, *586*, 327–344. [CrossRef]

30. Lange, A.; Hentschel, M.P.; Kupsch, A.; Müller, B.R. Numerical correction of X-ray detector backlighting. *Int. J. Mater. Res.* **2012**, *103*, 174–178. [CrossRef]

31. Al-Falahat, A.M.; Kupsch, A.; Hentschel, M.P.; Lange, A.; Kardjilov, N.; Markötter, H.; Manke, I. Correction approach of detector backlighting in radiography. *Rev. Sci. Instrum.* **2019**, *90*, 125108. [CrossRef]

32. Böhler, S.; Bartel, M.; Bohn, A.; Jacob, R.; Ganster, J.; Busse, T.; Balko, J. Highly dense cellulose acetate specimens with superior mechanical properties produced by fused filament fabrication. *Polymer* **2020**, *194*, 10. [CrossRef]

33. Schneider, C.A.; Rasband, W.S.; Eliceiri, K.W. NIH Image to ImageJ: 25 years of image analysis. *Nat. Methods* **2012**, *9*, 671–675. [CrossRef]

34. Newville, M.; Stensitzki, T.; Allen, D.B.; Rawlik, M.; Ingargiola, A.; Nelson, A. *LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python*; Astrophysics Source Code Library: Houghton, MI, USA, 2016; p. ascl-1606.

35. Evsevleev, S.; Müller, B.R.; Lange, A.; Kupsch, A. Refraction driven X-ray caustics at curved interfaces. *Nucl. Instrum. Methods Phys. Res. Sect. A* **2019**, *916*, 275–282. [CrossRef]