Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotoripiyopiyo/040b06ba19b20a9498c5f9f3820bd34e to your computer and use it in GitHub Desktop.
Save kotoripiyopiyo/040b06ba19b20a9498c5f9f3820bd34e to your computer and use it in GitHub Desktop.
【Python勉強中】for文の訓練
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
tokyo_tower = Image.open("tokyo_tower.png")
tower_color = np.array(tokyo_tower)
hist_r, bins_r = np.histogram(tower_color[:, :, 0].flatten(), bins=256)
hist_g, bins_g = np.histogram(tower_color[:, :, 1].flatten(), bins=256)
hist_b, bins_b = np.histogram(tower_color[:, :, 2].flatten(), bins=256)
plt.figure(figsize=(10, 3))
plt.subplot(1, 2, 1)
plt.imshow(tokyo_tower)
plt.subplot(1,2,2)
plt.plot(hist_r, color="red")
plt.plot(hist_g, color="blue")
plt.plot(hist_b, color="blue")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment