mean2

Average or mean of matrix elements

Syntax

B = mean2(A)
gpuarrayB = mean2(gpuarrayA)

Description

B = mean2(A) computes the mean of the values in A.

gpuarrayB = mean2(gpuarrayA) computes the mean of the values in gpuarrayA, performing the operation on a GPU. This syntax requires the Parallel Computing Toolbox™.

Code Generation

mean2 supports the generation of efficient, production-quality C/C++ code from MATLAB. To see a complete list of toolbox functions that support code generation, see List of Supported Functions with Usage Notes.

Class Support

The input image A can be numeric or logical. The output image B is a scalar of class double.

The input image gpuarrayA is a gpuArray whose underlying class is numeric or logical. The output image gpuarrayB is a gpuArray scalar with the underlying class double.

Examples

expand all

Compute the mean of an image

Read image.

I = imread('liftingbody.png');

Compute mean.

val = mean2(I)
val =

  140.2991

More About

expand all

Algorithms

mean2 computes the mean of an array A using mean(A(:)).

See Also

| |

Was this topic helpful?