I want to calculate the Structural Similarity Index (SSIM) between a generated and a target image (that have been picked randomly from an array of images).
This is what I have tried-
from skimage.metrics import structural_similarity as ssim
print(tar_image.shape)
print(gen_image.shape)
ssim_skimg = ssim(tar_image, gen_image,
data_range = gen_image.max() - gen_image.min(),
multichannel = True)
print("SSIM: based on scikit-image = ", ssim_skimg)
But I am getting this output:
(1, 128, 128, 3)
(1, 128, 128, 3)
ValueError: win_size exceeds image extent. If the input is a multichannel (color) image, set multichannel=True.
Can someone please tell me where I am going wrong and how I can fix this problem?
You have 3 channel images, so you should use the multichannel = True
argument.
Also you should remove the first dimension of your images to get (128,128,3)
shapes
import numpy as np
from skimage.metrics import structural_similarity as ssim
tar_image = np.zeros((128, 128, 3))
gen_image = np.zeros((128, 128, 3))
ssim_skimg = ssim(tar_image, gen_image, multichannel = True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.