Shortcuts

mmagic.evaluation.metrics.snr

Module Contents

Classes

SNR

Signal-to-Noise Ratio.

Functions

snr(gt, pred[, crop_border, input_order, convert_to, ...])

Calculate PSNR (Peak Signal-to-Noise Ratio).

class mmagic.evaluation.metrics.snr.SNR(gt_key: str = 'gt_img', pred_key: str = 'pred_img', collect_device: str = 'cpu', prefix: Optional[str] = None, crop_border=0, input_order='CHW', convert_to=None)[源代码]

Bases: mmagic.evaluation.metrics.base_sample_wise_metric.BaseSampleWiseMetric

Signal-to-Noise Ratio.

Ref: https://en.wikipedia.org/wiki/Signal-to-noise_ratio

参数
  • gt_key (str) – Key of ground-truth. Default: ‘gt_img’

  • pred_key (str) – Key of prediction. Default: ‘pred_img’

  • collect_device (str) – Device name used for collecting results from different ranks during distributed training. Must be ‘cpu’ or ‘gpu’. Defaults to ‘cpu’.

  • prefix (str, optional) – The prefix that will be added in the metric names to disambiguate homonymous metrics of different evaluators. If prefix is not provided in the argument, self.default_prefix will be used instead. Default: None

  • crop_border (int) – Cropped pixels in each edges of an image. These pixels are not involved in the SNR calculation. Default: 0.

  • input_order (str) – Whether the input order is ‘HWC’ or ‘CHW’. Default: ‘CHW’.

  • convert_to (str) – Whether to convert the images to other color models. If None, the images are not altered. When computing for ‘Y’, the images are assumed to be in BGR order. Options are ‘Y’ and None. Default: None.

Metrics:
  • SNR (float): Signal-to-Noise Ratio

metric = 'SNR'[源代码]
process_image(gt, pred, mask)[源代码]

Process an image.

参数
  • gt (Torch | np.ndarray) – GT image.

  • pred (Torch | np.ndarray) – Pred image.

  • mask (Torch | np.ndarray) – Mask of evaluation.

返回

SNR result.

返回类型

np.ndarray

mmagic.evaluation.metrics.snr.snr(gt, pred, crop_border=0, input_order='HWC', convert_to=None, channel_order='rgb')[源代码]

Calculate PSNR (Peak Signal-to-Noise Ratio).

Ref: https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio

参数
  • gt (ndarray) – Images with range [0, 255].

  • pred (ndarray) – Images with range [0, 255].

  • crop_border (int) – Cropped pixels in each edges of an image. These pixels are not involved in the PSNR calculation. Default: 0.

  • input_order (str) – Whether the input order is ‘HWC’ or ‘CHW’. Default: ‘HWC’.

  • convert_to (str) – Whether to convert the images to other color models. If None, the images are not altered. When computing for ‘Y’, the images are assumed to be in BGR order. Options are ‘Y’ and None. Default: None.

  • channel_order (str) – The channel order of image. Default: ‘rgb’.

返回

SNR result.

返回类型

float

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.