rockverse.voxel_image.Histogram#

class rockverse.voxel_image.histogram.Histogram(image, *, bins=None, region=None, mask=None, segmentation=None)[source]#

Compute and manage histograms, probability density functions (PDFs), cumulative distribution functions (CDFs), and percentiles for VoxelImage data.

This class provides methods to calculate histograms, PDFs, CDFs, and percentiles, with support for regions of interest, masks, and segmentation.

Parameters:
  • image (VoxelImage) – Input image.

  • bins (int or sequence of scalars, optional) – If int, number of equal-width bins in the range of image min and max. If sequence, defines bin edges (including rightmost edge), and ignores values outside bins when calculating the histogram. Default value is 256.

  • region (Region (optional)) – The region of interest in the image. If specified, only voxels within the region will be considered when computing the histogram.

  • mask (Boolean VoxelImage (optional)) – The mask to apply on the image data. If specified, only unmasked voxels will be considered when computing the histogram.

  • segmentation (Unsigned integer VoxelImage (optional)) – The segmentation data for image regions. If specified, histograms will also have individual counts for each segmentation phase.

Attributes#

image

The input voxel image.

region

The region associated to the histogram.

mask

The mask associated to the histogram.

segmentation

The segmentation associated to the histogram.

phases

Tuple with segmentation phases.

bins

The histogram bins.

bin_centers

The centers of the histogram bins.

min

The image minimum value.

max

The image maximum value.

count

Get the histogram count as a Pandas DataFrame.

pdf

Compute the Probability Density Function (PDF) from the calculated histogram.

cdf

Compute the Cumulative Distribution Function (CDF) for the full image and phase by phase as a pandas DataFrame.

Methods#

percentile(q)

Estimate the q-th percentiles by linear interpolation on histogram CDF and bins.