Finds the most common value in a matrix and returns it.
getBGcol(cnvs)
A matrix representing a text canvas.
A numeric value corresponding to the the most common value in cnvs
.
Finds the 'background' value in a matrix, defined as the most common value in a matrix.
Not necessarily intended to be called by the end user.
cnvs <- system.file("extdata/story01.png", package="FDBeye")
cnvs <- png::readPNG(cnvs)
fcnvs <- apply(cnvs, c(1,2), sum) # flatten to a single plane for convenience
getBGcol(fcnvs)
#> Warning: the condition has length > 1 and only the first element will be used
#> [1] 2.729412