M
M
MaksaTaksa2019-04-21 03:54:53
Python
MaksaTaksa, 2019-04-21 03:54:53

How to convert an image to a 2D python array?

There is this code in python. In the end, it makes a two-dimensional array from the picture, but the problem is that the array is 6x9, and I need 28x28, I will be grateful for any support...
from PIL import Image, ImageGrab
import numpy as np
img = Image.open('image. jpg')
arr = np.asarray(img, dtype='uint8')
print(arr)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2019-04-21
@Maksataksa

The first step is to style your code properly using the <code> tag
numpy.reshape
Gives a new shape to an array without changing its data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question