Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

phash

calculation of the 'phash' of an image


Description

This function calculates the phash of an image

Usage

phash(
  gray_image,
  hash_size = 8,
  highfreq_factor = 4,
  MODE = "hash",
  resize = "nearest"
)

Arguments

gray_image

a (2-dimensional) matrix or data frame

hash_size

an integer specifying the hash size (hash_size * highfreq_factor should be less than number of rows or columns of the gray_image)

highfreq_factor

an integer specyfing the highfrequency factor (hash_size * highfreq_factor should be less than number of rows or columns of the gray_image)

MODE

one of 'hash' (returns the hash of the image), 'binary' (returns binary identifier of the image)

resize

corresponds to one of 'nearest', 'bilinear' (resizing method)

Details

The function is a modification of the 'phash' function of the imagehash package [ please consult the COPYRIGHT file ]. The phash algorithm extends the average_hash by using the discrete cosine transform.

Value

either a hash-string or a binary vector

Examples

image = readImage(system.file("tmp_images", "2.jpg", package = "OpenImageR"))

image = rgb_2gray(image)

res_hash = phash(image, hash_size = 6, highfreq_factor = 3, MODE = 'hash')

res_binary = phash(image, hash_size = 6, highfreq_factor = 3, MODE = 'binary')

OpenImageR

An Image Processing Toolkit

v1.1.8
GPL-3
Authors
Lampros Mouselimis [aut, cre] (<https://orcid.org/0000-0002-8024-1546>), Sight Machine [cph] (findHOGFeatures function of the SimpleCV computer vision platform), Johannes Buchner [cph] (average_hash, dhash and phash functions of the ImageHash python library), Mohammad Haghighat [cph] (Gabor Feature Extraction), Radhakrishna Achanta [cph] (Author of the C++ code of the SLIC and SLICO algorithms (for commercial use please contact the author))
Initial release
2021-05-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.