Skip to content

MangoTheCat/visualTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

visualTest

Linux Build Status Windows Build status CRAN RStudio mirror downloads Coverage Status

R package to perform fuzzy comparison of images. The threshold argument allows the level of fuzziness to be compared.

Installation

Until visualTest gets on CRAN, you can install it directly from GitHub with

source("https://install-github.me/mangothecat/visualTest")

Usage

Call getFingerprint to calculate a fingerprint of an image file. You can then use compareWithFingerprint to compare it to the fingerprint of another file. Visually similar files will result similar fingerprints.

library(visualTest)
getFingerprint("mango.png")
#> [1] "FAB5894A8C963369"
getFingerprint("mango2.png")
#> [1] "FAB5894A8C963369"

getFingerprint("cat.jpg")
#> [1] "FA85C13A9865BCCA"

To use visualTest in your test cases, you can store the fingerprint of the desired image, and then compare that to the one generated in the test case.

Because various platforms generate slightly different images, you might need to allow some bits to change when you compare the image to the fingerprint. The default fingerprint is 64 bits long, and here we allow a mismatch of 8 bits:

tmp <- tempfile(fileext = ".png")

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
      pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])

plot of chunk unnamed-chunk-3

dev.copy(png, tmp)
dev.off()
isSimilar(tmp, "BA68E7B3948C8936", threshold = 8)
#> [1] TRUE

License

GPL 2 © Mango Solutions.

About

Fuzzy testing of graphical files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published