{"id":234,"date":"2012-09-06T22:42:01","date_gmt":"2012-09-07T02:42:01","guid":{"rendered":"http:\/\/antoine.wojdyla.free.fr\/blog\/?p=234"},"modified":"2012-09-24T11:11:50","modified_gmt":"2012-09-24T15:11:50","slug":"perceptive-hash","status":"publish","type":"post","link":"http:\/\/antoine.wojdyla.fr\/blog\/2012\/09\/06\/perceptive-hash\/","title":{"rendered":"Perceptive hash"},"content":{"rendered":"<p>Continuing with metrics&#8230;<\/p>Everybody can easily recognize a tune, a famous painting or the face of a friend. Not so for a computer, who must first <em>digitize<\/em> the information, and operate on this dataset to find similarities. Back in the beginning of computer era, people though that it would be   easy to recognize characters or voice, but technology had hard time with   these issues. <a href=\"http:\/\/en.wikipedia.org\/wiki\/Optical_character_recognition\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Optical_character_recognition', 'OCR']);\" >OCR<\/a> is still perfectible, while voice recognition is still not common (things are getting better, but <a href=\"http:\/\/en.wikipedia.org\/wiki\/Siri_%28software%29\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Siri_%28software%29', 'Siri']);\" >Siri<\/a> is still fallible)<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/hellosalut.png\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/hellosalut.png', '']);\" ><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-554\" title=\"hellosalut\" src=\"http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/hellosalut.png\" alt=\"\" width=\"501\" height=\"372\" srcset=\"http:\/\/antoine.wojdyla.fr\/blog\/wp-content\/uploads\/hellosalut.png 619w, http:\/\/antoine.wojdyla.fr\/blog\/wp-content\/uploads\/hellosalut-300x222.png 300w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/a><\/p><!--more--><\/p>This is of particular importance nowadays, since our societies tend to control more and more the population, in the name of terrorism prevention. Since they cannot employ as much operator as there are citizens, there is strong need automation and recognition. The general problem of recognition is to find <em>patterns<\/em> that reflects a <em>feature<\/em>.<\/p>I discovered the notion of &#8220;perceptive hash&#8221;, which is essentially the problem of recognition through the simplification of data, wondering how websites such as <a href=\"http:\/\/www.tineye.com\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/www.tineye.com\/', 'TinEye']);\" >TinEye<\/a>, worked in their way to find similar images. I subsequently discovered that there is an open source library called <a href=\"http:\/\/www.phash.org\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/www.phash.org\/', 'pHash']);\" >pHash<\/a> that allows this kind of features (not to mention computer vision frameworks such as <a href=\"http:\/\/opencv.org\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/opencv.org\/', 'OpenCV']);\" >OpenCV<\/a>, or the incredible <a href=\"http:\/\/code.google.com\/p\/accord\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/code.google.com\/p\/accord\/', 'Accord.net']);\" >Accord.net<\/a> developped by Cesar Souza)<\/p><strong>To find similar pictures<\/strong>, there are serveral hurdles. First : all the pictures might not have the same size, they can be cropped, (slightly) modified\u00a0 or rotated.It seems that there are two solutions. The first consists in a brutal dowsizing of the images, followed by a Fourier transform : the Fourier coefficients will capture the fingerprint of the image (this is somehow similar to how <a href=\"http:\/\/drgoulu.com\/2009\/07\/11\/comment-marche-shazam\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/drgoulu.com\/2009\/07\/11\/comment-marche-shazam\/', 'How Shazam works']);\" >How Shazam works<\/a>) for comparison to a database.<br \/>\nAnother option is consider the histogram instead of the picture, and perform comparision using least-square or <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bhattacharyya_distance\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Bhattacharyya_distance', 'Bhattacharya distance']);\" >Bhattacharya distance<\/a>.<\/p>\n<p style=\"text-align: center;\">\n<div id=\"attachment_559\" style=\"width: 479px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/histo.jpg\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/histo.jpg', '']);\" ><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-559\" class=\"size-full wp-image-559 \" title=\"histogram\" src=\"http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/histo.jpg\" alt=\"\" width=\"469\" height=\"287\" srcset=\"http:\/\/antoine.wojdyla.fr\/blog\/wp-content\/uploads\/histo.jpg 586w, http:\/\/antoine.wojdyla.fr\/blog\/wp-content\/uploads\/histo-300x183.jpg 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/a><\/p>\n<p id=\"caption-attachment-559\" class=\"wp-caption-text\">Size reduction and\/or histograms to find similar images<\/p>\n<\/div><p>I guess this is the one used by TinEye<br \/>\nThese methods are rather robust to slight changes in the image, for there is no information on scale, and because the actual <em>location of pixels <\/em>is erased<em> <\/em>.<br \/>\nNote that Google image search is based on contextual informations, rather than on actual images.<\/p><strong>Face recognition<\/strong> is another problem. First, one has to dectect a face. This is done through machine learning and particulare metrics. I remember (when I used it) that a popular algorithm was<a href=\"http:\/\/en.wikipedia.org\/wiki\/Viola%E2%80%93Jones_object_detection_framework\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Viola%E2%80%93Jones_object_detection_framework', ' Viola-Jones algorithm']);\" target=\"_blank\"> Viola-Jones algorithm<\/a>. The underlying idea is to compute what is called the so-called <a href=\"http:\/\/en.wikipedia.org\/wiki\/Summed_area_table\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Summed_area_table', 'integral image']);\" target=\"_blank\">integral image<\/a>,where each pixel is the some of all the preceding pixels and comparision with Haar basis function. It turns out that a face is (perceptively) the combination of certain Haar functions, the successful combinations being determined by learning. For Faci<em>al<\/em> recognition (i.e. to tell two person apart, in software such as iPhoto or facebook), I don&#8217;t know how they do!<\/p><strong>Spell correction<\/strong> is also a class of feature recognition. A good explanation of how it works is detailed <a href=\"http:\/\/norvig.com\/spell-correct.html\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/norvig.com\/spell-correct.html', 'here']);\" title=\"Spell correction\">here<\/a>. I first thought that the employed method would use specific word weighting, but no : it seems to be only inferences ;-(. I want to mention <a href=\"http:\/\/www.gef.free.fr\/metro.html\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/www.gef.free.fr\/metro.html', 'the map of Paris metro made only with anagrams']);\" >the map of Paris metro made only with anagrams<\/a> which really impressionned me. I still don&#8217;t know how the guy managed to get all these anagrams. Not by hand, I hope!<\/p><a href=\"http:\/\/www.gef.free.fr\/metro.jpg\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/www.gef.free.fr\/metro.jpg', '']);\" ><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-558\" title=\"metro_anagrammes\" src=\"http:\/\/antoine.wojdyla.free.fr\/blog\/wp-content\/uploads\/metro.png\" alt=\"\" width=\"499\" height=\"263\" srcset=\"http:\/\/antoine.wojdyla.fr\/blog\/wp-content\/uploads\/metro.png 499w, http:\/\/antoine.wojdyla.fr\/blog\/wp-content\/uploads\/metro-300x158.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/a><strong>For optical character recognition<\/strong>, they also use neural networks, probably in conjunction with <a href=\"http:\/\/en.wikipedia.org\/wiki\/Wavelets\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Wavelets', 'wavelet']);\" target=\"_blank\">wavelet<\/a> or <a href=\"http:\/\/en.wikipedia.org\/wiki\/Mathematical_morphology\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/en.wikipedia.org\/wiki\/Mathematical_morphology', 'mathematical morphology']);\" target=\"_blank\">mathematical morphology<\/a> to remove all unwanted features. But I never got very deep into that problem&#8230; Can somebody give me information on the state of the art?<\/p>&nbsp;<\/p>I want to mention here the website <a href=\"http:\/\/www.hooktheory.com\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/www.hooktheory.com\/', 'Hook theory']);\" >Hook theory<\/a> (and the companion <a href=\"http:\/\/itunes.apple.com\/us\/book\/hooktheory-music-theory-for\/id533715898?mt=11\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/itunes.apple.com\/us\/book\/hooktheory-music-theory-for\/id533715898?mt=11', 'iPad book']);\" >iPad book<\/a>) which tries to <em>explain<\/em> how music works, emotionnally.<br \/>\nI guess that understanding <em>why<\/em> a feature is the way it is is more sutble than brute-force search for patterns.<br \/>\nEmotion v<em>s<\/em>. Reason. Again<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuing with metrics&#8230;Everybody can easily recognize a tune, a famous painting or the face of a friend. Not so for a computer, who must first digitize the information, and operate on this dataset to find similarities. Back in the beginning of computer era, people though that it would be easy to recognize characters or voice, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,9],"tags":[],"class_list":["post-234","post","type-post","status-publish","format-standard","hentry","category-english","category-epistemology","category-science"],"_links":{"self":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts\/234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/comments?post=234"}],"version-history":[{"count":9,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts\/234\/revisions"}],"predecessor-version":[{"id":557,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts\/234\/revisions\/557"}],"wp:attachment":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/media?parent=234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/categories?post=234"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/tags?post=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}