From 841a1b0c72a192388f88d0f4c63b010ddf1ab9e5 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sun, 20 Dec 2015 17:42:22 -0500 Subject: [PATCH] Add multiplier to make the differences more noticable --- Base/include/FasTC/Image.h | 2 +- Base/src/Image.cpp | 3 ++- CLTool/src/compare.cpp | 13 +++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Base/include/FasTC/Image.h b/Base/include/FasTC/Image.h index 2f1997b..4723370 100644 --- a/Base/include/FasTC/Image.h +++ b/Base/include/FasTC/Image.h @@ -97,7 +97,7 @@ namespace FasTC { double ComputePSNR(Image *other); double ComputeSSIM(Image *other); - Image Diff(Image *other); + Image Diff(Image *other, float mult); double ComputeEntropy(); double ComputeMeanLocalEntropy(); diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index 405cb99..d0c3f89 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -199,7 +199,7 @@ const PixelType & Image::operator()(uint32 i, uint32 j) const { } template -Image Image::Diff(Image *other) { +Image Image::Diff(Image *other, float mult) { if (!other) { std::cerr << "Image::Diff - ERROR: other == null" << std::endl; assert(false); @@ -219,6 +219,7 @@ Image Image::Diff(Image *other) { for (int j = 0; j < GetHeight(); ++j) { for (int i = 0; i < GetWidth(); ++i) { result(i, j) = PixelAbs((*this)(i, j) - (*other)(i, j)); + result(i, j) *= mult; result(i, j).MakeOpaque(); } } diff --git a/CLTool/src/compare.cpp b/CLTool/src/compare.cpp index 039cf7a..49d5fed 100644 --- a/CLTool/src/compare.cpp +++ b/CLTool/src/compare.cpp @@ -80,15 +80,24 @@ void gen_random(char *s, const int len) { } int main(int argc, char **argv) { - if(argc != 3 && argc != 4) { + if(argc < 3 || argc > 5) { PrintUsageAndExit(); } bool diff_images = false; + float diff_multiplier = 1.0; int arg = 1; if (strncmp(argv[arg], "-d", 2) == 0) { diff_images = true; arg++; + + if (argc == 5) { + diff_multiplier = static_cast(atoi(argv[arg])); + if (diff_multiplier < 0) { + PrintUsageAndExit(); + } + arg++; + } } ImageFile img1f (argv[arg]); @@ -109,7 +118,7 @@ int main(int argc, char **argv) { FasTC::Image<> &img2 = *img2f.GetImage(); if (diff_images) { - FasTC::Image<> diff = img1.Diff(&img2); + FasTC::Image<> diff = img1.Diff(&img2, diff_multiplier); char fname_buf [5 + 16 + 4]; // "diff-" + hash + ".png" strncat(fname_buf, "diff-", 5);