JohannesBuchner / imagehash

A Python Perceptual Image Hashing Module
BSD 2-Clause "Simplified" License
3.17k stars 328 forks source link

[Question] Why use ITU-R 601-2 for grayscaling? #104

Closed m0rtalis closed 4 years ago

m0rtalis commented 4 years ago

Hi all, is there any particular reason to use the ITU-R 601-2 transform to convert an image to grayscale? I'm currently writing on my master thesis and noticed that most perceptual hashing algorithm use either that or the ITU-R 709 to convert images instead of other methods. I couldn't find any reason behind this and Kanan et. al. suggests in "https://doi.org/10.1371/journal.pone.0029740" that other methods might be better suited.

So is there any particular reason for it or was it just convenience?

JohannesBuchner commented 4 years ago

As far as I can tell, all of these methods are heuristics and somewhat arbitrarily chosen.

m0rtalis commented 4 years ago

Yes that's probably true. But was the conversion to grayscale here with image.convert("L").resize((hash_size, hash_size), Image.ANTIALIAS) also chosen arbitrarily or did you have a particular reason for it?

JohannesBuchner commented 4 years ago

I am unfamiliar with the IDs you mention. How would the other one be implemented in pillow? I think the answer is "it seems to work sufficiently and the other choices seem more critical".

m0rtalis commented 4 years ago

Ok thank you. I guess that was the answer I was looking for. Was just wondering if there was some reasoning behind it I just don't know but I guess not :) Thanks for your time