From 1b89d083740b39be0cbc0868504312bb32e611d1 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Wed, 6 Jun 2018 10:41:37 +0200 Subject: [PATCH] add normalisation wrt the total image intensity sum --- tools/clitkNormalizeImageFilter.ggo | 1 + ...clitkNormalizeImageFilterGenericFilter.txx | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/clitkNormalizeImageFilter.ggo b/tools/clitkNormalizeImageFilter.ggo index b67e3b8..c474c64 100644 --- a/tools/clitkNormalizeImageFilter.ggo +++ b/tools/clitkNormalizeImageFilter.ggo @@ -11,3 +11,4 @@ option "imagetypes" - "Display allowed image types" flag off option "input" i "Input image filename" string required option "output" o "Output image filename" string required option "mask" m "Mask input image filename" string optional +option "total_normalisation" n "Normalise such as the total is = 1.0" flag off \ No newline at end of file diff --git a/tools/clitkNormalizeImageFilterGenericFilter.txx b/tools/clitkNormalizeImageFilterGenericFilter.txx index e6911af..ea87733 100644 --- a/tools/clitkNormalizeImageFilterGenericFilter.txx +++ b/tools/clitkNormalizeImageFilterGenericFilter.txx @@ -144,13 +144,28 @@ namespace clitk ito.GoToBegin(); itm.GoToBegin(); + double total = 0.0; while (!ito.IsAtEnd()) { + if(itm.Get() == 1) { + ito.Set(((float) it.Get() - minImg)/(maxImg-minImg)); + total += ito.Get(); + } + ++it; + ++ito; + ++itm; + } + + // Normalisation wrt total ? + if (mArgsInfo.total_normalisation_flag) { + ito.GoToBegin(); + itm.GoToBegin(); + while (!ito.IsAtEnd()) { if(itm.Get() == 1) { - ito.Set(((float) it.Get() - minImg)/(maxImg-minImg)); + ito.Set(ito.Get()/total); } - ++it; ++ito; ++itm; + } } // // -- 2.47.1