Skip to content

Instantly share code, notes, and snippets.

@bryanlimy
Created March 2, 2018 00:21
Show Gist options
  • Save bryanlimy/b82ad03983831f1da7b0ae0a12337b4d to your computer and use it in GitHub Desktop.
Save bryanlimy/b82ad03983831f1da7b0ae0a12337b4d to your computer and use it in GitHub Desktop.
Python2 script to convert coloured image to grayscale
import cv2 as cv
def convert(filename):
img = cv.imread(filename)
gray = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
return cv.imwrite(filename, gray)
if __name__ == '__main__':
filename = raw_input('filename: ')
if filename:
print('status: ' + str(convert(filename)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment