A New Pseudo-Spectral Method Using the Discrete Cosine Transform

The pseudo-spectral (PS) method on the basis of the Fourier transform is a numerical method for estimating derivatives. Generally, the discrete Fourier transform (DFT) is used when implementing the PS method. However, when the values on both sides of the sequences differ significantly, oscillatory approximations around both sides appear due to the periodicity resulting from the DFT. To address this problem, we propose a new PS method based on symmetric extension. We mathematically derive the proposed method using the discrete cosine transform (DCT) in the forward transform from the relation between DFT and DCT. DCT allows a sequence to function as a symmetrically extended sequence and estimates derivatives in the transformed domain. The superior performance of the proposed method is demonstrated through image interpolation. Potential applications of the proposed method are numerical simulations using the Fourier based PS method in many fields such as fluid dynamics, meteorology, and geophysics.


Introduction
The discrete cosine transform (DCT) and discrete sine transform (DST) have been extensively studied, and they have played a crucial role in science and engineering for decades. For example, DCT is used for standard image and video compression such as JPEG and MPEG. DST is adopted for high efficiency video coding (HEVC). DCT and DST are closely related to the discrete Fourier transform (DFT) [1][2][3]. All the relevant transforms assume the periodicity of sequences. DFT assumes circular periodicity, where the left side of a sequence is placed next to the right side, while DCT and DST assume symmetric circular periodicity, where after a sequence is extended symmetrically, circular periodicity ensues. There are four types of DCT and DST (Types 1, 2, 3, and 4) corresponding to different types of symmetry. As is well known, DCT Type 2 (DCT-2) is employed for JPEG and MPEG, and DCT Type 3 is the inverse transform of DCT-2. Some applications use several types of DCT and DST, while others just use one type [4,5].
Pseudo-spectral (PS) methods originated from [6,7] and have been studied for solutions of partial differential equations [8]. The numerical solution is obtained via a finite set of expansion functions. Generally, for periodic problems, the Fourier series is used as expansion functions, while for non-periodic problems, orthogonal polynomials (e.g., Jacobi polynomials) are used. Legendre and Chebyshev polynomials are special cases of Jacobi polynomials, in which derivatives are obtained at unequally spaced points, such as Legendre-Gauss-Lobatto points and Chebyshev-Gauss-Lobatto points (also referred to as Chebyshev points) [9][10][11]. Different expansion functions for PS methods are chosen depending on the problems of applications. The PS method using Fourier series as expansion functions is employed for estimating derivatives at equally spaced points, which is common in fluid dynamics [12,13], meteorology, and geophysics, e.g., a direct numerical simulation for a turbulent flow [14], wave prediction [15], multibody modeling of wave energy converters [16], and seismogram simulation [17]. Generally, DFT is used for the PS method, and in periodic functions, approximations by the PS method using DFT (PS-DFT) are much more accurate than those by finite difference methods [18]. Moreover, the use of the fast Fourier transform (FFT) accelerates the process. However, conversely, use of DFT/FFT is problematic due to circular periodicity. If the values on both sides of sequences differ significantly, oscillatory approximations are observed around both sides, which is already well known as the Gibbs phenomenon.
Image interpolation by Hermite polynomials is a good example to understand the accuracy of derivatives. It requires pixel intensities and their derivatives that affect the accuracy of interpolation, where there is room for the choice of methods for calculating derivatives [19,20]. The combination with PS-DFT has been shown to outperform conventional interpolation methods such as bicubic and Lanczos in terms of both accuracy and speed [21]. However, it has not hitherto touched on the adverse effects by PS-DFT.
In the present paper, we study PS methods based on symmetric extension to address the problem of the Gibbs phenomenon induced by PS-DFT in image interpolation. We are motivated by the seminal work [21] combining Hermite polynomials with PS-DFT for image interpolation. We focus on the symmetric extension of a sequence in the spatial domain, which attenuates the difference in values at both sides for suppressing the Gibbs phenomenon. The DCT can enable sequences to function as symmetrical extended sequences. We mathematically derive two types of PS methods using DCT from the relation between DFT and DCT. We evaluate the proposed methods through combining with Hermite polynomials for image interpolation. The results testify to the efficacy of the PS method based on symmetric extension. This paper thus extends earlier results available in the literature [22].
The remainder of the paper is organized as follows. In Section 2, we provide preliminaries in the form of relevant definitions. We present and derive two PS methods based on symmetric extension in Section 3. Our evaluations of image interpolation are detailed in Section 4. Finally, conclusions are put forward in Section 5.
Notations: Let Z and R be the sets of integers and real numbers, respectively. Sequences and signals in the time domain are represented as lower case letters, and their coefficients in the transformed domain are denoted as upper case letters. The operator T −1 indicates an inverse transform that assigns a sequence in the transformed domain to a corresponding sequence in the time domain. The derivatives of x(n) with respect to n are represented as x (n). We use an asterisk to denote the complex conjugate, i.e., X * (k) is the complex conjugate of X(k).

