All Projects → westonplatter → Phashion

westonplatter / Phashion

Licence: mit
Ruby wrapper around pHash, the perceptual hash library for detecting duplicate multimedia files

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Phashion

CRC4Docker
Python scripts for the textbook "Image Analysis, Classification and Change Detection in Remote Sensing, Fourth Revised Edition"
Stars: ✭ 84 (-87.61%)
Mutual labels:  image-analysis
image-checker
Provides image optimisation information within the browser
Stars: ✭ 14 (-97.94%)
Mutual labels:  image-analysis
Resnetcam Keras
Keras implementation of a ResNet-CAM model
Stars: ✭ 269 (-60.32%)
Mutual labels:  image-analysis
DICOMautomaton
A multipurpose tool for medical physics.
Stars: ✭ 35 (-94.84%)
Mutual labels:  image-analysis
objectfit-focalpoint
Generate the object-position value to capture an image's focal point given a custom aspect-ratio.
Stars: ✭ 14 (-97.94%)
Mutual labels:  image-analysis
BoneJ2
Plugins for bone image analysis
Stars: ✭ 17 (-97.49%)
Mutual labels:  image-analysis
PSCognitiveService
Powershell module to access Microsoft Azure Machine learning RESTful API's or Microsoft cognitive services
Stars: ✭ 46 (-93.22%)
Mutual labels:  image-analysis
Itkwidgets
Interactive Jupyter widgets to visualize images, point sets, and meshes in 2D and 3D
Stars: ✭ 338 (-50.15%)
Mutual labels:  image-analysis
pyslide
Digital Pathology Whole Slide Image Analysis Toolbox
Stars: ✭ 38 (-94.4%)
Mutual labels:  image-analysis
Menyoki
Screen{shot,cast} and perform ImageOps on the command line 🌱 🏞️
Stars: ✭ 255 (-62.39%)
Mutual labels:  image-analysis
noflo-image
Image processing components for NoFlo.
Stars: ✭ 14 (-97.94%)
Mutual labels:  image-analysis
phoenix
phoenix is a small command line image forensics tool
Stars: ✭ 39 (-94.25%)
Mutual labels:  image-analysis
TrackMate
TrackMate is your buddy for your everyday tracking.
Stars: ✭ 82 (-87.91%)
Mutual labels:  image-analysis
MPoL
A flexible Python platform for Regularized Maximum Likelihood imaging
Stars: ✭ 21 (-96.9%)
Mutual labels:  image-analysis
Image Similarity
计算图片之间的相似度
Stars: ✭ 292 (-56.93%)
Mutual labels:  image-analysis
python-bioimage-analysis-tutorial
The new and improved 2018 version of the EMBL Python BioImage Analysis Tutorial. Now finally in python 3!
Stars: ✭ 41 (-93.95%)
Mutual labels:  image-analysis
amazon-rekognition-engagement-meter
The Engagement Meter calculates and shows engagement levels of an audience participating in a meeting
Stars: ✭ 49 (-92.77%)
Mutual labels:  image-analysis
Simpleitk
SimpleITK: a layer built on top of the Insight Toolkit (ITK), intended to simplify and facilitate ITK's use in rapid prototyping, education and interpreted languages.
Stars: ✭ 458 (-32.45%)
Mutual labels:  image-analysis
Amazon Rekognition Video Analyzer
A working prototype for capturing frames off of a live MJPEG video stream, identifying objects in near real-time using deep learning, and triggering actions based on an objects watch list.
Stars: ✭ 309 (-54.42%)
Mutual labels:  image-analysis
imagetotext.app
Copy text from the raster images online
Stars: ✭ 46 (-93.22%)
Mutual labels:  image-analysis

Phashion

Build Status

Phashion is a Ruby wrapper around the pHash library, "perceptual hash", which detects duplicate and near-duplicate multimedia files (e.g. images, audio, video, though Phashion currently only supports images.). "Near-duplicates" are images that come from the same source and show essentially the same thing, but may have differences in such features as dimensions, bytesizes, lossy-compression artifacts, and color levels.

See an overview of Phashion on Mike's blog.

Installation

You install it just like any other Ruby gem:

gem install phashion

Phashion is somewhat involved to install as it has a few dependencies. Phashion wraps these dependencies into a custom tarball that is built locally just for this gem so you don't have to do anything special. Look in the ext/phashion_ext folder for more details.

Compatibility

Because of this complexity, it is possible the gem install will fail on your platform. Phashion has been tested on:

  • Mac OSX 10.6
  • Mac OSX 10.9
  • Ubuntu 8.04
  • Ubuntu 12.04

Please open a GitHub issue if you have installation problems.

Prerequisites

Linux

  • libjpeg-dev
  • libpng-dev

Mac

  • imagemagick
  • libjpeg (Hombrew, brew install libjpeg; Macports, port install jpeg)
  • libpng (Hombrew, brew install libpng; Macports, port install libpng)

Common Errors

  • ld: library not found for -ljpeg – Did you install libjpeg?
  • ... sh: convert: command not found; sh: gm: command not found – Did you install imagemagick?
  • ... checking for sqlite3ext.h... *** extconf.rb failed *** ... – Did you install libpng-dev and/or libjpeg-dev?

Usage

Testing if one image is a duplicate of another

require 'phashion'
img1 = Phashion::Image.new(filename1)
img2 = Phashion::Image.new(filename2)
img1.duplicate?(img2)
# --> true

Optionally, you can set the minimum Hamming distance in the second argument, an options Hash:

img1.duplicate?(img2, :threshold => 5)
# --> true

img1.duplicate?(img2, :threshold => 0)  
# --> false

Finding the Hamming distance between two images

require 'phashion'
img1 = Phashion::Image.new(filename1)
img2 = Phashion::Image.new(filename2)
img1.distance_from(img2)  
# --> 6

Threshold for dupe-detection

Currently, the maximum Hamming distance between two duplicate images is set at 15. As per mperham's explanation:

A “perceptual hash”is a 64-bit value based on the discrete cosine transform of the image’s frequency spectrum data. Similar images will have hashes that are close in terms of Hamming distance. That is, a binary hash value of 1000 is closer to 0000 than 0011 because it only has one bit different whereas the latter value has two bits different. The duplicate threshold defines how many bits must be different between two hashes for the two associated images to be considered different images. Our testing showed that 15 bits is a good value to start with, it detected all duplicates with a minimum of false positives.

As a reference point, here are the Hamming distances in these test comparisons using /test/jpg/Broccoli_Super_Food.jpg as the source image:

Variation Hamming distance
JPG to PNG 0
Lossy JPG (Photoshop Save for Web quality = 20) 0
Thumbnail (from 500px to 100px) 2
Color correction (saturation +20 w auto-correct) 2
Black and white 2
Extraneous whitespace cropped (500x349 to 466x312) 12
A sloppy rotation of 5 degrees clockwise 14
Horizontally-flipped 32

Gem uses customized pHash 0.9.6

In order to detech duplicate alpha PNGs, the gem uses a custom version of pHash 0.9.6. The customization is limited to only these changes, westonplatter/[email protected]. The gem will be moving back to the pHash master branch once it supports detection of alpha PNG file types.

Testing

To run the test suite:

$ cd phashion
$ bundle install
$ rake compile
$ rake test

Author

Mike Perham, http://mikeperham.com, http://twitter.com/mperham, mperham AT gmail.com

Copyright

Copyright (c) 2010-2014 Mike Perham. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].