img_contrast returns the RMS contrast of an image img. A higher value indicates higher contrast.

img_contrast(img)

Arguments

img

An image in form of a matrix or array of numeric values. Use e.g. img_read() to read an image file into R.

Value

a numeric value (RMS contrast)

Details

The function returns the RMS contrast of an image img. The RMS contrast is defined as the standard deviation of the normalized pixel intensity values. A higher value indicates higher contrast. The image is automatically normalized if necessary (i.e., normalization into range [0, 1]).

For color images, the weighted average between each color channel's values is computed.

References

Peli, E. (1990). Contrast in complex images. Journal of the Optical Society of America A, 7, 2032--2040. doi:10.1364/JOSAA.7.002032

See also

Examples

# Example image with relatively high contrast: berries
berries <- img_read(system.file("example_images", "berries.jpg", package = "imagefluency"))
#
# display image
grid::grid.raster(berries)
#
# get contrast
img_contrast(berries)

# Example image with relatively low contrast: bike
bike <- img_read(system.file("example_images", "bike.jpg", package = "imagefluency"))
#
# display image
grid::grid.raster(bike)
#
# get contrast
img_contrast(bike)