Skip to content

Instantly share code, notes, and snippets.

@oak-tree
Last active January 24, 2019 15:19
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 oak-tree/4ed7e1399a22f29dddfd748bc8e6f17d to your computer and use it in GitHub Desktop.
Save oak-tree/4ed7e1399a22f29dddfd748bc8e6f17d to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def do_something(img):
return np.dot(img[...,:3], [0.299, 0.587, 0.114])
img = mpimg.imread('image.png')
result = do_something(img)
plt.imshow(result, cmap = plt.get_cmap('gray'))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment