pyiqa.archs.niqe_arch ===================== .. py:module:: pyiqa.archs.niqe_arch .. autoapi-nested-parse:: 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: MATLAB codes: http://live.ece.utexas.edu/research/quality/niqe_release.zip ILNIQE Metric Created by: Chaofeng Chen (https://github.com/chaofengc) Reference: - Python codes: https://github.com/IceClear/IL-NIQE/blob/master/IL-NIQE.py - Matlab codes: https://www4.comp.polyu.edu.hk/~cslzhang/IQA/ILNIQE/Files/ILNIQE.zip Module Contents --------------- .. py:data:: default_model_urls .. py:function:: compute_feature(block: torch.Tensor, ilniqe: bool = False) -> torch.Tensor Compute features. :param block: Image block in shape (b, c, h, w). :type block: Tensor :returns: Features with length of 18. :rtype: list .. py:function:: 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 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. :type mu_pris_param: Tensor :param cov_pris_param: Covariance of a pre-defined multivariate Gaussian model calculated on the pristine dataset. :type cov_pris_param: Tensor :param gaussian_window: A 7x7 Gaussian window used for smoothing the image. :type gaussian_window: Tensor :param block_size_h: Height of the blocks in to which image is divided. Default: 96 (the official recommended value). :type block_size_h: int :param block_size_w: Width of the blocks in to which image is divided. Default: 96 (the official recommended value). :type block_size_w: int .. py:function:: 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 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. :type crop_border: int :param test_y_channel: Whether converted to 'y' (of MATLAB YCbCr) or 'gray'. :type test_y_channel: Bool :param pretrained_model_path: The pretrained model path. :type pretrained_model_path: str :returns: NIQE result. :rtype: Tensor .. py:function:: gauDerivative(sigma, in_ch=1, out_ch=1, device=None) .. py:function:: 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 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. :type mu_pris_param: Tensor :param cov_pris_param: Covariance of a pre-defined multivariate Gaussian model calculated on the pristine dataset. :type cov_pris_param: Tensor :param principleVectors: Features from official .mat file. :type principleVectors: Tensor :param meanOfSampleData: Features from official .mat file. :type meanOfSampleData: Tensor :param resize: resize image. Default: True. :type resize: Bloolean :param block_size_h: Height of the blocks in to which image is divided. Default: 84 (the official recommended value). :type block_size_h: int :param block_size_w: Width of the blocks in to which image is divided. Default: 84 (the official recommended value). :type block_size_w: int .. py:function:: 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 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. :type crop_border: int :param pretrained_model_path: The pretrained model path. :type pretrained_model_path: str :returns: IL-NIQE result. :rtype: Tensor .. py:class:: 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) Bases: :py:obj:`torch.nn.Module` :param - channels: Number of processed channel. :type - channels: int :param - test_y_channel: whether to use y channel on ycbcr. :type - test_y_channel: bool :param - crop_border: Cropped pixels in each edge of an image. These :type - crop_border: int :param pixels are not involved in the metric calculation.: :param - pretrained_model_path: The pretrained model path. :type - pretrained_model_path: str .. rubric:: 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. .. py:method:: forward(x: torch.Tensor) -> torch.Tensor Computation of NIQE metric. Input: x: An input tensor. Shape :math:`(N, C, H, W)`. Output: score (tensor): results of ilniqe metric, should be a positive real number. Shape :math:`(N, 1)`. .. py:class:: ILNIQE(channels: int = 3, crop_border: int = 0, pretrained_model_path: str = None) Bases: :py:obj:`torch.nn.Module` :param - channels: Number of processed channel. :type - channels: int :param - test_y_channel: whether to use y channel on ycbcr. :type - test_y_channel: bool :param - crop_border: Cropped pixels in each edge of an image. These :type - crop_border: int :param pixels are not involved in the metric calculation.: :param - pretrained_model_path: The pretrained model path. :type - pretrained_model_path: str .. rubric:: 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. .. py:method:: forward(x: torch.Tensor) -> torch.Tensor Computation of NIQE metric. Input: x: An input tensor. Shape :math:`(N, C, H, W)`. Output: score (tensor): results of ilniqe metric, should be a positive real number. Shape :math:`(N, 1)`.