X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkNormalizeImageFilterGenericFilter.txx;h=ea8773334d2307d99953eab8c0a133690c215bc8;hb=5578995d9a82792833333eeb3dd5c8ecac967293;hp=99a43a464ad8157367caf9f5ed7e301b0736ac64;hpb=c45f077f35553cdc72396626ac601080093d273b;p=clitk.git diff --git a/tools/clitkNormalizeImageFilterGenericFilter.txx b/tools/clitkNormalizeImageFilterGenericFilter.txx index 99a43a4..ea87733 100644 --- a/tools/clitkNormalizeImageFilterGenericFilter.txx +++ b/tools/clitkNormalizeImageFilterGenericFilter.txx @@ -94,7 +94,7 @@ namespace clitk // Reading input typename InputImageType::Pointer input = this->template GetInput(0); - typename MaskImageType::Pointer mask = NULL; + typename MaskImageType::Pointer mask = ITK_NULLPTR; if(mArgsInfo.mask_given) { mask = this->template GetInput(1); } @@ -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; + } } // //