0

I want to import an image and the store all the pixel values in an array. How can I do this ?

This is what I have tried already but the array is wrong.

from PIL import Image
im = Image.open('red-flower.jpg', 'r')
pix_val = list(im.getdata())
1
  • 1
    Use numpy.array(im.getdata())? Commented Jul 16, 2019 at 7:14

1 Answer 1

1

You have the parameters wrong for Image.open():

import numpy as np
from PIL import Image

im = Image.open('red-flower.jpg')
array = np.array(im)

Documentation here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.