1. Introduction
The discrete Fourier transform (DFT) is a fundamental tool for data processing and analysis in many fields of science and technology [
1]. The DFT is especially used in digital signal and image processing. If a one-dimensional discrete Fourier transform is used in the processing and analysis of one-dimensional signals, such as speech and other audio signals [
2,
3], then in the case of image processing and recognition, we are dealing with a two-dimensional DFT [
4,
5,
6,
7,
8,
9].
The rapid development of signal and image processing technologies has led to advanced data processing techniques using data representation and processing in the hypercomplex domain. This led to the proposal to represent each pixel of a color image as a quaternion [
10,
11,
12,
13,
14].
The old approach to using color channels to process color images was to use separate channels for the primary colors red, green, and blue. This approach divided the color image into three separate channels. In fact, three 2D matrices were formed, as a result of the presence of three channels for color images, and the computations with each matrix were carried out independently in grayscale. With this approach, due to channel separation, the cross-correlation between channels was lost at the start of the process because the color image was not considered as a whole [
14,
15].
In the quaternion-based method, a color image was considered as one matrix consisting of pure quaternion numbers. Such a matrix is processed as a whole. In order to convert an RGB image into a quaternion matrix, the RGB channels were simply inserted into the vector part of the quaternion matrix. In addition, such a representation of the pixel matrix made it possible to significantly reduce the computational complexity of color image processing methods compared to three-channel processing.
A natural development of research within the framework of the quaternion-valued representation of pixels in color images was the definition of a two-dimensional quaternion discrete Fourier transform (2-D QDFT) and the development of fast algorithms for 2-D QDFT implementation [
12,
16,
17,
18,
19].
As for the one-dimensional QDFT, this issue has not been studied in detail, since many computer scientists simply did not see the use of such a transform. That is why there are relatively few research studies on this topic [
16,
19,
20,
21,
22,
23,
24]. In this article, we would like to fill this gap and give a detailed definition of 1-D QDFT, as well as propose a fast method for its implementation.
2. Quaternions
Quaternions were introduced by Hamilton in 1843 [
25]. They fulfill the usual rules of algebra, but their multiplication is not commutative. Quaternions have four components, one real and three imaginary. In usual notation, which comes from complex numbers, the quaternion
q is written in the form
where
a,
b,
c, and
d are real numbers, and
i,
j,
k are imaginary units that obey the following rules of multiplication:
Quaternions are also called hypercomplex numbers (together with coquaternions, biquaternions, tessarines, octonions, sedenions, etc.). A quaternion has a real part—
a in (
1)—and an imaginary part, which has three components and is usually denoted by
. The imaginary part
of a quaternion may be associated with a 3-space vector
, and it is often called the vector part of the quaternion. For this reason, the real part is often called the scalar part of the quaternion
q, and denoted by
. The whole quaternion may be represented as
, i.e., the sum of its scalar and vector parts. A quaternion in which the real (or scalar) part is equal to zero is called a pure quaternion.
The conjugate of a quaternion
q is designed by
and obtained, as in complex numbers, by negating the imaginary part, so
The modulus of a quaternion
q follows the definition for complex numbers, so
A quaternion with a unit modulus is called a unit quaternion. The inverse of a quaternion
q, denoted by
, such that
is given by
Euler’s formula for the complex exponential is also true for quaternions, so
where
is a unit pure quaternion and
is a real number–angle. Any quaternion
q may be represented in the polar form as
where
is called the eigenaxis, and
is called the eigenangle of the quaternion
q.
A quaternion
q may be also represented as a generalized complex number [
26]
where its real and imaginary parts are ordinary complex numbers
The imaginary units
i and
j should be different and orthogonal (where the orthogonality of pure quaternions is understood as for vectors in
vector space). Definition (
9) of a quaternion is known as the Cayley–Dickson form. Using this form, the quaternion
q may be written as
where it can be seen by multiplying out, using the rules (
3), that the result is the same as in the definition (
1). The two parts
and
are called the simplex and perplex parts of the quaternion
q, respectively, and the decomposition of the quaternion into these parts is known as symplectic decomposition [
26]. Such a decomposition of a quaternion can be used to calculate the QDFT, as will be shown in
Section 4.
The product of two quaternions
and
can be represented by the products of their scalar and vector parts
where “·” denotes the scalar product and “×” denotes the cross product of vectors. Generally, quaternion multiplication is neither commutative nor anti-commutative because the dot product is commutative and the cross product is anti-commutative. When
q and
are pure quaternions, then
, so
. If, moreover,
, we say that pure quaternions
q and
are perpendicular (
). Then
and
. In general, two quaternions whose vector parts are parallel, in the usual vector sense, are called parallel quaternions. Likewise, if their vector parts are perpendicular, they are called perpendicular quaternions [
11].
3. Two Types of Quaternion Discrete Fourier Transform
Although the quaternion Fourier transform is mainly used for two-dimensional data, i.e., images, it has been specified for one-dimensional data as well [
19,
21]. We will only deal with the discrete version of the one-dimensional quaternion Fourier transform.
Let
,
,
, and
be the components of a discrete quaternion signal
with the number of samples
N. Then
for
, where
,
,
, and
are real numbers.
Let
be a unit pure quaternion and
,
,
be its coefficients associated with the imaginary units
i,
j,
k, respectively:
where
The choice of
is arbitrary, but it matters. In applications, the case
is often used; thus, taking into account (
15), we obtain
.
Since quaternion multiplication is not commutative, two different 1-D quaternion discrete Fourier transforms were defined, which are referred to as right-side and left-side QDFTs.
The right-side 1-D quaternion discrete Fourier transform is defined as follows:
for
, where the quaternion exponents are to the right of
, and
is any unit pure quaternion.
It should be noted that for any choice of , , so this transform can be regarded as a generalization of the standard complex discrete Fourier transform in which the imaginary unit i has been generalized to a vector imaginary unit . This means that if and the input signal is complex-valued, that is all samples have values , then this transform is reduced to the usual complex-valued discrete Fourier transform.
According to (
7), the quaternion exponent can be written in the form
or, if we introduce the denotations
and take into account (
14), the quaternion exponent can by written as
Putting expressions (
13) and (
19) into (
16), the right-side quaternion discrete Fourier transform can be written in the form
After multiplying the expressions in square brackets, according to the rules (
2) and (
3) of multiplication of imaginary units, we can write the result as
where
,
,
, and
are real numbers. It is easy to check that they take the following forms:
The left-side 1-D quaternion discrete Fourier transform is defined as
for
, where the quaternion exponents are on the left side in multiplications. Taking into account (
13) and (
19), the right-side quaternion discrete Fourier transform (
26) can be written in the form
After multiplying the expressions in square brackets, according to the rules (
2) and (
3) of multiplication of imaginary units, we can write the result as
where
,
,
, and
are real numbers. It is easy to check that they take the following forms:
Unlike the complex-valued DFT, the left-side and right-side QDFTs are slightly different transforms. From (
22) and (
29), we can see that the real parts of both transforms are the same but the imaginary parts differ from each other in the signs of some components of the sums (compare (
23) with (
30), (
24) with (
31), and (
25) with (
32)). Obviously, this follows from the non-commutative nature of quaternions multiplication. However, if we choose
(i.e.,
and
) and the complex-valued input signal
(i.e.,
), then both of these transforms will be reduced to the usual complex-valued DFT.
Moreover, by analyzing (
22)–(
25) and (
29)–(
32), it is easy to see that all components of both QDFTs are linear combinations of the real and imaginary parts of four ordinary Fourier transforms for the real signals
,
,
, and
—components of the quaternion signal
. This will be further explained in
Section 5. Therefore, for determining the right-side or left-side QDFT, the calculation of four discrete Fourier transforms for the four real-valued components of the quaternion signal is needed.
Figure 1 shows graphical representations of four components of the right-side and the left-side QDFTs for the quaternion signal
with
samples, where
4. Calculation of QDFTs by Symplectic Decomposition
The use of the symplectic decomposition method allows both QDFTs to be computed by performing only two complex-valued discrete Fourier transforms instead of four. This approach was used in [
26] to calculate the two-dimensional left-side QDFT. In this work, we will show how to also use the symplectic decomposition method to reduce the computational complexity of calculating one-dimensional right-side and left-side QDFTs.
If we take arbitrary two unit pure quaternions
and
, such that
(pure quaternions are perpendicular when their dot product is equal to zero), and the third unit pure quaternion
, we can represent the quaternion signal
as
The change of the imaginary units from
i,
j,
k to
,
,
corresponds to the change of the basis in
vector space from
,
,
to another basis of three mutually orthogonal unit vectors; so for each sample, we obtain the new coordinates by multiplying the matrix inverse to the change-of-basis matrix by the old coordinates vector
The change-of-basis matrix
depends on the choice of new imaginary units. For example, if we take the imaginary units
,
,
, as in [
26]
then the change-of-basis matrix has the form
In Cayley–Dickson form (
38) has the form
This is a symplectic decomposition of each sample
into a simplex part
and a perplex part
both isomorphic to the standard complex number. The result is a pair of complex signals. They may be stored using the same space as the quaternion signal
. The symplectic decomposition splits a quaternion into two perpendicular planes. These planes intersect only at the origin (in 4-space). Each of these planes may be regarded as an Argand plane. The first is the Argand plane of the simplex part; its real axis is identical to the scalar axis of quaternion space and its imaginary axis is
. The second is the Argand plane of the perplex part; this plane is perpendicular to both axes of the Argand plane of the simplex part. The real axis of this plane is identical to
and its imaginary axis is
.
Let the axis of transform kernel of the right-side QDFT in (
16) be chosen as
, i.e.,
. Then (
16), can be rewritten as
The sum in (
47) can be written as the sum of two terms. The first term, which is the simplex part of
, has the form
This is isomorphic to the discrete Fourier transform for a complex input. The only difference is that the imaginary unit is called
instead of
i. Hence, calculation of
comes down to the computation of a complex DFT for the simplex part
of
. This can be performed using the FFT algorithm. The second term
where, during the transformation, we used the equality
, which is true for pure, perpendicular quaternions. It is easy to see that
is the perplex part of
. So, the calculation of
comes down to the computation of a complex inverse discrete Fourier transform (IDFT) for the perplex part
of
, but without multiplying the result by
. This can be performed using the IFFT algorithm.
After calculating the simplex and perplex parts of the output signal
, we want to write
using the imaginary units
i,
j, and
k instead of
,
, and
, i.e.,
In the associated
vector space, this corresponds to returning to the old base
,
,
, so it can be done by the operation inverse to (
39), i.e.,
Summarizing the above considerations, in order to calculate the right-side QDFT using symplectic decomposition, the input signal should be represented by new imaginary units such that the first becomes the axis of the transform kernel. This corresponds to a change of the basis in the associated vector space (for each sample of the quaternion-valued input signal). Then, a single complex DFT and a single complex IDFT should be calculated for the simplex and perplex parts of the quaternion-valued input signal, respectively. Finally, we have to return to the standard imaginary units i, j, and k, which corresponds to a return to the old basis in the associated vector space.
A similar, and even simpler, consideration may be given to the left-side QDFT. Assuming that the axis of the transform kernel of the left-side QDFT in (
26) is chosen as
, and using the symplectic decomposition of the quaternion input signal
, (
26), can be rewritten as
The sum in (
52) can be written as the sum of two terms. The first term, which is the simplex part of
has the form
Calculation of comes down to the computation of complex-valued DFTs for the simplex part of . This can be performed using the FFT algorithm. In addition, .
The second term has the form
It is easy to see that is the perplex part of . Calculation of also comes down to the computation of complex-valued DFTs for the perplex part of . This can be performed using the FFT algorithm. Summarizing the above considerations, it can be argued that in order to calculate the left-side QDFT using a symplectic decomposition, the input signal should be represented by new imaginary units, the first of which will be equal to the axis of the transform kernel. This step is the same as in calculating the right-side QDFT. Then two complex DFTs should be calculated—for the simplex and perplex parts of the quaternion-valued input signal. In the end, as with the right-side QDFT calculation, the return to the standard imaginary units i, j, and k is needed.
5. The Simplest Method of QDFT Calculation
We will use the matrix notation to describe the QDFTs. Let
be a vector of samples of the quaternion input signal, where
for
, so it can be written in the form
Similarly
and
are the quaternion output vectors of the right-side and left-side QDFTs, respectively, where
and
, so they can be written as
Let square matrices of cosine and sine coefficients be denoted by
and
, respectively, so
where the entries
and
of the matrices
and
, respectively, are defined in (
18). Note that the matrix
, where
is the DFT matrix.
In matrix notation, we can write (
22)–(
25), which describe the right-side QDFT, in the forms
Figure 2 shows a data flow diagram for calculating the right-side QDFT. The straight lines in the figures indicate the data transmission buses, so that each bus simultaneously transmits all elements of a real-valued vector. By default, we assume that data flows from left to right. Therefore, we do not use arrows, so as not to clutter up the drawings. The points at which the lines converge denote the element-wise summation of the input vectors. The rectangles show the operation of multiplying a vector by a matrix, the designation of which is inscribed inside the rectangle, and the circles show the operation of multiplying all elements of the input vector by a constant inscribed in the circle.
Now, we will develop a similar algorithm for the left-side QDFT. In matrix notation, the equivalents of (
29)–(
32), which describe the left-side QDFT, are as follows:
Figure 3 shows the data flow diagram for calculation of the left-side QDFT.
To calculate both QDFTs—the right-side and the left-side—you need to multiply the matrices
and
by each of the four components of the quaternion-valued input vector
. Since the components of the input vectors are real values, these operations can be performed by computing the DFT for each component of the input vector and dividing the real and imaginary parts of the result, i.e.,
6. 1-D QDFT Proposal
By computing both QDFTs, the main computational cost is related to multiplying the four components of the quaternion-valued input vector by the matrices
and
. This is equivalent to calculating the DFTs for each of the four components and separating the real and imaginary parts, as was described in
Section 5. It seems that in order to calculate any QDFT, it is necessary to compute four DFTs. However, it is known that the same operation can be done by performing only two Fourier transforms for two complex-valued input vectors, since each of the two DFTs for real-valued input vectors can be computed with one DFT for the complex-valued input vector. To explain this, let us introduce two real-valued vectors
and
formed from the complex-valued vector
. Let
be the DFT output for input
,
—the DFT output for input
, and
—the DFT output for complex-valued input
. Although the DFTs outputs for the real-valued inputs are complex-valued, their real and imaginary parts have special symmetries, namely
for
. It is said that for a real-valued input signal, the real part of its DFT is symmetric and the imaginary part is antisymmetric.
For each coefficient
of DFT output for complex-valued signal
, we can write
However, the DFT is a linear transform, so it can be also written as
Taking into account properties (
72) and (
73), (
78) can be written in the form
and (
79) as
By adding and subtracting the sides of (
80) and (
76), we obtain, respectively
and
Similarly, by adding and subtracting the sides of (
77) and (
81) we obtain, respectively
and
We introduce the denotation
, which means the signal reversed in time. So, for
, we have
where the matrix
, which is responsible for reversing signal in time, has the form
Then, (
82) written in vector notation has the form
Analogously, (
85) written in vector notation has the form
Similarly, (
84) written in vector notation has the form
In the end, (
83) written in vector notation has the form
Going back to QDFT transforms, the quaternion-valud input vector
has four real-valued component
,
,
,
. Let us denote their complex Fourier transforms by
,
,
,
. They are all complex-valued, and
From the components of the quaternion input vector
, we can create two complex inputs vectors
and
. Then, we calculate the complex discrete Fourier transforms for these, i.e.,
and
, using the fast algorithm, and separate their real and imaginary parts. Then, according to (
88)–(
91), for the first complex vector
, we obtain
and, similarly, for the second complex-valued vector
, we obtain
The data flow diagrams for our method of QDFT calculation are shown in
Figure 4 for the right-side QDFT and in
Figure 5 for the left-side QDFT.
It should be noted that the proposed method, unlike the method using symplectic decomposition, does not require changing the basis in the pure quaternions subspace and, consequently, calculating the new basis vectors and change-of-basis matrix.
7. Computational Complexity Discussion
We will now compare the computational complexity of the different ways to calculate a QDFT, taking into account the number of multiplications and additions of real numbers needed to compute this transform (these numbers are the same for the right-side and left-side transforms). Since, in each case, the ordinary FFT algorithm is used, we denote by
the number of real multiplications necessary to compute the DFT for a complex/real signal with
N samples. Similarly, let
denote the number of additions of real numbers needed to determine the FFT of such a signal. In this comparison, we will omit the method of calculating QDFTs resulting directly from the definitions (
16) or (
26) because its computational complexity is much higher.
Let us start with the most basic calculation method resulting from (
60)–(
63) or (
64)–(
67), respectively. Since, according to (
68), calculating the products of
and
is equivalent to finding the FFT for the
part of the quaternion vector
, and similarly, for the other
,
,
parts of the quaternion input vector, we need to calculate four FFTs, which requires
multiplications and
additions of real numbers. Then, each of the products
,
,
,
has to be multiplied by three real coefficients
,
, and
, which gives
multiplications of real numbers. The last step is to add the four components of the sum. Since each sum consists of four vectors, it takes
additions to calculate the sum. There are four such sums, so we have
additions of real numbers. Summarizing the above considerations, in order to calculate the DQFT according to this method,
multiplications and
additions of real numbers should be performed, where
and
The next method in the comparison is the method based on symplectic decomposition. First, all samples of the quaternion signal should be expressed using the new imaginary units
,
,
, which corresponds to the multiplication of the matrix inverse to the change-of-basis matrix by the vector containing the imaginary components of the sample according to (
39). Such an operation for one sample requires nine multiplications and six additions of real numbers. For
N samples of the quaternion signal, we get
multiplications and
additions of real numbers. Then, a single ordinary complex FFT and a single IFFT (without dividing the result by
N), or two complex FFTs, should be calculated, according to (
48), (
49) or (
53), (
54), which require
multiplications and
additions of real numbers. The resulting quaternion output signal is expressed using the new imaginary units
,
,
, and we want it to be represented by standard imaginary units
i,
j,
k. This corresponds to the multiplication of the change-of-basis matrix by the vector containing the imaginary components of the resulting vector according to (
51). To do this for
N samples of the quaternion output signal,
multiplications and
additions of real numbers is needed. To recap the method based on symplectic decomposition, calculating the QDFT according to this method requires
multiplications and
additions of real numbers, where
and
Finally, we evaluate the numbers of arithmetic operations needed for our method of QDFT calculation. Our method is also based on (
60)–(
63) for the right-side QDFT or (
64)–(
67) for the left-side QDFT, but taking into account relations (
92)–(
95), the products
,
,
,
,
,
and
,
are calculated from (
96)–(
103). This method requires the calculation of two FFTs, hence
multiplications and
additions of real numbers is needed. Then, the real/imaginary parts of the FFT results are added/subtracted (some after reordering their elements, which corresponds to multiplying the matrix
by these elements, as was shown in
Figure 3 and
Figure 4—this does not require any arithmetic operations) and divided by 2. This may seem to require
additions and
multiplications of real numbers. In fact,
,
,
,
are Fourier transforms of real-valued vectors, so they have symmetry, as in (
72)–(
73), and only half of their entries have to be calculated. Thus, the number of real additions reduces to
. Multiplying by the factor
in (
96)–(
103) does not require any multiplication operation. It is just a simple bit shift to the right. Then, as in the first method, each of the products
,
,
,
has to be multiplied by three real coefficients
,
, and
, which gives
multiplications of real numbers. The last step is to add the four components of each sum in (
60)–(
63) for the right-side QDFT or (
64)–(
67) for the left-side QDFT, as in the first method. This requires
additions of real numbers. Summarizing the above considerations, in order to calculate any of the QDFT according to our method
multiplications and
additions of real numbers have to be performed, where
and
Table 1 presents estimates for the numbers of multiplications and additions of real numbers necessary to determine any of the QDFTs in the three presented methods of QDFT calculation. It is easy to see that although our method has more additions than method 2, it requires fewer multiplications. Furthermore, the total number of arithmetic operations in our method is the smallest among the three compared methods for calculating the QDFT.
In terms of the number of arithmetic operations, our method is very similar to the symplectic decomposition method. To compare the 1-D QDFT computation times of these two methods, we implemented them in Matlab R2022b on a computer with an Intel(R) Core(TM) i5-7400 CPU and 8 GB RAM. For quaternion signals of different lengths
N, which are powers of 2, and 100,000 repetitions of transform calculation, we obtained the times, in seconds, presented in
Table 2.
The dependencies in
Table 2 are not an exact reflection of the dependencies in
Table 1, because the calculation time also includes the time needed to transfer data from and to memory, which
Table 1 does not take into account. Despite this, it can be observed from
Table 2 that the times needed to calculate the 1-D QDFT with the proposed method are shorter than for the method using symplectic decomposition. However, it should be remembered that the time of computation depends very much on the way the code was written and on the implementation platform.