Fourier Transform and Matrix-vector Multiplication
Fourier Transform Math Background and Dot-product Engine Matrix-vector Multiplication Analysis About Software Flow Based On MATLAB
The code is not accessible via the internet due to copyright and academic secrecy restrictions.
Fourier Transform
K. R. Rao and P. Yip, Discrete cosine transform: algorithms, advantages, applications.
We will start by recalling the definition of the Fourier transform. Given a function x(t) for , its Fourier transform is given by
,
subject to the usual existence conditions for the integral. Here, , is the radian frequency and is the frequency in Hertz. The function x(t) can be recovered by the inverse Fourier transform, i.e.,
If x(t) is defined only for , we can construct a function y(t) given by:
Then
We can now define this as the Fourier cosine transform (FCT) of x(t) given by
Noting that is an even function of , we can apply the Fourier inversion to to obtain
The convolution property: Recall that the convolution of two functions x(t) and y(t) is given by
The Fourier cosine transform of x*y is given by
where denotes the Fourier sine transform (FST) given by
has a kernel given by
Let and be the sampled angular frequency and time, where and represent the unit sample intervals for frequency and time, respectively; m and n are integers.
If we further let where N is an integer, we have
which represents a discretized Fourier cosine kernel. But, it is far simpler, both mathematically and conceptually, to regard the discrete kernel as elements in an (N + 1) by (N + 1) transform matrix. Let his matrix be denoted by [M]. Then, the mnth element of this matrix is
When [M] is applied to a column vector , we obtain the vector
such that
where
DCT-II:
where
Fourier cosine transform (FCT) of x(t) given by
DCT-II Forward:
where
DCT-II Inverse:
where
Signal flow graph for DCT-II, N=8.
Discrete Fourier Transform (DFT) converts the sampled signal or function from its original domain (order of time or position) to the frequency domain. It is regarded as the most important discrete transform and used to perform Fourier analysis in many practical applications including mathematics, digital signal processing and image processing.
Discrete cosine transform (DCT) is a Fourier-related transform similar to DFT, but using only real numbers. Comparing to DFT, DCT has two strong advantages: first, it is much easier to compute, second and more important, it has nice energy compaction.
Analysis About Software Flow Based On MATLAB
Accelerating Discrete Fourier Transforms with dot-product engine
Code and test images @github private repository
I analyze the software flow without compression from the paper.
————————————————————————————————————-
———————– Analyze DPE based on Discrete Cosine Transform ———————–
MATLAB function dctmtx generates DCT matrix – conductance:
https://www.mathworks.com/help/images/ref/dctmtx.html
MCA DCT matrix for DCT result
D: output of MATLAB function ‘dctmtx’
Map D to MCA conductance on the left for the DCT of the columns of Image: D * A (DPE1)
Map D’ to MCA conductance on the right for the DCT of the rows of Image: A * D’ (DPE2)
D = dctmtx(n) returns the n-by-n discrete cosine transform (DCT) matrix, which you can use to perform a 2-D DCT on an image. (dct = D*A *D’)
2D DCT result: dct = D*A * D’
IDCT result: IDCT = D’ * dct * D
- If you have an
n
-by-n
image,A
, then
is the DCT of the columns ofD
*AA
andD'*A
is the inverse DCT of the columns ofA
. - The two-dimensional DCT of
A
can be computed asD*A *D'
. This computation is sometimes faster than usingdct2
, especially if you are computing a large number of small DCTs, becauseD
needs to be determined only once.For example, in JPEG compression, the DCT of each 8-by-8 block is computed. To perform this computation, usedctmtx
to determineD
, and then calculate each DCT usingD*A *D'
(whereA
is each 8-by-8 block). This is faster than callingdct2
for each individual block.
Software Flow Output
Please refer to the results below. Three channels from original RGB image range is [0,1], and IDCT range is [0,1] too, however, DCT matrix has negative or ~90 value.
Channel Red Green Blue First DPE and DCT Output without Circuit Simulation
Error Analysis
- Simulate quantization error from ADC, i.e., the error caused during ,
- Then, analyze error of Y in .
- For ADC, voltage criteria discrete delta , .
Additional Information Below
Syntax D = dctmtx(n)
Description
D = dctmtx(n) returns the n-by-n discrete cosine transform (DCT) matrix, which you can use to perform a 2-D DCT on an image. (dct = D*A *D’)
Example: dctmtx
A = im2double(imread(‘rice.png’));
%return 256×256 double
A = im2double(imread(‘lena_std.tif’));
%return 512×512x3 double
but
D = dctmtx(size(A,1));
%return 512×512 no mater original image is gray or color.
Matlab Code (Wrong for RGB Image)
I can’t directly process RGB color image in this way. I need to partition it into three 512×512 matrices, process and recombine.
clear all;
A=im2double(imread(‘lena_std.tif’));
%return 512x512x3 double for color
imshow(A)
sizeA_1=size(A,1)
%return 512.
D = dctmtx(size(A,1));
%Calculate the discrete cosine transform matrix.
%return 512×512 no mater the original image is gray or color.
dct = D.*A.*D’;
%Multiply the input image A by D to get the DCT of the columns of A,
%and by D’ to get the inverse DCT of the columns of A.
%return 512x512x3 double for color.
%If you have an n-by-n image, A, then D*A is the DCT of the columns of A and D’*A is the inverse DCT of the columns of A.
imshow(dct)
Result: