I'm trying to generate jigsaw puzzle pieces using Python as part of a project I'm interested in. There are libraries such as openCV and Pillow that allow splitting the image into square pieces and of course they allow masking, but I want something that allows me to input custom cut shapes, perhaps as a bezier curve or similar. Is there a good library for this or is it necessary to write my own, perhaps outputing bezier shapes to a png mask and using that? Thanks
for my school project, I need to find images in a large dataset. I'm working with python and opencv. Until now, I've managed to find an exact match of an image in the dataset but it takes a lot of time even though I had 20 images for the test code. So, I've searched few pages of google and I've tried the code on these pages
image hashing
building an image hashing search engine
feature matching
Also, I've been thinking to search through the hashed dataset, save their paths, then find the best feature matching image among them. But most of the time, my narrowed down working area is so much different than what is my query image.
The image hashing is really great. It looks like what I need but there is a problem: I need to find an exact match, not similar photos. So, I'm asking you guys, if you have any suggestion or a piece of code might help or improve the reference code that I've linked, can you share it with me? I'd be really happy to try or research what you guys send or suggest.
opencv is probably the wrong tool for this. The algorithms there are geared towards finding similar matches, not exact ones. The general idea is to use machine learning to teach the code to recognize what a car looks like so it can detect cars in videos, even when the color or form changes (driving in the shadow, different make, etc).
I've found two approaches work well when trying to build an image database.
Use a normal hash algorithm like SHA-256 plus maybe some metadata (file or image size) to find matches
Resize the image down to 4x4 or even 2x2. Use the pixel RGB values as "hash".
The first approach is to reduce the image to a number. You can then put the number in a look up table. When searching for the image, apply the same hashing algorithm to the image you're looking for. Use the new number to look in the table. If it's there, you have a match.
Note: In all cases, hashing can produce the same number for different pictures. So you have to compare all the pixels of two pictures to make sure it's really an exact match. That's why it sometimes helps to add information like the picture size (in pixels, not file size in bytes).
The second approach allows to find pictures which very similar to the eye but in fact slightly different. Imagine cropping off a single pixel column on the left or tilting the image by 0.01°. To you, the image will be the same but for a computer, they will by totally different. The second approach tries to average small changes out. The cost here is that you will get more collisions, especially for B&W pictures.
Finding exact image matches using hash functions can be done with the undouble library (Disclaimer: I am also the author). 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.
I work with a huge library of components (step files) that are currently used in various products. My goal is to identify parts with great similarity in order to unify them. At the moment I can think of two solutions:
Compare certain properties of the 3D data with a suitable python library. E.g. identify parts with similar volume and dimensions.
Convert step files to JPG and compare the images with one of the many image processing libraries.
Both have their pitfalls.
Is there a library that can handle step files or do you know a better way to solve the problem?
You are underestimating the complexity of this project. Once the STEP geometry is loaded, taking dimensions on it (apart from bounding box extents) can be really cumbersome. Very different parts can have the same volume and comparing bitmaps you completely ignore the hidden part of the geometry.
I am trying to write a script (in bash using imagemagick or in python), to generate an image similar as in this example:
The source is 25 separate jpeg's. So far I have written a script (imagemagick) which takes each of the images and detects the contours of the person and replaces the white background with a transparent one.
The next step is to fit the contours randomly into one large image. Each image should fit into the larger image, without overlapping it's neighbors. It seems I need to some type of collision detection.
I am looking for pointers on how to tackle this problem.
I'm trying to write a python program that will take a screen shot and then scan the image for a specific combination of pixels, or pattern. For example: it takes a screen shot of a web page and scans the whole image for a 10X10 pixel pattern. It would also be nice if it could record the x-y position of the image on the screen.
I searched the internet for hours for a solution but found nothing. I only know the basics of python and wouldn't know where to begin with this program.
Take a look at some basic pattern recognition and machine vision literature. In order to address your question considerably more detail is needed.
Is the pattern a binary image, a grayscale image, or a color image?
How often do you need to do this?
Have you looked at the Python Imaging Library (PIL)?
How big of an image do you want to search?
A good course of action is to look at PIL, and then look at convolution in Fourier space to localize the target regions (relatively) quickly. Finally, a good Google search is your friend.