Aperture¶
Adaptive aperture mask construction. The functions live at the
top-level noobase.aperture namespace (not under noobase.image), but
are listed alongside the image-domain pages here because they consume
2-D image cutouts.
grow_mask(data, seed_pixels, *, detection=None, err=None, label_map=None, label_allowed=None, connectivity='eight', shape_weight=1.0, min_neighbor_support=2, min_pixels_before_shape_gate=8, fill_min_cardinal_support=3, snr_threshold=<object object at 0x7faa155006a0>, snr_hysteresis=3, gradient_ratio_threshold=1.0, gradient_hysteresis=3, gradient_lo_percentile=75.0, gradient_hi_percentile=99.0, min_pixels_before_stop_check=30, check_interval=5, annulus_thickness=2)
¶
Grow a boolean source mask outward from one or more seed pixels.
Growth is a greedy region grow on a max-heap. Each candidate pixel's
priority is its detection value plus a shape reward proportional
to how many of its neighbours are already in the mask, so growth
fills concavities before extending arms. A hard min_neighbor_support
floor (after a warm-up) refuses pixels with too few in-mask
neighbours, forbidding one-pixel-wide tendrils. Two annulus stop
criteria (SNR and radial gradient) decide when to stop, measured on
data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
2-D image of dtype |
required |
seed_pixels
|
sequence of (int, int) or ndarray of shape (N, 2)
|
One or more |
required |
detection
|
ndarray
|
2-D image, same shape and dtype as |
None
|
err
|
ndarray
|
2-D 1-sigma error image, same shape and dtype as |
None
|
label_map
|
ndarray
|
2-D |
None
|
label_allowed
|
sequence of int
|
Whitelisted labels the mask may occupy. Include the background label explicitly if growth into background is desired. |
None
|
connectivity
|
(four, eight)
|
Pixel adjacency used for heap-neighbour expansion, neighbour
support, and annulus dilation. Default |
"four"
|
shape_weight
|
float
|
Soft compactness bias, in units of the heap-key image noise
level (see the module docstring). |
1.0
|
min_neighbor_support
|
int
|
Hard floor on a candidate's in-mask neighbour count, enforced
once |
2
|
min_pixels_before_shape_gate
|
int
|
Admitted-pixel count before the |
8
|
fill_min_cardinal_support
|
int or None
|
Unconditional concavity fill (the closing counterpart to
|
3
|
snr_threshold
|
float
|
Threshold for the cumulative inner-annulus signal-to-noise stop.
If unspecified, defaults to |
<object object at 0x7faa155006a0>
|
snr_hysteresis
|
int
|
Consecutive checks with SNR below threshold required to fire.
Default |
3
|
gradient_ratio_threshold
|
float
|
Threshold for the |
1.0
|
gradient_hysteresis
|
int
|
Consecutive checks with ratio above threshold required to fire.
Default |
3
|
gradient_lo_percentile
|
float
|
Each annulus is summarised, in the gradient ratio, by the mean of
its pixels within this percentile band rather than a plain mean.
The lower bound (default |
75.0
|
gradient_hi_percentile
|
float
|
Each annulus is summarised, in the gradient ratio, by the mean of
its pixels within this percentile band rather than a plain mean.
The lower bound (default |
75.0
|
min_pixels_before_stop_check
|
int
|
Lower bound on the admitted-pixel count before stop checks may
fire. Default |
30
|
check_interval
|
int
|
Evaluate stop criteria every |
5
|
annulus_thickness
|
int
|
Per-ring dilation iteration count. Default |
2
|
Returns:
| Type | Description |
|---|---|
GrowthResult
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For any invalid input — see the parameter descriptions for the constraints; the message identifies the specific violation. |
GrowthResult
¶
Result of grow_mask: the boolean source mask plus the termination
reason and the heap-loop iteration count.
mask
property
¶
The boolean source mask, shape (rows, cols) matching the
input data.
n_iterations
property
¶
Number of pixels admitted by the heap loop after the seeds. The
total number of True pixels in mask equals
n_iterations plus the (de-duplicated) seed count.
stop_reason
property
¶
Why the growth terminated. One of "snr_below",
"gradient_flip", or "filled" — the last is the failure
outcome (mask reached the cutout edge before any stop fired).