Convolve¶
Bare correlation kernels (NaN-naive) and their NaN-as-missing renormalized variants, plus a Gaussian kernel constructor.
The kernels are written as correlation (the kernel is not flipped).
For a symmetric kernel correlation and convolution coincide; the
image.convolve_psf wrapper flips the PSF first to give true
convolution.
Gaussian Kernel¶
gaussian1d(sigma, *, truncate=4.0, sampling='erf_integrated', normalization='sum', dtype=None)
builtin
¶
Build a 1-D Gaussian correlation kernel of odd length
2 * ceil(truncate * sigma) + 1, centered at index len // 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sigma
|
float
|
Gaussian sigma in pixels. Must be positive. |
required |
truncate
|
float
|
Half-support in units of |
4.0
|
sampling
|
(erf_integrated, point_sampled)
|
|
"erf_integrated"
|
normalization
|
(sum, l2, none)
|
Kernel normalization. |
"sum"
|
dtype
|
numpy dtype
|
Either |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
1-D Gaussian kernel of odd length. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
1-D Correlation¶
conv1d(signal, kernel, *, boundary='zero')
builtin
¶
1-D correlation of signal with kernel (the kernel is not
flipped — for a symmetric kernel this coincides with convolution).
NaN-naive: a non-finite tap propagates into its output element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal
|
ndarray
|
1-D signal, dtype |
required |
kernel
|
ndarray
|
1-D kernel, same dtype as |
required |
boundary
|
(zero, reflect, nearest)
|
Out-of-bounds tap handling. Default |
"zero"
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Same shape and dtype as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
conv_axis(image, kernel, *, axis=0, boundary='zero')
builtin
¶
Apply [conv1d] independently along axis of a 2-D image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
2-D image, dtype |
required |
kernel
|
ndarray
|
1-D kernel, same dtype as |
required |
axis
|
int
|
|
0
|
boundary
|
(zero, reflect, nearest)
|
Out-of-bounds tap handling. Default |
"zero"
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Same shape and dtype as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
2-D Correlation¶
conv2d(image, kernel, *, boundary='zero')
builtin
¶
2-D correlation of image with kernel (the kernel is not
flipped). NaN-naive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
2-D image, dtype |
required |
kernel
|
ndarray
|
2-D kernel, same dtype as |
required |
boundary
|
(zero, reflect, nearest)
|
Out-of-bounds tap handling. Default |
"zero"
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Same shape and dtype as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NaN-as-Missing Renormalized Correlation¶
conv2d_renorm(image, kernel)
builtin
¶
2-D renormalized correlation (NaN-as-missing). Returns (value,
weight) where value = N / D over the finite taps and
weight = D is the kernel-weighted valid-tap sum. Out-of-bounds is
always missing; no boundary switch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
2-D image, dtype |
required |
kernel
|
ndarray
|
2-D kernel, same dtype as |
required |
Returns:
| Type | Description |
|---|---|
tuple of (ndarray, ndarray)
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
conv_axis_renorm(image, kernel, *, axis=0)
builtin
¶
1-D renormalized correlation along axis of a 2-D image
(NaN-as-missing). Returns (value, weight) with the same
semantics as [conv2d_renorm].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
2-D image, dtype |
required |
kernel
|
ndarray
|
1-D kernel, same dtype as |
required |
axis
|
int
|
|
0
|
Returns:
| Type | Description |
|---|---|
tuple of (ndarray, ndarray)
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |