Create a cosine wave image.
- f = iacos(s, t, theta, phi)
- f: Image.
- s: Image. size: [rows cols].
- t: Image. Period: in pixels.
- theta: Double. spatial direction of the wave, in radians. 0 is a wave on the horizontal direction.
- phi: Double. Phase
1. import numpy as np 2. 3. def iacos(s, t, theta, phi): 4. r, c = np.indices(s) 5. tc = t / np.cos(theta) 6. tr = t / np.sin(theta) 7. f = np.cos(2*np.pi*(r/tr + c/tc) + phi) 8. return f
Generate a cosine wave image of size s with amplitude 1, period T, phase phi and wave direction of theta. The output image is a double array.
1. from ia636 import iacos, ianormalize 2. 3. f = iacos([128,256], 100, pi/3, 0) 4. adshow(ianormalize(f, [0,255]))
- is the direction of the cosine wave.
- is the wave period, in number of pixels.
- and are the period or wave length in the vertical and horizontal directions, respectively, in number of pixels.
- and are the number of image rows and columns, respectively.
- and are the normalized frequency in the horizontal and vertical directions, respectively, in cycles per image dimension.
- iacosdemo -- Illustrate discrete cosine wave and its DFT showing its periodic nature.