Linked Questions
44 questions linked to/from How do I convert a PIL Image into a NumPy array?
-1 votes
1 answer
3k views
How to convert PIL image to numpy array? [duplicate]
When I do np.asarray(my_img) or array(my_img).shape it returns (2412L, 3600L, 3L) on a jpg image,but I just want a 2D (2412L, 3600L) array, so how to convert it correctly? Thanks in advance. my_image ...
-1 votes
1 answer
813 views
python PIL image.getdata() returns data returns more data than is expected [duplicate]
the following: image = Image.open(name, 'r') data = np.array(image.getdata()) data.reshape(image.size) returns: Traceback (most recent call last): File "/home/usr/colorviewer/main.py", ...
0 votes
1 answer
744 views
How to use image from PIL ImageGrab without saving it to a file? [duplicate]
I'm trying to compare the structural similarity of two images with the skimage package but it only works if use two images saved on my pc and not when I use an image created by ImageGrab from PIL even ...
1 vote
0 answers
694 views
How to convert a PIL image into a list of lists not numpy object type [duplicate]
from PIL import * image = ImageGrab.grab() from the variable image i would like to obtain a list of lists in witch every pixel is rappresented like [R,G,B] every line of the image by the first index ...
0 votes
0 answers
107 views
How can i transform my Boolean list of lists to 1s and 0s? [duplicate]
[[ True False False True True True True True True False False True True True True True True True True True True True True True False False True True True True False False ...
1 vote
0 answers
90 views
I have got a 2-D array storing pixel value , how can i show them as an image [duplicate]
I have got the pixel value of an image patch as the following shows, but how should I show them as an image patch by using python? Is there a method in the PIL library? array([[162, 162, 161, 162, ...
474 votes
8 answers
203k views
What is the difference between np.array() and np.asarray()?
What is the difference between NumPy's np.array and np.asarray? When should I use one rather than the other? They seem to generate identical output.
11 votes
2 answers
17k views
Find location of image inside bigger image
So i have an image lets say small.png and a bigger image big.png .The small image occurs 2 times in the bigger image and i wish to find its location. I tried using numpy and Image but got error '...
4 votes
2 answers
13k views
How would I scale a 2-dimensional array in python?
I'm not sure how to go about scaling a 2-dimensional array. Given the array below, whose dimensions are 8x10, say I needed to scale it to 5x6 -- I've looked for concrete examples on wikipedia, but ...
9 votes
2 answers
11k views
Comparing (similar) images with Python/PIL
I'm trying to calculate the similarity (read: Levenshtein distance) of two images, using Python 2.6 and PIL. I plan to us e the python-levenshtein library for fast comparison. Main question: What ...
4 votes
3 answers
13k views
TypeError: unsupported operand type(s) for /: 'Image' and 'int'
I wanted to convert the PIL Image object into a numpy array. I tried using the following codes it showing an error TypeError Traceback (most recent call last) <ipython-input-133-0898103f22f0> ...
4 votes
3 answers
9k views
Using multiprocessing with the PIL
I have some code that does (independent) operations on a bunch of Python Imaging Library (PIL) Image objects. I would like to try and speed this up using parallel processing, so I read up on the ...
4 votes
1 answer
7k views
Read PDF as a picture
I have some pdf, I want to read them as pictures to get all the pixels info. So I tried first to convert the pdf into jpeg: from pdf2image import convert_from_path img = convert_from_path('mypdf....
3 votes
1 answer
4k views
How to use neural nets to recognize handwritten digits
I followed a tutorial for creating a simple neural network using signoidal function "Using neural nets to recognize handwritten digits", the tutorial is very simple with theory and code examples. ...
0 votes
1 answer
2k views
Convert a PIL image to a numpy array
I want to convert a PIL image to a numpy array. Numpy's asarray function simply puts the image in a 0-dimensional array. (Pdb) p img <PIL.Image._ImageCrop image mode=RGB size=1024x0 at 0x106953560&...