multissim
Multiscale structural similarity (MSSSIM) index for image quality
Syntax
Description
calculates the multiscale structural similarity (MSSSIM) index,
score
= multissim(I
,Iref
)score
, for image I
, using
Iref
as the reference image. A value closer to 1 indicates better
image quality and a value closer to 0 indicates poorer quality.
MSSSIM is only defined for grayscale images. For inputs with more than two dimensions,
multissim
treats each element of higher dimensions as a separate 2D
grayscale image.
controls aspects of the computation using one or more namevalue arguments. For example,
specify the number of scales using the score
= multissim(I
,Iref
,Name,Value
)'NumScales'
argument.
[
also returns the local MSSSIM index value for each pixel in each scaled version of
score
,qualityMaps
] = multissim(___)I
. The qualitymap
output is a cell array
containing maps for each of the scaled versions of I
. Each quality map
is the same size as the corresponding scaled version of I
.
Examples
Calculate MSSSIM
Load an image into the workspace.
Iref = imread('pout.tif');
Create a noisy version of the image for comparison purposes.
I = imnoise(Iref,'salt & pepper',0.05);
Display the original image and noisy image.
figure; montage({Iref,I});
Calculate the MSSSIM index that measures the quality of the input image compared to the reference image.
score = multissim(I,Iref)
score = single
0.6732
Calculate MSSSIM and Get Local MSSSIM Maps
Load an image into the workspace.
Iref = imread('pout.tif');
I = Iref;
Add noise to a localized part of the image.
I(1:100,1:100) = imnoise(Iref(1:100,1:100),'salt & pepper',0.05);
Display the original image and the noisy image.
figure; montage({Iref,I});
Calculate the local MSSSIM index maps for the noisy image, qualitymaps
, using the original image as the reference. The return value, qualitymaps
, is a cell array containing a quality map for each of the scaled versions of the image. Each map is the same size as the corresponding scaled version of the image.
[~, qualitymaps] = multissim(I,Iref);
figure
montage(qualitymaps,'Size',[1 5])
Calculate MSSSIM Specifying Scale Weights
Load an image into the workspace.
Iref = imread('pout.tif');
Create a noisy version of the image for comparison purposes.
I = imnoise(Iref,'salt & pepper',0.05);
Display the original image and the noisy version of the image.
figure; montage({Iref,I});
Calculate the MSSSIM index for the noisy image, using the original image as the reference. Specify how much to weigh the local MSSSIM index calculations for each scaled image, using the 'ScaleWeights'
argument. The example uses the weight values defined in the article by Wang, Simoncelli, and Bovik.
score = multissim(I,Iref,'ScaleWeights',[0.0448,0.2856,0.3001,0.2363,0.1333])
score = single
0.6773
Calculate MSSSIM of Color Image
Read a color image into the workspace.
RGB = imread("kobi.png");
Create a version of the image with added salt and pepper noise.
RGBNoisy = imnoise(RGB,"salt & pepper");
Display the two images in a montage.
montage({RGB,RGBNoisy})
Calculate the MSSSIM of each color channel of the noisy image.
score = multissim(RGBNoisy,RGB); score = squeeze(score)
score = 3x1 single column vector
0.7084
0.7135
0.7066
Calculate MSSSIM for dlarray
Input
Read a color image into the workspace.
ref = imread("strawberries.jpg");
ref = im2single(ref);
Simulate a batch of six images by replicating the image along the fourth dimension.
refBatch = repmat(ref,[1 1 1 6]);
Create a copy of the batch of images, adding salt and pepper noise.
noisyBatch = imnoise(refBatch,"salt & pepper");
Create a formatted dlarray
object for the original and noisy batch of images. The format is "SSCB" for spatialspatialchannelbatch.
dlrefBatch = dlarray(refBatch,"SSCB"); dlnoisyBatch = dlarray(noisyBatch,"SSCB");
Calculate the MSSSIM score of the noisy data with respect to the original data.
scores = multissim(dlnoisyBatch,dlrefBatch);
Remove the singleton dimensions corresponding to the spatial dimensions and display the scores. Each element is the MSSSIM score for one color channel of one image of the batch.
squeeze(scores)
ans = 3(C) x 6(B) single dlarray 0.8334 0.8335 0.8348 0.8335 0.8340 0.8349 0.8325 0.8316 0.8309 0.8310 0.8317 0.8326 0.8140 0.8123 0.8166 0.8129 0.8136 0.8123
Input Arguments
I
— Input image
numeric array  dlarray
object
Input image, specified as a numeric array of any dimension or a dlarray
(Deep Learning Toolbox) object.
Formatted dlarray
objects cannot include more than one channel label,
more than one batch label, and more than two spatial labels.
Data Types: single
 double
 int16
 uint8
 uint16
Iref
— Reference image
numeric array  dlarray
object
Reference image, specified as a numeric array of any dimension or a dlarray
(Deep Learning Toolbox) object.
Formatted dlarray
objects cannot include more than one channel label,
more than one batch label, and more than two spatial labels.
Data Types: single
 double
 int16
 uint8
 uint16
