13 #ifndef itkNeighborhoodFirstOrderStatistics_h
14 #define itkNeighborhoodFirstOrderStatistics_h
16 #include "itkConstNeighborhoodIterator.h"
24 template<
typename TNeighborhoodType,
typename TPixelOutputType >
39 static const char *
const FeatureNames[] = {
"MEAN",
"VARIANCE",
"SKEWNESS",
"KURTOSIS",
"MIN",
"MAX"};
40 return FeatureNames[f];
47 double min = 10000000;
48 double max = -10000000;
50 for (
unsigned int i = 0; i < it.Size(); ++i)
52 double value = it.GetPixel(i);
54 sqmean += (value * value);
55 max = (value > max) ? value : max;
56 min = (value < min) ? value : min;
61 double variance = sqmean - mean * mean;
63 double stdderivation = std::sqrt(variance);
67 for (
unsigned int i = 0; i < it.Size(); ++i)
69 double value = it.GetPixel(i);
70 double tmpskewness = (value - mean) / stdderivation;
71 skewness += tmpskewness * tmpskewness * tmpskewness;
72 kurtosis += (value - mean) * (value - mean) * (value - mean) * (value - mean);
74 skewness /= it.Size();
75 kurtosis /= it.Size();
76 kurtosis /= (variance * variance);
78 if(skewness!=skewness){
81 if(kurtosis!=kurtosis){
86 output_vector[
MEAN] = mean;
90 output_vector[
MIN] = min;
91 output_vector[
MAX] = max;