All Projects → poslegm → scala-phash

poslegm / scala-phash

Licence: MIT license
Image comparison by hash codes

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to scala-phash

dhash-vips
vips-powered ruby gem to measure images similarity, implementing dHash and IDHash algorithms
Stars: ✭ 75 (+368.75%)
Mutual labels:  image-comparison, perceptual-hashing
pikt
🎨 Image-based poetic programming language.
Stars: ✭ 72 (+350%)
Mutual labels:  images
AdversarialBinaryCoding4ReID
Codes of the paper "Adversarial Binary Coding for Efficient Person Re-identification"
Stars: ✭ 12 (-25%)
Mutual labels:  hashing
sdbm
SDBM non-cryptographic hash function
Stars: ✭ 43 (+168.75%)
Mutual labels:  hashing
Floral
Minimal design gallery app for Android.
Stars: ✭ 23 (+43.75%)
Mutual labels:  images
Data-Structures-Algorithms-Handbook
A series of important questions with solutions to crack the coding interview and ace it!
Stars: ✭ 30 (+87.5%)
Mutual labels:  hashing
CryptoManana
An Advanced PHP Cryptography Framework
Stars: ✭ 15 (-6.25%)
Mutual labels:  hashing
py-rfc2397
A Python RFC2397 ("data url") implementation
Stars: ✭ 16 (+0%)
Mutual labels:  images
ImageOnMap
Repo for ImageOnMap, a bukkit plugin created to display any image using a map
Stars: ✭ 162 (+912.5%)
Mutual labels:  images
mqttorg-graphics
Graphics and branding for the MQTT website
Stars: ✭ 21 (+31.25%)
Mutual labels:  images
img
A python library to display images in the terminal
Stars: ✭ 55 (+243.75%)
Mutual labels:  images
batch-transforms
Batch equivalent of PyTorch Transforms.
Stars: ✭ 33 (+106.25%)
Mutual labels:  images
metrohash-rs
Rust MetroHash
Stars: ✭ 45 (+181.25%)
Mutual labels:  hashing
vue-piece-slider
animated slides in a fragmented look 🐞🌳✡️📐
Stars: ✭ 95 (+493.75%)
Mutual labels:  images
ksoftapi.py
Official API Wrapper for KSoft.Si API
Stars: ✭ 31 (+93.75%)
Mutual labels:  images
etiketai
Etiketai is an online tool designed to label images, useful for training AI models
Stars: ✭ 63 (+293.75%)
Mutual labels:  images
image-zoom
smooth, iOS/medium.com style thumbnail viewing
Stars: ✭ 35 (+118.75%)
Mutual labels:  images
hes-gallery
Light, dependency free, responsive gallery script
Stars: ✭ 27 (+68.75%)
Mutual labels:  images
image-compressor
Frontend javascript module for resizing and compressing images
Stars: ✭ 41 (+156.25%)
Mutual labels:  images
rid-covid
Image-based COVID-19 diagnosis. Links to software, data, and other resources.
Stars: ✭ 74 (+362.5%)
Mutual labels:  images

Scala pHash

Build Status Maven

Scala fork of pHash library. This library identifies whether images are similar. You can try it at demo page.

Original pHash uses CImg library for image processing but I could not find CImg for jvm. Therefore I use java.awt and self-made functions for image processing. Consequently, results of my library is different from original phash.

How to use

My library implements three Perceptual Hashing algorithms: Radial Hash, DCT hash and Marr hash. More info about it.

sbt dependencies

libraryDependencies += "com.github.poslegm" %% "scala-phash" % "1.2.2"

API

There is three functions for each hashing algorithm. Let's consider them by example of DCT hash:

  • def dctHash(image: BufferedImage): Either[Throwable, DCTHash] ― compute image's hash;
  • def unsafeDctHash(image: BufferedImage): DCTHash ― compute image's hash unsafely (danger of exception);
  • def dctHashDistance(hash1: DCTHash, hash2: DCTHash): Long ― compare hashes of two images.

Similar functions written for Marr and Radial Hash algorithms.

All public api with scaladocs decsribed in object PHash.

Example

import scalaphash.PHash._
import javax.imageio.ImageIO

val img1 = ImageIO.read(new File("img1.jpg"))
val img2 = ImageIO.read(new File("img2.jpg"))

val radialDistance: Either[Throwable, Double] = for {
  img1rad <- radialHash(img1)
  img2rad <- radialHash(img2)
} yield radialHashDistance(img1rad, img2rad)

radialDistance.foreach {
  case distance if distance > 0.95 => println("similar")
  case _ => println("not similar")
}

radialDistance.left.foreach(e => println(e.getMessage))

Radial distance is more when images are similar. DCT and Marr distances are less when images are similar. Recommended to make a decision on image similarity when at least two hashes pass thresholds.

radial: 0.9508017124330319
dct: 13
marr: 0.5052083333333334

radial: 0.3996241672331173
dct: 41
marr: 0.4704861111111111

Warning

My results is not compatible with original pHash. Use original library if you have an opportunity.
Also, it works much slower than c++ version (about 5-7 times).

Thanks

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].