Created
September 16, 2017 05:25
-
-
Save dzhwinter/c0e1edfdfac329006f0ef1bb5cd7873d to your computer and use it in GitHub Desktop.
flatten image
This file contains 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 sys | |
import cv2 | |
import json | |
IMAGE_SIZE = 28 | |
if len(sys.argv) < 2: | |
print "usage: python readimg.py filename" | |
exit(1) | |
filename = sys.argv[1] | |
# gray image, size = (28, 28) | |
img = cv2.imread(filename, 0) | |
img.resize((IMAGE_SIZE, IMAGE_SIZE)) | |
img = img.flatten() | |
print json.dumps({"img": img.tolist()}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment