Skip to content

Instantly share code, notes, and snippets.

@JustinSDK
Created May 18, 2021 07:38
Show Gist options
  • Save JustinSDK/e4627b8f943390cf9d390c0f2e78d98e to your computer and use it in GitHub Desktop.
Save JustinSDK/e4627b8f943390cf9d390c0f2e78d98e to your computer and use it in GitHub Desktop.
Sin 灰階變化
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
freq = 5
stop = .25
sample_rate = 800
x = np.linspace(0, stop, int(stop * sample_rate), endpoint = False)
gray = 125 + np.sin(freq * 2 * np.pi * x) + 125
plt.imshow(gray.reshape(1, 200).repeat(200, axis = 0), cmap = cm.gray)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment