Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssim计算问题 #45

Open
kerryhhh opened this issue Feb 21, 2023 · 1 comment
Open

ssim计算问题 #45

kerryhhh opened this issue Feb 21, 2023 · 1 comment

Comments

@kerryhhh
Copy link

kerryhhh commented Feb 21, 2023

def calculate_ssim(img1, img2):
'''calculate SSIM
the same outputs as MATLAB's
img1, img2: [0, 255]
'''
if not img1.shape == img2.shape:
raise ValueError('Input images must have the same dimensions.')
if img1.ndim == 2:
return ssim(img1, img2)
elif img1.ndim == 3:
if img1.shape[2] == 3:
ssims = []
for i in range(3):
ssims.append(ssim(img1, img2))
return np.array(ssims).mean()
elif img1.shape[2] == 1:
return ssim(np.squeeze(img1), np.squeeze(img2))
else:
raise ValueError('Wrong input image dimensions.')

计算ssim这里的第180行是不是写错了?处理3通道图片的时候

@pkuxmq
Copy link
Owner

pkuxmq commented Mar 2, 2023

是的,应该是ssims.append(ssim(img1[..., i], img2[..., i])),这一部分的代码是直接使用的当时BasicSR中的代码,后来BasicSR应该对此进行了修正。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants