Calculate the entropy of the image

Description

A function that calculates the entropy of the image based on its histogram.

Usage

1
imageEntropy(histogram)

Arguments

histogram

A histogram of the image pixel values, as calculated by the hist() function.

Details

The entropy of an image is a useful indicator of how visually complex the image is.

Value

A value representing the entropy of the image.

Examples

1
2
3
4
5
6
7
library(CulturalAnalytics)
library(jpeg)
imgdir<-paste(system.file(package = "CulturalAnalytics"), "images", sep = "/")
imgs<-paste(imgdir, dir(path = imgdir, pattern = ".jpg"), sep = "/")
img<-readJPEG(imgs[1])
histogram<-hist(imageToIntensity(img), breaks=0:255/255, plot=FALSE)
entropy<-imageEntropy(histogram)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.