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/ad5cc68ce5d47fb43982021b54441482 to your computer and use it in GitHub Desktop.
Save kotoripiyopiyo/ad5cc68ce5d47fb43982021b54441482 to your computer and use it in GitHub Desktop.
【Python勉強中】for文の訓練2
%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