imagestats#
- dataeval.metrics.stats.imagestats(images: Iterable[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], flags: ImageStat = ImageStat.ALL_STATS) StatsOutput#
Calculates image and pixel statistics for each image
This function computes various statistical metrics (e.g., mean, standard deviation, entropy) on the images as a whole, based on the specified flags. It supports multiple types of statistics that can be selected using the flags argument.
- Parameters:
images (ArrayLike) – Images to run statistical tests on
flags (ImageStat, default ImageStat.ALL_STATS) – Metric(s) to calculate for each image. The default flag
ImageStat.ALL_STATScomputes all available statistics.
- Returns:
A dictionary-like object containing the computed statistics for each image. The keys correspond to the names of the statistics (e.g., ‘mean’, ‘std’), and the values are lists of results for each image or numpy arrays when the results are multi-dimensional.
- Return type:
StatsOutput
See also
ImageStat,channelstats,Outliers,DuplicatesNotes
All metrics in the ImageStat.ALL_PIXELSTATS flag are scaled based on the perceived bit depth (which is derived from the largest pixel value) to allow for better comparison between images stored in different formats and different resolutions.
ImageStat.ZERO and ImageStat.MISSING are presented as a percentage of total pixel counts
Examples
Calculating the statistics on the images, whose shape is (C, H, W)
>>> results = imagestats(images, flags=ImageStat.MEAN | ImageStat.ALL_VISUALS) >>> print(results.mean) [0.16650391 0.52050781 0.05471802 0.07702637 0.09875488 0.12188721 0.14440918 0.16711426 0.18859863 0.21264648 0.2355957 0.25854492 0.27978516 0.3046875 0.32788086 0.35131836 0.37255859 0.39819336 0.42163086 0.4453125 0.46630859 0.49267578 0.51660156 0.54052734 0.56152344 0.58837891 0.61230469 0.63671875 0.65771484 0.68505859 0.70947266 0.73388672 0.75488281 0.78271484 0.80712891 0.83203125 0.85302734 0.88134766 0.90625 0.93115234] >>> print(results.zeros) [0.12561035 0. 0. 0. 0.11730957 0. 0. 0. 0.10986328 0. 0. 0. 0.10266113 0. 0. 0. 0.09570312 0. 0. 0. 0.08898926 0. 0. 0. 0.08251953 0. 0. 0. 0.07629395 0. 0. 0. 0.0703125 0. 0. 0. 0.0645752 0. 0. 0. ]