Created
January 27, 2014 15:34
-
-
Save habi/8650623 to your computer and use it in GitHub Desktop.
Convert an Image from RGB to monochrome, based on the formula from https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
This file contains hidden or 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
import numpy as np | |
def rgb2gray(rgb): | |
''' | |
convert an image from rgb to grayscale | |
http://stackoverflow.com/a/12201744/323100 | |
''' | |
return numpy.dot(rgb[..., :3], [0.299, 0.587, 0.144]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment