Hi and welcome to a new installment of the Signal of the Day. Today we will be talking about Moire patterns. Let's start with a piece of advice. Whenever you hit your 15 minutes of fame, and you're called in for a TV interview, do not wear a striped shirt, because if you do, you will probably look like this. You could see that there are a lot of spurious patterns and lines that do not belong to the shirt at all. But they are created by the image production mechanism of the television camera. These are called moiré patterns, and moiré is a French word that indicates actually a form of textile with a lot of surface decoration. In general moiré patterns can be created on purpose for either artistic or entertainment reasons. And the simplest way to do that is to take a regular pattern, like this set of vertical lines, and then we take another copy of the same pattern, we rotate its pattern a little bit differently, and then we superimpose them. And then you see that new patterns appear in the superposition, like for instance here, it appears that there are some horizontal lines that are not present in the original pattern. This is because our brain is designed to see and discover patterns in everything that we see and that we hear. This is really what we're good at as human beings. And so, when presented with an original or unexpected set of intersecting lines, it makes more sense to the brain to see horizontal lines that give a much cleaner structure to the image that we see. Similarly, we can generate more complex moiré patterns using slightly more complex base patterns. This set of lines for instance has a Gaussian distribution in inter-line distances. And if we superimpose the same pattern but just rotated by a few degrees, we can get moiré patterns that are curvilinear. We can experience moiré patterns in one dimension as well. Perhaps the most common instance of that is when you're waiting in line in a traffic jam, and you see the indicator lights of the car in front of you blinking at slightly different speeds. As you look at the blinking lights, you will see that your brain is trying to find a regular rhythm, a regular pattern in this collective blinking. And sometimes you think you have found it, but you will realize that you lose it a few seconds later when the lights go out of sync once again. We can simulate this effect with an audio file. And here is the superposition of two click sequences. The first is a click sequence at 100 bpm, and the second sequence has a 102 bpm. So there is a 2 bpm difference between the two. And when we play them together, they sound like this. [SOUND] Certainly, at some point during the sequence, you thought you had discovered a regular pattern, which didn't really exist, because the beats were always slightly out of sync, just as in the case of the visual moiré patterns. Also here, the effect is a function of the closeness in rate between the two click sequences. If the sequences were widely different, then we wouldn't hear this phantom rhythm. These effects have been put to great use by some music composers. And one of the probably most famous pieces exploiting this ghost rhythm is the Impromptu by Chopin. Most of the piece is based on the contrast between slightly different numbers of notes played in the same amount of time. Here, for instance, you see this is a pattern that occurs throughout the piece, and you have six notes in the bass and eight notes in the treble. The stagger rhythm caused by this eight over six ratio is what gives this piece an extremely compelling dynamism and always throws you a little bit off-kilter as you listen to it. [MUSIC] Another type of moiré pattern that takes place in one dimension is frequency beatings. So let's start with a simple sinusoid like this. This sounds like so if we play it [SOUND] So we have a bass tone. Now, let's add a second sinusoid at a slightly higher frequency, which looks like this. If we sum the sinusoids, the resulting wave form will look like so. And if we play it, it will sound like two tones playing in parallel. This is what is called a dyad in music. [SOUND] So, nothing particularly remarkable up to this point. However, if we start with a sinusoid at a given frequency, and we add a second sinusoid at a frequency that is just slightly different but not very far away, so something like this. We sum the two sinusoids together. We obtain a waveform that looks like that. And if we play it, it sounds like this. [NOISE] Now here, as you noticed, you don't hear two frequencies anymore, you hear just one frequency, but the tone is modulated in amplitude. It's as if a tremolo had been applied to the note. So we perceive these two frequencies together as an amplitude modulated single frequency, because this makes more sense to the brain. Now, to understand why that is so, let's zoom in this plot and look at several periods of this waveform, and you can see that there is a clear amplitude envelope that is itself a sinusoid, and whose frequency is much lower than either of the frequencies of the original sinusoids. We can analyze the situation mathematically, so here we write our signal. It's the sum of two sinusoidal components. We can use a discrete time representation. It's no problem. And by using a simple trigonometric identity, we can express this sum as the product of two terms. The first one is a cosine at a frequency which is the difference between the two original frequencies. And the second is a cosine at the frequency, which is the average of the two frequencies. Now, this average, since the frequencies are very close together, is basically equivalent to the first frequency. And so we have an amplitude modulation factor here, which is sinusoidal in nature, that oscillates at a very small frequency, which is the difference between the two frequencies divided by two. And this amplitude term modulates as standard cosine term at the original frequency, so that our brain and our ears are unveiling this hidden pattern for us. Okay, so we've been talking about how to generate moiré patterns, both in one and two dimensions, but what about the patterns that appear disruptively in spite of our wishes, like in the case of a striped shirt worn on TV. Those moiré patterns are caused by aliasing. And to give you an example how they come to be, take the same pattern that we used to generate the curvilinear moiré in our second example. You remember, we generated the moiré by taking the same pattern, tilting it slightly, and superimposing it to the original pattern. Now here, we're gonna do a different thing. We're going to take this image and down sample it by a factor of two in both the horizontal and vertical direction. So we're going to get an image which is four times smaller. And if we do that, we get something like this. And you can see that the size reduction has generated moiré patterns in the image. If we look more in detail by magnifying this reduced size image, we see that the sub-sampling has disrupted the parallel lines that formed the original pattern. In other words, the implicit sampling period for the sub-sampled image is not fine enough to perfectly capture the structure of parallel lines. Since in nature, curved lines are much more common than straight lines, the brain looks at this arrangement of pixels and immediately fills it in with a structure of a wave-like nature. Now, in 2D, it's a little bit difficult to go through the frequency, the main explanation of why aliasing creates moiré pattern. But luckily, in one dimension, it's much easier. And we will follow that approach. So, let's go back to our sinusoidal friends. Here we're going to be working in the continuous time domain, and we are building a waveform which is composed of two sinusoidal components in continuous time. The first one has a frequency of 165 Hz, and the second one is its first harmonic. Namely, it has a frequency of twice that. If we sample this waveform, then we will have a digital spectrum, DTFT. And so, for instance, if we choose a sampling frequency of 1000 HZ, the previous waveform will have the following spectrum. One component will be a 0.33 pi, and the first harmonic will be a 0.66 pi, with of course the negative components symmetric around zero. Now if we sample this at 500 Hz instead, what happens is that the fundamental frequency will be mapped to 0.626 pi, and the first harmonic, which now falls beyond the Nyquist frequency, will be aliased back and will be aliased back at the 0.68 Pi. So these two harmonics that used to be at frequencies one double of the other now lie very, very close together and will give rise to beatings as we've heard before. [SOUND] Since unwanted moiré patterns are caused by aliasing, it should come as no surprise that in order to avoid moiré patterns, we should lowpass our original image before we acquire it. So in the case of photography or TV for instance, we need to put a lowpass filter on the lens of the camera before we shoot a striped shirt. So here for instance on the left, you see what happens when you take a picture of a shirt without a lowpass filter, and on the right you have the same shirt but now acquired with a lowpass filter. Although you're losing some detail, some fine grain detain in the texture of the shirt, which now is sort of like a uniform gray, you do not have moiré patterns. Finally, let's look at a practical application of moiré patterns, and this comes in the form of secure printing. The idea is this. Take a 20 euro banknote, for instance, this is a specimen image provided by the European Bank. The banknote is embedded with very, very fine lines, especially for instance in this area here, that are too fine for most scanners or camera to capture correctly. So if you take this banknote and try to make more money by photocopying it or scanning it with your scanner, what you get is something like this. The moiré patterns appear in the secure zone of the banknote and clearly end your career as a forger from the start.