Created
January 18, 2020 20:42
-
-
Save jeanmidevacc/40a7fcdf5bcd5d038bb2f2725b111c0e to your computer and use it in GitHub Desktop.
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
from PIL import Image | |
def build_mlimage(path, config_resize = (100,50), is_bw = True): | |
# Access the image | |
img = Image.open(path) | |
# Resizing and conversion in black and white (if necessary) | |
if is_bw: | |
newimg = img.resize(config_resize, Image.ANTIALIAS).convert('L') | |
else: | |
newimg = img.resize(config_resize, Image.ANTIALIAS) | |
# Flatten the image during the return | |
return np.array(newimg).flatten().tolist() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment