Module: sarpyx.utils.metrics

File: sarpyx/utils/metrics.py

Performance Metrics for Complex-Valued SAR Image Super-Resolution. This module provides comprehensive evaluation metrics for Synthetic Aperture Radar (SAR) super-resolution algorithms. SAR super-resolution aims to enhance spatial resolution while preserving both amplitude (magnitude) and phase information. The metrics are organized into three main categories: 1. **Magnitude Fidelity Metrics** (Amplitude Domain): - Mean Squared Error (MSE) and Root MSE (RMSE) - Peak Signal-to-Noise Ratio (PSNR) - Structural Similarity Index (SSIM) - Amplitude Correlation Coefficient (CC) 2. **Phase Accuracy Metrics** (Phase Domain): - Mean Phase Error (MAE/RMSE of Phase) - Complex Correlation Coefficient (Interferometric Coherence) - Phase-Only Correlation (Phase Consistency) 3. **SAR-Specific Structural Metrics**: - Equivalent Number of Looks (ENL) - Resolution Gain (Spatial Resolution Improvement) All metrics accept complex-valued numpy arrays representing SAR images and provide quantitative assessment of super-resolution quality for both research and operational applications. References: IEEE Geoscience and Remote Sensing literature for SAR image quality assessment, Remote Sensing journal publications on SAR super-resolution, and IEEE TGRS articles on interferometric coherence and SAR image processing.

Exported Symbols (__all__)

No explicit __all__ list. Public symbols inferred from implementation.

Public Functions (11)

mse_complex function

Compute mean squared error between two complex SAR images.

File location: sarpyx/utils/metrics.py:84

Signature

mse_complex(ref: np.ndarray, pred: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array

Return Type

float

MSE value as float. Lower values indicate higher amplitude fidelity.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import mse_complex

result = mse_complex(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

rmse_complex function

Root mean squared error for complex SAR images.

File location: sarpyx/utils/metrics.py:109

Signature

rmse_complex(ref: np.ndarray, pred: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array

Return Type

float

RMSE value as float in original units

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import rmse_complex

result = rmse_complex(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

psnr_amplitude function

Compute PSNR (in dB) between two complex SAR images by comparing their amplitudes.

File location: sarpyx/utils/metrics.py:123

Signature

psnr_amplitude(ref: np.ndarray, pred: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array (ground truth)
prednp.ndarrayyes-Predicted complex SAR image array (generated)

Return Type

float

PSNR value in decibels. Higher values indicate better quality. Returns inf if MSE is zero (perfect reconstruction).

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import psnr_amplitude

result = psnr_amplitude(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

ssim_amplitude function

Compute SSIM between two complex SAR images using their amplitudes.

File location: sarpyx/utils/metrics.py:165

Signature

ssim_amplitude(ref: np.ndarray, pred: np.ndarray, window_size: int=7, return_components: bool=False) -> Union[float, Tuple[float, float, float, float]]

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array
window_sizeintno7Size of local window for computing statistics
return_componentsboolnoFalseIf True, returns individual SSIM components

Return Type

Union[float, Tuple[float, float, float, float]]

If return_components=False: Mean SSIM value (0 to 1) If return_components=True: Tuple of (ssim, luminance, contrast, structure) Higher values indicate better structural similarity.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import ssim_amplitude

result = ssim_amplitude(ref=<ref>, pred=<pred>)

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

amplitude_correlation function

Pearson correlation coefficient between two images' amplitudes.

File location: sarpyx/utils/metrics.py:224

Signature

amplitude_correlation(ref: np.ndarray, pred: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array

Return Type

float

Correlation coefficient (0 to 1 for non-negative amplitudes). Value of 1 indicates perfect linear similarity.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import amplitude_correlation

result = amplitude_correlation(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

phase_error_stats function

Compute mean absolute error (MAE) and root mean squared error (RMSE) of phase.

File location: sarpyx/utils/metrics.py:260

Signature

phase_error_stats(ref: np.ndarray, pred: np.ndarray) -> Tuple[float, float]

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array

Return Type

Tuple[float, float]

Tuple of (mae, rmse) in radians. Lower values indicate higher phase fidelity.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import phase_error_stats

result = phase_error_stats(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

complex_coherence function

Compute the complex coherence (magnitude of correlation) between two complex images.

File location: sarpyx/utils/metrics.py:295

Signature

complex_coherence(ref: np.ndarray, pred: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array

Return Type

float

Coherence value (0 to 1). Value of 1 indicates perfect complex match.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import complex_coherence

result = complex_coherence(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

phase_coherence function

Compute phase-only coherence between two complex images.

File location: sarpyx/utils/metrics.py:330

Signature

phase_coherence(ref: np.ndarray, pred: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array
prednp.ndarrayyes-Predicted complex SAR image array

Return Type

float

Phase coherence value (0 to 1). Higher values indicate better phase consistency.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import phase_coherence

result = phase_coherence(ref=<ref>, pred=<pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

enl function

Compute Equivalent Number of Looks (ENL) for a given intensity image.

File location: sarpyx/utils/metrics.py:361

Signature

enl(intensity_image: np.ndarray) -> float

Parameters

ParameterTypeRequiredDefaultDescription
intensity_imagenp.ndarrayyes-2D array of intensity values (|amplitude|²)

Return Type

float

ENL value. Higher values indicate less speckle noise.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import enl

result = enl(intensity_image=<intensity_image>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

resolution_gain function

Estimate resolution gain by comparing autocorrelation widths of original vs super-res images.

File location: sarpyx/utils/metrics.py:387

Signature

resolution_gain(orig: np.ndarray, sr: np.ndarray, threshold: float=0.5) -> float

Parameters

ParameterTypeRequiredDefaultDescription
orignp.ndarrayyes-Original lower resolution complex SAR image array
srnp.ndarrayyes-Super-resolved complex SAR image array
thresholdfloatno0.5Threshold fraction (0-1) for defining mainlobe width

Return Type

float

Resolution gain factor. Value > 1 indicates resolution improvement. Value of ~2 indicates roughly double linear resolution.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import resolution_gain

result = resolution_gain(orig=<orig>, sr=<sr>)

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

evaluate_sar_metrics function

Compute comprehensive SAR super-resolution metrics.

File location: sarpyx/utils/metrics.py:447

Signature

evaluate_sar_metrics(ref: np.ndarray, pred: np.ndarray, window_size: int=7, threshold: float=0.5) -> dict

Parameters

ParameterTypeRequiredDefaultDescription
refnp.ndarrayyes-Reference complex SAR image array (ground truth)
prednp.ndarrayyes-Predicted complex SAR image array (super-resolved)
window_sizeintno7Window size for SSIM computation
thresholdfloatno0.5Threshold for resolution gain computation

Return Type

dict

Dictionary containing all computed metrics with descriptive keys. Returns default values if arrays are invalid (e.g., from incomplete downloads).

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.metrics import evaluate_sar_metrics

result = evaluate_sar_metrics(ref=<ref>, pred=<pred>)

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

Public Classes (0)

No public classes detected.