Find similar image using image upload - php

Here, I want to search am image from MySQL by upload an image.
I have tried with hash and rgb and also with hex. But I am not getting the perfect picutres as google.
For e.g. If you find Koala.jpg, then you can see only those photos related to Koala.jpg. But I am getting other photos too with above try.
Is there any suggestions that I can search image from the database by image upload.
Thanks in advance.

Introduction
As I understand your question, how can I search for similar image while I am uploading the image?
Before I dig more in details, I would roughly give a little introduction to the topic.
To be able to search or analysis images in computer, we need to go through some processes and convert the image to a numbers representation. This make it possible to do almost every thing.
There are different similarity search Algorithms, and it is a very heat topic a lot researchers working to improve the techniques and developing better ways.
Depending on your requirement, there are a lot of things involved in it, like how big file is, how fast you expecting the results, is it while the person is upload, how many images should be processed at the time etc.
Google has a lot powerful servers and a lot of machine learning that makes it very smooth to compare images almost with no delays.
IMO you need gather some theoretical information that will help you a lot understanding the process around it.
Some links with information regarding my explanation:
https://en.wikipedia.org/wiki/Reverse_image_search
https://en.wikipedia.org/wiki/Google_Images#Search_by_image
scientific paper http://ai.stanford.edu/~gal/Research/OASIS/
I am pretty sure with a bit more google search you can find a lot of theoretical resources.
Now back to your question,
The following lib/class IMO will solve your problem.
Libpuzzle is a PHP library to find similar picture
(https://www.pureftpd.org/project/libpuzzle)
PHP Compare Images Similarity is also a PHP class
(http://www.phpclasses.org/package/8255-PHP-Compare-two-images-to-find-if-they-are-similar.html)
I will leave some link that might enlighten you as well, that said you have few steps to reach your goal:
Start test one of these libraries and see which one fits you best
Then try to test by uploading and comparing image
Few more links:
Image similarity comparison
Image comparison - fast algorithm
Good way to identify similar images?
Find similar images in (pure) PHP / MySQL
http://nekkidphpprogrammer.blogspot.dk/2014/01/not-all-bits-are-created-equal.html
Algorithm for finding visually similar photos from a database?
Image comparison - fast algorithm

Related

Compare Image with a Photo of the Image

I've a Problem to solve, but couldn't find a solution.
I need to compare a original image with a photo of the same image, and the function should return true if the photos are equal or false if the photos are not equal.
The photo can also have another size as the original image, and also if the photo contains only a part of the original it should detect the original.
Can I use normal face detection library's or do you have a better solution to solve this problem?
Thanks
There are several ways you could approach this problem. If you are looking to see if images are EXACTLY the same. You could go after the file. Using an md5 comparison you can help determine to see if it's the exact same file. Now this won't work for ACTUALLY comparing them.
If you want to actually compare the contents of the pictures you have, I suggest taking a look at PHP's gd library.
After some googling around I found a nice blog entry here about comparing the similarity of images. It's a good read.
A good method to start off with when comparing photos with GD is making the images the same size. The size should be reasonable so I'd say somewhere around 16x16. You should then consider RGB values, shapes, etc.
Some other libraries I should point you to are libpuzzle and imagemagick. Both of which make it pretty easy for comparing images in PHP. The documentation is pretty bad though so it may require a lot more googling and actual testing. Good luck!

PDF Verification in PHP

What is the best way in PHP to determine if a PDF is filled out correctly? The source PDF is a faxed form that contains handwritten data. Is an image comparison an option? If the form is filled out on a computer, I know I can use pdftotext to verify that the fields are completed or not. I just don't know how to verify handwritten data.
For hand-written data an image comparison may definitely be an option. See for example the following answer for a basic idea how to start tackling this task:
Imagemagick : “Diff” an Image
However, the job may be much more difficult when faxed images come into play. (We all know how bad a quality you can get from faxes. Also, they frequently are skewed by a small degree. And they may be slightly scaled, compared to the original. Not to forget that their resolution is 204x196dpi, which adds a bit of a distortion. And lastly -- how do you get the faxed form back into PHP? This might involve another step of scanning in the paper, which again will not necessarily add quality to the result.
Still, ImageMagick may be able to handle all this: it can -deskew images, it can reduce or completly remove -noise, and it can -distort, -scale and -repage images and much more...

given two images, determine whether one is edited from the other (and which is the original)

suppose there is an image on web without watermark. And someone downloads it and makes some edits on it like adding watermark etc etc. Is it possible to write a script in php to compare these two images. Like when I submit these two images to the script, it should be able to output the original image and manipulated image.
I read google's webmaster page which says
Google often finds multiple copies of the same image online. We use many different signals to identify the original source of the image
Blockquote
This is the main concern of my question
One more doubt is will there be any meta tags inside an image. if at all how to read them. Is it possible to edit them. Are there any information(not visual) inside an image which cannot be edited.
Anything within the image can be edited (it is, after all, just a collection of bytes), and it's definitely trivial for someone to add a watermark to an image, or simply change the contrast ever-so-slightly, to make it a very different file from the original. There are several other non-destructive changes that would make image files look completely different to a naive comparison algorithm (e.g., scaling, changing filetypes and compression, changing brightness, rotation, etc.).
Advanced image processing algorithms, however, can still often identify similarities between images that have been manipulated in ways like those above. There are many algorithms to do this, and honestly you could spend thousands of hours trying to roll an algorithm like this yourself. These sorts of algorithms are referred to as "content-based image retrieval."
You might be better off calling into engine that's already been developed to do exactly this. Here are some possibilities:
TinEye has a RESTful API that you can use, described here.
You could scrape the response from Google's Search by Image results using this technique.
You could use any of the number of suggestions within this slightly older StackOverflow post.
Good luck!
Photos taken by digital cameras usually have exif data embedded.
You can get the data with the exif_read_data function in PHP.
As for identifying similar images, here's some useful resources:
TinEye
SO Q on image similarity
The comments on Resig's article
You could submit both images to ImageEdited and see which one has been edited. Even if the exif data's missing, it tells when an image has been created with a program.

How to improve this wallpaper gallery?

Gallery - http://schnell.dreamhosters.com/wallpapers.php
The purpose of this gallery is simple - store a lot of wallpapers and sort them by resolution and/or aspect ratio for people to browse and download as they like. There's a few features I've wanted to work in, but I'm not quite sure how best to do them or how to do them at all. The presentation is in HTML 4, CSS, Javascript and jQuery + plugins. The work behind the scenes is done in PHP.
1 - Make the images downloadable without 'Save Image As...'. Right now I'm using a contrivance whereby clicking the Download link in the bottom-right of each image's box opens a new box with instructions telling the user to 'Right Click. Save Image As...'. I'd like to avoid this entirely if possible.
2 - Make the searching and sorting faster and more efficient. Right now all the images are stored in a folder on my webspace and I use a shell command and a lot of fancy filtering in PHP to get the images I want based on the filters (the page number I'm on and the aspect ratio or resolution I chose). I thought of maybe doing something with MySQL, but I haven't quite figured out yet how I'd do that and maintain the structure my page has.
3 - Make the images load faster. There's probably no easy coding solution to this, so this one is more of a 'I wish' than a 'I want to'.
4 - Improve the layout. This one is more subjective and 'artsy' I suppose, but any suggestions would be nice.
5 - An upload system. Give the ability to upload your own wallpapers and maybe include a short description or some tags. I have absolutely no idea how to handle this as I've never worked with uploading of files before. And this also leads to...
6 - A tagging system or some other type of user-made sorting system. Again, no experience here.
Any insight on any of these issues would be great, and feel free to throw in any suggestions of your own.
Send the files with the MIME type "application/octet-stream" to make a browser download rather than display them
It would definitely be better to store information about the images in a database rather than exploring the filesystem
The images really aren't loading slowly for me, so I can't really suggest anything here. If your site gets larger (much larger) you might want to look into CDNs
The layout is OK but it needs some design, it's incredibly plain at the moment. It would also be nice to see more information on the images - what they are of, where they're from, who made them, etc (don't forget: correct copyright attribution)
You probably want to read the PHP handbook section on handling file uploads. To handle description and tags, you'll definitely want a database of some sort.
Also not hard if you have a correctly formed database. If you've never designed a schema before you probably want to learn a little about normalisation and many-to-many relationships to do the tags.
Lastly you didn't ask for it, but it'd be nice if it were possible to have the same image in multiple resolutions (quite common on image sites - think Flickr, Deviantart, etc).

Recognize image with PHP

I run a site with lots of small images (www.iconfinder.com) and would like to develop a feature that can compare and recognize images. A user should be able to upload an image (icon) and then the site will respond with information about the image if it's in the database.
What is the approach to finding similar (or the same image). I know I can compare md5 of the two images, but I also want be able to find matches if the are scaled.
This is a good start if you are interested in looking at doing it in PHP:
http://www.intelliot.com/blog/2008/03/sorted-directory-listing-image-resizing-comparison-and-similarity-in-php/
There probably aren't a lot of languages LESS suited to this task than PHP. You should really look for an image comparison library with a C compatible API and figure out how to glue that into your PHP application.
Identical images can be checked with an md5sum, but detecting if somebody uploads a scaled image, which displays the same thing as the other is very hard. This requires digital image processing.
An approach is to scale down all images to a certain width (say 100px). Then check a few coordinates for the color. If another image matches a big part (say 80%), it might be the same image.
But if the image is lighter... this won't work.

Categories