compare_similarities_two_images: Compare similarities between two images

View source: R/compare_similarities_two_images.R

compare_similarities_two_imagesR Documentation

Compare similarities between two images

Description

Uses magick to compare the similarities between the different sections of the images.It computes the absolute error and the perceptual hash of each pairwise comparison. Measures such as fuzz, root mean squared error are also available as optional measures.

Usage

compare_similarities_two_images(rv)

Arguments

rv

a list provided by user input containing the paths to the two images being compared, whether the images must be streteched to the maximum width and height of the two images, the number of sections into which the width and height must be split, and the number of resizes.

Value

A csv file containing the results

Note

This is part of a suite of functions required to compare images.

Author(s)

Kurinchi Gurusamy

References

https://sites.google.com/view/equal-group/home

See Also

pairwise_comparison() compare_similarities_same_image()

Examples

# Create a plot and save this as file
filename_1 <- tempfile(fileext = ".png")
png(filename_1, width = 300, height = 450, units = "px")
plot.new()
hist(rnorm(100))
recordPlot()
dev.off()
# One more plot for comparison
filename_2 <- tempfile(fileext = ".png")
png(filename_2, width = 300, height = 450, units = "px")
plot.new()
boxplot(rnorm(100))
recordPlot()
dev.off()

# Create a list to simulate the uploads of shiny app
rv <- {list(
  file_upload_image_1 = cbind.data.frame(datapath = ""), 
  file_upload_image_2 = cbind.data.frame(datapath = ""), 
  stretch_images = "No", 
  number_of_resizes_between = 1,
  extra_parameters_between = c("fuzz"),
  file_upload_image = cbind.data.frame(datapath = ""), 
  number_of_splits = 3, 
  number_of_resizes_within = 1,
  extra_parameters_within = c("fuzz")
)}
# Allocate the file paths
rv$file_upload_image_1$datapath <- filename_1
rv$file_upload_image_2$datapath <- filename_2

# Perform the function
library(magick)
results <- compare_similarities_two_images(rv)

EQUALCompareImages documentation built on Sept. 9, 2025, 5:35 p.m.