pyiqa.archs.niqe_arch¶
NIQE and ILNIQE Metrics NIQE Metric
Created by: https://github.com/xinntao/BasicSR/blob/5668ba75eb8a77e8d2dd46746a36fee0fbb0fdcd/basicsr/metrics/niqe.py Modified by: Jiadi Mo (https://github.com/JiadiMo) Reference:
- ILNIQE Metric
Created by: Chaofeng Chen (https://github.com/chaofengc) Reference:
Module Contents¶
- pyiqa.archs.niqe_arch.compute_feature(block: torch.Tensor, ilniqe: bool = False) torch.Tensor[source]¶
Compute features. :param block: Image block in shape (b, c, h, w). :type block: Tensor
- Returns:
Features with length of 18.
- Return type:
list
- pyiqa.archs.niqe_arch.niqe(img: torch.Tensor, mu_pris_param: torch.Tensor, cov_pris_param: torch.Tensor, block_size_h: int = 96, block_size_w: int = 96) torch.Tensor[source]¶
Calculate NIQE (Natural Image Quality Evaluator) metric. :param img: Input image. :type img: Tensor :param mu_pris_param: Mean of a pre-defined multivariate Gaussian
model calculated on the pristine dataset.
- Parameters:
cov_pris_param (Tensor) – Covariance of a pre-defined multivariate Gaussian model calculated on the pristine dataset.
gaussian_window (Tensor) – 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).
block_size_w (int) – Width of the blocks in to which image is divided. Default: 96 (the official recommended value).
- pyiqa.archs.niqe_arch.calculate_niqe(img: torch.Tensor, crop_border: int = 0, test_y_channel: bool = True, color_space: str = 'yiq', mu_pris_param: torch.Tensor = None, cov_pris_param: torch.Tensor = None, **kwargs) torch.Tensor[source]¶
Calculate NIQE (Natural Image Quality Evaluator) metric. :param img: Input image whose quality needs to be computed. :type img: Tensor :param crop_border: Cropped pixels in each edge of an image. These
pixels are not involved in the metric calculation.
- Parameters:
test_y_channel (Bool) – Whether converted to ‘y’ (of MATLAB YCbCr) or ‘gray’.
pretrained_model_path (str) – The pretrained model path.
- Returns:
NIQE result.
- Return type:
Tensor
- pyiqa.archs.niqe_arch.ilniqe(img: torch.Tensor, mu_pris_param: torch.Tensor, cov_pris_param: torch.Tensor, principleVectors: torch.Tensor, meanOfSampleData: torch.Tensor, resize: bool = True, block_size_h: int = 84, block_size_w: int = 84) torch.Tensor[source]¶
Calculate IL-NIQE (Integrated Local Natural Image Quality Evaluator) metric. :param img: Input image. :type img: Tensor :param mu_pris_param: Mean of a pre-defined multivariate Gaussian
model calculated on the pristine dataset.
- Parameters:
cov_pris_param (Tensor) – Covariance of a pre-defined multivariate Gaussian model calculated on the pristine dataset.
principleVectors (Tensor) – Features from official .mat file.
meanOfSampleData (Tensor) – Features from official .mat file.
resize (Bloolean) – resize image. Default: True.
block_size_h (int) – Height of the blocks in to which image is divided. Default: 84 (the official recommended value).
block_size_w (int) – Width of the blocks in to which image is divided. Default: 84 (the official recommended value).
- pyiqa.archs.niqe_arch.calculate_ilniqe(img: torch.Tensor, crop_border: int = 0, mu_pris_param: torch.Tensor = None, cov_pris_param: torch.Tensor = None, principleVectors: torch.Tensor = None, meanOfSampleData: torch.Tensor = None, **kwargs) torch.Tensor[source]¶
Calculate IL-NIQE metric. :param img: Input image whose quality needs to be computed. :type img: Tensor :param crop_border: Cropped pixels in each edge of an image. These
pixels are not involved in the metric calculation.
- Parameters:
pretrained_model_path (str) – The pretrained model path.
- Returns:
IL-NIQE result.
- Return type:
Tensor
- class pyiqa.archs.niqe_arch.NIQE(channels: int = 1, test_y_channel: bool = True, color_space: str = 'yiq', crop_border: int = 0, version: str = 'original', pretrained_model_path: str = None)[source]¶
Bases:
torch.nn.Module- Parameters:
channels (-) – Number of processed channel.
test_y_channel (-) – whether to use y channel on ycbcr.
crop_border (-) – Cropped pixels in each edge of an image. These
calculation. (pixels are not involved in the metric)
pretrained_model_path (-) – The pretrained model path.
References
Mittal, Anish, Rajiv Soundararajan, and Alan C. Bovik. “Making a “completely blind” image quality analyzer.” IEEE Signal Processing Letters (SPL) 20.3 (2012): 209-212.
- class pyiqa.archs.niqe_arch.ILNIQE(channels: int = 3, crop_border: int = 0, pretrained_model_path: str = None)[source]¶
Bases:
torch.nn.Module- Parameters:
channels (-) – Number of processed channel.
test_y_channel (-) – whether to use y channel on ycbcr.
crop_border (-) – Cropped pixels in each edge of an image. These
calculation. (pixels are not involved in the metric)
pretrained_model_path (-) – The pretrained model path.
References
Zhang, Lin, Lei Zhang, and Alan C. Bovik. “A feature-enriched completely blind image quality evaluator.” IEEE Transactions on Image Processing 24.8 (2015): 2579-2591.