Preliminaries
First, we provide the definitions of the relevant transforms and their relations. Then, we briefly describe the PS method using DFT.

Definitions of DFT, DCT-1, and DCT-2
Let x(n), n ∈ Z be a sequence of length N. The forward and inverse discrete Fourier transforms are defined as: and: respectively, where W N = exp(−j2π/N) and j = √ −1.

Relation between DFT and DCT
The DCT coefficients of an original sequence correspond to the DFT coefficients of the sequence to which the original sequence is extended symmetrically. Let x(n) be the original sequence of length N. Figure 1 shows an original sequence and the sequence extended symmetrically depending on the type of DCT. The difference between DCT-1 and DCT-2 is where the axis of symmetry lies. Specifically, the axis of symmetry of DCT-1 lies directly between the samples of a sequence, while that of DCT-2 lies at a half-sample between the samples. The symmetrically extended sequence,x 1 (n), for DCT-1 from x(n), as shown in Figure 1a, is given as:x The relation between DFT coefficients and DCT-1 coefficients is expressed for k = 0, 1, · · · , N − 1 as: The symmetrically extended sequence,x 2 (n), for DCT-2, as shown in Figure 1b, is given from The relation between DFT coefficients and DCT-2 coefficients is expressed for k = 0, 1, . . . , N − 1 as: Thus, DCTs can enable sequences to behave as symmetrically extended sequences without the manual extension of symmetry.

PS Method Using the DFT
The PS method using DFT (PS-DFT) is a numerical method for estimating the derivatives of sequences. The underlying theory behind PS-DFT is the time derivative properties of the Fourier transform.
We assume x(n) are samples of a differentiable continuous-time signal, x a (t), t ∈ R at time nT s , i.e., x(n) = x a (nT s ) where T s represents a sampling period that satisfies the Nyquist sampling theorem. When the time axis is normalized by a factor of T s , the samples of the derivative of x a (t) with respect to t are written as: where 1 = ∂n/∂t from t = nT s and T s = 1. From (2), the derivative, x (n), of x(n) with respect to n is expressed as: Observe that the DFT coefficient, X (k), of x (n) is given in (12) as: Note that the coefficients X (k) require complex conjugate symmetry so that x (n) are real numbers. Therefore, we can obtain the derivatives by the inverse DFT from the coefficients multiplying the DFT coefficients of the original sequence by the factors with respect to k. The steps involved in implementing PS-DFT are summarized as follows.
1. N-point DFT is applied to the sequence of length N to obtain X(k) according to (1). 2. X(k) is multiplied by j2πk/N to obtain X (k) according to (13). 3. The inverse DFT is applied to X (k) according to (2).

PS Method Based on Symmetric Extension
Here, we derive two PS methods depending on the type of symmetry extension, considering the PS-DFT of symmetrically extended sequences. We assume that the symmetrically extended sequence is the samples that satisfy the Nyquist sampling theorem of a differentiable continuous-time signal where the time axis is normalized.
From (2),x 1 (n) is given as: where M = N − 1. With the symmetry properties of DFT, it is developed as: From (8), replacingX 1 (k) by X C 1 (k), we have: Therefore, we define the PS method using DCT-1 in the forward transform as PS-DCT1 together with the inverse transform, T −1 PS−DCT1 , given by: where: Note that T −1 PS−DCT1 corresponds to a sign inverted DST Type 1 (DST-1).

