Abstract
Terahertz time-domain spectroscopic imaging has become a common and useful technique for various interdisciplinary studies. Raster scan is still the most general and reliable imaging modality due to the lack of matrix detectors. In terahertz raster scanning imaging, row displacements occur due to the use of a two-way continuous scanning mode, the lack of delay line triggering, or other technical factors. The displacements result in image distortion which significantly affects the subsequent data analysis. In this article, a row displacement correction algorithm based on a genetic algorithm is proposed. The algorithm corrects images based on the principle that row displacements result in an increase of high-frequency components of the Fourier spectrum transformed along the image column direction. The algorithm performance is comprehensively verified by both numerical simulation and experimental data, showing a promising effectiveness and robustness on different sample types, shapes, orientations, and spatial distributions. The algorithm corrects the displacements numerically regardless of the causing factors, offering a wide adaptability for various THz systems to improve the scanning efficiency and image quality.
Similar content being viewed by others
Avoid common mistakes on your manuscript.
1 Introduction
Terahertz (THz) waves are noninvasive, sensitive to free carriers and biomolecular vibrations, and transparent to many optically opaque materials. It has been widely applied in many fields including cultural relics conservation [1], agriculture [2], food security [3], communication [4, 5], and biomedicine [6]. THz imaging, often realized based on a THz time-domain spectroscopy (THz-TDS) system, combines THz spectroscopy and imaging that every spatial pixel contains a coherently detected complex spectrum. It provides multidimensional data in the spatial, temporal, and frequency domain, revealing lateral and axial properties of long-range intermolecular interaction, hydrogen bond rearrangement, and free carrier movement. As a result, THz-TDS imaging is an important technique in chemical recognition [7], medical diagnosis [8, 9], substance identification [10, 11], defect detection [12, 13], etc.
Due to the lack of efficient matrix detectors, raster scan is the primary imaging mode for THz-TDS. In this mode, THz optics or samples are equipped on a translational X–Y stage [14, 15]. Signals are recorded at each spatial position to form an image. Apart from raster scan, focal plane imaging by employing a CCD camera in the electro-optic sampling system or by using compress-sensing techniques can form coherent THz spectroscopic images without mechanical movements [16,17,18]. However, they require either an intense pumping laser or an efficient spatial modulator. In terms of the signal-to-noise ratio, bandwidth, and field-of-view, raster scan is still the best and most widely used mode for THz imaging.
Signals in THz-TDS are obtained by rapidly oscillating the optical delay line to sample the electric field in time-domain. The scanning speed, or equivalently the signal acquisition rate, is about few hertz to tens of hertz, depending on the stage type and scanning length. As a result, the most accurate way to perform an image scan is the “move-stop” mode. In this scheme, the X–Y stage moves to each target position and stops, waits until the signal has been fully sampled, and moves to the next position. However, such a scanning scheme is very low in efficiency as a majority of time is spent on the acceleration and deceleration without data acquisition. To obtain a high imaging speed, the continuous scanning mode is more widely used, in which the stage continuously moves along the X direction with a constant speed without a dwell time for every pixel. This then requires a synchronization between the optical delay line and the X stage, as shown in Fig. 1. The delay line sends a trigger signal when it starts sampling a THz signal. The X stage accelerates immediately. Because the acceleration time will not be exactly an integer multiple of the signal acquisition time, there will be a waiting range at which the X stage moves at a constant speed without signal acquisition until the next full THz signal arrives. After that, \(M\) numbers of signals are continuously recorded with \(M=\left\lfloor\frac{\left|{X}_{{\text{end}}}-{X}_{{\text{start}}}\right|}{{X}_{{\text{resolution}}}}\right\rfloor-1\). \(M\) decides the number of columns and this definition ensures that the X stage is still at a constant speed after the last signal has been obtained. The stage then moves by a small amount to Xend, decelerates, stops, and moves to the next row by moving in the Y direction by the amount specified by the Y resolution.
There are two optional scanning modes after that. In the one-way scanning mode, the X stage moves back to the start point of Xstart-Xacc and scans the next row in the same direction as the previous row. This method is most reliable as the trigger signal aligns different rows without any displacement, which is also adopted in most commercial THz-TDS imaging products. Obviously, the major limitation of the one-way scan is the low efficiency. There is no signal recording when the X stage moves back to the starting position; hence, nearly half of the scanning time is wasted. In a two-way scanning mode shown in the lower part of Fig. 1, the X stage moves backward to scan the next row in an opposite direction. This is most efficient as it saves the time moving back to the start point. However, displacements between different rows occur because the position when it starts recording the first signal mismatches with the position recording the last signal of the previous row. Comparisons between different scanning modes have been extensively studied in ref. [19], and a calibration method has been proposed but requires the accurate knowledge about the physical parameters of the stage and the delay line.
In practical experiments, other factors such as command sending delays or unstable stage acceleration could also lead to row displacements [19]. In addition, a precise trigger requires a synchronization connection between the optical delay line and the X-Y stage, which is not always accessible in many commercial THz-TDS systems. In that case, even the one-way scanning mode results in row displacements. In this article, we present a robust displacement correction method based on a genetic algorithm (GA) for THz imaging. We verify its performance from both theoretical simulation and experimental results. The algorithm enables employing the most efficient two-way scanning mode without a trigger and it is insensitive to technical delay factors. This paper is organized as follows. We will introduce the theory and algorithm design in Sect. 2. The numerical simulation and experimental verification will be demonstrated in Sect. 3. Conclusions are provided in Sect. 4.
2 Methods
2.1 Theory
According to the Fourier theory, the frequency spectrum of a signal indicates the frequency components needed to compose the signal in time or space. Fast-varying signals contain more high-frequency components and vice versa. Row displacements result in image distortion and a direct consequence is the increased variation along the column direction (i.e., between rows). Figure 2a plots a simulated image containing a rectangle, a triangle, and a circle. The number of rows is \(N=100\) and the number of columns is \(M=110\). Random row displacements were manually applied to all rows and the result is shown in Fig. 2b. Figure 2c and d are the natural logarithm amplitude of the Fast Fourier Transformed (FFT) spectrums of all columns of Fig. 2a and b, respectively. An obvious increase in the amplitude at high frequencies is observed in Fig. 2d, verifying the prediction that row displacement increases the rapid variation components along the column direction.
In light of this, row displacements can be corrected by minimizing the high-frequency amplitude of the FFT spectrum. Therefore, we define function \({f}_{1}\) in Eq. 1 to evaluate the average high-frequency amplitude of the corrected image, which is normalized to that of the original image as:
where
where \(k\) is the frequency index, \(j\) is the column index, and \({I}_{{\text{org}}}\left(j\right)\) and \({I}_{{\text{corr}}}\left(j\right)\) are original and corrected image values of the \(j\) th column. \(N/2\) is the number of data points of the frequency spectrum. The average is applied over the frequency components with \(k\ge N/20\), which is an empirical value that takes the upper 90% frequencies into consideration. Figure 3 shows the averaged spectral amplitudes of the aligned and the displaced images shown in Fig. 2 a and b, respectively. The gray area indicates the region with \(k\ge N/20\) that is evaluated by Eq. 1.
Averaged spectral amplitudes of the aligned and the displaced images shown in Fig. 2 a and b, respectively. The gray area indicates the region with \(k\ge N/20\)
The alignment can be done by searching displacement index \(x\left(i\right)\) for all rows by minimizing \({f}_{1}\), where \(x\left(i\right)\) refers to the number of pixels that were displaced in the ith row. The positive or negative sign of \(x\left(i\right)\) indicates the displacement direction towards the start or the end of the row. To improve the robustness, we further define a second evaluation function \({f}_{2}\) as:
The key principle of this function is that the displacements \(x\) should have an average value of about 0 due to its random characteristics. However, we do not directly calculate the average of \(x\). Instead, we use \({\text{MovAve}}\left(x\left(i\right), 11\right)\) to calculate the moving average of \(x\left(i\right)\) for every adjacent 11 data points and use the average of the absolute values to evaluate the random distribution, where 11 is an empirical parameter. The difference compared to directly averaging all data points is that the applied method tends to reduce the average value of every 11 data points. In this way, every small section of the row displacements should distribute randomly. Figure 4 shows a simulated example. \(x\) represents a potential solution to correct a misaligned image. Overall, \(x\left(i\right)\) is randomly distributed over 50 rows with an average value very close to 0, as indicated by the dashed black line. However, the moving average of every 11 values is not always close to 0; hence, the average of the absolute value (i.e., the dashed yellow curve) will be large. The given example tends to move some sections of rows leftward and some sections rightward, which is unlikely to happen in practical situations; hence, it will result in a relatively large value of \({f}_{2}\).
The total evaluation function is a weighted sum of \({f}_{1}\) and \({f}_{2}\) by:
where \(a\) is a weighting coefficient to balance the contribution of the two functions, which is defined as 0.2 in this work.
2.2 Algorithm
The image correction becomes a problem of searching \(N\) unknown displacement values \(x\left(i\right)\) by minimizing \(f\). This forms a multivariate optimization issue as \(N\) is typically large, depending on the image size, resulting in an issue of “curse of dimensionality” [20]. Meta-heuristic algorithms are suitable for large-scale multivariate optimization. GA is one such algorithm derived from the evolution theory [21], which has been widely applied in THz image denoising, characterization, and adaptive sampling [22,23,24,25]; hence, it is applied in this work.
Table 1 gives the steps of the algorithm. The first step of GA is initialization, which randomly assigns \(P\) groups (i.e., \(P\) populations) of displacement vector \({x}_{p}\left(i\right)\) with \(p\) (\(1\le p\le P\)) indicating the number of groups. We define \(P=40\sqrt{N}\), being proportional to the square root of the row number, such that the population size is automatically adjusted according to the number of rows needed to be corrected. \({x}_{p}\left(i\right)\) is randomly assigned within \(\pm d\) where d is an integer defining the maximum displacement. The values of \({x}_{p}\) represent genes in a population. As our system does not provide a trigger signal to align all rows, \(d=3\) is set in the experiment to allow a larger displacement correction. The second step evaluates the populations. The original image is corrected according to \({x}_{p}\left(i\right)\) by shifting the ith row by \({x}_{p}\left(i\right)\), resulting in \(P\) corrected images of \({I}_{p}\left(i,j\right)\). \({I}_{p}\left(i,j\right)\) and \({x}_{p}\left(i\right)\) are evaluated by Eq. 3 with \({f}_{p}\) representing their fitness. Subsequently, ranking, crossover, and mutation are standard steps of GA that mimic the natural evolution process to produce better solutions from the iteration. In detail, ranking sorts the populations in an ascending order according to \({f}_{p}\). Crossover randomly exchanges a part of the genes (i.e., \({x}_{p}\left(i\right)\)) between every two adjacent populations in the top half populations, producing a new offspring generation. The newly produced and the remained top half populations are sent to the next evaluation loop. The population size is kept unchanged in this way. Mutation randomly changes some of the genes in the produced population to maintain the divergency of the optimization. This avoids being tracked into local minimums. Steps 2–6 repeat until reaching the maximum iteration number. The population with the minimum \({f}_{p}\) in the last iteration is exported as the optimal solution of the algorithm.
3 Verification
3.1 Simulation
We first verified the proposed method by the numerically simulated image shown in Fig. 2. The proposed algorithm was applied to the misaligned image and the result is shown in Fig. 5a. The corrected image coincides nicely the original image, showing that the algorithm has successfully compensated the displacements. Figure 5b gives the quantitative comparison between the simulated \(x\left(i\right)\) applied to the misaligned image and the values found from the algorithm (for rows with \(20\le i\le 80\) that contain amplitude variations). All values are perfectly matched, demonstrating that the evaluation function has successfully guided the optimization towards the correct row positions and the algorithm is efficient in multivariate optimization.
Numerical verification of the algorithm. a Corrected image of the displaced image shown in Fig. 2b. b \(x\left(i\right)\) applied to the displaced image and the values found from the algorithm
3.2 Experiments
The algorithm was further verified experimentally. In the first experiment, transmission images from a metal resolution panel with different patterns were used, containing circles, rectangles, and a radial pattern. These images are quasi-binary as metal has a transmission of 0 and the air pattern region has a transmission of 1, providing a high contrast that any little displacement can be clearly observed. In the second experiment, a tooth slice transmission image was used to verify the performance on samples with irregular shape and gradual spatial variation. All the experiments were conducted based on the THz-TDS system (Menlo System TeraSmart). Samples were assembled on the X-Y stage (OptoSigma, OSMS20-85(XY)-M6).
Figure 6a shows the measured THz image of the radial pattern formed by six triangles and Fig. 6c shows the image of two closely spaced circles with a diameter of 1 mm, respectively. The scanning step was set as 0.1 mm in both the X and Y directions. We plot the images by the amplitudes at 1.3 THz, which provides a sufficiently high spatial resolution to clearly resolve the displacements. Misaligned rows can be clearly seen due to the two-way scanning mode and the lack of a trigger as explained above. Figure 6b and d show the corrected images by the proposed algorithm. The jagged borders in the original image have been mostly eliminated. The shapes of triangles and circles were well reconstructed by the correction. Very small misalignment can be seen from the weakly distorted middle vertical line at the center of Fig. 6b, which is likely due to the limited spatial amplitude variation along the row direction; hence, the displacements have limited influence on the evaluation function. Overall, the results demonstrate that our algorithm works well for correcting images of different spatial shapes. The algorithm takes 23 s and 2 s on a general PC (Intel i5-10500, Ram 16 GB) for the radial-pattern image (101 rows) and the circle-pattern image (31 rows), which is sufficiently fast for data analysis.
We further apply the algorithm to images shown in Fig. 7 a and c, which contain rectangular bars with edges perpendicular and 45° to the X axis, respectively. The corrected results shown in Fig. 7 b and d verify the stable performance of the algorithm on different sample orientations. Being insensitive to image rotations is important in practical imaging applications. However, slight distortion can be observed, for example, the slightly curved edge near the top left and bottom right of Fig. 7d. The parameter setting of the evaluation function could be the main reason and the correction can be improved by optimizing these parameters.
In the multivariate optimization, robustness is an important aspect of the algorithm, which evaluates the variation of the optimal solution in different independent runs. To investigate the robustness, we repeated 10 independent runs for the above four images in Figs. 6 and 7, and analyze the variation of the optimal solutions. Let \({x}_{r}\left(i\right)\) denote the optimal solution in the rth run, and \(\overline{x }\left(i\right)\) be the average of the 10 runs, Eq. 4 defines the standard deviation \(\sigma \left(i\right)\) of \({x}_{r}\left(i\right)\) as:
where
The average of \(\sigma \left(i\right)\) over the rows within the set of \(I\) was calculated as:
where \(I\) contains rows with a minimum amplitude variation greater than 0.1. This is because some rows, for example, the first and the last few rows in Fig. 7a, have a constant amplitude along the row direction; the displacement has no influence on the image and cannot be accurately determined. \(\tilde{\sigma }\) of images with different patterns is shown in Fig. 8, which has values all below 0.15, corresponding to an average positioning error less than 0.15 × 0.1 mm = 0.015 mm. The values for the circular and the rectangular bar images are even close to zero, showing a high robustness of the optimization algorithm.
We further apply the algorithm on a tooth slice sample. The optical image is shown in Fig. 9a. The sample contains the dentin, enamel, and epoxy resin embedding material. It has a thickness of about 400 μm and was fixed on a low-density sponge having a THz transmission of ~ 1 due to the 99% porosity. Figure 9b shows the THz transmission image of the sample at 1.3 THz. Compared to the standard metal resolution panel, it is less regular in shape and the transmission values vary more gradually in space. The misalignment has led to jagged irregular borders, resulting in difficulties in margin recognition and region segmentation, especially for the enamel area. Figure 9c plots the image after correction, showing a continuous and smooth border. The sample structure and borders coincide well with the optical image. The boundaries between different regions are clearly distinguished. The narrow enamel region is now well resolved and continuous in space, which has a much better contrast to the dentin region compared to the optical image due to the high sensitivity of THz light to the degree of mineralization [26]. The results demonstrate the great performance of the algorithm on practical samples with arbitrary shapes and transmission values.
4 Conclusions
In this article, we propose a row displacement correction algorithm for accurate and high-speed THz raster scanning imaging. The algorithm is built on two theoretical assumptions. First, the row displacements generate high-frequency components in the Fourier spectrum along the column direction. Second, the displacements of different rows are random and should have an average value close to 0. We defined the evaluation function according to the above theory and determined the displacements based on a GA. We verified the algorithm performance via both the numerical simulated and experimental images. The simulation quantitatively verifies the perfect reconstruction of the image. The experimental results of the metal panel demonstrate the effectiveness for samples of different shapes and orientations. The application on a tooth slice further verifies the great performance on practical irregular samples. The statistical analysis on multiple algorithm runs validates the algorithm robustness.
The algorithm can correct row displacements regardless of the causing factors, including the two-way scan, the lack of trigger, and any other technical misalignment factors. Especially, the use of the two-way scanning mode without a need of trigger signal maximizes the scanning speed and the versatility of the algorithm. It removes the need of the stage synchronization with the delay line and simplifies the program design. Therefore, it can be widely applied in various THz systems to provide a high scanning efficiency and image quality. The proposed method also has some limitations. One is the pixel losses and hence a reduced field-of-view due to the need of edge-cutting after the alignment. This is because row boundaries are not located within the same column after being shifted by different numbers of pixels, and columns with incomplete pixels were discarded. However, we note that it only takes an additional 0.15 s for each row to compensate for the maximum 6 columns removed (assuming a 40-Hz signal acquisition rate). Another major limitation is the parameter optimization for the evaluation function, including the high-frequency threshold N/20, the moving average number, and the weight α of function \({f}_{2}\), which are determined empirically. Although they were proved good enough for most examples demonstrated in this work, they could be further optimized using a larger image dataset to provide a more objective setting and a better robustness.
Data Availability
Data are available from the corresponding authors upon reasonable request.
References
Borg, B., Dunn, M., Ang, A. & Villis, C. The application of state-of-the-art technologies to support artwork conservation: Literature review. Journal of Cultural Heritage 44, 239–259 (2020).
Afsah-Hejri, L. et al. Terahertz spectroscopy and imaging: A review on agricultural applications. Computers and Electronics in Agriculture 177, 105628 (2020).
Ren, A., Zahid, A., Fan, D. & Yang, X. State-of-the-art in terahertz sensing for food and water security – A comprehensive review. Trends in Food Science & Technology 85, 241–251 (2019).
Xu, C., Ren, Z., Wei, J. & Lee, C. Reconfigurable terahertz metamaterials: From fundamental principles to advanced 6G applications. iScience 25, (2022).
Huang, Y., Shen, Y. & Wang, J. From Terahertz Imaging to Terahertz Wireless Communications. Engineering S2095809922006361 (2022) doi:https://doi.org/10.1016/j.eng.2022.06.023.
Yang, X. et al. Biomedical Applications of Terahertz Spectroscopy and Imaging. Trends in Biotechnology 34, 810–824 (2016).
Fischer, B., Hoffmann, M., Helm, H., Modjesch, G. & Jepsen, P. U. Chemical recognition in terahertz time-domain spectroscopy and imaging. Semicond. Sci. Technol. 20, S246–S253 (2005).
Peng, Y., Shi, C., Wu, X., Zhu, Y. & Zhuang, S. Terahertz Imaging and Spectroscopy in Cancer Diagnostics: A Technical Review. BME Frontiers 2020, 1–11 (2020).
Yan, Z., Zhu, L.-G., Meng, K., Huang, W. & Shi, Q. THz medical imaging: from in vitro to in vivo. Trends in Biotechnology 40, 816–830 (2022).
Yang, Y., Zhai, D., Zhang, Z. & Zhang, C. THz Spectroscopic Identification of Red Mineral Pigments in Ancient Chinese Artworks. J Infrared Milli Terahz Waves 38, 1232–1240 (2017).
Ahi, K. & Anwar, M. Advanced terahertz techniques for quality control and counterfeit detection. in Conference on Terahertz Physics, Devices, and Systems X - Advanced Applications in Industry and Defense (eds. Anwar, M. F., Crowe, T. W. & Manzur, T.) 98560G (2016). doi:https://doi.org/10.1117/12.2228684.
Hu, J. et al. Autonomous dynamic line-scan continuous-wave terahertz non-destructive inspection system combined with unsupervised exposure fusion. NDT & E International 132, 102705 (2022).
Strąg, M. & Świderski, W. Non-destructive inspection of military-designated composite materials with the use of Terahertz imaging. Composite Structures 306, 116588 (2023).
Yeo, W. S. & Berger, J. Application of Raster Scanning Method to Image Sonification, Sound Visualization, Sound Analysis and Synthesis. in Proceedings of the 9th International Conference on Digital Audio Effects (2006).
Lang, F. C. et al. A novel raster-scanning method to fabricate ultra-fine cross-gratings for the generation of electron beam moiré fringe patterns. Optics and Lasers in Engineering 86, 281–290 (2016).
Wu, Q., Hewitt, T. D. & Zhang, X. ‐C. Two‐dimensional electro‐optic imaging of THz beams. Appl. Phys. Lett. 69, 1026–1028 (1996).
Usami, M., Yamashita, M., Fukushima, K., Otani, C. & Kawase, K. Terahertz wideband spectroscopic imaging based on two-dimensional electro-optic sampling technique. Appl. Phys. Lett. 86, 141109 (2005).
Stantchev, R. I., Yu, X., Blu, T. & Pickwell-MacPherson, E. Real-time terahertz imaging with a single-pixel detector. Nat Commun 11, 2535 (2020).
Han, D.-H. & Kang, L.-H. High-speed THz imaging using two-way raster scanning method without dwell time. J Mech Sci Technol 33, 1079–1086 (2019).
Yang, Z., Tang, K. & Yao, X. Large scale evolutionary optimization using cooperative coevolution. Information Sciences 178, 2985–2999 (2008).
Kochenderfer, M. J. & Wheeler, T. A. Algorithms for optimization. (The MIT Press, 2019).
Chen, X., Sun, Q., Stantchev, R. I. & Pickwell-MacPherson, E. Objective and efficient terahertz signal denoising by transfer function reconstruction. APL Photonics 5, 056104 (2020).
Yuan, B. et al. Nondestructive Evaluation of Thermal Barrier Coatings Thickness Using Terahertz Technique Combined with PCA–GA–ELM Algorithm. Coatings 12, 390 (2022).
Li, Z., Guan, A., Ge, H. & Lian, F. Wavelength selection of amino acid THz absorption spectra for quantitative analysis by a self-adaptive genetic algorithm and comparison with mwPLS. Microchemical Journal 132, 185–189 (2017).
Li, K., Chen, X., Shen, S., Zhang, R. & Pickwell-MacPherson, E. Genetic-Algorithm-Based Optimization for Terahertz Time-Domain Adaptive Sampling. IEEE Trans. THz Sci. Technol. 9, 675–683 (2019).
Pickwell, E. et al. A Comparison of Terahertz Pulsed Imaging with Transmission Microradiography for Depth Measurement of Enamel Demineralisation in vitro. Caries Res 41, 49–55 (2007).
Funding
The work is in part supported by the National Natural Science Foundation of China (61988102); Key Research and Development Program of Guangdong Province (2019B090917007); Science and Technology Planning Project of Guangdong Province (2019B090909011); and Guangzhou Science and Technology Planning Project (2023A04J0339).
Author information
Authors and Affiliations
Contributions
T.Z. and H.C. performed the measurement. T.Z. and X.C. performed the simulation and data analysis. K.L. prepared the sample. G.F. and X.C. supervised the work. T.Z. and X.C. wrote and revised the paper with input from all co-authors.
Corresponding author
Ethics declarations
Competing Interests
The authors declare no competing interests.
Ethics Approval
Not applicable.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
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 licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence 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 licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Zhu, T., Chen, H., Liu, K. et al. A Row Displacement Correction Algorithm for High-speed and Accurate Terahertz Raster Scanning Imaging. J Infrared Milli Terahz Waves 44, 1038–1051 (2023). https://doi.org/10.1007/s10762-023-00955-w
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10762-023-00955-w