X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkImageStatisticsGenericFilter.txx;h=82a11ab5355a86134a3a6cc666ff9136b04dc423;hb=05306a598620f8eecd320abc606d1cff4b96f333;hp=80ae83a611e37f5f11f11e1be30f6072fbecddee;hpb=8eccf1e25d2ab7273145d2475ae015aea5f6ff94;p=clitk.git diff --git a/tools/clitkImageStatisticsGenericFilter.txx b/tools/clitkImageStatisticsGenericFilter.txx index 80ae83a..82a11ab 100644 --- a/tools/clitkImageStatisticsGenericFilter.txx +++ b/tools/clitkImageStatisticsGenericFilter.txx @@ -20,6 +20,7 @@ #include "itkNthElementImageAdaptor.h" #include "itkJoinSeriesImageFilter.h" +#include "itkImageRegionConstIterator.h" #include "clitkImageStatisticsGenericFilter.h" #include "clitkCropLikeImageFilter.h" @@ -166,6 +167,7 @@ namespace clitk } else { labelImage=LabelImageType::New(); + labelImage->SetDirection(input->GetDirection()); labelImage->SetRegions(input->GetLargestPossibleRegion()); labelImage->SetOrigin(input->GetOrigin()); labelImage->SetSpacing(input->GetSpacing()); @@ -231,8 +233,21 @@ namespace clitk statisticsFilter->Update(); + //find localization for max and min (the last pixel found) + typename InputImageType::IndexType minIndex, maxIndex; + if (m_Verbose && m_Localize) { + itk::ImageRegionConstIterator imageIterator(input_adaptor,input_adaptor->GetLargestPossibleRegion()); + while(!imageIterator.IsAtEnd()) { + if (imageIterator.Get() == statisticsFilter->GetMinimum(label)) + minIndex = imageIterator.GetIndex(); + if (imageIterator.Get() == statisticsFilter->GetMaximum(label)) + maxIndex = imageIterator.GetIndex(); + ++imageIterator; + } + } + // Output - if (m_Verbose) std::cout<<"N° of pixels: "; + if (m_Verbose) std::cout<<"N° of pixels: "; std::cout<GetCount(label)<GetMean(label)<GetVariance(label)<GetMinimum(label)<GetMaximum(label)<GetSum(label)<GetCount(label)*spacing_cc<GetBoundingBox(label).size(); i++) std::cout<GetBoundingBox(label)[i]<<" ";