Shortcuts

mmagic.evaluation.metrics.niqe

Module Contents

Classes

NIQE

Calculate NIQE (Natural Image Quality Evaluator) metric.

Functions

estimate_aggd_param(block)

Estimate AGGD (Asymmetric Generalized Gaussian Distribution) parameters.

compute_feature(block)

Compute features.

niqe_core(img, mu_pris_param, cov_pris_param, ...[, ...])

Calculate NIQE (Natural Image Quality Evaluator) metric.

niqe(img, crop_border[, input_order, convert_to])

Calculate NIQE (Natural Image Quality Evaluator) metric.

class mmagic.evaluation.metrics.niqe.NIQE(key: str = 'pred_img', is_predicted: bool = True, collect_device: str = 'cpu', prefix: Optional[str] = None, crop_border=0, input_order='HWC', convert_to='gray')[源代码]

Bases: mmagic.evaluation.metrics.base_sample_wise_metric.BaseSampleWiseMetric

Calculate NIQE (Natural Image Quality Evaluator) metric.

Ref: Making a “Completely Blind” Image Quality Analyzer. This implementation could produce almost the same results as the official MATLAB codes: http://live.ece.utexas.edu/research/quality/niqe_release.zip

We use the official params estimated from the pristine dataset. We use the recommended block size (96, 96) without overlaps.

参数
  • key (str) – Key of image. Default: ‘pred_img’

  • is_predicted (bool) – If the image is predicted, it will be picked from predictions; otherwise, it will be picked from data_batch. Default: True

  • 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 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: ‘gray’.

Metrics:
  • NIQE (float): Natural Image Quality Evaluator

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

Process an image.

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

  • pred (np.ndarray) – Pred image.

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

返回

NIQE result.

返回类型

result (np.ndarray)

mmagic.evaluation.metrics.niqe.estimate_aggd_param(block)[源代码]

Estimate AGGD (Asymmetric Generalized Gaussian Distribution) parameters.

参数

block (np.ndarray) – 2D Image block.

返回

alpha (float), beta_l (float) and beta_r (float) for the AGGD

distribution (Estimating the parames in Equation 7 in the paper).

返回类型

tuple

mmagic.evaluation.metrics.niqe.compute_feature(block)[源代码]

Compute features.

参数

block (np.ndarray) – 2D Image block.

返回

Features with length of 18.

返回类型

feat (List)

mmagic.evaluation.metrics.niqe.niqe_core(img, mu_pris_param, cov_pris_param, gaussian_window, block_size_h=96, block_size_w=96)[源代码]

Calculate NIQE (Natural Image Quality Evaluator) metric.

Ref: Making a “Completely Blind” Image Quality Analyzer. This implementation could produce almost the same results as the official MATLAB codes: http://live.ece.utexas.edu/research/quality/niqe_release.zip

Note that we do not include block overlap height and width, since they are always 0 in the official implementation.

For good performance, it is advisable by the official implementation to divide the distorted image in to the same size patched as used for the construction of multivariate Gaussian model.

参数
  • img (np.ndarray) – Input image whose quality needs to be computed. The image must be a gray or Y (of YCbCr) image with shape (h, w). Range [0, 255] with float type.

  • mu_pris_param (np.ndarray) – Mean of a pre-defined multivariate Gaussian model calculated on the pristine dataset.

  • cov_pris_param (np.ndarray) – Covariance of a pre-defined multivariate Gaussian model calculated on the pristine dataset.

  • gaussian_window (ndarray) – A 7x7 Gaussian window used for smoothing the image.

  • block_size_h (int) – Height of the blocks in to which image is divided. Default: 96 (the official recommended value). Default: 96.

  • block_size_w (int) – Width of the blocks in to which image is divided. Default: 96 (the official recommended value). Default: 96.

返回

NIQE quality.

返回类型

np.ndarray

mmagic.evaluation.metrics.niqe.niqe(img, crop_border, input_order='HWC', convert_to='y')[源代码]

Calculate NIQE (Natural Image Quality Evaluator) metric.

Ref: Making a “Completely Blind” Image Quality Analyzer. This implementation could produce almost the same results as the official MATLAB codes: http://live.ece.utexas.edu/research/quality/niqe_release.zip

We use the official params estimated from the pristine dataset. We use the recommended block size (96, 96) without overlaps.

参数
  • img (np.ndarray) – Input image whose quality needs to be computed. The input image must be in range [0, 255] with float/int type. The input_order of image can be ‘HW’ or ‘HWC’ or ‘CHW’. (BGR order) If the input order is ‘HWC’ or ‘CHW’, it will be converted to gray or Y (of YCbCr) image according to the convert_to argument.

  • crop_border (int) – Cropped pixels in each edge of an image. These pixels are not involved in the metric calculation.

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

  • convert_to (str) – Whether converted to ‘y’ (of MATLAB YCbCr) or ‘gray’. Default: ‘y’.

返回

NIQE result.

返回类型

niqe_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.