#This tool supports multiple images on the input, or even 4D, but all images must be of the same type and dimensions.
purpose "Compute statistics on an image, or on part of an image specified by a mask and label(s). The tool also supports multichannel images, which is useful, e.g., for vector fields. All channels are processed (separately) by default, but only one channel may be chosen."
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
-option "input" i "Input image filename" string no multiple
-option "channel" c "Image channel to be used in statistics (-1 to process all channels)" int no default="-1"
-option "mask" m "Mask image filename (uchar)" string no
-option "label" l "Label(s) in the mask image to consider" int no multiple default="1"
-option "histogram" - "Compute histogram, allows median calculation" string no
-option "dvhistogram" - "Compute dose volume histogram" string no
-option "bins" - "Number of histogram bins" int no default="100"
-option "lower" - "Lower histogram bound" double no default="-1000"
-option "upper" - "Upper histogram bound" double no default="1000"
+option "input" i "Input image filename" string no multiple
+option "channel" c "Image channel to be used in statistics (-1 to process all channels)" int no default="-1"
+option "mask" m "Mask image filename (uchar)" string no
+option "label" l "Label(s) in the mask image to consider" int no multiple default="1"
+option "localize" - "With verbose, write the index coordinates of the max and min" flag off
+option "histogram" - "Compute histogram, allows median calculation" string no
+option "dvhistogram" - "Compute dose volume histogram" string no
+option "bins" - "Number of histogram bins" int no default="100"
+option "lower" - "Lower histogram bound" double no default="-1000"
+option "upper" - "Upper histogram bound" double no default="1000"
-option "allow_resize" r "Resize mask if different from input" flag off
+option "allow_resize" r "Resize mask if different from input" flag off
{
m_ArgsInfo=a;
m_Verbose=m_ArgsInfo.verbose_flag;
+ m_Localize=m_ArgsInfo.localize_flag;
if(m_ArgsInfo.input_given)
m_InputFileName=m_ArgsInfo.input_arg[0];
// Data members
//----------------------------------------
args_info_clitkImageStatistics m_ArgsInfo;
- bool m_Verbose;
+ bool m_Verbose, m_Localize;
std::string m_InputFileName;
};
#include "itkNthElementImageAdaptor.h"
#include "itkJoinSeriesImageFilter.h"
+#include "itkImageRegionConstIterator.h"
#include "clitkImageStatisticsGenericFilter.h"
#include "clitkCropLikeImageFilter.h"
statisticsFilter->Update();
+ //find localization for max and min (the last pixel found)
+ typename InputImageType::IndexType minIndex, maxIndex;
+ if (m_Verbose && m_Localize) {
+ itk::ImageRegionConstIterator<InputImageAdaptorType> 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<<statisticsFilter->GetCount(label)<<std::endl;
if (m_Verbose) std::cout<<"Mean: ";
std::cout<<statisticsFilter->GetMean(label)<<std::endl;
std::cout<<statisticsFilter->GetVariance(label)<<std::endl;
if (m_Verbose) std::cout<<"Min: ";
std::cout<<statisticsFilter->GetMinimum(label)<<std::endl;
+ if (m_Verbose && m_Localize) {
+ std::cout<<" in voxel of index: ";
+ std::cout<<minIndex<<std::endl;
+ }
if (m_Verbose) std::cout<<"Max: ";
std::cout<<statisticsFilter->GetMaximum(label)<<std::endl;
+ if (m_Verbose && m_Localize) {
+ std::cout<<" in voxel of index: ";
+ std::cout<<maxIndex<<std::endl;
+ }
if (m_Verbose) std::cout<<"Sum: ";
std::cout<<statisticsFilter->GetSum(label)<<std::endl;
if (m_Verbose) std::cout<<"Volume (cc): ";