1 #ifndef itkNeighborhoodFirstOrderStatistics_h
2 #define itkNeighborhoodFirstOrderStatistics_h
4 #include "itkConstNeighborhoodIterator.h"
12 template<
typename TNeighborhoodType,
typename TPixelOutputType >
27 static const char *
const FeatureNames[] = {
"MEAN",
"VARIANCE",
"SKEWNESS",
"KURTOSIS",
"MIN",
"MAX"};
28 return FeatureNames[f];
31 inline OutputVectorType
operator()(
const NeighborhoodType & it)
const
35 double min = 10000000;
36 double max = -10000000;
38 for (
int i = 0; i < it.Size(); ++i)
40 double value = it.GetPixel(i);
42 sqmean += (value * value);
43 max = (value >
max) ? value : max;
44 min = (value <
min) ? value : min;
49 double variance = sqmean - mean * mean;
51 double stdderivation = std::sqrt(variance);
55 for (
int i = 0; i < it.Size(); ++i)
57 double value = it.GetPixel(i);
58 double tmpskewness = (value - mean) / stdderivation;
59 skewness += tmpskewness * tmpskewness * tmpskewness;
60 kurtosis += (value - mean) * (value - mean) * (value - mean) * (value - mean);
62 skewness /= it.Size();
63 kurtosis /= it.Size();
64 kurtosis /= (variance * variance);
66 if(skewness!=skewness){
69 if(kurtosis!=kurtosis){
73 OutputVectorType output_vector;
74 output_vector[
MEAN] = mean;
vnl_vector_fixed< TPixelOutputType, OutputCount > OutputVectorType
NeighborhoodFirstOrderStatistics()
static const char * GetFeatureName(unsigned int f)
OutputVectorType operator()(const NeighborhoodType &it) const
static const unsigned int OutputCount
TNeighborhoodType NeighborhoodType