r/compsci • u/[deleted] • Dec 24 '20
Demonstration of a reverse image search algorithm for detecting transformed images, partial images, and sub-images (link in comments)
35
u/nekokattt Dec 24 '20
So how does it take into account varying resolutions and stuff like shitty JPEG compression artifacts over an image?
Surely if it uses a hash algorithm, (thinking of SHA-256 for example), you'd get wildly different results when you compare them.
Also, how do you know exactly what points to take on the transformed example to get the correct hash for the non transformed image? How does it take into account stuff like varying light or colourspaces?
Genuinely curious, if anyone could ELI5 this for me? Audiovisual processing isn't my strong point
47
Dec 24 '20 edited Dec 24 '20
Instead of a cryptographic hash like SHA-256, a perceptual hash is used for comparing the similarity of images. In this case they use pHash. Here is an explanation of how a perceptual hash works.
It generates the keypoints using an edge detection algorithm.
7
2
u/merlinsbeers Dec 25 '20
How badly does the image have to be warped before the edge detection stops finding the same points?
1
u/ItzWarty Dec 25 '20 edited Dec 25 '20
You expect to have feature points flicker or be subject to noise but that's why the algorithm deals with triplets and leveraged a scale / orientation / affine transformation invariant feature detector. It's common in some other algorithms to then compute a mapping (homography) from one image to another to compute how many points match up from one image to another, and then from there you can compute a best fit on matched points to further refine your result.
3
u/FrAxl93 Dec 24 '20
How does the hash work? What if the image in the database is stored with a different color map or maybe same color map but different brightness/contrast/whatever? Equal hash means that they are equal at a bit level.
Edit: u/nekokattt has already asked this and an answer was provided :)
8
Dec 24 '20
It's a perceptual hash. Similar images (different color, compression artifacts, slight cropping, etc) have similar hashes.
4
u/hawkinsst7 Dec 25 '20
I feel like "most" people are most familiar with Crypto hashes (they get all the publicity) but there are whole worlds of other areas of cs that is, in many ways, harder and interesting
2
u/Empty_Direction_3102 Dec 24 '20
So that’s how repostsleuthbot works. Nice
6
Dec 24 '20
Kinda, but not this complicated. I'm pretty sure it's just generating a single perceptual hash for the entire image.
57
u/liveloveslaughter Dec 24 '20
I have often wondered how reverse searching works. Thanks for posting!
17
1
Dec 24 '20
Its really wonky when they start doing this for audio.
Wont just be able to slightly alter pitch or duration anymore to avoid detection
3
Dec 24 '20
I think that's already being done, for things like Shazam, or for Youtube's copyright detection system.
1
u/_w1kke_ Dec 25 '20
Do you know of an open source implementation for audio?
2
Dec 25 '20
https://github.com/worldveil/dejavu
https://github.com/dpwe/audfprint
https://github.com/AddictedCS/soundfingerprinting
(you can find more by searching for "audio fingerprint")
2
3
2
2
1
1
u/rspktprvcybee Dec 25 '20
That’s amazing you figured that out. Explain what interested you in finding algorithms or hash cryptography or other secret math and why hide it in ways so secretive? It would be perfect for a crook like a money laundering thief who are usually the ones with that kind of time to invest brain power like that or i bet you’re a genius. That’s it I bet you’re super clever.
1
19
u/[deleted] Dec 24 '20
online demo: https://pippy360.github.io/transformationInvariantImageSearch/
github: https://github.com/pippy360/transformationInvariantImageSearch/
Does anyone know of other algorithms for sub-image detection, or papers on the subject?