Does anyone know of a method to make images picklable? I am trying to pass OpenCV images between processes to separate display from real-time processing of an OpenCV video. I have tried PIL Image.tostring(), but to no avail. Is there a standard technique?
This is what you are looking for: pickleable image object
Making it a dict and then using the information in the dict to recreate the image again. Hopefully this helps
OpenCV's newer cv2 module uses NumPy arrays, which are inherently pickleable. See my answer here: https://stackoverflow.com/a/17054961/1510289
Related
I used the convert Imagemagik utility to create the grayscale jpg images. Need help in finding the equivalent utility in Python. I tried PIL but this create png images.
I thought of calling the "convert" utility through python. Is there any better solution than this.
I want to feed the images in tensorflow. The issue is I am using tensorflow 1.1.
Huh? This works fine and creates a grey JPEG:
from PIL import Image
image=Image.open('start.png')
grey=image.convert('L')
grey.save("result.jpg")
Here is the effect I am trying to achieve - Imagine a user submits an image, then a python script to cycle through each JPEG/PNG for a similar image in the current working directory.
Close to how Google image search works (when you submit your image and it returns similar ones). Should I use PIL or OpenCV?
Preferably using Python3.4 by the way, but Python 2.7 is fine.
Wilson
I mean, why not use both? It's trivial to convert PIL images into OpenCV images and vice-versa, and both have niche functions that can make your life easier. Pair them up with sklearn and numpy, and you're cooking with gas.
I created the undouble library in Python which seems a match for your issue.
It uses Hash functions to detect (near-)identical images in for example a directory. It works using a multi-step process of pre-processing the images (grayscaling, normalizing, and scaling), computing the image hash, and the grouping of images based on a threshold value.
How can i transform Image1 to Image2 using matplotlib.pyplot or another library in Python?
Image 1:
Image 2:
(This image turned out to be confidential,i removed it because i can't delete the post. Sorry for the inconvenience)
Any help is appreciated.
Have a look at the Python Imageing Library (which also has python bindings, by the way), especially the ImageFilter module.
But tools like ImageMagick or one of the built-in filters in Gimp might be more suitable for experimenting.
Is it the experimental data and already filtered from image 1 to image 2 by someone else? I wonder whether you have the point spread function along with the raw image 1?
I'm trying to make a program which can draw some objects on an image
the features what i need are
can draw vector(or bitmap) objects (eg. dots, lines..) on pre-existing image file (especially jpg format)
can keep track that objects and find by id or x,y coordinates
can move/modify/remove that objects
please recommend some nice library or code samples for these features.
(I'm trying with WxPython.PseudoDC, but I think it is not what i'm looking for)
thanks.
PIL is the library for you. You can use ImageDraw class. There is no integration between PIL and wxPython, so you should convert from one Image class to another, but that's not a problem.
For interactive graphical programming, look at pyprocessing.
how about guiqwt,
Here is an example:
http://packages.python.org/guiqwt/examples.html#image-plot-tools
I want to load a number of images from harddrive and place them on a larger white background. And I want to do it in Python. I am wondering what is the best way of doing that. I am using a windows machine and I can use any library I want. Any pointer to a webpage or a sample code that can point me to a good direction would be appreciated.
Something like this:
A very popular image processing library for Python is PIL. The official PIL tutorial might be useful, especially the section about "Cutting, Pasting and Merging Images".
PIL isn't enough. Try also with PIL the aggdraw library.
But aggdraw also isn't enough. It works poorly with transparency. I mean 0.5-1 gray pixel around opaque object over the transpparent area.