Java library to compare image similarity
You could take a look at two answers on SO itself: this one is about image comparison itself, offering links to stuff in C++ (if I read correctly) while this one offers links to broader approaches, one being in C.
I would suggest starting with the second link since there's links on that discussion that'll lead to implementation code of some relevant techniques which you might be able to "translate" into Java yourself.
That's the best my google skills could do, no Java though - sorry. I hope it's a good starting point!
EDIT:
Here's someone with your problem who wrote his own comparison class in Java. I didn't read the source code though. He expressly states that he couldn't find Java libraries for that purpose either, so that's why he wrote it himself.
Oh, and this question on SO has probably the best links on this, all regarding Java libraries of image processing. Hopefully there's one amongst them that can compare images for similarity.
Ok, last edit:
The Java Image Processing Cookbook shows a Java implementation of a basic algorithm to determine the difference between two pictures. It also has an email to contact the guy who wrote it as well as a host of references. No library though.
EDIT after reading your comment to your question:
Unless you've already checked all of the above links, since what you want seems to be checking whether two images are equal, I would suggest starting with the Java Image Processing Cookbook (since that has an implementation of an algorithm in Java to check for equal images) and the last link to an SO question. Also, check PerceptualImageDiff and the source code of that project (C++); it sounds really nifty - it's apparently supposed to check whether two images look equal to the human visual system.
Comparing image similarity using OpenCV in Java
This is possible in Java, using ASIFT, implemented in OpenImaj library.
Example here
Asift extacts local features from a image and then it's used a matcher in order to detect similar features.
ASIFT online demo here: http://demo.ipol.im/demo/my_affine_sift/
image comparison in java
Check out the OpenCV library.
You can find there exactly what you need. Take a look here for example of how to compare images.
Measure similarity of two images in Java or ImageMagick
You would use ImageMagick like this to compare your two images:
compare -metric ae a.png b.png null:
1161
or, the longer form using convert
convert -metric ae a.png b.png -compare -format "%[distortion]" info:
1161
The -metric ae
means "tell me the absolute error", i.e. the number of pixels that differ between the two images. In this case, the answer is 1161, which is exactly half the pixels, i.e. 50%.
If you specifically want 50% output, you can do the maths on the image dimensions with ImageMagick like this, if you use bash
:
n=$(compare -metric ae a.png b.png null:)
identify -format "%[fx:$n*100/(w*h)]" a.png
or the longer form, using convert
:
n=$(compare -metric ae a.png b.png null:)
convert -format "%[fx:$n*100/(w*h)]" a.png info:
50
If you are dealing with jpg
images (and therefore lossy compression and artefacts) rather than png
images, you may want to add in a fudge factor
of a few percent, using the -fuzz
parameter to allow almost identical pixels to count as being the same:
convert -fuzz 10% -metric ae ....
If you are unfortunate enough to have to use Windows, the way to do the above is arcane and unintelligible, but looks like this:
@echo off
for /f "tokens=1,2,3,*" %%G in ('convert -metric ae a.png b.png -compare -format "%%w %%h %%[distortion]" info:') DO set /a percent=(%%I * 100) /(%%G * %%H)
echo %percent%
How can I compare two images for similarities (Not exact matches with MD5)?
There are two distinct tasks - identify area of interest ( which can be done with Haar cascades - same as face detection ) and recognition of identified image which can be
done with invariant moment techniques (like Hu moments - it was good enough to count soviet tanks on satellite images so it shall be good for pokemons). Nice property of invariant moments is soft degradation of results in case of low quality - you get a list of probability for symbols - like this is 80% pikachu and 30% something else.
We are developing OCR library based on invariant moments for use in android here:
https://sourceforge.net/projects/javaocr/
(
pure java and reasonable speed , and there are android samples in demos subdirectory.
And here is app based on javaocr, it will recognize black on white phone number and dial it: https://play.google.com/store/apps/details?id=de.pribluda.android.ocrcall&feature=search_result#?t=W251bGwsMSwyLDEsImRlLnByaWJsdWRhLmFuZHJvaWQub2NyY2FsbCJd
)
You may also consider some aiming help so user positions symbol to be matched properly
( so first task will use real intellect )
Image processing i.e. matching similar images in java
For image processing I suggest using OpenCV library to get started. It has feature detectors which you can use to detect and find similar objects within an image like this. There are quite a few examples online you can use to perform the function you need. It is a pretty big topic so I can't share a lot, but I hope this can give you a head start :)
Image Similarity Java
Feature Matching Java (Stackoverflow answer)
library that identifies similar images
I came across this fantastic list of software for computer vision: http://www.cs.cmu.edu/~cil/v-source.html
And decided to look at these 2 tools in more detail:
- http://libpuzzle.pureftpd.org/project/libpuzzle
- http://appsrv.cse.cuhk.edu.hk/~jkzhu/felib.html
Related Topics
Can't Make Jackson and Lombok Work Together
No Tests Found with Test Runner 'Junit 4'
List All Files in the Folder and Also Sub Folders
Calling Getters on an Object VS. Storing It as a Local Variable (Memory Footprint, Performance)
Spring Security 5:There Is No Passwordencoder Mapped for the Id "Null"
Filling Combobox from Database by Using Hibernate in Java
How to Dynamically Build a Multi-Dimensional Array in Java
Why Does Java's Java.Time.Format.Datetimeformatter#Format(Localdatetime) Add a Year
Gson: Directly Convert String to JSONobject (No Pojo)
Apache Tomcat Not Showing in Eclipse Server Runtime Environments
How to Get a Index Value from Foreach Loop in Jstl
How to Convert Timestamp to Date in Java
How to Get Which Jradiobutton Is Selected from a Buttongroup
Auto Adjust the Height of Rows in a Jtable
Command Line Progress Bar in Java
How to Redirect to Another Action Class Without Using on Struts.Xml