Hi,
There is an operational difference in the function “ssim” when called without passing the name-value argument “DataFormat”. The difference in the output values as described in your query arises because a 2-D RGB image is treated differently in these two scenarios.
When no optional parameters are provided, the function processes the image in the default manner. This is equivalent to passing the value “SSS” as the “DataFormat” parameter. This signifies that the image has 3 spatial dimensions.
ref = imread("peppers.png");%load 2D RGB Image
A = imgaussfilt(ref,1.5,"FilterSize",11,"Padding","replicate");%create a blurred copy
montage({ref A})%plot the 2 images side-by-side
title("Reference Image (Left) vs. Blurred Image (Right)")
[ssimVal,ssimMap] = ssim(A,ref);%default operation
disp(ssimVal)
[ssimVal,ssimMap] = ssim(A,ref, 'DataFormat', 'SSS');%call the function with 'DataFormat' set to 'SSS'
disp(ssimVal)
However, when the “DataFormat” argument is set to “SSC”, the function interprets that the image in question has 2 spatial dimensions and 1 channel dimension. This is the recommended format for processing 2-D RGB images as per MATLAB documentation - https://www.mathworks.com/help/releases/R2023b/images/ref/ssim.html?searchHighlight=ssim&s_tid=doc_srchtitle#:~:text=Example%3A%20%22SSC%22%20indicates%20that%20the%20array%20has%20two%20spatial%20dimensions%20and%20one%20channel%20dimension%2C%20appropriate%20for%202%2DD%20RGB%20image%20data. Hence, there is a difference in the output value, as seen here:
[ssimVal,ssimMap] = ssim(A,ref, 'DataFormat', 'SSC');%call the function with 'DataFormat' set to 'SSC'
disp(mean(ssimVal))
For more information on the function “ssim”, please refer to this documentation link -
Hope this helps!
Raghava