Created
July 13, 2020 12:19
-
-
Save kotoripiyopiyo/ad5cc68ce5d47fb43982021b54441482 to your computer and use it in GitHub Desktop.
【Python勉強中】for文の訓練2
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) | |
rgb = [0] * 6 | |
j = 0 | |
for i in range(0, 5, 2): | |
rgb[i], rgb[i+1] = np.histogram(tower_color[:, :, j].flatten(), bins=256) | |
j += 1 | |
plt.figure(figsize=(10, 3)) | |
plt.subplot(1, 2, 1) | |
plt.imshow(tokyo_tower) | |
rgbcolor = ["red", "green", "blue"] | |
k = 0 | |
plt.subplot(1,2,2) | |
for i in range(0, 5, 2): | |
plt.plot(rgb[i], color=rgbcolor[k]) | |
k +=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment