kornelski / dssim

Image similarity comparison simulating human perception (multiscale SSIM in Rust)
https://kornel.ski/dssim
GNU Affero General Public License v3.0
1.09k stars 70 forks source link

Assertion `ssim > 0' fails for Images <= 15 pixel wide or high #29

Closed rcanavan closed 7 years ago

rcanavan commented 8 years ago

When used with any image with width or height less than or equal to 15, dssim fails with an Assertion:

dssim: src/dssim.c:668: to_dssim: Assertion `ssim > 0' failed.
Aborted (core dumped)
kornelski commented 8 years ago

Can you attach an example image? What platform are you running on?

rcanavan commented 8 years ago

I'm using Ubuntu 16.04 x64 with libpng12-0 1.2.54-1ubuntu1. The test images were generated with xv 3.10a+patches and imagemagick 7.0.2-1 and re-scaled to various sizes using convert -resize ??x??. 15x15: a b

1x1: x y

kornelski commented 7 years ago

Probably fixed in 4f9b12106e35bb3f1b9382dd064dece3a3f3f365

rcanavan commented 7 years ago

Fixes the crash, but dssim when comparing an image with a single black pixel and an image with a single white pixel is 0.00000000. I've also tested a 2x2 black and white checkerboard against its inverse or a red and green checkerboard - both return 0.00000000. That doesn't seem right.

convert xc:black b.png
convert xc:white w.png
dssim  b.png  w.png
0.00000000      w.png
kornelski commented 7 years ago

SSIM is not meaningful for a single pixel. This implementation uses blur, so it's also doing poorly for sizes smaller than the blur radius. Try with at least 8x8 pixels.