The image statistics algorithm performs a two dimensional (2D) operation on the input image with the provided mask image of same dimensions. The mask defines the pixels considered for the operation. The algorithm calculates the per-channel statistics namely pixel count, sum, mean, variance, covariance of the input image masked by the mask image. Both variance and covariance are stored in a single 4x4 covariance matrix, where the diagonal is the variance and the non-diagonal elements are the covariance per-channel, considering 4 maximum number of channels.
The image stats works calculating various per-channel statistics of the input image defined by the mask image. The various statistics that can be calculated have their own flags. The output is stored in an array of type VPI_ARRAY_TYPE_STATISTICS. The user can choose which statistics should be calculated.
VPI_STAT_PIXEL_COUNT - Calculates the number of non-zero pixel values in the mask image.
VPI_STAT_SUM - Calculates the per-channel sum (in float), of all the valid* input image pixels.
VPI_STAT_MEAN - Calculates the per-channel mean (in float), of all the valid* input image pixels. This flag automatically activates the VPI_STAT_PIXEL_COUNT and VPI_STAT_SUM flags.
VPI_STAT_VARIANCE - Calculates the per-channel variance (in float), of all the valid* input image pixels. This flag automatically activates the VPI_STAT_MEAN flag.
VPI_STAT_COVARIANCE - Calculates the inter-channel covariance (in float), of all the valid* input image pixels. This flag automatically activates the VPI_STAT_VARIANCE flag.
*valid - Here valid means the input image pixels that have corresponding non-zero mask pixels.
C API functions
For list of limitations, constraints and backends that implements the algorithm, consult reference documentation of the following functions:
Create the mask image to be used. It must match the dimensions of the input image.. Can be NULL if no mask is required. Has to be of format VPI_IMAGE_FORMAT_U8.