compare_images: Compare image pairs in a Shiny app

View source: R/compare_images.R

compare_imagesR Documentation

Compare image pairs in a Shiny app

Description

compare_images takes two sets of images and displays them in pairs for comparison.

Usage

compare_images(
  x, 
  y, 
  match = NULL, 
  batch_size = 100L,
  match_defaults = c(Match = TRUE, `Likely match` = TRUE, 
    `Possible match` = FALSE, `No match` = FALSE), 
  info = NULL, 
  ...
)

Arguments

x, y

A matchr_image, matchr_signature or character vector which contains references to a set of images. If a matchr_image vector, images will be drawn directly from the in-memory pixel information in the vector. If a matchr_signature vector, the images will be retrieved from the file paths or URLs contained in each matchr_signature element. If a character vector, the vector elements will be assumed to be file paths or URLs, from which the images will be retrieved.

match

An optional character vector. Image pairs will be grouped by these values. (If there are more than 10 unique values, the function will issue a warning, since this probably implies that the wrong vector was passed to the argument.)

batch_size

An integer scalar. The number of images to display at a time in the Shiny app (default 100).

match_defaults

A named logical vector. Rows whose match argument value corresponds to a name in this vector will have a starting status of "match" in the comparison app if the named element's value is TRUE and "no match" if it is FALSE. If this argument is NULL, all image pairs will have a starting status of "match".

info

An optional data frame with information to be shown at the top of the comparison app.

...

Additional named vectors which will be displayed per-image pair when the "Show details" button is toggled in the comparison app. These vectors must be the same length as the x and y inputs, and their contents will be truncated to fit in the comparison app, so they should be relatively terse. Names are only to identify ... arguments; they will not be displayed alongside the vector contents. If multiple arguments to ... are supplied, they will be concatenated with "; ".

Details

The interface presents pairs of images alongside a best guess as to the match status ("Match" or "No match"). For matches which are correctly identified, no further action is necessary, while incorrect identifications can be corrected by clicking "Match" or "No match" next to the image pair. Images are presented in batches, and at any point the user can click the "Save and exit" button to close the comparison app and retrieve the results up through the last batch which was viewed. This means that even extremely large sets of potential matches can be manually verified over the course of several sessions. Through the "Enable highlighting" button, specific matches can be highlighted for further follow-up after image comparison is finished.

The match field can contain any character strings, and image pairs will be grouped by these values. (If there are more than 10 unique values for match, the function will issue a warning, since this probably implies that the match field was misidentified.) By default, all image pairs will start with a value of "match" in the comparison app. But if the values of the match field correspond to a name in the function's "match" argument, then the value will be "match" if the corresponding "match" argument value is TRUE, and "no match" if the corresponding "match" argument value is FALSE. For example, by default the "match" argument is: ⁠c("Match" = TRUE, "Likely match" = TRUE, "Possible match" = FALSE⁠. So any image pairs with a match field value of "Match" or "Likely match" will start with a value of "match" in the comparison app, while any image pairs with a match field value of "Possible match" will start with a value of "no match" in the comparison app.

Value

A data frame with the following fields: x and y (or whatever these fields were originally named) from the original df data frame; new_match_status, which is a character vector with possible entries "match" and "no match"; and a logical vector new_highlight which is TRUE for any matches which were highlighted using the in-app interface. The output will only have non-missing new_match_status values for each image pairing that confirmed, which is determined by how many pages into the Shiny app the user proceeded, and thus how many pairings were viewed. Rows with pairings which were not viewed will have an NA value in new_match_status and new_highlight. If all pages are viewed, then the output will have no NA values.

Examples

## Not run: 
# Assign the output of compare_images to retrieve results
change_table <- compare_images(test_urls, test_urls)

## End(Not run)

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