Created
June 2, 2019 18:16
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 | |
import numpy as np | |
def pixels_from_path(file_path): | |
im = Image.open(file_path) | |
np_im = np.array(im) | |
#matrix of pixel RGB values | |
return np_im | |
def vector_of_pixels(np_im): | |
pixels = [] | |
for row in np_im: | |
for pixel in row: | |
pixels.append(pixel) | |
return np.asarray(pixels) | |
file_path = "mypic.png" | |
np_im = pixels_from_path(file_path) | |
pixels = vector_of_pixels(np_im) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment