-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Description
Parent Epic
Part of #172 (2D Resonance Imaging)
Description
Implement spatial regularization to leverage neighboring pixel information.
Approach
Physical samples typically have:
- Spatial smoothness in composition
- Correlation between neighboring pixels
- Sharp boundaries at material interfaces
Use this prior knowledge to regularize fitting.
Methods to Consider
1. Spatial Binning (Simple)
- Aggregate N×N pixel blocks
- Trade spatial resolution for statistics
2. Gaussian Smoothing
- Apply Gaussian filter to initial estimates
- Use smoothed values as priors
3. Total Variation Regularization
- Penalize large gradients in abundance maps
- Preserves sharp edges
- Optimization-based approach
4. Graph-Based Regularization
- Model pixel relationships as graph
- Propagate information along edges
Proposed Interface
class SpatialRegularization:
"""Spatial regularization for 2D abundance fitting."""
def __init__(
self,
method: str = "total_variation", # or "gaussian", "graph"
strength: float = 0.1,
):
...
def regularize(
self,
initial_abundances: np.ndarray, # (height, width)
uncertainties: np.ndarray,
) -> np.ndarray:
"""Apply spatial regularization."""
...
def iterative_fit(
self,
spectra: np.ndarray, # (height, width, n_energies)
n_iterations: int = 5,
) -> np.ndarray:
"""Iterative fitting with spatial regularization."""
# Alternating: fit pixels → regularize → use as prior → refit
...Tasks
- Implement simple spatial binning
- Implement Total Variation regularization
- Test on synthetic data with known spatial structure
- Compare methods on edge preservation
- Document trade-offs
Assignees
Jean (LANL)