Fix some small bugs with SSIM.

This commit is contained in:
Pavel Krajcevski 2013-10-11 13:05:59 -04:00
parent 8d37d6eee5
commit 2d8c291107
2 changed files with 7 additions and 3 deletions

View file

@ -106,8 +106,8 @@ namespace FasTC {
} }
double ComputePSNR(Image<PixelType> *other); double ComputePSNR(Image<PixelType> *other);
double ComputeMSSIM(Image<PixelType> *other) const; double ComputeMSSIM(Image<PixelType> *other);
// Function to allow derived classes to populate the pixel array. // Function to allow derived classes to populate the pixel array.
// This may involve decompressing a compressed image or otherwise // This may involve decompressing a compressed image or otherwise
// processing some data in order to populate the m_Pixels pointer. // processing some data in order to populate the m_Pixels pointer.

View file

@ -222,6 +222,7 @@ template<typename PixelType>
static Image<PixelType> FilterValid(const Image<PixelType> &img, uint32 size, double sigma) { static Image<PixelType> FilterValid(const Image<PixelType> &img, uint32 size, double sigma) {
assert(size % 2); assert(size % 2);
Image<IPixel> gaussian(size, size); Image<IPixel> gaussian(size, size);
GenerateGaussianKernel(gaussian, size, sigma);
Image<PixelType> tmp = img; Image<PixelType> tmp = img;
tmp.Filter(gaussian); tmp.Filter(gaussian);
@ -237,7 +238,7 @@ static Image<PixelType> FilterValid(const Image<PixelType> &img, uint32 size, do
} }
template<typename PixelType> template<typename PixelType>
double Image<PixelType>::ComputeMSSIM(Image<PixelType> *other) const { double Image<PixelType>::ComputeSSIM(Image<PixelType> *other) {
if(!other) { if(!other) {
return -1.0; return -1.0;
} }
@ -247,6 +248,9 @@ double Image<PixelType>::ComputeMSSIM(Image<PixelType> *other) const {
return -1.0; return -1.0;
} }
ComputePixels();
other->ComputePixels();
double C1 = (0.01 * 255.0 * 0.01 * 255.0); double C1 = (0.01 * 255.0 * 0.01 * 255.0);
double C2 = (0.03 * 255.0 * 0.03 * 255.0); double C2 = (0.03 * 255.0 * 0.03 * 255.0);