create_signature: Generate unique images signatures for an image vector

View source: R/create_signature.R

create_signatureR Documentation

Generate unique images signatures for an image vector

Description

create_signature takes a vector of image or file paths and generates "perceptual hashes" which allow similar images to be matched with each other.

Usage

create_signature(image, rm_black_bars = TRUE, ...)

## S3 method for class 'matchr_image'
create_signature(image, rm_black_bars = TRUE, quiet = FALSE, ...)

## S3 method for class 'character'
create_signature(
  image,
  rm_black_bars = TRUE,
  backup = TRUE,
  quiet = FALSE,
  ...
)

Arguments

image

Vector of class matchr_image (imported using load_image), or character vector of file paths or URLs which can be imported to matchr_image using load_image.

rm_black_bars

Logical scalar. Should horizontal black bars be detected and removed from the image signature? Because these bands lead to an image signature dominated by black values, leaving them in the signature can lead to false positive matches.

...

Additional arguments passed to methods.

quiet

A logical scalar. Should the function execute quietly, or should it return status updates throughout the function (default)?

backup

A logical scalar. Should the function store an ongoing backup of progress in a hidden object .matchr_env$sig_backup in the package's environment (default)? If TRUE, the function will attempt to resume progress if it detects a previous backup, and it will remove the backup if the function successfully completes. Backups can be removed with remove_backups.

Details

Images are down-sampled to 8x8 greyscale bitmaps and passed through a discrete cosine transformation, from which 128-bit signatures are calculated. These signatures can identify a given image even if the image is rescaled or compressed, and thus serves as a reliable indicator of whether two images are the same.

Value

A vector of class matchr_signature of the same length as the input vector.

Examples

## Not run: 
# Import image with load_image then create signature
img <- load_image(test_urls)
create_signature(img)

# Or create signature directly from path/URL
create_signature(test_urls)

# By default top/bottom black bars are removed, but leave them with rm_black_bars = FALSE
create_signature(img, rm_black_bars = FALSE)

## End(Not run)

UPGo-McGill/matchr documentation built on July 19, 2023, 1:02 p.m.