tfmri.image.ssim2d
tfmri.image.ssim2d¶
- ssim2d(img1, img2, max_val=None, filter_size=11, filter_sigma=1.5, k1=0.01, k2=0.03, name='ssim2d')[source]¶
Computes the structural similarity index (SSIM) between two 2D images.
This function operates on batches of multi-channel inputs and returns an SSIM value for each image in the batch.
- Parameters
img1 – A
Tensor
. First batch of images. Must have rank >= 3 with shapebatch_shape + [height, width, channels]
.height
andwidth
must be greater than or equal tofilter_size
. Can have integer or floating point type, with values in the range[0, max_val]
.img2 – A
Tensor
. Second batch of images. Must have rank >= 3 with shapebatch_shape + [height, width, channels]
.height
andwidth
must be greater than or equal tofilter_size
. Can have integer or floating point type, with values in the range[0, max_val]
.max_val – The dynamic range of the images (i.e., the difference between the maximum and the minimum allowed values). Defaults to 1 for floating point input images and
MAX
for integer input images, whereMAX
is the largest positive representable number for the data type.filter_size – The size of the Gaussian filter. Defaults to 11.
filter_sigma – The standard deviation of the Gaussian filter. Defaults to 1.5.
k1 – Factor used to calculate the regularization constant for the luminance term, as
C1 = (k1 * max_val) ** 2
. Defaults to 0.01.k2 – Factor used to calculate the regularization constant for the contrast term, as
C2 = (k2 * max_val) ** 2
. Defaults to 0.03.name – Namespace to embed the computation in.
- Returns
A
Tensor
of typefloat32
and shapebatch_shape
containing an SSIM value for each image in the batch.
References
- 1
Zhou Wang, A. C. Bovik, H. R. Sheikh and E. P. Simoncelli, “Image quality assessment: from error visibility to structural similarity,” in IEEE Transactions on Image Processing, vol. 13, no. 4, pp. 600-612, April 2004, doi: 10.1109/TIP.2003.819861.