The ImageStat Module
The ImageStat module evaluates statistical density configurations across whole canvas buffers or targeted vector paths. Using this module, developers can calculate exposure value properties, average luminance boundaries, or color variances across pixel channels.
Statistical Assessment Code Blueprint
The practical routine below showcases how to initialize a tracking proxy instance, append evaluation mask profiles, and safely parse channel variances:
from PIL import Image, ImageStat
# Load pixel channels into active runtime memory context
with Image.open("sample_matrix.png") as source_surface:
# Example 1: Map complete surface statistics globally
global_metrics = ImageStat.Stat(source_surface)
print(f"Channel Means: {global_metrics.mean}")
# Example 2: Filter processing coordinates using an operational binary mask
with Image.open("bounding_mask.png") as operational_mask:
isolated_metrics = ImageStat.Stat(source_surface, mask=operational_mask)
print(f"Masked Root-Mean-Square (RMS): {isolated_metrics.rms}")
# Example 3: Extract from an isolated histogram array structure directly
custom_histogram = source_surface.histogram()
array_metrics = ImageStat.Stat(custom_histogram)
Functions & Class Constructors
Calculates data matrices for the supplied image target. When providing an operational mask channel parameter, pixel coordinates evaluated with an entry index matching 0 are rejected from final density tabulations.
Populates a statistical data proxy container via a pre-calculated historical pixel listing instead of traversing an active raster target map.
Lazily Evaluated Target Attributes Reference
[R, G, B] matrix footprint). Properties are parsed lazily; computing metrics triggers mathematical execution chains exclusively on a per-request basis.
stat.extrema
Returns the absolute minimum and maximum values found sequentially within each individual layer channel matrix tracker.
stat.count
Returns the total aggregated operational pixel point elements tracked across the specified evaluation region bounds.
stat.sum
Returns the total numeric summation accumulation of all included pixel positions sorted across individual layers.
stat.sum2
Returns the total squared summation value of pixel distributions across each component channel vector.
stat.mean
Returns the true computed arithmetic mean brightness value found within the assessed target coordinates.
stat.median
Returns the exact median layout position derived from sorting the individual localized histogram channel points.
stat.rms
Calculates and returns the precise quadratic mean value configuration (Root-Mean-Square) per channel step.
stat.var
Extracts the underlying numerical variance indicators across targeted structural pixel array fields.
stat.stddev
Returns the absolute mathematical standard deviation metric calculated across each processed layer track.