Only report MSSIM

This commit is contained in:
Pavel Krajcevski 2013-10-12 16:37:48 -04:00
parent 996c81ef01
commit f1b564fdb2
6 changed files with 9 additions and 29 deletions

View file

@ -106,7 +106,7 @@ namespace FasTC {
}
double ComputePSNR(Image<PixelType> *other);
double ComputeSSIM(Image<PixelType> *other, double *mssim = 0);
double ComputeSSIM(Image<PixelType> *other);
// Function to allow derived classes to populate the pixel array.
// This may involve decompressing a compressed image or otherwise

View file

@ -261,7 +261,7 @@ static Image<IPixel> FilterValid(const Image<IPixel> &img, uint32 size, double s
}
template<typename PixelType>
double Image<PixelType>::ComputeSSIM(Image<PixelType> *other, double *mssim) {
double Image<PixelType>::ComputeSSIM(Image<PixelType> *other) {
if(!other) {
return -1.0;
}
@ -384,11 +384,7 @@ double Image<PixelType>::ComputeSSIM(Image<PixelType> *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<float>(mu1_sq(i, j));
@ -403,19 +399,11 @@ double Image<PixelType>::ComputeSSIM(Image<PixelType> *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<double>(w * h);
}
return minSSIM;
return mssim / static_cast<double>(w * h);
}
// !FIXME! These won't work for non-RGBA8 data.

View file

@ -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);
}

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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");
}