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

test ssim_torch and skimage #23

Open
ignorant96 opened this issue Oct 6, 2020 · 1 comment
Open

test ssim_torch and skimage #23

ignorant96 opened this issue Oct 6, 2020 · 1 comment

Comments

@ignorant96
Copy link

Hi, I just test pytorch_msssim.ssim and skimage. When I compute ssim value with these two methods on 2d matrix, I got different results, I want to know what the problem is. Maybe I use ssim in a wrong way? Here are my codes and results.

code:
`import torch
from skimage.metrics import structural_similarity
from pytorch_msssim import ssim

m0 = torch.ones(7, 7, dtype=torch.float) # OR matrix
m0[4:7, 0:3] = 0

m_sig = torch.ones(7, 7, dtype=torch.float)
m_sig[4:7, 0] = 0

ssim_out = ssim(m0.reshape(1, 1, 7, 7), m_sig.reshape(1, 1, 7, 7))
print('pytorch_ssim_value = ' + str(ssim_out.numpy()))

ssim_value2 = structural_similarity(m_sig.numpy(), m0.numpy())
print('ssim_value = ' + str(ssim_value2))`

results:
ytorch_ssim_value = 0.9836789
ssim_value = 0.4858374093651142

@VainF
Copy link
Owner

VainF commented Oct 6, 2020

The default behavior of structural_similarity is inconsistent with the original paper. Please add these args:

ssim_skimage = structural_similarity(img, img_noise, win_size=11, multichannel=True,
                                    sigma=1.5, data_range=1, use_sample_covariance=False, gaussian_weights=True)

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