getFingerprint: Get Image Fingerprint

Description Usage Arguments Details Examples

View source: R/getFingerprint.R

Description

Get a fingerprint of an image, that does not depend on the fine details of the image. The fingerprint can be used to compare images generated on different machines, platforms, etc. It supports PNG, JPG and BMP images currently.

Usage

1
getFingerprint(file, algorithm = c("dct", "original"))

Arguments

file

single character naming PNG, JPG or BMP file from which to get fingerprint. It can also be a gzip compressed file with extension .gz.

algorithm

fingerprint algorithm. Possible values: original, dct. See details below.

Details

It implements two algorithms. The default algorithm uses a Discrete Cosine Transform (DCT). It first resizes both images into 64x64 size to speed up further calculations. Then it calculates the DCT of both images, takes the top-left 8x8 cells of the DCT, and calculate the difference to the median DCT for both. The result is a 64-bit string represented as a hexadecimal string. The algorithm is similar to and inspired by phash (http://www.phash.org/) and imagehash (https://github.com/jenssegers/imagehash).

The original algorithm calculates the Fast Discrete Fourier Transform of both images, columnwise. Then it takes the imaginary parts of the results, sums them up rowwise, and checks when the sums switch sign.

Examples

1
2
3
getFingerprint(
  system.file(package = "visualTest", "compare", "stest-00.jpg.gz")
)

MangoTheCat/visualTest documentation built on May 7, 2019, 2:24 p.m.