wittenbe / Hearthstone-Image-Recognition

A twitch.tv bot to extract card/class data for automated scoring and other shenanigans
GNU General Public License v2.0
93 stars 15 forks source link

Perceptual Hash implementation #4

Open remcoros opened 10 years ago

remcoros commented 10 years ago

I'm currently writing a stats tracker / recognizer in C#.

After looking closely at the original phash implementation and reading about some theory, It seems they extract the Y (luma) component from the image instead of just converting it to a grayscale.

Your code: cv::cvtColor(image, temp1, CV_BGR2GRAY);

Reasoning behind this is that the Luma component is more important in recognizing differences in images.

I think using openCv you can convert it to YCbCr and then use cv::split to get the first (0) channel.

I have no clue if this helps for you, but I spend a lot of time optimizing my C# version of the phash (although i'm using different libs, the concept stays the same).

Hope this helps you!

wittenbe commented 10 years ago

From some (limited) testing, it seemed that my current implementation is a bit better (lower hamming distances for similar images, higher for differing ones, by about 1-2 bits) than the demo over at phash.org, but the tests performed were by no means extensive. I'll definitely look into it (albeit much later) Are there any papers or material in general you'd recommend on phash?

remcoros commented 10 years ago

Other then the phash site / http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html and the usual google/code search not really.

I found your recognizer actually just by googling around. I just noticed the difference in use of color channel.

Could also be that luminosity is more important in natural image recognition only rather then computer generated graphics. That may be way you see a slightly better result.

I didn't do too much testing either, just went with the original implementation as I trust they did some research.