X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkImageStatisticsGenericFilter.txx;h=82a11ab5355a86134a3a6cc666ff9136b04dc423;hb=05306a598620f8eecd320abc606d1cff4b96f333;hp=b87114d6d591008f715c8d20989fdc3c6fd7b49d;hpb=c0ba47479246ee1d42c2e9c8de5912e4b75c3e98;p=clitk.git diff --git a/tools/clitkImageStatisticsGenericFilter.txx b/tools/clitkImageStatisticsGenericFilter.txx index b87114d..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); } } @@ -166,9 +167,11 @@ namespace clitk } else { labelImage=LabelImageType::New(); + labelImage->SetDirection(input->GetDirection()); 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]); } @@ -212,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)<GetCount(label)*spacing_cc<GetBoundingBox(label).size(); i++) std::cout<GetBoundingBox(label)[i]<<" ";