Say you have two images:
and
These pictures are nearly identical save for a few pixels that are different colors. Is there a native way in Objective-C to identify if two pictures are nearly identical? If not, is there another way to do it?
Say you have two images:
and
These pictures are nearly identical save for a few pixels that are different colors. Is there a native way in Objective-C to identify if two pictures are nearly identical? If not, is there another way to do it?
My suggestion for identifying if two images are nearly identical is doing a pixel by pixel comparison between both images and keeping track of the similarities as a percentage (or difference since you want to determine if two images are "nearly identical" and the amount of processing/operations for determining differences would be less compared to determining similarities).
Furthermore this is all subjective. Are you referring to "nearly identical" on a pixel level or human eye level? Hope this was helpful :)
In computer vision and image processing the definition for nearly identical can vary a lot from application to application, therefore the method to calculate similarity/identity will also vary depending on the problem at hand.
In your case it seems that the images have identical resolutions and you are just interested in the number of pixels that are different.
I would suggest that you iterate over both images and XOR the pixel values (if they are identical, the result will be zero).
No, there is definitely no native way to do that in Objective-C – I mean no explicit method on e.g. NSImage
. but you can surely do it the hard way, comparing pixel to pixel etc.
Also there is no clear definition of "identical", since two images can seem identical for the human eyes, but can be totally different from another point of view.
Regarding your question which you added in your edit:
There is for example OpenCV, which can do a lot of stuff you could use. Have a look at it OpenCV
…and also there is another nice discussion here on StackOverflow: Image Comparison - fast algorithm