Skip to content

Instantly share code, notes, and snippets.

@vijay120
Created December 4, 2016 02:00
Show Gist options
  • Save vijay120/b3e7f5adcd90bc04679561e08cf62856 to your computer and use it in GitHub Desktop.
Save vijay120/b3e7f5adcd90bc04679561e08cf62856 to your computer and use it in GitHub Desktop.
def grayscale(img):
"""Applies the Grayscale transform
This will return an image with only one color channel
but NOTE: to see the returned image as grayscale
you should call plt.imshow(gray, cmap='gray')"""
return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
image = mpimg.imread('test_images/solidYellowCurve2.jpg')
# grayscale the image
grayscaled = grayscale(image)
plt.imshow(grayscaled, cmap='gray')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment