{"id":13320562,"url":"https://github.com/starkdg/phash","last_synced_at":"2025-03-11T02:31:52.110Z","repository":{"id":60712825,"uuid":"192099564","full_name":"starkdg/phash","owner":"starkdg","description":"open source perceptual hashing library","archived":false,"fork":false,"pushed_at":"2020-10-13T14:33:53.000Z","size":3734,"stargazers_count":16,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-29T19:29:30.693Z","etag":null,"topics":["audio","cpp","image","open-source","perceptual-hashing"],"latest_commit_sha":null,"homepage":"https://phash.dev/product/phashgpl","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starkdg.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-15T16:20:31.000Z","updated_at":"2024-05-23T15:59:05.000Z","dependencies_parsed_at":"2022-10-03T16:00:30.075Z","dependency_job_id":null,"html_url":"https://github.com/starkdg/phash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkdg%2Fphash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkdg%2Fphash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkdg%2Fphash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkdg%2Fphash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starkdg","download_url":"https://codeload.github.com/starkdg/phash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242959438,"owners_count":20212979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","cpp","image","open-source","perceptual-hashing"],"created_at":"2024-07-29T18:36:14.801Z","updated_at":"2025-03-11T02:31:52.104Z","avatar_url":"https://github.com/starkdg.png","language":"C++","readme":"# pHash\u0026trade; Perceptual Hashing Library\n\npHash is a collection of perceptual hashing algorithms for image,\naudo, video and text media.  \n\n## Installation\n\nBuild and install like so:\n\n```\ncd \u003cproject-dir\u003e\ncmake .\nmake\nsudo make install\n```\n\nTo run tests:\n\n```\nctest\n```\nLook at the tests in the tests/ folder to see how they are used.\n\n\nThe build can exclude various hashing algorithms by passing\nthe variables USE_IMAGE_HASH, USE_AUDIO_HASH, USE_VIDEO_HASH\nOR USE_TEXT_HASH to cmake program: `cmake -DUSE_IMAGE_HASH=1`\n\nThe Windows build currently does not work.  If anyone manages to\nget it to work, please send a pull request with the changes.\n\n\n## Image Hashing\n\nThere are four image hash algorithms in the pHash librarie.\n\n1. DCT image hash\\\n   A 64-bit binary hash based on the global discrete cosine transform (dct)\n   of the image.  Comparisons are made by calculating the hamming distance,\n   or the number of places where the bits differ, between two hashes.\n\n2. Radial Image Hash\\\n   A perceptual hash based on the variances of pixels taken from strips of\n   various angles across the center of the image.\n   \n3. MH Image hash\\\n   Based on the mexican hast wavelet function.\n   \n4. BMB Image Hash - Box-Mean-Binarized Hash\\\n   The image is divided up into 16x16 pixel-sized boxes.  The\n   mean value is calculated for each box in the gird, and a binarized\n   hash is formed based on each mean value with respect to the median\n   of those mean values. A basic hamming distance is used to compute\n   distances.\n\nThere is an example program in `examples/imghash.cpp` to evaluate the\nimage hashes. Basically, it takes two directories of image files.  One\ndirectory must be an exact replica of the other except for a specific\ndistortion applied to the images in one of the directories.  The\noriginal/distorted pairs must have the same filename.\n\nThe program calculates the image hashes for each pair of images and\ncomputes the distance.  A histogram of these distances is then plotted.\n\nAs a point of reference, a histogram of distances between the image\nhashes of random dissimilar images is also plotted.  The peaks of the two histograms\nshould exhibit good separation. The program, imghash prints out the two histograms\nto an output file.  This file can then be used by a tool such as gnuplot to plot\nthe histograms.\n\nHere is a python script for processing a test set of image files:\n[test set of image files](https://github.com/starkdg/pyConvnetPhash/blob/master/preprocess_image_files.py)\n\n\nRun `./imghash --help` to show a list of options to provide.\n\n\n### Results\n\nTest results for the image hashes can be summed up in the following table. To conduct the test,\nan assortment of about one hundred natural images was amassed.  The distorted replicas were then\ncreated by the above script.  The entries in the table represent the percentage of similar distances\nthat fall above the threshold values.  The threshold values are set to be the average dissimilar distance\nminus one and two standard deviations.  Values close to zero indicate the hashes ability to distinguish\nbetween similar and wholely different images for that particular distortion.  \n\n![image hash test result](https://github.com/starkdg/phash/raw/master/resources/imghash-test-results.png \"image phash tests\")\n\nAs you can see, the distortions proving the toughest are rotation, shear, crop, horizontal and vertical flip.  The dct image\nhash offers fairly good results - especially given that it is only 64 bits of information.  The 32-byte length BMB hash offers\nsome modest improvements.  \n\nThe radial hash disappoints with a further degradation in the bright, dark and histogram equalization distortions.\n\n## Audio Hash\n\nAn audio hash is included here for completeness.  There is a fuller java\nimplementation here: [JPHashAudio](https://github.com/starkdg/JPhashAudio)\n\n## Video Hash\n\nA video hash is included, although admittedly a bit buggy.  A fuller c++\nimplementation is available here: [ClipSeekr](https://github.com/starkdg/clipseekr)\n\n## Text Hash\n\n\n\n\n## Requirements for Example Programs\n\nBoost 1.70.0 - Only the filesystem, system and program_options libraries.\n\n\n## Requirements for Image Hash\n\nCImg v.6.6 (included) \\   \nlibtiff-dev (optional) \\\nlibpng-dev (optional) \\\nlibjpeg-dev (optional)\n\n\n## Requirements for Video Hash\n\nffmpeg v2.8.15 \"feynman release\" \\\n  libavformat \\\n  libavcodec \\\n  libavswscale\n\n## Requirements for Audio Hash\n\nlibsndfile v1.0.27 \\\nlibsamplerate v0.1.8 \\\nlibmpg123 v1.23.8 (optional) \\\nlibvorbis v1.3.5 (optional) \\\nlibogg v1.3.2 (optional)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkdg%2Fphash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarkdg%2Fphash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkdg%2Fphash/lists"}