**Any** image can be reconstructed from a series of sinusoidal gratings.

A sinusoidal grating looks like thisâ€¦

/2

Show thread

Itâ€™s called a sinusoidal grating because the grayscale values vary according to the sine function.

If you plot the values along a horizontal line of the grating, youâ€™ll get a plot of a sine function

/3

Show thread

There's one more parameter that defines a sinusoidal grating: the phase. Gratings with a different phase are shifted with respect to each otherâ€¦

/7

Show thread

You can create a 2D sinusoidal grating in #Python using #NumPy and display it using #matplotlib

/8

Show thread

You can find the parameters of a sinusoidal grating by using the 2D #FourierTransform.

The dots shown contain the amplitude and phase of the grating. Their position from the centre gives the frequency, and their orientation represents the orientation of the grating.

/10

Show thread

Now, if you have lots of gratings superimposed on each other, the #FourierTransform gives you a pair of dots for each of the components

/11

Show thread

Now, here’s the “magical” part of #Fourier theory.

*Any* image is made up of lots of sinusoidal gratings. So, the 2D Fourier Transform of an image gives you thousands of pairs of dots, and each pair represent a sinusoidal grating.

/12

Show thread

And therefore, you can reconstruct the image by adding all of those sinusoidal gratings together.

The more gratings you add, the closer the result is to the actual image

/13

Show thread

There's a lot more than can fit in a single thread.

If you want to read more detail, and go through the step-by-step writing of the code to decompose & recostruct *any* image, read full article here:

#coding #2dfourierimages #2dfouriertransform #fourier

/16

You'll find me easily on Twitter too if you're on there as well. That's a bigger account and get's a lot of interesting conversations going with others in the #Python world

You can see the sort of things I'm interested it there (until this timeline fills up a bit): https://twitter.com/s_gruppetta_ct