basicsr.metrics.__init__¶
- basicsr.metrics.__init__.calculate_niqe(img, crop_border, input_order='HWC', convert_to='y', **kwargs)[source]¶
Calculate NIQE (Natural Image Quality Evaluator) metric.
Paper: 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
> MATLAB R2021a result for tests/data/baboon.png: 5.72957338 (5.7296) > Our re-implementation result for tests/data/baboon.png: 5.7295763 (5.7296)
We use the official params estimated from the pristine dataset. We use the recommended block size (96, 96) without overlaps.
- Parameters:
img (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’.
- Returns:
NIQE result.
- Return type:
float
- basicsr.metrics.__init__.calculate_psnr(img, img2, crop_border, input_order='HWC', test_y_channel=False, **kwargs)[source]¶
Calculate PSNR (Peak Signal-to-Noise Ratio).
Reference: https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
- Parameters:
img (ndarray) – Images with range [0, 255].
img2 (ndarray) – Images with range [0, 255].
crop_border (int) – Cropped pixels in each edge of an image. These pixels are not involved in the calculation.
input_order (str) – Whether the input order is ‘HWC’ or ‘CHW’. Default: ‘HWC’.
test_y_channel (bool) – Test on Y channel of YCbCr. Default: False.
- Returns:
PSNR result.
- Return type:
float
- basicsr.metrics.__init__.calculate_ssim(img, img2, crop_border, input_order='HWC', test_y_channel=False, **kwargs)[source]¶
Calculate SSIM (structural similarity).
Paper: Image quality assessment: From error visibility to structural similarity
The results are the same as that of the official released MATLAB code in https://ece.uwaterloo.ca/~z70wang/research/ssim/.
For three-channel images, SSIM is calculated for each channel and then averaged.
- Parameters:
img (ndarray) – Images with range [0, 255].
img2 (ndarray) – Images with range [0, 255].
crop_border (int) – Cropped pixels in each edge of an image. These pixels are not involved in the calculation.
input_order (str) – Whether the input order is ‘HWC’ or ‘CHW’. Default: ‘HWC’.
test_y_channel (bool) – Test on Y channel of YCbCr. Default: False.
- Returns:
SSIM result.
- Return type:
float