fitniqe

Fit custom model for NIQE image quality score

Syntax

model = fitniqe(imds)
model = fitniqe(imds,Name,Value)

Description

example

model = fitniqe(imds) creates a Naturalness Image Quality Evaluator (NIQE) model from reference image datastore imds.

example

model = fitniqe(imds,Name,Value) creates a NIQE model using additional parameters to control the model calculation.

Examples

collapse all

Load a set of natural images into an image datastore. These images are shipped in Image Processing Toolbox™ in a directory named 'imdata'.

setDir = fullfile(toolboxdir('images'),'imdata');
imds = imageDatastore(setDir,'FileExtensions',{'.jpg'});

Train a custom NIQE model using the image datastore.

model = fitniqe(imds);
Extracting features from 37 images.
.
Completed 3 of 37 images.  Time: Calculating...
..
Completed 11 of 37 images.  Time: 00:32 of 01:11
..
Completed 14 of 37 images.  Time: 00:43 of 01:30
....
Completed 28 of 37 images.  Time: 00:53 of 01:05
...
Done.

Read an image of a natural scene. Display the image.

I = imread('car1.jpg');
imshow(I)

Calculate the NIQE score for the image using the custom model. Display the score.

niqeI = niqe(I,model);
fprintf('NIQE score for the image is %0.4f.\n',niqeI)
NIQE score for the image is 1.8601.

Load a set of natural images into an image datastore. These images are shipped in Image Processing Toolbox™ in a directory named 'imdata'.

setDir = fullfile(toolboxdir('images'),'imdata');
imds = imageDatastore(setDir,'FileExtensions',{'.jpg'});

Create the custom model of NSS features using the image datastore. Specify a block size and use the default sharpness threshold.

model = fitniqe(imds,'BlockSize',[48 96])
Extracting features from 37 images.
.
Completed 3 of 37 images.  Time: Calculating...

Completed 4 of 37 images.  Time: 00:45 of 09:18
...
Completed 12 of 37 images.  Time: 01:00 of 02:27
.
Completed 14 of 37 images.  Time: 01:18 of 03:00

Completed 17 of 37 images.  Time: 01:33 of 03:04
...
Completed 23 of 37 images.  Time: 01:43 of 02:35
...
Completed 31 of 37 images.  Time: 01:56 of 02:14
......
Done.
model = 
  niqeModel with properties:

                  Mean: [1x36 double]
            Covariance: [36x36 double]
             BlockSize: [48 96]
    SharpnessThreshold: 0

Read a natural image into the workspace. Display the image.

I = imread('yellowlily.jpg');
imshow(I)

Calculate the NIQE score for the image using the custom model. Display the score.

niqeI = niqe(I,model);
fprintf('NIQE score for the image is %0.4f.\n',niqeI)
NIQE score for the image is 2.9944.

Input Arguments

collapse all

Reference image datastore, specified as an ImageDatastore object. Images within the datastore must be real, nonsparse, m-by-n or m-by-n-by-3 matrices of data type single, double, int16, uint8, or uint16.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: model = fitniqe(imds,'BlockSize',[48 36]) fits a NIQE model using 48-by-36 pixel blocks.

Block size used to partition the images, specified as the comma-separated pair consisting of 'BlockSize' and a 2-element row vector of positive even integers. Blocks are nonoverlapping. Natural scene statistics, which are calculated from the blocks, define the output model.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Sharpness threshold, specified as the comma-separated pair consisting of 'SharpnessThreshold' and a numeric scalar in the range [0, 1]. The sharpness threshold, s, controls which image blocks are used to compute the model. fitniqe computes the model using all blocks that have sharpness more than s times the maximum sharpness among all blocks.

Data Types: single | double

Output Arguments

collapse all

Custom model of image features, returned as a niqeModel object.

Tips

  • The custom dataset specified in the image datastore imds should consist of images that are perceptually pristine to human subjects. However, the definition of pristine depends on the application. For example, a pristine set of microscopy images has a different set of quality criteria than images of buildings or outdoor scenes. When training a custom NIQE model, use images with varied image content and with potentially different sets of quality criteria.

References

[1] Mittal, A., R. Soundararajan, and A. C. Bovik. "Making a Completely Blind Image Quality Analyzer." IEEE Signal Processing Letters. Vol. 22, Number 3, March 2013, pp. 209–212.

Introduced in R2017b