Compare two images the same or not (iOS)

Possible duplicate:
How to compare one image with another to see if they look like a certain percentage on the iPhone?

I found this code and try to understand it better:

UIImage *img1 = // Some photo; UIImage *img2 = // Some photo; NSData *imgdata1 = UIImagePNGRepresentation(img1); NSData *imgdata2 = UIImagePNGRepresentation(img2); if ([imgdata1 isEqualToData:imgdata2]) { NSLog(@"Same Image"); } 

Will this confirm that image 1 exactly matches image 2? Is this method the best practice or is there a better approach to this?

+4
source share
2 answers

Your code compares two images bit by bit, so yes, this is a 100% comparison.

If you need something faster, you can create a hash from each UIImage and compare the two hashes, as described here .

+5
source

Take a look at this link, it talks about how to sample images to see percent similarity: How to compare one image with another to see if they are similar to a certain percentage on iPhone?

+1
source

All Articles