# How to perform a Stockwell Transform on a 2D matrix

I was looking at performing a Stockwell transform on a matrix (or an image as it has two directions - the matrix I am interested in has a spatial dimension and a time dimension, but this should make no difference) instead of an array. Whilst there are a couple of codes that perform a Stockwell transform on an array (see infomation about Stockwell Transform for links to 2 of them and http://www.mathworks.com/matlabcentral/fileexchange/45848-stockwell-transform--s-transform- for one without for loops), I could not find one for a matrix/image.

According to Mansinha et al. (1997), for a matrix $h(x,y)$ the S-transform can be defined as

$S(x,y,k_x,k_y) = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} H(\alpha + k_x, \beta + k_y) e^{-\frac{2\pi ^2 \alpha^2}{k_x^2}} e^{-\frac{2\pi ^2 \beta^2}{k_y^2}} e^{i2\pi (\alpha x + \beta y)} \mathrm{d}\alpha \mathrm{d}\beta$

for $k_x \neq 0$ and $k_y \neq 0$; where $H(k_x,k_y)$ is the 2D Fourier transform of the matrix $h(x,y)$. $x$ and $y$ are spatial variables and $k_x$ and $k_y$ are the corresponding wavenumbers.

The discrete form of the above according to the same paper is given by

$S(pT_x, qT_y, \frac{n}{NT_x}, \frac{m}{MT_y}) = \sum\limits_{n'=0}^{N-1}\sum\limits_{m'=0}^{M-1} H(\frac{n'+n}{NT_x},\frac{m'+m}{MT_y}) e^{-\frac{2\pi^2 n'^2}{n^2}} e^{-\frac{2\pi^2 m'^2}{m^2}} e^{\frac{i2\pi n'p}{N}} e^{\frac{i2\pi m'q}{M}}$

for $n \neq 0$, $m \neq 0$; where $H$ is the 2D Fourier transform of the matrix $h(pT_x,qT_y)$ and $p=0...,N-1$, $q=0...,M-1$ and $T_x,T_y$ are the sampling intervals in the respective directions.

Therefore (if I understand it correctly) the above process is a inverse Fourier transform to a multiplication in the frequency domain.

Unfortunately, I was unable to code up because the 2D Fourier transform of $h(pT_x,qT_y)$ has the same dimensions as $h$ and thusthere is a mismatch with $H(\frac{n'+n}{NT_x},\frac{m'+m}{MT_y})$.

Any help in coding the above in MATLAB is greatly appreciated. This (http://www.mathworks.com/matlabcentral/fileexchange/45848-stockwell-transform--s-transform-) is a very efficient 1D transform which has helped me understand how it works. The link for the paper is http://www.sciencedirect.com/science/article/pii/S0031920197000472 (if you have access to it)

• If you have the Matlab code for the 2D Stockwell transform you mentionned accessible, I am interested (the link is not working anymore). Thanks!
– user16307
Commented Jun 19, 2015 at 16:59
• I'm sorry, I don't seem to have it. I remember trying it though and constantly encountering memory issues and that is why I gave up on it. I ended up using the 1D transform from Matlab file exchange. Commented Jun 22, 2015 at 10:05
• @Merfolk Try this function, you might find it useful: mathworks.com/matlabcentral/fileexchange/… Commented Jul 7, 2015 at 10:47

## 1 Answer

There is a MATLAB code available for the Stockwell transform here. It also includes a code for the one-dimensional transform but it is less efficient that the Mathworks file exchange code that is mentioned in the question. This is because one uses for loops and the other doesn't.

Using this 2D S-transform function, you can quickly run into memory issues. You can easily modify the code to specify the exact positions of x and y that you need, so that S is not 4 dimensional.