Filters API
The IBSI 2 filters make response maps of an image. A filter runs as a filter step of the pipeline, or as a direct call (see Image Filtering):
# Pipeline usage
{"step": "filter", "params": {"type": "log", "sigma_mm": 1.5}}
# Direct usage
from pictologics.filters import laplacian_of_gaussian, BoundaryCondition
response = laplacian_of_gaussian(image.array, sigma_mm=1.5, spacing_mm=image.spacing)
Available Filters
| Filter | Function | Use Case |
|---|---|---|
| Mean | mean_filter |
Local averaging |
| Gaussian | gaussian_filter |
Smoothing at a physical scale |
| LoG | laplacian_of_gaussian |
Edge/blob detection |
| Laws | laws_filter |
Texture energy |
| Gabor | gabor_filter |
Directional patterns |
| Wavelet | wavelet_transform |
Multi-resolution analysis |
| Simoncelli | simoncelli_wavelet |
Non-separable wavelet |
| Riesz | riesz_transform, riesz_log, riesz_simoncelli |
Rotation-equivariant transforms |
Capability Metadata
A versioned, machine-readable record of what each filter supports: the input and kernel dimensions, plane-wise runs, the average over the orthogonal planes, rotation pooling, the supported and the effective boundaries, the Riesz orders, steering, and the behaviour with anisotropic spacing. Compliance tools read it in place of the signatures and the source.
supported_boundaries lists what a function accepts; effective_boundary tells what happens
at the border. The FFT filters report as_specified_via_padding: a non-periodic boundary is
made by a pad, the filter and a crop, and the transform stays periodic on the padded image.
pictologics.filters.CAPABILITIES_SCHEMA_VERSION = '1.1.0'
module-attribute
Semantic version of the :data:FILTER_CAPABILITIES schema.
Bump the major component on breaking changes (field removal/retyping), the minor component when adding fields or filter entries, and the patch component for corrections that don't change the schema shape.
pictologics.filters.FilterCapability
dataclass
Declarative capability record for one IBSI 2 filter (or Riesz variant).
Every field is grounded in the corresponding filter implementation; see
:data:FILTER_CAPABILITIES for the per-filter values and the source
evidence behind each one.
Attributes:
| Name | Type | Description |
|---|---|---|
input_dimensionality |
tuple[int, ...]
|
Dimensionality/dimensionalities of the top-level
image array the filter function accepts, e.g. |
kernel_dimensionality |
int
|
Dimensionality of the convolution/transform
kernel itself (2 or 3). May differ from |
slice_plane_execution |
bool
|
True if the filter applies its kernel plane-wise (slice-by-slice) rather than as a single volumetric operation. |
orthogonal_plane_averaging |
bool
|
True if the filter supports averaging its plane-wise response over the 3 orthogonal anatomical planes. |
rotation_pooling |
tuple[str, ...]
|
Pooling method names accepted for pseudo-rotational
invariance (e.g. |
supported_boundaries |
tuple[str, ...]
|
|
effective_boundary |
str
|
What actually happens at the image border. One of
|
supported_riesz_orders |
Optional[str]
|
Description of the Riesz derivative orders
accepted (Riesz-family filters only), or |
structure_tensor_steering |
bool
|
True if the filter can steer its kernel
using a structure tensor. Currently |
anisotropic_spacing |
str
|
How the filter handles anisotropic
|
Source code in pictologics/filters/capabilities.py
pictologics.filters.FILTER_CAPABILITIES = {'mean': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='not_applicable'), 'log': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='supported'), 'gaussian': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='supported'), 'laws': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=('max', 'average', 'min'), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='not_applicable'), 'gabor': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=2, slice_plane_execution=True, orthogonal_plane_averaging=True, rotation_pooling=('max', 'average', 'min'), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='supported'), 'wavelet': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=('max', 'average', 'min'), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='not_applicable'), 'simoncelli': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified_via_padding', supported_riesz_orders=None, structure_tensor_steering=False, anisotropic_spacing='not_applicable'), 'riesz': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified_via_padding', supported_riesz_orders='Tuple[int, ...] (l1, ..., ld): any non-negative ints summing to L >= 1; see get_riesz_orders(max_order, ndim) to enumerate all combinations.', structure_tensor_steering=False, anisotropic_spacing='not_applicable'), 'riesz_log': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified_via_padding', supported_riesz_orders='Tuple[int, ...] (l1, ..., ld): any non-negative ints summing to L >= 1; see get_riesz_orders(max_order, ndim) to enumerate all combinations.', structure_tensor_steering=False, anisotropic_spacing='supported'), 'riesz_simoncelli': FilterCapability(input_dimensionality=(3,), kernel_dimensionality=3, slice_plane_execution=False, orthogonal_plane_averaging=False, rotation_pooling=(), supported_boundaries=_ALL_BOUNDARIES, effective_boundary='as_specified_via_padding', supported_riesz_orders='Tuple[int, ...] (l1, ..., ld): any non-negative ints summing to L >= 1; see get_riesz_orders(max_order, ndim) to enumerate all combinations.', structure_tensor_steering=False, anisotropic_spacing='not_applicable')}
module-attribute
Capability record for every public filter, keyed by pipeline filter-type name.
See the module docstring for the "riesz" / "riesz_log" /
"riesz_simoncelli" keying scheme.
pictologics.filters.get_filter_capabilities(name)
Look up the capability record for a filter by its pipeline filter-type name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Pipeline filter-type name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
FilterCapability
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Source code in pictologics/filters/capabilities.py
Boundary Conditions
A filter step takes the boundary as a name: "mirror", "nearest", "periodic" (or "wrap") or "zero" (or "constant"). A direct call also takes the enum. See Boundaries and Padding.
pictologics.filters.BoundaryCondition
Bases: Enum
IBSI 2 boundary conditions for image padding (GBYQ).
Maps to scipy.ndimage mode parameter values.
Example
Source code in pictologics/filters/base.py
Results and Kernels
pictologics.filters.FilterResult
dataclass
Container for filter response maps and metadata.
Example
Source code in pictologics/filters/base.py
dtype
property
Data type of the response map.
shape
property
Shape of the response map.
pictologics.filters.LAWS_KERNELS = _LAWS_KERNELS
module-attribute
Dictionary of normalized Laws kernels (IBSI 2 Table 6).
Filter Functions
pictologics.filters.mean_filter(image, support=15, boundary=BoundaryCondition.ZERO, source_mask=None, padding_value=0.0)
Apply 3D mean filter (IBSI code: S60F).
The mean filter computes the average intensity over an M×M×M spatial support. Per IBSI 2 Eq. 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
support
|
int
|
Filter support M in voxels (must be odd, YNOF) |
15
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for padding (GBYQ) |
ZERO
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. When provided, uses normalized convolution to exclude invalid (sentinel) voxels from mean computation. |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
Union[NDArray[floating[Any]], tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask is None: Response map with same dimensions as input |
Union[NDArray[floating[Any]], tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask provided: Tuple of (response_map, output_valid_mask) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If support is not an odd positive integer |
Example
Apply Mean filter with 15-voxel support:
import numpy as np
from pictologics.filters import mean_filter
# Create dummy 3D image
image = np.random.rand(50, 50, 50)
# Apply filter
response = mean_filter(image, support=15, boundary="zero")
# With source_mask for sentinel exclusion
mask = image > -1000 # Valid voxels
response, valid_mask = mean_filter(image, support=15, source_mask=mask)
Note
Support M is defined in voxel units as per IBSI specification.
Source code in pictologics/filters/mean.py
pictologics.filters.gaussian_filter(image, sigma_mm, spacing_mm=1.0, truncate=4.0, boundary=BoundaryCondition.ZERO, source_mask=None, padding_value=0.0)
gaussian_filter(
image: npt.NDArray[np.floating[Any]],
sigma_mm: float,
spacing_mm: Union[
float, Tuple[float, float, float]
] = ...,
truncate: float = ...,
boundary: Union[BoundaryCondition, str] = ...,
source_mask: None = ...,
padding_value: float = ...,
) -> npt.NDArray[np.floating[Any]]
gaussian_filter(
image: npt.NDArray[np.floating[Any]],
sigma_mm: float,
spacing_mm: Union[
float, Tuple[float, float, float]
] = ...,
truncate: float = ...,
boundary: Union[BoundaryCondition, str] = ...,
source_mask: npt.NDArray[np.bool_] = ...,
padding_value: float = ...,
) -> Tuple[
npt.NDArray[np.floating[Any]], npt.NDArray[np.bool_]
]
Apply a 3D Gaussian filter (IBSI code: 8BC3): a smoothing low-pass filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
sigma_mm
|
float
|
Scale σ* in mm (41LN) |
required |
spacing_mm
|
Union[float, Tuple[float, float, float]]
|
Voxel spacing in mm (scalar or a value for each axis) |
1.0
|
truncate
|
float
|
Filter size cutoff in σ units (default 4.0, WGPM) |
4.0
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for padding (GBYQ) |
ZERO
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. When provided, normalized convolution leaves out the invalid voxels. |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
Union[NDArray[floating[Any]], Tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask is None: Response map (float32) with the dimensions of the input. |
Union[NDArray[floating[Any]], Tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask is given: (response map, output valid mask). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Note
- σ is converted from mm to voxels: σ_voxels = σ_mm / spacing_mm
- The kernel of each axis has the radius ⌊truncate × σ_voxels + 0.5⌋ and sums to 1
Source code in pictologics/filters/gaussian.py
pictologics.filters.laplacian_of_gaussian(image, sigma_mm, spacing_mm=1.0, truncate=4.0, boundary=BoundaryCondition.ZERO, source_mask=None, padding_value=0.0)
laplacian_of_gaussian(
image: npt.NDArray[np.floating[Any]],
sigma_mm: float,
spacing_mm: Union[
float, Tuple[float, float, float]
] = ...,
truncate: float = ...,
boundary: Union[BoundaryCondition, str] = ...,
source_mask: None = ...,
padding_value: float = ...,
) -> npt.NDArray[np.floating[Any]]
laplacian_of_gaussian(
image: npt.NDArray[np.floating[Any]],
sigma_mm: float,
spacing_mm: Union[
float, Tuple[float, float, float]
] = ...,
truncate: float = ...,
boundary: Union[BoundaryCondition, str] = ...,
source_mask: npt.NDArray[np.bool_] = ...,
padding_value: float = ...,
) -> tuple[
npt.NDArray[np.floating[Any]], npt.NDArray[np.bool_]
]
Apply 3D Laplacian of Gaussian filter (IBSI code: L6PA).
The LoG is a band-pass, spherically symmetric operator. Per IBSI 2 Eq. 3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
sigma_mm
|
float
|
Standard deviation in mm (σ*, 41LN) |
required |
spacing_mm
|
Union[float, Tuple[float, float, float]]
|
Voxel spacing in mm (scalar for isotropic, or tuple) |
1.0
|
truncate
|
float
|
Filter size cutoff in σ units (default 4.0, WGPM) |
4.0
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for padding (GBYQ) |
ZERO
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. When provided, uses normalized convolution to exclude invalid (sentinel) voxels from computation. |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
Union[NDArray[floating[Any]], tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask is None: Response map with same dimensions as input |
Union[NDArray[floating[Any]], tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask provided: Tuple of (response_map, output_valid_mask) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Apply LoG filter with 5.0mm sigma on an image with 2.0mm spacing:
import numpy as np
from pictologics.filters import laplacian_of_gaussian
# Create dummy 3D image
image = np.random.rand(50, 50, 50)
# Apply filter
response = laplacian_of_gaussian(
image,
sigma_mm=5.0,
spacing_mm=(2.0, 2.0, 2.0),
truncate=4.0
)
# With source_mask for sentinel exclusion
mask = image > -1000
response, valid_mask = laplacian_of_gaussian(
image, sigma_mm=5.0, spacing_mm=2.0, source_mask=mask
)
Note
- σ is converted from mm to voxels: σ_voxels = σ_mm / spacing_mm
- Filter size: M = 1 + 2⌊d×σ + 0.5⌋ where d=truncate
- The kernel should sum to approximately 0 (zero-mean)
- A float64 image of 131,072 voxels (about 51³) or more runs as one FFT convolution with the same truncated kernels and boundary: about 2 times faster than the separable passes, with values within about 1e-15 of the largest response value.
- A smaller float64 image runs the passes in float32, as a float32 image does: faster, with values within about 1e-7 of the largest response value.
- With a
padding_value, the padded image counts.
Source code in pictologics/filters/log.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
pictologics.filters.laws_filter(image, kernels, boundary=BoundaryCondition.ZERO, rotation_invariant=False, pooling='max', compute_energy=False, energy_distance=7, use_parallel=None, source_mask=None, padding_value=0.0)
laws_filter(
image: npt.NDArray[np.floating[Any]],
kernels: str,
boundary: Union[BoundaryCondition, str] = ...,
rotation_invariant: bool = ...,
pooling: str = ...,
compute_energy: bool = ...,
energy_distance: int = ...,
use_parallel: Union[bool, None] = ...,
source_mask: None = ...,
padding_value: float = ...,
) -> npt.NDArray[np.floating[Any]]
laws_filter(
image: npt.NDArray[np.floating[Any]],
kernels: str,
boundary: Union[BoundaryCondition, str] = ...,
rotation_invariant: bool = ...,
pooling: str = ...,
compute_energy: bool = ...,
energy_distance: int = ...,
use_parallel: Union[bool, None] = ...,
source_mask: npt.NDArray[np.bool_] = ...,
padding_value: float = ...,
) -> Tuple[
npt.NDArray[np.floating[Any]], npt.NDArray[np.bool_]
]
Apply 3D Laws kernel filter (IBSI code: JTXT).
Laws kernels detect texture patterns via separable 1D filters combined into 2D/3D filters via outer products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
kernels
|
str
|
Kernel specification as string, e.g., "E5L5S5" for 3D |
required |
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for padding (GBYQ) |
ZERO
|
rotation_invariant
|
bool
|
If True, apply pseudo-rotational invariance (O1AQ) using max pooling over 24 right-angle rotations |
False
|
pooling
|
str
|
Pooling method for rotation invariance ("max", "average", "min") |
'max'
|
compute_energy
|
bool
|
If True, compute texture energy image (PQSD) |
False
|
energy_distance
|
int
|
Chebyshev distance δ for energy computation (I176) |
7
|
use_parallel
|
Union[bool, None]
|
If True, use parallel processing for rotation_invariant mode. If None (default), auto-enables for images > 20,000 voxels. Only affects rotation_invariant mode. |
None
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. In non-rotation-invariant mode, uses normalized separable convolution to exclude invalid (sentinel) voxels. In rotation-invariant mode, invalid voxels are zero-filled as a first-order approximation (the rotated kernels preclude normalized convolution). |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
Union[NDArray[floating[Any]], Tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask is None: Response map (or energy image if compute_energy=True) |
Union[NDArray[floating[Any]], Tuple[NDArray[floating[Any]], NDArray[bool_]]]
|
If source_mask provided: Tuple of (response_map, output_valid_mask) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
Defensive check raised if no response was computed; not expected to occur in normal use. |
Example
Apply Laws E5L5S5 kernel with rotation invariance and texture energy:
Note
- Kernels are normalized (deviate from Laws' original unnormalized)
- Energy is computed as: mean(|h|) over δ neighborhood
- For rotation invariance, energy is computed after pooling
- Uses separable 1D convolutions for ~8x speedup over full 3D
Source code in pictologics/filters/laws.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
pictologics.filters.gabor_filter(image, sigma_mm, lambda_mm, gamma=1.0, theta=0.0, spacing_mm=1.0, boundary=BoundaryCondition.ZERO, rotation_invariant=False, delta_theta=None, pooling='average', average_over_planes=False, use_parallel=None, source_mask=None, region=None, response='modulus', padding_value=0.0)
Apply 2D Gabor filter to 3D image (IBSI code: Q88H).
The Gabor filter is applied in the axial plane (k1, k2) and optionally averaged over orthogonal planes. Per IBSI 2 Eq. 9.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
sigma_mm
|
float
|
Standard deviation of Gaussian envelope in mm (41LN) |
required |
lambda_mm
|
float
|
Wavelength in mm (S4N6) |
required |
gamma
|
float
|
Spatial aspect ratio (GDR5), typically 0.5 to 2.0 |
1.0
|
theta
|
float
|
Orientation angle in radians (FQER), clockwise in (k1,k2) |
0.0
|
spacing_mm
|
Union[float, Tuple[float, float, float]]
|
Voxel spacing in mm (scalar or per-axis tuple). Each
plane's kernel is built from that plane's own two in-plane
axis spacings, so anisotropic spacing (including anisotropic
z, relevant when |
1.0
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for padding (GBYQ) |
ZERO
|
rotation_invariant
|
bool
|
If True, average over orientations |
False
|
delta_theta
|
Optional[float]
|
Orientation step for rotation invariance (XTGK) |
None
|
pooling
|
str
|
Pooling method ("average", "max", "min") |
'average'
|
average_over_planes
|
bool
|
If True, average 2D responses over 3 orthogonal planes |
False
|
use_parallel
|
Union[bool, None]
|
If True, process slices in parallel. If None (default), auto-enables when the slices to filter hold more than ~46³ voxels. |
None
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. When provided, zeros out invalid (sentinel) voxels before FFT-based convolution to prevent contamination. |
None
|
region
|
Optional[Tuple[slice, slice, slice]]
|
Optional box of the image (one slice per axis). Only the response in the box is computed, and the result has the box shape. Each plane still filters whole slices, so the values are those of the whole image. |
None
|
response
|
str
|
The part of the complex response (5P3T): "modulus" (0J1M, default), "angle" (V530, in radians), "real" (F7DI) or "imaginary" (LI3Y). The orientations pool this part. |
'modulus'
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[floating[Any]]
|
Response map (the |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Apply Gabor filter with rotation invariance over orthogonal planes:
import numpy as np
from pictologics.filters import gabor_filter
# Create dummy 3D image
image = np.random.rand(50, 50, 50)
# Apply filter
response = gabor_filter(
image,
sigma_mm=10.0,
lambda_mm=4.0,
gamma=0.5,
rotation_invariant=True,
delta_theta=0.7853981633974483, # pi/4
average_over_planes=True
)
Note
- Returns the part of h = g ⊗ f that
responsenames (default the modulus |h|) - 2D filter applied slice-by-slice, then optionally over planes
- Uses single complex FFT convolution for ~2x speedup
- Each plane's kernel uses that plane's own two in-plane spacings. When they are equal (the isotropic-in-plane case, including the default axial-only plane under typical (x, y, z) spacing with x == y), the kernel is built on a voxel-unit grid. When they differ, the kernel is built on a physical-coordinate (mm) grid with a per-axis radius, giving a rectangular kernel that follows the true spacing of each axis.
Source code in pictologics/filters/gabor.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
pictologics.filters.wavelet_transform(image, wavelet='db2', level=1, decomposition='LHL', boundary=BoundaryCondition.ZERO, rotation_invariant=False, pooling='average', use_parallel=None, source_mask=None, padding_value=0.0)
Apply 3D separable wavelet transform (undecimated/stationary).
Uses the à trous algorithm for undecimated wavelet decomposition. The transform is translation-invariant (unlike decimated transform). A NaN or inf voxel spreads over the non-zero taps of the kernel only, not over its whole span.
Supported wavelets
- "haar" (UOUE): Haar wavelet
- "db2", "db3": Daubechies wavelets
- "coif1": Coiflet wavelet
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
wavelet
|
str
|
Wavelet name (e.g., "db2", "coif1", "haar") |
'db2'
|
level
|
int
|
Decomposition level (GCEK) |
1
|
decomposition
|
str
|
Which response map to return, e.g., "LHL", "HHH" |
'LHL'
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for padding |
ZERO
|
rotation_invariant
|
bool
|
If True, average over 24 rotations |
False
|
pooling
|
str
|
Pooling method for rotation invariance |
'average'
|
use_parallel
|
Union[bool, None]
|
If True, the 24 rotations of rotation_invariant mode and their passes run in numba's threads; False runs them in one thread. If None (default), True for images of more than 15,000 voxels. |
None
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. When provided, zeros out invalid (sentinel) voxels before wavelet decomposition to prevent contamination. |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[floating[Any]]
|
Response map for the specified decomposition |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Apply Daubechies 2 wavelet transform at level 1, returning LHL coefficients:
Source code in pictologics/filters/wavelets.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
pictologics.filters.simoncelli_wavelet(image, level=1, boundary=BoundaryCondition.PERIODIC, source_mask=None, padding_value=0.0)
Apply Simoncelli non-separable wavelet (IBSI code: PRT7).
The Simoncelli wavelet is isotropic (spherically symmetric) and implemented in the Fourier domain. Per IBSI 2 Eq. 27.
For decomposition level N, the frequency band is scaled by j = N-1: - Level 1 (j=0): band [π/4, π] (highest frequencies) - Level 2 (j=1): band [π/8, π/2] - Level 3 (j=2): band [π/16, π/4]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
level
|
int
|
Decomposition level (1 = highest frequency band) |
1
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition. The filter is inherently periodic (FFT-based),
so |
PERIODIC
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[floating[Any]]
|
Band-pass response map (B map) for the specified level |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Apply first-level Simoncelli wavelet (highest frequency band):
Source code in pictologics/filters/wavelets.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
pictologics.filters.riesz_transform(image, order, boundary=BoundaryCondition.PERIODIC, source_mask=None, padding_value=0.0)
Apply Riesz transform (IBSI code: AYRS).
The Riesz transform computes higher-order all-pass image derivatives in the Fourier domain. Per IBSI 2 Eq. 34.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
order
|
Tuple[int, ...]
|
Tuple (l1, l2, l3) specifying derivative order per axis e.g., (1,0,0) = first-order along k1 (gradient-like) (2,0,0), (1,1,0), (0,2,0) = second-order (Hessian-like) |
required |
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition. The filter is inherently periodic (FFT-based),
so |
PERIODIC
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. When provided, zeros out invalid (sentinel) voxels before FFT-based transform to prevent contamination. |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[floating[Any]]
|
Riesz-transformed image (real part) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Compute first-order Riesz transform along the k1 axis:
Note
- First-order Riesz components form the image gradient
- Second-order Riesz components form the image Hessian
- All-pass: doesn't amplify high frequencies like regular derivatives
Source code in pictologics/filters/riesz.py
pictologics.filters.riesz_log(image, sigma_mm, spacing_mm=1.0, order=(1, 0, 0), truncate=4.0, boundary=BoundaryCondition.PERIODIC, source_mask=None, padding_value=0.0)
Apply Riesz transform to LoG-filtered image.
Combines multi-scale analysis (LoG) with directional analysis (Riesz). First applies LoG filtering, then applies Riesz transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
sigma_mm
|
float
|
LoG scale in mm |
required |
spacing_mm
|
Union[float, Tuple[float, float, float]]
|
Voxel spacing in mm |
1.0
|
order
|
Tuple[int, ...]
|
Riesz order tuple (l1, l2, l3) |
(1, 0, 0)
|
truncate
|
float
|
LoG truncation parameter |
4.0
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for the whole LoG-then-Riesz chain. PERIODIC (the
default) runs the LoG with its own ZERO boundary, then the Riesz transform on
the image as it is. Another boundary pads the image once with that boundary
(see |
PERIODIC
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. With PERIODIC, the LoG uses normalized convolution, and the mask zeroes the invalid voxels again before the Riesz stage. With another boundary, the mask zeroes the invalid voxels of the final response. |
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[floating[Any]]
|
Riesz-transformed LoG response |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Compute first-order Riesz transform of LoG-filtered image at 5mm scale:
Source code in pictologics/filters/riesz.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
pictologics.filters.riesz_simoncelli(image, level=1, order=(1, 0, 0), boundary=BoundaryCondition.PERIODIC, source_mask=None, padding_value=0.0)
Apply Riesz transform to Simoncelli wavelet-filtered image.
Combines isotropic multi-scale analysis (Simoncelli) with directional analysis (Riesz) for rotation-invariant directional features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[floating[Any]]
|
3D input image array |
required |
level
|
int
|
Simoncelli decomposition level |
1
|
order
|
Tuple[int, ...]
|
Riesz order tuple (l1, l2, l3) |
(1, 0, 0)
|
boundary
|
Union[BoundaryCondition, str]
|
Boundary condition for the whole Simoncelli-then-Riesz chain.
With the default |
PERIODIC
|
source_mask
|
Optional[NDArray[bool_]]
|
Optional boolean mask where True = valid voxel. Because
|
None
|
padding_value
|
float
|
The constant of constant value padding (Z3VE), with the ZERO (constant) boundary. Default 0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[floating[Any]]
|
Riesz-transformed Simoncelli response |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
Compute second-order Riesz transform (Hessian-like) of Simoncelli level 2:
Source code in pictologics/filters/riesz.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |