Shearing your Data with a Fourier Transform
Posted on November 14, 2007
Filed Under Signal Processing |
Here’s a neat little trick that has helped me out a few times.
It often happens, when acquiring 2D data, that the resulting data set seems slanted, or sheared in some way. This can be the result of hardware error or some other artifact in your system (it happens to me all the time when acquiring 2D MRI data). How can you “unshear” such data? By simply shifting one of the function’s arguments, as shown below:
However, ideas are one thing and implementations are another. Is there an elegant way of getting this done, especially with discrete data sets? Yes, if you use Fourier transforms. Here is how it’s done.
Recall that, to multiply a function’s Fourier transform by a phase is equivalent to translating the function itself. Mathematically speaking, given a function f(x), its Fourier transform is:

Multiplying this by a phase, we obtain:

Making a change of variables,
, this becomes:

Now we can - by inspection alone - see that inverse transforming this will yield f(x-a). We can use this property to shear our 2D data set. The trick is to Fourier transform the data only along one dimension. Say we want to shear our data as in the above figure. Then we will FT our function along the x-axis,

and multiply the result by a phase linear in both the FT-ed variable and the non-FT-ed variable:

where
is a constant that determines the amount of shearing (set to 0 for no shearing). Writing this out in full, we obtain:

Substituting
yields:

We immediately see that, once we inverse-Fourier backward, we will obtain the sheared function
, as desired.
To wrap things up, here is some MATLAB code to get you going:
% Assume dataset is our 2D data set, and suppose we'd like to shear it along the x-direction
alpha = 0.1; % This determines the amount of shearing
[Nx,Ny] = size(dataset);
[xx,yy] = ndgrid([1:Nx],[1:Ny]);
dataset_FT = fft(dataset,[],1);
dataset_FT = dataset_FT.*exp(i*alpha*xx.*yy);
dataset_sheared = ifft(dataset_FT,[],1);
Comments
Leave a Reply
