Li–Osher Weighted Median Filter
- Weighted Median Filtering (Li–Osher) is an edge-preserving nonlinear filter that employs local weighted L1 minimization to adaptively refine image and motion boundaries.
- It leverages heterogeneous patch similarity weights to suppress noise while maintaining sharp discontinuities in optical flow estimation.
- Its integration in variational optical flow pipelines yields measurable improvements in angular and endpoint error metrics on benchmark datasets.
The Li–Osher weighted median filter is an edge-preserving nonlinear filter defined by a local, weighted minimization of the loss. It extends the classical median filter by allowing heterogeneous weighting of observations, resulting in enhanced adaptability to image and motion boundaries. The weighted median, as introduced by Li and Osher in the context of PDE-based denoising, has been leveraged as a critical post-processing refinement in optical flow methods to better preserve flow discontinuities while suppressing noise. Doshi and Kiran (Doshi et al., 2022) implement this filter as the final sharpening step in an edge-preserving variational optical-flow pipeline, reporting marked improvements in both flow accuracy and edge fidelity.
1. Mathematical Formulation
At each pixel , for a scalar signal (e.g., a flow component), the filter operates on the local square neighborhood
with half-width . Each neighbor is assigned a nonnegative weight . The filtered output is the minimizer of the weighted cost:
Alternatively, defining the nondecreasing order statistics 0 (with corresponding weights 1), 2 is the smallest 3 for which the cumulative weight 4 satisfies 5.
2. Parameters and Weight Computation
Three principal parameters define the filter:
- Window size 6: Typical choices are 7, selected and tuned per dataset or sequence.
- Patch similarity weights 8: For any 9,
0
where 1 is a Gaussian with standard deviation 2 (patch-smoothing), 3 is a contrast-sensitivity parameter (often the flow grid spacing), and 4 is the reference image. Both 5 and 6 are jointly tuned per sequence.
- (Optional) Regularization term: The generalized energy 7 is used with 8, yielding a pure weighted median.
Weights are computed based on patch similarity, following the nonlocal means paradigm, with larger 9 for similar patches.
3. Algorithmic Implementation
A single pass proceeds as follows for each pixel 0:
- Neighborhood extraction: Collect 1 with 2.
- Weight computation: For each 3, compute 4.
- Sort and select:
- Form the set of pairs 5 for all 6.
- Sort by 7 in ascending order.
- Accumulate weights, select the minimal 8 at which accumulated weight passes half the total, set as 9.
Boundary handling is performed by mirror-padding or clamping at image edges. Weights 0 are recomputed only once per sequence or iteration and cached. Sorting is implemented via bucket sort or 1 selection algorithms, where 2. Per-pixel computational complexity is 3 for both weight lookup and median selection.
4. Integration in Optical Flow Estimation
The weighted median filter is applied as a post-processing refinement after coarse-to-fine variational optical flow estimation with 4-TV regularization solved by the Chambolle–Pock primal–dual scheme. At each pyramid level, after the final (possibly iterated) classical median filtering, the Li–Osher weighted median filter is applied once per flow component. The output is upsampled for initialization at the next pyramid level. Only a single weighted median pass is conducted per level, with the final, full-resolution pass being emphasized for edge sharpening.
Pipeline summary:
| Step | Operation | Location in Pipeline |
|---|---|---|
| Solve variational flow | Chambolle–Pock primal-dual | Per pyramid level |
| Iterated median | Standard (unweighted) median, possibly multiple passes | Per pyramid level |
| Weighted median | Li–Osher filter, one pass per flow component | After all variational and iterated median steps |
5. Empirical Performance and Edge Preservation
Application of the weighted median filter as the final refinement sharpens flow-field discontinuities—specifically at object boundaries—mitigating “bleeding” artifacts intrinsic to 5-TV regularization. On the Middlebury optical flow dataset, the end-to-end pipeline of Doshi & Kiran, which incorporates both iterated median and Li–Osher weighted median filtering, achieves an average angular error (AAE) of 6 and an average end-point error (EPE) of 7 pixels, improving upon HS+nonlocal (8, 9 px) and HS+nonlocal+guided filter (0, 1 px). Approximately 2 of the edge fidelity improvement is attributed to the weighted median step, as observed by the authors. In controlled tests with synthetic data, the filter preserves sharp motion edges even under heavy Gaussian or salt-and-pepper noise, outperforming pure iterated median filtering in maintaining crisp vector-field boundaries (Doshi et al., 2022).
6. Implementation Optimizations
To ensure computational feasibility, weights are cached in compact (3 arrays per-pixel or per-warp. Efficient 4 selection strategies are employed for the median calculation. No GPU acceleration is reported, but the algorithm's pixelwise independence is well-suited for parallelization on architectures such as CUDA. For 5, real-time application is considered practically attainable on modern hardware.
7. Context, Limitations, and Further Directions
The Li–Osher weighted median filter generalizes the median to accommodate spatially or photometrically varying influences, enhancing edge-preservation over classical filters. Its use in variational optical flow estimation demonstrates the practical utility of patch-based weighting rooted in nonlocal means concepts. While the improvement in flow accuracy attributable solely to the weighted median is not isolated in ablation studies, integration within existing variational frameworks yields measurable benefits in edge sharpness and accuracy under noise. A plausible implication is that further optimization, adaptive parameter learning, or extension to higher-dimensional flows could enhance performance in related imaging and motion analysis applications (Doshi et al., 2022).