13 #ifndef itkFirstOrderStatisticsFeatureFunctor_h
14 #define itkFirstOrderStatisticsFeatureFunctor_h
16 #include <itkConstNeighborhoodIterator.h>
30 template<
typename TNeighborhoodType,
typename TPixelOutputType >
45 static const char *
const FeatureNames[] = {
"MEAN",
"VARIANCE",
"SKEWNESS",
"KURTOSIS",
"MIN",
"MAX"};
46 return FeatureNames[f];
53 double min = 10000000;
54 double max = -10000000;
56 for (
unsigned int i = 0; i < it.Size(); ++i)
58 double value = it.GetPixel(i);
60 sqmean += (value * value);
61 max = (value > max) ? value : max;
62 min = (value < min) ? value : min;
67 double variance = sqmean - mean * mean;
69 double stdderivation = std::sqrt(variance);
73 for (
unsigned int i = 0; i < it.Size(); ++i)
75 double value = it.GetPixel(i);
76 double tmpskewness = (value - mean) / stdderivation;
77 skewness += tmpskewness * tmpskewness * tmpskewness;
78 kurtosis += (value - mean) * (value - mean) * (value - mean) * (value - mean);
80 skewness /= it.Size();
81 kurtosis /= it.Size();
82 kurtosis /= (variance * variance);
84 if(skewness!=skewness){
87 if(kurtosis!=kurtosis){
92 output_vector[
MEAN] = mean;
96 output_vector[
MIN] = min;
97 output_vector[
MAX] = max;
Functor that computes first-order statistics (mean, variance, skewness, kurtosis, min,...
static const char * GetFeatureName(unsigned int f)
NeighborhoodFirstOrderStatistics()
OutputVectorType operator()(const NeighborhoodType &it) const
TNeighborhoodType NeighborhoodType
vnl_vector_fixed< TPixelOutputType, OutputCount > OutputVectorType
static const unsigned int OutputCount