Skip to content

Instantly share code, notes, and snippets.

@anupam-io
Last active February 22, 2021 09:11
Show Gist options
  • Save anupam-io/63924a6285af96db3dcaebd2892a0886 to your computer and use it in GitHub Desktop.
Save anupam-io/63924a6285af96db3dcaebd2892a0886 to your computer and use it in GitHub Desktop.
Flattening a colored image by converting into grayscale
import numpy as np
import cv2
img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
img = cv2.resize(img, (20, 20))
img = np.array(img).ravel()
img = img.reshape(-1)
print(img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment