From edfc6bde788569e82488f44ccde8f905422962b3 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Tue, 26 Aug 2014 13:34:35 -0400 Subject: [PATCH] Be a little more defensive about calculating SSIM --- Base/src/Image.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index ea18b36..7240e7a 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -316,6 +316,11 @@ double Image::ComputeSSIM(Image *other) { const uint32 filterSz = 11; const double filterSigma = 1.5; + if(img1.GetWidth() < filterSz || img1.GetHeight() < filterSz || + img2.GetWidth() < filterSz || img2.GetHeight() < filterSz) { + return -1.0; + } + Image mu1 = FilterValid(img1, filterSz, filterSigma); Image mu2 = FilterValid(img2, filterSz, filterSigma);