Skip to content
Back to skills

Peaksignalnoiseratiowithblockedeffect

ASecurity

Compute the PeakSignalNoiseRatioWithBlockedEffect metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute PeakSignalNoiseRatioWithBlockedEffect, or asks how to score with PeakSignalNoiseRatioWithBlockedEffect.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 11, 2026
documentationpython

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill peaksignalnoiseratiowithblockedeffect --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Peaksignalnoiseratiowithblockedeffect?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Peaksignalnoiseratiowithblockedeffect
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-peaksignalnoiseratiowithblockedeffect/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-peaksignalnoiseratiowithblockedeffect)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: peaksignalnoiseratiowithblockedeffect
description: Compute the PeakSignalNoiseRatioWithBlockedEffect metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute PeakSignalNoiseRatioWithBlockedEffect, or asks how to score with PeakSignalNoiseRatioWithBlockedEffect.
metadata:
  skill_kind: metric
  source_lib: torchmetrics
  import_path: torchmetrics.image.PeakSignalNoiseRatioWithBlockedEffect
  source: library_introspection
---

# peaksignalnoiseratiowithblockedeffect

> Metric `PeakSignalNoiseRatioWithBlockedEffect` from `torchmetrics` (torchmetrics.image.PeakSignalNoiseRatioWithBlockedEffect)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with PeakSignalNoiseRatioWithBlockedEffect, or
mentions `torchmetrics.image.PeakSignalNoiseRatioWithBlockedEffect` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics.image import PeakSignalNoiseRatioWithBlockedEffect

# PeakSignalNoiseRatioWithBlockedEffect(data_range: Union[float, tuple[float, float]], block_size: int = 8, **kwargs: Any) -> None
```

## Library docstring

```
Computes `Peak Signal to Noise Ratio With Blocked Effect`_ (PSNRB).

.. math::
    \text{PSNRB}(I, J) = 10 * \log_{10} \left(\frac{\max(I)^2}{\text{MSE}(I, J)-\text{B}(I, J)}\right)

Where :math:`\text{MSE}` denotes the `mean-squared-error`_ function. This metric is a modified version of PSNR that
better supports evaluation of images with blocked artifacts, that oftens occur in compressed images.

.. attention::
    Metric only supports grayscale images. If you have RGB images, please convert them to grayscale first.

As input to ``forward`` and ``update`` the metric accepts the following input

- ``preds`` (:class:`~torch.Tensor`): Predictions from model of shape ``(N,1,H,W)``
- ``target`` (:class:`~torch.Tensor`): Ground truth values of shape ``(N,1,H,W)``

As output of `forward` and `compute` the metric returns the following output

- ``psnrb`` (:class:`~torch.Tensor`): float scalar tensor with aggregated PSNRB value

Args:
    data_range: the range of the data. If a tuple is provided then the range is calculated as the difference and
        input is clamped between the values.
    block_size: integer indication the block size
    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Example:
    >>> from torch import rand
    >>> metric = PeakSignalNoiseRatioWithBlockedEffect(data_range=1.0)
    >>> preds = rand(2, 1, 10, 10)
    >>> target = rand(2, 1, 10, 10)
    >>> metric(preds, target)
    tensor(7.2893)
```

## Quick recipe

```python
import torchmetrics.image as _m
score = _m.PeakSignalNoiseRatioWithBlockedEffect(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.