Derivation of PS-DCT2
In a similar manner, PS-DCT2 is derived. From the definition in (2), the derivative,x 2 (n), of the symmetrically extended sequence,x 2 (n), for DCT-2 in (9) is expressed with the DFT coefficients,X 2 (n), ofx 2 (n) as:x which is developed with the symmetry properties of DFT as: From (10), we have: Therefore, we define the PS method using DCT-2 in the forward transform as PS-DCT2 together with the inverse transform, T −1 PS−DCT2 , given by: where: Note that T −1 PS−DCT2 corresponds to a sign inverted DST Type 2 (DST-2).

Extension to Second and Higher Derivatives
The second and higher derivatives are obtained by differentiating the first derivative repeatedly. For example, from (28), the second derivatives based on the symmetric extension for DCT-2 are given as: where:

Application to Image Interpolation
We focus on whole-image interpolation for applications such as image registration and motion correction, rather than interpolation for a small portion of an image. We evaluate the proposed methods combined with Hermite polynomials for image interpolation in terms of accuracy and speed. Interpolation by Hermite polynomials is referred to as Hermite interpolation.

Hermite Interpolation
Let y i and y i be the nodal value and the nodal derivative at t i ∈ Z, (i = 0, 1, . . . , I), respectively. The Hermite polynomial f (t), t ∈ R, of degree 2I + 1, is given [19] by: where: when I = 1 (degree=3), f (t) in (32) requires two nodal values and two nodal derivatives nearest the location t for estimating the value at t, which is referred to as cubic Hermite interpolation (CHI).

Methods and Environment
We performed geometrical transformation by interpolation to evaluate the proposed methods. The derivatives required for CHI are obtained by PS-DCT1, PS-DCT2, PS-DFT, first-order forward difference (1-FD), second-order central finite difference (2-CLFD), fourth-order central finite difference (4-CLFD), and fourth-order compact finite difference (4-CTFD) [24]. In addition to these results, we provide results according to the cubic natural spline (CNS) to facilitate comparison with other interpolation methods.
We used a total of 12 grayscale images of size 256 × 256 in standard image data base (SIDBA) [25]. The resulting images are evaluated by the signal-to-noise ratio (SNR) given as: where g(n) and r(n) represent the ground truth sample and the final resulting sample, respectively. All algorithms were implemented in MATLAB and run on a macOS system with a 2.3 GHz Intel Core i5 and 8 GB memory.

Image Translation
The image was shifted by 0.05 pixels in the horizontal direction in each step. The output of the previous step was used for the input. After 20 steps, the image was shifted by one pixel. Figure 2 shows a portion on the leftmost side of the final output after successive image translation of the image "Barbara". The results from PS-DFT suffered severe artifacts compared to those from the other methods. Figure 3 shows the absolute errors of the final output, where black corresponds to zero error, values greater than 20 are white, and values between zero and 20 are intermediate shades of gray. It can be clearly discerned that there is less error associated with PS-DCT1 and PS-DCT2 compared to the other methods. The errors resulting from PS-DCT1, PS-DCT2, and PS-DFT are concentrated on the both sides of the image. Table 1 summarizes the SNRs between the final output and the image shifted by one pixel (ground truth). The highest SNR for each image is in bold. It can be observed that the SNRs of the results from PS-DCT1 and PS-DCT2 were greater than the SNRs of PS-DFT. Accordingly, it was discerned that symmetric extension in the PS method was effective. On average, CNS yielded the highest SNR. However, in several images, PS-DCT2 was better than CNS.    Next, we changed the evaluation area. Figure 4 shows the SNRs for each image when the evaluated area was narrowed by m columns on each side of the image. It can be seen that the SNRs of PS-DCT1, PS-DCT2, and PS-DFT increased significantly when m = 1 and then continued to increase slowly for m > 1, while the SNRs of the other methods slightly increased when m = 1, then plateaued for m > 1. The results imply that there are large adverse effects by PS-DCT1 and PS-DCT2 within one column on both sides of the results. That is, we can obtain superior results by excluding only one pixel at each side. Table 2 summarizes the SNRs of the final output when m = 1. Compared to Table 1, the SNRs increased across all methods. Notably, the SNRs of PS-DCT1, PS-DCT2, and PS-DFT increased significantly. PS-DCT2 performed best, except with respect to the image "LAX". Table 2. SNRs (dB) of the final output after successive image translation (m = 1).

