Created
July 13, 2020 12:18
-
-
Save kotoripiyopiyo/040b06ba19b20a9498c5f9f3820bd34e to your computer and use it in GitHub Desktop.
【Python勉強中】for文の訓練
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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