mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-23 03:53:49 +00:00
Only report MSSIM
This commit is contained in:
parent
996c81ef01
commit
f1b564fdb2
6 changed files with 9 additions and 29 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue