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 / MS-SSIM implementation #1

Open
b3nk4n opened this issue Sep 2, 2016 · 4 comments
Open

SSIM / MS-SSIM implementation #1

b3nk4n opened this issue Sep 2, 2016 · 4 comments

Comments

@b3nk4n
Copy link

b3nk4n commented Sep 2, 2016

This is not really an issue, but might be helpful for you:
While checking out your (awesome) code, I just discovered this TODO:

# TODO: Add SSIM error http://www.cns.nyu.edu/pub/eero/wang03-reprint.pdf

I was looking for an SSIM/MS-SSIM implementation in TensorFlow for a while. Because I could not discovery anything, I ported some Matlab/C++ code to TensorFlow. I've posted the code on StackOverflow, so feel free to use and improve it:

Stack Overflow: SSIM / MS-SSIM for TensorFlow

@dyelax
Copy link
Owner

dyelax commented Sep 2, 2016

Hey @bsautermeister, thanks for the link! I'll check that out and integrate it when I have a chance. Or, if you'd like to add it in yourself and submit a pull request, I'd be happy to accept.

@b3nk4n
Copy link
Author

b3nk4n commented Sep 5, 2016

I will, as soon as I find time for that.

By the way: I'm not sure, but after comparing your PSNR implementation with it's formula in the paper and the PSNR Wikipedia-Definition for colored images:

For color images with three RGB values per pixel, the definition of PSNR is the same except the MSE is the sum over all squared value differences divided by image size and by three.

I think that you miss the by three. As you are using the formula for colored images and take the sum over all 3 dimension (tf.reduce_sum(...,[1, 2, 3]), I think you should consider the 3rd dimension for your num_pixels as well:

num_pixels = tf.to_float(shape[1] * shape[2] * shape[3])

Or am I wrong? :)

EDIT

Probably the same thing for sharpness-differences error as well...

@dyelax
Copy link
Owner

dyelax commented Sep 9, 2016

Good catch. Fixed!

@daji2112
Copy link

daji2112 commented May 6, 2021

I know this is very very late but I wanted to get the SSIM @dyelax or @bsautermeister, did one of you got the chance to integrate it with the code, or Is there any other way to calculate the SSIM for this paper like for example, compare_ssim or tf.image.ssim, even can we calculate the psnr with tf.image.psnr..... I would really appreciate a reply. Thank you for this helpful code @dyelax

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

No branches or pull requests

3 participants