machinevisiontoolbox.Image.mean

Image.mean(*args, **kwargs)[source]

Mean value of all pixels

Parameters:
  • args – additional positional arguments to numpy.mean

  • kwargs – additional keyword arguments to numpy.mean

Returns:

mean value

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('flowers1.png')
>>> img.mean()
105.4632164514867
>>> img = Image.Read('flowers1.png', dtype='float32')
>>> img.mean(axis=2)
array([[0.2092, 0.2065, 0.2837, ..., 0.8471, 0.8523, 0.949 ],
       [0.2026, 0.2092, 0.2863, ..., 0.881 , 0.915 , 0.9987],
       [0.2039, 0.2065, 0.2719, ..., 0.7869, 0.9699, 0.9948],
       ...,
       [0.3595, 0.2928, 0.2784, ..., 0.366 , 0.3739, 0.3908],
       [0.3438, 0.2837, 0.2471, ..., 0.3569, 0.3634, 0.3804],
       [0.3216, 0.268 , 0.2353, ..., 0.3386, 0.3529, 0.3686]],
      dtype=float32)
Note:
  • The return value type is the same as the image type.

  • By default the result is a scalar computed over all pixels, if the axis option is given the results is a 1D or 2D NumPy array.

Seealso:

numpy.mean