Finds the most common value in a matrix and returns it.

getBGcol(cnvs)

Arguments

cnvs

A matrix representing a text canvas.

Value

A numeric value corresponding to the the most common value in cnvs.

Details

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.

Author

Dave Braze <davebraze@gmail.com>

Examples

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