Skip to main content

MinMaxClip

MinMaxClip(n_min=1, n_max=1, grow=None)

Reject the smallest and largest unmasked values at each pixel.

Parameters

n_min : int or float = 1

Number of minimum-side values to reject. Values >= 1 are a frame count. Values in [0, 1) are a fraction of the total frame count N, converted via int(N * n_min + 0.001).

n_max : int or float = 1

Same convention as n_min, applied to the maximum-side tail.

grow : float or None = None

Optional radius in pixels used to grow mask_rej spatially after rejection. Axis 0 is the stack axis and is never grown across. None disables growth and skips the extra calculation.

Notes

Sort the M finite, unmasked samples at each output pixel. With N the original image count, a request a (n_min or n_max) resolves to::

A = int(N * a + 0.001) if 0 <= a < 1 else int(a)
k = int(M * A / N + 0.001)

Reject k samples from that tail, first the low tail, then the high tail of the remaining values. Both counts use the initial M; available samples limit the cuts. Thus masked/non-finite inputs reduce even count-based requests proportionally. For example, N=10, M=5, n_min=2 removes one minimum. This is rank selection, not a value threshold: tied values may be split. There is no spread estimate or iteration; low/upp are retained extrema.

For derivations and worked examples, see the Rejection Methods tutorial.

Methods

Name Description
apply Apply MinMaxClip to an image stack.

apply

MinMaxClip.apply(arr, mask=None, *, validate=True)

Apply MinMaxClip to an image stack.

Parameters

arr : (ndarray, shape(N, *spatial))

Image stack. Inputs with more than 3 dimensions are flattened internally; output shapes match the trailing spatial dimensions of the input.

mask : ndarray of bool = None

Input mask; True means already masked. Must have the same shape as arr before any internal flattening.

validate : bool = True

If True, validate inputs before calling the kernel.

Returns

: mask_rej, std, low, upp, nit, output_flags : tuple of ndarray

Rejection mask and diagnostics from :func:imcombiners.kernels.minmax. std is the per-pixel clipping spread for SigClip, reference noise for CCDClip, and None for algorithms without a spread diagnostic.

Notes

Sort the M finite, unmasked samples at each output pixel. With N the original image count, a request a (n_min or n_max) resolves to::

A = int(N * a + 0.001) if 0 <= a < 1 else int(a)
k = int(M * A / N + 0.001)

Reject k samples from that tail, first the low tail, then the high tail of the remaining values. Both counts use the initial M; available samples limit the cuts. Thus masked/non-finite inputs reduce even count-based requests proportionally. For example, N=10, M=5, n_min=2 removes one minimum. This is rank selection, not a value threshold: tied values may be split. There is no spread estimate or iteration; low/upp are retained extrema.

For derivations and worked examples, see the Rejection Methods tutorial.