Live data from Hacker News

How Perceptual Hashes Work

hackerfactor.com

31–40 of 77 posts

Re: How Perceptual Hashes Work

#31

"With pictures, high frequencies give you detail, while low frequencies show you structure." I have a vague idea of what this means but can someone please explain it in a bit more detail?

I believe he's referring to the DCT transform, in which the image is interpreted as a mixture of sinusoidal waves. Low frequencies then correspond to differences between separate areas of the picture, while high frequencies correspond to texture.

I'm not a big fan of the periodic transforms, but they do have that nice perceptual interpretation.

Re: How Perceptual Hashes Work

#32
post #14
post #11

Earlier quoted context omitted.

That would be a good idea as along as you have a good distance between images (d(image1, image2) small equivalent to image1 and image2 are equivalent). I have little experience in image processing, but this is generally a hard problem with complex signals (as images, music and speech are). Most of what is described in the article concerns dimension reduction, where the goal overlaps with the above.

The article explicitly mentions Hamming distance, which is also what I mean by bit distance.

Yes, but his remarks suggests that hamming distance is not very nice for pictures after his transformation (d(i1, i2) == 5 -> small, d(i1, i2) == 10 -> big). As I am not familiar with image signals, I don't know if this can be somehow mitigated with other techniques. Of course, the only way to be sure would be to actually test it, but I would not bet much on it.

Another issue I forgot to mention is that each "point" (image ) is a k-dimensional vector. Organizing those so that to easily retrieve points which are close to each other quickly becomes intractable. Conventional techniques like kd-trees quickly break down when k is above a few units, because of the curse of dimensionality. This introduces a "non-linearity" in your distance which makes comparing points in a k-dimension space quite different than in 2/3 dimension spaces.

Re: How Perceptual Hashes Work

#33

"With pictures, high frequencies give you detail, while low frequencies show you structure." I have a vague idea of what this means but can someone please explain it in a bit more detail?

Ok, I'll take a shot at this.

Let's work in one dimension rather than two dimensions. It's easy enough to extend later.

You know that a any signal is the sum of a (potentially infinite) number of sine waves. For example, a square wave is the sum of ever higher-frequency (but smaller-amplitude) sine waves.

The higher frequencies are necessary to get the sharp edges.

If you strip the high frequencies, the sharp edges dissapear, leaving only the larger motions of the lower-frequency (yet bigger amplitude) waves.

So the low frequencies are the hill, and the high frequencies are the grass.

Does that make sense?

Edit: Here's an image: http://cnx.org/content/m0041/latest/fourier4.png

Re: How Perceptual Hashes Work

#34
If you're interested in this article, then you may interested in locality sensitive hashing (LSH), a randomized hash that has been used seemingly everywhere. I recently used it to speed up music source separation (papers pending).

The idea is similar to the one mentioned in this article, but more general. Unlike a cryptographically secure hash where x != y implies that h(x) != h(y) (collisions aside), LSH says that if x and y are "near", then P(h(x) = h(y)) is "high". This quality is important when doing robust similarity search. For example, if your image is noisy or rotated or scaled, you hope that you can still find the clean version in a database.

LSH has been used in many application domains including images, video, music, text, bioinformatics, and more. LSH is not directly comparable to a feature extraction algorithm such as SIFT.

[Edited for clarity.]

Re: How Perceptual Hashes Work

#36

I have a feeling there is a deep connection between perceptual hashes and compressed sensing. Could someone more familiar with the latter weigh in?

Kinda sorta not really. Compressed sensing and sparse coding show that, under certain sparsity assumptions, you can perfectly reconstruct your original data with fewer bits than previously thought. It is a coding principle.

Perceptual hashes (or hashes in general) are used for fast indexing and retrieval. You cannot recreate the original data from a hash, pretty much by definition.

So hashes and coding algorithms both provide smaller representations of data. But hashes are used for indexing and do not provide the original data, or even an approximation thereof, while compressed sensing can.

Re: How Perceptual Hashes Work

#37
post #33

"With pictures, high frequencies give you detail, while low frequencies show you structure." I have a vague idea of what this means but can someone please explain it in a bit more detail?

Ok, I'll take a shot at this. Let's work in one dimension rather than two dimensions. It's easy enough to extend later. You know that a any signal is the sum of a (potentially infinite) number of sine waves. For example, a square wave is the sum of ever higher-frequency (but smaller-amplitude) sine waves. The higher frequencies are necessary to get the sharp edges. If you strip the high frequencies, the sharp edges d…

Thanks, that is a bit more helpful.

Re: How Perceptual Hashes Work

#38

"With pictures, high frequencies give you detail, while low frequencies show you structure." I have a vague idea of what this means but can someone please explain it in a bit more detail?

In short, a wave with a high frequency has a short wavelength, and vice-versa.

The Discrete Cosine Transform is a variant of a 2-dimensional Fourier Transform. The 1-D version of a Fourier Transform is what we use to break a signal, like a sound wave, into its constituent frequencies. It takes as input the wave amplitude at various times, and returns amplitudes for various frequencies. If you were to take waves of those frequencies and amplitudes, and add them together, you would get back the original sound wave you started with. (I'm hand-waving away a bunch of details like phase, boundary conditions, undersampling, and overtones--but this is the general idea.)

You can make the Fourier Transform and its relatives deal with images the same way as sound, by pretending that the image is periodic, i.e. that you are tiling an infinite wall with copies of that image. You could create this same wall by overlaying waves of color on top of each other. The Fourier Transform will find these waves, the same way it found the frequencies for the sound.

With sound, low frequency = slow vibration = long wavelength (imagine an oscilliscope). High frequency = rapid vibration = short wavelengths. So if you were to try yo draw a picture using waves instead of a brush, you would use low frequencies for large things like a head. You would use medium frequencies to add smaller objects like eyes. You would use high frequencies to give small details, like hair or freckles, or the specific shape of a specific person's head.

Re: How Perceptual Hashes Work

#39

If you're interested in this article, then you may interested in locality sensitive hashing (LSH), a randomized hash that has been used seemingly everywhere. I recently used it to speed up music source separation (papers pending). The idea is similar to the one mentioned in this article, but more general. Unlike a cryptographically secure hash where x != y implies that h(x) != h(y) (collisions aside), LSH says that i…

Thank you for that term. LSH looks like a very useful technique.
Post reply on HN