NameValue Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Namevalue arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: score = multissim(I,Iref,"NumScales",3);
NumScales
— Number of scales
5
(default)  positive integer
Number of scales used to calculate the MSSSIM index, specified as a positive
integer. Setting NumScales
to 1
is equivalent
to using the ssim
function with its
Exponents
namevalue argument set to [1 1
1]
. The size of the input image limits the number of scales. The
multissim
function scales the image
(NumScales
 1) times, downsampling the image by a factor of 2
with each scaling.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
ScaleWeights
— Relative values across scales
vector of positive numbers
Relative values across the scales, specified as a vector of positive elements. The
length of the vector is equal to the number of scales, because each element
corresponds to one of the scaled versions of the original image. The
multissim
function normalizes the values to 1. By default, the
scale weights equal fspecial
("gaussian",[1,numScales],1)
. The
multissim
function uses a Gaussian distribution as the default
because the human visual sensitivity peaks at middle frequencies and decreases in both
directions. For an example of setting ScaleWeights
, see Calculate MSSSIM Specifying Scale Weights.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
Sigma
— Standard deviation
1.5
(default)  positive number
Standard deviation of the isotropic Gaussian function, specified as a positive
number. This value specifies the weighting of the neighborhood pixels around a pixel
for estimating local statistics. The multissim
function uses
weighting to avoid blocking artifacts when estimating local statistics.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
DynamicRange
— Dynamic range of input image
positive number
Dynamic range of the input image, specified as a positive number. The default
value of DynamicRange
depends on the data type of image
I
, and is calculated as diff(
. For example, the default dynamic
range is getrangefromclass
(I))255
for images of data type uint8
, and
the default is 1
for images of data type double
or single
with pixel values in the range [0, 1].
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
Output Arguments
score
— MSSSIM index
numeric scalar  numeric array  dlarray
object
MSSSIM index for image quality, returned as a numeric scalar, numeric array, or
dlarray
(Deep Learning Toolbox) object
as indicated in the table. The value of score
is typically in the
range [0, 1]. The value 1 indicates the highest quality and occurs when
I
and Iref
are equivalent. Smaller values
correspond to poorer quality. For some combinations of inputs and namevalue pair
arguments, score
can be negative.
Input Image Type  MSSSIM Value 

2D numeric matrices  Numeric scalar with a single MSSSIM measurement. 
2D dlarray objects  1by1 dlarray object with a single MSSSIM
measurement. 
ND numeric arrays with N>2  Numeric array of the same dimensionality as the input images. The first two
dimensions of score are singleton dimensions. There is one
MSSSIM measurement for each element along the higher dimensions. 
Unformatted ND 

Formatted ND  dlarray object of the same dimensionality as the input
images. The spatial dimensions of score are singleton
dimensions. There is one MSSSIM measurement for each element along any channel
or batch dimension. 
qualityMaps
— Local MSSSIM index values
cell array of numeric arrays  cell array of dlarray
objects
Local MSSSIM index values for each pixel in each scaled version, returned as a cell
array of numeric arrays or a cell array of dlarray
(Deep Learning Toolbox)
objects. The size of the cell array is 1byNumScales
. Each element
in qualityMaps
indicates the quality of the corresponding pixel at
the corresponding scale factor. The format of each element uses the formatting of the
scores
argument, based on the format of the input images.
Algorithms
The structural similarity (SSIM) index measures perceived quality by quantifying the SSIM
between an image and a reference image (see ssim
). The multissim
function calculates the MSSSIM index
by combining the SSIM index of several versions of the image at various scales. The MSSSIM
index can be more robust when compared to the SSIM index with regard to variations in viewing
conditions.
The multissim
function uses doubleprecision arithmetic for input
images of class double
. All other types of input images use
singleprecision arithmetic.
References
[1] Wang, Z., Simoncelli, E.P., Bovik, A.C. Multiscale Structural Similarity for Image Quality Assessment. In: The ThirtySeventh Asilomar Conference on Signals, Systems & Computers, 2003, 1398–1402. Pacific Grove, CA, USA: IEEE, 2003. https://doi.org/10.1109/ACSSC.2003.1292216.
Extended Capabilities
ThreadBased Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports threadbased environments. For more information, see Run MATLAB Functions in ThreadBased Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Image Processing on a GPU.
Version History
Introduced in R2020aR2022b: Support for threadbased environments
multissim
now supports threadbased
environments.
R2021a: Calculate metrics of deep learning arrays and specify dimensions of computation
The multissim
function now accepts dlarray
input
for deep learning applications.
This function also supports formatted data with dimension labels of
'S'
(spatial), 'C'
(channel), and
'B'
(batch). For data with a batch dimension, the function returns a
separate result for each index along the batch dimension.
R2021a: Support for GPU acceleration
multissim
now supports GPU acceleration
(requires Parallel Computing Toolbox™).
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)