Module: sarpyx.processor.utils.metrics
File: sarpyx/processor/utils/metrics.py
No module docstring available; module purpose is inferred from implementation.
Exported Symbols (__all__)
No explicit __all__ list. Public symbols inferred from implementation.
Public Functions (6)
luminance function
Calculate the luminance component of SSIM.
File location: sarpyx/processor/utils/metrics.py:12
Signature
luminance(img1: np.ndarray, img2: np.ndarray) -> float
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
img1 | np.ndarray | yes | - | First input image as numpy array. |
img2 | np.ndarray | yes | - | Second input image as numpy array. |
Return Type
float
Luminance similarity value.
Exceptions
None explicitly documented; inferred from implementation.
Side Effects
- inferred from implementation
Example Usage
from sarpyx.processor.utils.metrics import luminance
result = luminance(img1=<img1>, img2=<img2>)
Edge Cases
No explicit edge-case section found; behavior is inferred from implementation.
contrast function
Calculate the contrast component of SSIM.
File location: sarpyx/processor/utils/metrics.py:33
Signature
contrast(img1: np.ndarray, img2: np.ndarray) -> float
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
img1 | np.ndarray | yes | - | First input image as numpy array. |
img2 | np.ndarray | yes | - | Second input image as numpy array. |
Return Type
float
Contrast similarity value.
Exceptions
None explicitly documented; inferred from implementation.
Side Effects
- inferred from implementation
Example Usage
from sarpyx.processor.utils.metrics import contrast
result = contrast(img1=<img1>, img2=<img2>)
Edge Cases
No explicit edge-case section found; behavior is inferred from implementation.
structure function
Calculate the structure component of SSIM.
File location: sarpyx/processor/utils/metrics.py:54
Signature
structure(img1: np.ndarray, img2: np.ndarray) -> float
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
img1 | np.ndarray | yes | - | First input image as numpy array. |
img2 | np.ndarray | yes | - | Second input image as numpy array. |
Return Type
float
Structure similarity value.
Exceptions
None explicitly documented; inferred from implementation.
Side Effects
- inferred from implementation
Example Usage
from sarpyx.processor.utils.metrics import structure
result = structure(img1=<img1>, img2=<img2>)
Edge Cases
No explicit edge-case section found; behavior is inferred from implementation.
create_window function
Create a 2D Hann window for SSIM calculation.
File location: sarpyx/processor/utils/metrics.py:77
Signature
create_window(window_size: int, channel: int) -> torch.Tensor
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
window_size | int | yes | - | Size of the window. |
channel | int | yes | - | Number of channels. |
Return Type
torch.Tensor
2D Hann window as torch tensor.
Exceptions
None explicitly documented; inferred from implementation.
Side Effects
- inferred from implementation
Example Usage
from sarpyx.processor.utils.metrics import create_window
result = create_window(window_size=<window_size>, channel=<channel>)
Edge Cases
No explicit edge-case section found; behavior is inferred from implementation.
ssim function
Calculate Structural Similarity Index Measure (SSIM) between two images.
File location: sarpyx/processor/utils/metrics.py:96
Signature
ssim(img1: Union[torch.Tensor, np.ndarray], img2: Union[torch.Tensor, np.ndarray], window_size: int=11, window: Optional[torch.Tensor]=None, size_average: bool=True, full: bool=False, val_range: Optional[Tuple[float, float]]=None) -> torch.Tensor
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
img1 | Union[torch.Tensor, np.ndarray] | yes | - | First input image as tensor or numpy array. |
img2 | Union[torch.Tensor, np.ndarray] | yes | - | Second input image as tensor or numpy array. |
window_size | int | no | 11 | Size of sliding window for SSIM calculation. |
window | Optional[torch.Tensor] | no | None | Pre-computed window tensor. If None, creates Hann window. |
size_average | bool | no | True | If True, returns mean SSIM value. |
full | bool | no | False | If True, returns full SSIM map (currently unused). |
val_range | Optional[Tuple[float, float]] | no | None | Dynamic range of input images as (min, max) tuple. |
Return Type
torch.Tensor
SSIM value or map as torch tensor.
Exceptions
None explicitly documented; inferred from implementation.
Side Effects
- inferred from implementation
Example Usage
from sarpyx.processor.utils.metrics import ssim
result = ssim(img1=<img1>, img2=<img2>)
Edge Cases
Includes optional parameters with implementation-defined fallback behavior. Documented return may be None for some execution paths.
psnr function
Calculate Peak Signal-to-Noise Ratio (PSNR) between two images.
File location: sarpyx/processor/utils/metrics.py:174
Signature
psnr(img1: Union[torch.Tensor, np.ndarray], img2: Union[torch.Tensor, np.ndarray], max_val: float=1.0) -> torch.Tensor
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
img1 | Union[torch.Tensor, np.ndarray] | yes | - | First input image as tensor or numpy array. |
img2 | Union[torch.Tensor, np.ndarray] | yes | - | Second input image as tensor or numpy array. |
max_val | float | no | 1.0 | Maximum possible pixel value. |
Return Type
torch.Tensor
PSNR value as torch tensor.
Exceptions
None explicitly documented; inferred from implementation.
Side Effects
- inferred from implementation
Example Usage
from sarpyx.processor.utils.metrics import psnr
result = psnr(img1=<img1>, img2=<img2>)
Edge Cases
Includes optional parameters with implementation-defined fallback behavior.
Public Classes (0)
No public classes detected.