diff --git a/Base/include/Image.h b/Base/include/Image.h index 2550481..0b56aed 100644 --- a/Base/include/Image.h +++ b/Base/include/Image.h @@ -106,7 +106,7 @@ namespace FasTC { } double ComputePSNR(Image *other); - double ComputeSSIM(Image *other, double *mssim = 0); + double ComputeSSIM(Image *other); // Function to allow derived classes to populate the pixel array. // This may involve decompressing a compressed image or otherwise diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index 74a9fe7..c2c9d33 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -261,7 +261,7 @@ static Image FilterValid(const Image &img, uint32 size, double s } template -double Image::ComputeSSIM(Image *other, double *mssim) { +double Image::ComputeSSIM(Image *other) { if(!other) { return -1.0; } @@ -384,11 +384,7 @@ double Image::ComputeSSIM(Image *other, double *mssim) { } } - double minSSIM = 1.0; - if(mssim) { - *mssim = 0.0; - } - + double mssim = 0.0; for(uint32 j = 0; j < h; j++) { for(uint32 i = 0; i < w; i++) { double m1sq = static_cast(mu1_sq(i, j)); @@ -403,19 +399,11 @@ double Image::ComputeSSIM(Image *other, double *mssim) { ((2.0 * m1m2 + C1) * (2.0 * s1s2 + C2)) / ((m1sq + m2sq + C1) * (s1sq + s2sq + C2)); - if(mssim) { - *mssim += ssim; - } - - minSSIM = ::std::min(ssim, minSSIM); + mssim += ssim; } } - if(mssim) { - *mssim /= static_cast(w * h); - } - - return minSSIM; + return mssim / static_cast(w * h); } // !FIXME! These won't work for non-RGBA8 data. diff --git a/Base/test/TestImage.cpp b/Base/test/TestImage.cpp index f1c2a68..ff9d8d3 100644 --- a/Base/test/TestImage.cpp +++ b/Base/test/TestImage.cpp @@ -164,8 +164,6 @@ TEST(Image, ComputeMSSIM) { } } - double MSSIM; - double SSIM = img.ComputeSSIM(&img, &MSSIM); + double SSIM = img.ComputeSSIM(&img); EXPECT_EQ(SSIM, 1.0); - EXPECT_EQ(MSSIM, 1.0); } diff --git a/CLTool/src/clunix.cpp b/CLTool/src/clunix.cpp index 303e42b..a53f0f1 100644 --- a/CLTool/src/clunix.cpp +++ b/CLTool/src/clunix.cpp @@ -260,11 +260,9 @@ int main(int argc, char **argv) { fprintf(stderr, "Error computing PSNR\n"); } - double MSSIM; - double SSIM = img.ComputeSSIM(ci, &MSSIM); + double SSIM = img.ComputeSSIM(ci); if(SSIM > 0.0) { fprintf(stdout, "SSIM: %.9f\n", SSIM); - fprintf(stdout, "MSSIM: %.9f\n", MSSIM); } else { fprintf(stderr, "Error computing MSSIM\n"); } diff --git a/CLTool/src/clwin32.cpp b/CLTool/src/clwin32.cpp index a24418a..cb745c4 100644 --- a/CLTool/src/clwin32.cpp +++ b/CLTool/src/clwin32.cpp @@ -264,11 +264,9 @@ int _tmain(int argc, _TCHAR* argv[]) fprintf(stderr, "Error computing PSNR\n"); } - double MSSIM; - double SSIM = img.ComputeSSIM(ci, &MSSIM); + double SSIM = img.ComputeSSIM(ci); if(SSIM > 0.0) { fprintf(stdout, "SSIM: %.9f\n", SSIM); - fprintf(stdout, "MSSIM: %.9f\n", MSSIM); } else { fprintf(stderr, "Error computing MSSIM\n"); } diff --git a/CLTool/src/compare.cpp b/CLTool/src/compare.cpp index 5e7d5d9..c439916 100644 --- a/CLTool/src/compare.cpp +++ b/CLTool/src/compare.cpp @@ -96,11 +96,9 @@ int main(int argc, char **argv) { fprintf(stderr, "Error computing PSNR\n"); } - double MSSIM; - double SSIM = img1.ComputeSSIM(&img2, &MSSIM); + double SSIM = img1.ComputeSSIM(&img2); if(SSIM > 0.0) { fprintf(stdout, "SSIM: %.9f\n", SSIM); - fprintf(stdout, "MSSIM: %.9f\n", MSSIM); } else { fprintf(stderr, "Error computing MSSIM\n"); }