scallops.visualize.utils.channel_thresholds
- scallops.visualize.utils.channel_thresholds(image, percentile_min=0.0, percentile_max=99.0, pad_min=0, pad_max=0, thresholds=None)
Compute thresholds per channel for contrast adjustment in visualization.
- Parameters:
image (DataArray) – XArray with dimensions (t,c,z,y,x) or (i,t,c,z,y,x)
percentile_min (Sequence[float] | float) – Determines the minimal threshold for contrast adjustment. If a list, apply different percentiles per channel. If a float, apply the same percentile for all channels.
percentile_max (Sequence[float] | float) – Determines the maximal threshold for contrast adjustment. If a list, apply different percentiles per channel. If a float, apply the same percentile for all channels.
pad_min (Sequence[float] | float) – Adjust the minimum value for visualization. If a list, apply different pads per channel. If a float, apply the same pad for all channels.
pad_max (Sequence[float] | float) – Adjust the maximum value for visualization. If a list, apply different pads per channel. If a float, apply the same pad for all channels.
thresholds (dict[int, tuple[float, float]]) – Optional precomputed dictionary mapping channel to tuple of (tmin, tmax).
- Returns:
A dictionary that maps channel to tuple of (tmin, tmax) for contrast adjustment.
- Example:
import numpy as np import xarray as xr from scallops.visualize.utils import channel_thresholds # Create synthetic data channels, z, y, x = 3, 10, 100, 100 synthetic_data = np.random.rand(channels, z, y, x) synthetic_image = xr.DataArray(synthetic_data, dims=("c", "z", "y", "x")) # Compute thresholds thresholds = channel_thresholds( synthetic_image, percentile_min=1, percentile_max=99 ) print(thresholds)
- Return type:
dict[int, tuple[float, float]]