X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkImageStatisticsGenericFilter.txx;h=82a11ab5355a86134a3a6cc666ff9136b04dc423;hb=05306a598620f8eecd320abc606d1cff4b96f333;hp=6a2a68ebbda35234061b8fa5ca8e6ab30b5120ab;hpb=37f2a4c7521970a552c751a8a95de460b767a6fd;p=clitk.git diff --git a/tools/clitkImageStatisticsGenericFilter.txx b/tools/clitkImageStatisticsGenericFilter.txx index 6a2a68e..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" @@ -156,7 +157,7 @@ namespace clitk } else { - std::cerr << "Mask image has a different size/spacing than input. Abort" << std::endl; + std::cerr << "Mask image has a different size/spacing than input. Abort. (Use option to resize)" << std::endl; exit(-1); } } @@ -170,6 +171,7 @@ namespace clitk labelImage->SetRegions(input->GetLargestPossibleRegion()); labelImage->SetOrigin(input->GetOrigin()); labelImage->SetSpacing(input->GetSpacing()); + labelImage->SetDirection(input->GetDirection()); labelImage->Allocate(); labelImage->FillBuffer(m_ArgsInfo.label_arg[0]); } @@ -213,7 +215,7 @@ namespace clitk std::cout<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)<