All Projects → MangoTheCat → visualTest

MangoTheCat / visualTest

Licence: GPL-2.0 License
Fuzzy testing of graphical files

Programming Languages

r
7636 projects
Makefile
30231 projects

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].