The perceptual-hashes Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The perceptual-hashes Reference Manual

This is the perceptual-hashes Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 05:31:30 2022 GMT+0.

Table of Contents


1 Introduction

perceptual-hashes

Build Status CI

perceptual-hashes library computes perceptual hashes for images (supported formats include formats supported by imago + jpeg). Perceptual hashes are a measure of similarity between images.

Installation

You can install perceptual-hashes from Ultralisp repository. Add Ultralisp repository to quicklisp (if you haven't already):

(ql-dist:install-dist "http://dist.ultralisp.org/"
                      :prompt nil)

and install perceptual-hashes:

(ql:quickload :perceptual-hashes)

Supported algorithms

The following algorithms are supported:

You can find more information here.

Examples

(defconstant +threshold+ 45
    "The distance between hashes can vary from 0 to (length hash) =
1024. If it is small enough (<= ~45) the images are similar")

(defun images-similar-p (image-name-1 image-name-2)
    (let ((hash1 (perceptual-hashes:ahash image-name-1))
          (hash2 (perceptual-hashes:ahash image-name-2)))
        (< (perceptual-hashes:hamming-distance hash1 hash2)
           +threshold+)))

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 perceptual-hashes

Perceptual hash algorithms for images

Author

Vasily Postnicov <shamaz.mazum@gmail.com>

License

2-clause BSD

Version

0.1

Dependencies
  • imago/pngload (system).
  • jpeg-turbo (system).
  • array-operations (system).
Source

perceptual-hashes.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


3.1.1 perceptual-hashes/perceptual-hashes.asd

Source

perceptual-hashes.asd.

Parent Component

perceptual-hashes (system).

ASDF Systems

perceptual-hashes.


3.1.2 perceptual-hashes/src/package.lisp

Source

perceptual-hashes.asd.

Parent Component

perceptual-hashes (system).

Packages

perceptual-hashes.


3.1.3 perceptual-hashes/src/conditions.lisp

Dependency

src/package.lisp (file).

Source

perceptual-hashes.asd.

Parent Component

perceptual-hashes (system).

Public Interface

3.1.4 perceptual-hashes/src/load-image.lisp

Dependency

src/conditions.lisp (file).

Source

perceptual-hashes.asd.

Parent Component

perceptual-hashes (system).

Internals

read-jpeg-grayscale (function).


3.1.5 perceptual-hashes/src/hashes.lisp

Dependency

src/load-image.lisp (file).

Source

perceptual-hashes.asd.

Parent Component

perceptual-hashes (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 perceptual-hashes

Source

src/package.lisp.

Use List
  • array-operations/all.
  • common-lisp.
  • imago.
  • jpeg-turbo.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: ahash (image)

Return aHash (average hash) of an @c(image) which can be a string, a pathname or an @c(imago:image) object. If @c(image) is a string or a pathname, the image is loaded using this pathname.
This algorithm is based on whenever a pixel is brighter or darker than the average luminance of all pixels.

Package

perceptual-hashes.

Source

src/hashes.lisp.

Function: dhash (image)

Return dHash (gradient hash) of an @c(image) which can be a string, a pathname or an @c(imago:image) object. If @c(image) is a string or a pathname, the image is loaded using this pathname.
This algorithm is based on whenever a pixel is brighter or darker than the neighbour pixels.

Package

perceptual-hashes.

Source

src/hashes.lisp.

Function: hamming-distance (hash1 hash2)

Calculate Hamming distance between two hashes.

Package

perceptual-hashes.

Source

src/hashes.lisp.


5.1.2 Conditions

Condition: hash-error
Package

perceptual-hashes.

Source

src/conditions.lisp.

Direct superclasses
  • error.
  • simple-condition.
Direct subclasses

hash-unknown-format.

Condition: hash-unknown-format
Package

perceptual-hashes.

Source

src/conditions.lisp.

Direct superclasses

hash-error.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Constants

Constant: +thumb-size+

The image will be resized to a small square with a side +thumb-size+ before a hash is calculated.

Package

perceptual-hashes.

Source

src/hashes.lisp.


Previous: , Up: Internals   [Contents][Index]

5.2.2 Ordinary functions

Function: get-image (image)
Package

perceptual-hashes.

Source

src/hashes.lisp.

Function: read-jpeg-grayscale (filename)

Read jpeg image into IMAGO:GRAYSCALE-IMAGE object

Package

perceptual-hashes.

Source

src/load-image.lisp.

Function: thumbnail-pixels (image &optional thumb-size)
Package

perceptual-hashes.

Source

src/hashes.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
C  
Index Entry  Section

+
+thumb-size+: Private constants

C
Constant, +thumb-size+: Private constants

Jump to:   +  
C