Image Pre-Processing

Build filter stacks to improve correlation quality. Test interactively with side-by-side raw vs. processed comparison.

Overview

Filters are applied sequentially from top to bottom. Temporal filters should precede spatial filters. All changes auto-save to config.yaml.

Temporal Filters

Operate across multiple frames (batches) to remove persistent features.

  • time -- Subtract local minimum across batch
  • pod -- SVD-based background removal (Mendez et al.)

Spatial Filters

Operate per-frame via scipy.ndimage.

  • Smoothing: gaussian, median
  • Normalization: norm, norm2, maxnorm
  • Background: ssmin, invert
  • Enhancement: lmax, clahe

Temporal Filters

Require batch processing. Set batch size via the Batch Size input (appears when temporal filters are in the stack). Frame A and Frame B channels are processed independently.

FilterParametersAlgorithmRemoves
timeNoneSubtract per-pixel minimum over batchStatic backgrounds, reflections
podNone (auto mode detection)SVD decomposition; auto-detect noise threshold; subtract signal modesCoherent structures, time-varying backgrounds

Spatial Filters

Applied per-frame after temporal filters. Kernel sizes are auto-adjusted to be odd.

FilterParametersDescription
gaussiansize: [7, 7], sigma: 1.0Gaussian low-pass smoothing. Reduces high-frequency noise while preserving large-scale intensity. Uses a finite (FIR) kernel.
mediansize: [5, 5]Replaces each pixel with its neighbourhood median. Removes salt-and-pepper noise and hot pixels without blurring edges.
normsize: [7, 7], max_gain: 1.0Range normalize: subtracts the local minimum then divides by the local range (max − min). Maps each pixel to [0, 1] relative to its neighbourhood. Good general-purpose contrast equalization.
norm2size: [7, 7], max_gain: 1.0Smoothed range normalize: like norm, but box-smooths both the min and max envelopes before normalizing. More robust to single-pixel noise spikes.
maxnormsize: [7, 7], max_gain: 1.0Background normalize: divides by the smoothed local minimum (background level). Equalizes illumination gradients — particles come out as values > 1, background → 1. Max gain limits amplification in dark regions.
ssminsize: [7, 7]SSMin (sliding minimum background subtraction). Median-smooths, extracts the local minimum (background envelope), box-smooths it, and subtracts. Removes slowly-varying background (laser sheet profile, reflections). Output clipped to ≥ 0.
lmaxsize: [7, 7]Morphological dilation (local maximum). Replaces each pixel with the maximum in its neighbourhood. Useful for expanding bright features and peak detection.
invert(none)Inverts intensity: output = max(image) − pixel. For background-oriented schlieren (BOS) or shadowgraph where particles are dark on a bright background.
claheclip_limit: 2.0, tile_grid_size: [8, 8]Contrast Limited Adaptive Histogram Equalization. Enhances local contrast in tiles, useful for images with uneven illumination or very low contrast.

GUI Workflow

The ImagePairViewer displays raw and processed images side-by-side with synchronised zoom/pan.

Workflow

  1. Add filters from the dropdown. They appear as expandable cards in the filter stack.
  2. Configure parameters for each filter. Reorder with up/down arrows, remove with delete.
  3. Click Test Filters to apply the stack to the current frame (or batch for temporal filters).
  4. Compare raw vs. processed. Zoom into regions of interest.
  5. Use playback controls to verify consistency across frames.
Spatial-only stacks

Near-instant results -- only the current frame is processed.

With temporal filters

Processes the full batch. Progress indicator shown during computation.

Recommended order: Temporal filters first (time, pod) for background removal, then spatial filters for noise reduction and contrast enhancement.

YAML Reference

filters: # Temporal (require batch processing) - type: time - type: pod # Spatial (per-frame, order matters) - type: gaussian size: [7, 7] # [int, int]: kernel [h, w] (odd only) sigma: 1.0 # float: std dev in pixels - type: median size: [5, 5] # [int, int]: kernel [h, w] (odd only) - type: norm # Range normalize size: [7, 7] max_gain: 1.0 # float: max amplification in low-contrast regions - type: norm2 # Smoothed range normalize size: [7, 7] max_gain: 1.0 - type: maxnorm # Background normalize size: [7, 7] max_gain: 1.0 - type: ssmin # Subtract background size: [7, 7] - type: lmax # Local maximum (dilation) size: [7, 7] - type: invert # Invert (max - pixel) - type: clahe # Adaptive histogram equalization clip_limit: 2.0 tile_grid_size: [8, 8] batches: size: 30 # Frames per batch (for temporal filters)

Parameter Quick Reference

FilterTypeParameterDefault
timeTemporal(none)-
podTemporal(none)-
gaussianSpatialsize, sigma[7,7], 1.0
medianSpatialsize[5, 5]
normSpatialsize, max_gain[7,7], 1.0
norm2Spatialsize, max_gain[7,7], 1.0
maxnormSpatialsize, max_gain[7,7], 1.0
ssminSpatialsize[7, 7]
lmaxSpatialsize[7, 7]
invertSpatial(none)-
claheSpatialclip_limit, tile_grid_size2.0, [8,8]

Next: PIV Processing

Configure cross-correlation parameters for vector field computation.

Continue to PIV Processing