Last active
July 1, 2021 17:05
-
-
Save AMindToThink/933feb391b08a53c2380d399feacb562 to your computer and use it in GitHub Desktop.
A method that turns a grid of images into a matrix of images. Input the image, the number of rows (numy), and the number of columns (numx). Get a specific image from the matrix with [row, column].
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
def matrixImages(image, numy, numx): | |
yFrac = image.shape[0] // numy | |
xFrac = image.shape[1] // numx | |
itemIcons = np.zeros((numy, numx, yFrac, xFrac, 3)) | |
for i in range(numy): | |
for j in range(numx): | |
itemIcons[i, j] = image[i * yFrac : (i + 1) * yFrac, j * xFrac : (j + 1) * xFrac]/255 | |
return itemIcons |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment