Linked Questions
44 questions linked to/from How do I convert a PIL Image into a NumPy array?
1 vote
2 answers
600 views
Transparency is turned to an olive green
This code: import numpy import PIL.Image base = PIL.Image.open('grin-emoji-by-twitter.png').convert('RGBA') base2 = numpy.array(base) print(base2.shape) print(base2) produces the following output: (...
2 votes
1 answer
447 views
Reduce 3D volume mask by uniform margin in python
I'm working with 3D boolean arrays that mask a volume. My goal is to take a mask and reduce the area of the mask by some margin, m, in all dimensions. Is there an easy way to do this using some ...
-1 votes
2 answers
331 views
Improve CPU time of conditional statement
I have written an if-elif statement, which I believe not be very efficient: first_number = 1000 second_number = 700 switch = { 'upperRight': False, 'upperLeft': False, 'lowerRight': False,...
1 vote
1 answer
530 views
Add some bit stream to image png
I've converted the png image to a base 2-bit sequence with the following program from PIL import Image, ImageFile from io import BytesIO out = BytesIO() with Image.open("download.png") as ...
0 votes
1 answer
494 views
rotate image clockwise by reversing the width and length of image doesnt work
def rotate_picture_90_left(img: Image) -> Image: img_width, img_height = img.size pixels = img.load() # create the pixel map # for every pixel for i in range(img_width): ...
0 votes
0 answers
481 views
Implementation of RGB PCA on an image
I want to implement PCA (Principal Component Analysis) to get an RGB version on an image . I'm opening the images from a github repository . I found a very helpful similar question here (Reverse ...
0 votes
1 answer
316 views
C++ format pixels data for PySide2 QImage.fromData()
I am developing an Image viewer. My main goal is to make something able to easily load .EXR files along with all other main formats. I based it around : PySide2 (Qt) for the UI. OpenImageIO for .exr ...
0 votes
0 answers
343 views
Byte representation of an image differs depending on method used to read it
I was trying to perform some data augmentation in object detection models in tensorflow so I was checking the compatibility of different image representations. First I was just reading an image file ...
0 votes
0 answers
169 views
Cannot get Image written with cv2 and PIL Python 2.7
I am using python 2.7 with OpenCV and PIL Running on windows 10 I am trying to get an image written with cv2.imwrite() like follow Code: x={{"Some Process On an Image "}} #now saving the ...
-1 votes
2 answers
112 views
Where is the bottleneck in my image manipulation code?
I wrote this script to do some image processing on a large number of PNG files (around 1500 in total). They are organized into subdirectories. That's my code: from PIL import Image import os path = &...
0 votes
1 answer
119 views
How to save what a tkinter window looks like without screenshot? (Possibly a numpy array?)
I have a short program that generates images of 1, 2, 3, and 4 random coloured circles to train a neural network on. My issue is, just doing 4000 images takes about 20-30 mins, and I need about 50000 ...
1 vote
1 answer
113 views
problems with PIL
Today I tried to switch pygame's image.load() to Pil's Image.open() but (as usual) I got problems. At the beginning of the code I have this fragment with pygame's image.load(): class Gamesprite(): ...
0 votes
1 answer
66 views
Convert Mat objects into standard 12x12 Matrix
I have each character as a Mat object which are of different sizes. Some sample images are, I am trying to convert them to an Image using PIL and then into a standard 12x12 matrix which will be ...
0 votes
0 answers
56 views
PIL Image Conversion
Could you please advise how can we convert the <PIL.Image.Image image mode=L size=675x1200 at 0x16193333D48> to Real image through Python. Because when I storing outputimg in FTP its storing ...