When converting an analog signal to a digital signal, it is possible to observe only frequencies up to 1/2 the sampling frequency $ f_s $. This frequency is called the Nyquist frequency, but it is known that it cannot be observed even if it contains vibrations that exceed this Nyquist frequency. Vibrations above this Nyquist frequency are treated as low frequencies. Treating high-frequency vibrations that exceed the Nyquist frequency as low frequencies is called aliasing (aliasing).
Considering the discrete Fourier transform of data with $ N $ numbers from $ x_0 $ to $ x_ {N-1} $
C_k = \frac{1}{N}\sum_{m=0}^{N-1} x_me^{-i\frac{2\pi km}{N}}
k = 0, 1, 2, …, N-1
The frequency corresponding to k is
f_k = \frac{kf_s}{N}
It will be. Since k exists up to (N-1), it becomes $ f_ {N-1} = \ frac {(N-1) f_s} {N} $, and vibrations exceeding the Nyquist frequency of $ f_s / 2 $ can be expressed. That's right ..., $ C_k $ and $ C_ {Nk} $ are known to be complex conjugates of each other.
C_k = C_{N-k}^*
Therefore, wrapping will occur centered on $ f_s / 2 $. Don't be afraid to misunderstand that the $ C_ {N-k} $ wave will be treated as a $ C_k $ frequency wave.
Use numpy to generate high resolution images (5000x5000). This is regarded as a pseudo analog signal.
import numpy as np
import matplotlib.pyplot as plt
#Specify the size of the image
img_size_origin = 5000
#Zero matrix as an image
img = np.zeros([img_size_origin, img_size_origin])
#Image pixel values depend on y coordinate
y = np.arange(img_size_origin)
#Period 100 pixels
amp = np.sin(2*np.pi*0.01*y)
for i in range(img_size_origin):
img[:, i] = amp
plt.imshow(img, cmap="gray")
plt.show()
This will generate an image with 50 stripes. Since it has 50 stripes, if the entire image is regarded as one cycle, there are 50 Hz waves.
Extract only 1 pixel per [comp x comp] from this image and generate a new image. If comp = 5, the extracted pixels will have coordinates of [3 + 5n, 3 + 5m]. (n> = 0, m> = 0)
comp = 99
#Calculate the image size of the output
img_size = img.shape[0]//comp
print(img_size)
#Output image
img_comp = np.zeros([img_size, img_size])
#[comp×comp]Extract only the center pixel from the pixels of
for i in range(img_size):
for j in range(img_size):
img_comp[i, j] = img[(i*comp) + (comp//2), (j*comp) + (comp//2)]
plt.imshow(img_comp, cmap="gray")
plt.show()
plt.plot(img_comp[:, 0])
plt.show()
I couldn't observe the 50 Hz wave well, and it became a 0.5 Hz wave.
I couldn't observe the 50 Hz wave well, and it became a 1 Hz wave.
I couldn't observe the 50 Hz wave well, and it became a 2 Hz wave.
It seems that a lot of mysterious images can be made (small average feeling)
Recommended Posts