Image Rotation
The image was rotated by 24 degrees in each step. The output of the previous step was used for the input. After 15 steps, the image was fully rotated. We made each output image the same size as the input, cropping and zero-padding the rotated image to fit. As a result, the part with pixel intensities other than zero of the final output became circular. Figure 5 shows a portion near the circumference of the final output after successive rotation of the image "Lenna". The results from PS-DCT1, PS-DCT2, and PS-DFT were clearer than those from the other methods, but there were minor artifacts in the homogeneous area of the results. Figure 6 shows the absolute errors of the final output. Again, black denotes zero error; values greater than 20 are white; and values between zero and 20 are intermediate shades of gray. There was less error associated with PS-DCT1, PS-DCT2, and PS-DFT compared to the other methods. Table 3 summarizes the SNRs of the final output when the evaluation area was narrowed by one pixel of the inner the circle, where the highest SNR for each image is in bold. It can be seen that PS-DCT2 yielded the best SNRs of all the methods. However, compared to Table 2, there were no significant differences among PS-DCT1, PS-DCT2, and PS-DFT. One reason for this was that the rotated image for the next input in successive rotation was zero-padded so that the image should be square, which attenuated the Gibbs phenomenon. Another reason was that errors were not concentrated in one place, due to rotation.  Table 4 summarizes the arithmetic operations of PS-DCT1, PS-DCT2, and PS-DFT for a sequence of length N. The operations of PS-DCT1 and PS-DCT2 were based on Wang's algorithm [26]. The operations of PS-DFT were based on the FFT [27], which were converted to operations in real numbers in which one multiplication of complex numbers was converted to three multiplications and three additions according to Nakayama's method [28] and one addition of complex numbers was converted to two additions. Figure 7 shows the comparison of the arithmetic operations based on Table 4.
We measured the execution time for image interpolation. All algorithms were executed on a macOS system with a 2.3GHz Intel Core i5 and 8GB memory. A total of 12 images of size 256 × 256 were used. Table 5 summarizes the mean execution time for successive image translation and successive image rotation. The proposed methods ran slightly more slowly than PS-DFT, but the execution time was acceptable. Together with the above qualities, the results testified to the efficacy of the proposed methods.  Table 4. Arithmetic operations for PS-DCT1, PS-DCT2, and PS-DFT in real numbers.

Conclusions
We proposed PS methods based on symmetric extension to attenuate the oscillatory approximation that occurs with DFT. Using DCT, derivatives can be estimated in the transformed domain with sequences behaving as symmetrically extended sequences without a manual extension of symmetry. We derived two PS methods, PS-DCT1 and PS-DCT2, from the relation between DFT and DCT. Through image interpolation by Hermite polynomials, we showed that the proposed methods outperform PS-DFT. DCT can be calculated in real numbers rather than in the complex numbers that are required for DFT. Moreover, DCT has fast algorithms, as well as DFT. Therefore, the proposed methods are advantageous in terms of accuracy and validity compared to PS-DFT.
The potential applications of the proposed method are numerical simulations/modeling using the Fourier based PS method to solve several equations in many fields such as fluid dynamics, meteorology, and geophysics. Furthermore, the proposed method may be applicable to numerical methods where the Fourier based PS method has not been used before, such as those relevant to sensor networks and radar imaging [29][30][31]. The future work of this paper will study potential applications with numerical analysis.