Go to the documentation of this file.00001
00002 #ifndef VIFA_HISTOGRAM_H
00003 #define VIFA_HISTOGRAM_H
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vbl/vbl_ref_count.h>
00028 #include <vbl/vbl_smart_ptr.h>
00029 #include <vul/vul_timestamp.h>
00030
00031 class vifa_histogram : public vul_timestamp,
00032 public vbl_ref_count
00033 {
00034 enum histogram_type{HISTOGRAM=0, CONTRAST_HIST, NUM_TYPES};
00035 protected:
00036 char delimiter;
00037 float* vals;
00038 float* counts;
00039
00040 int num;
00041 float delta;
00042 float vmax, vmin;
00043 mutable float mean;
00044 mutable float standard_dev;
00045
00046 virtual int GetIndex(float i) const;
00047
00048 public:
00049
00050 vifa_histogram();
00051 vifa_histogram(int, float, float);
00052 vifa_histogram(float*, float*, int);
00053 vifa_histogram(const vifa_histogram& h);
00054
00055 vifa_histogram(vifa_histogram const*, float width, bool preserveCounts=false);
00056
00057 virtual ~vifa_histogram();
00058
00059
00060 vifa_histogram* Scale(float scale_factor);
00061 vifa_histogram* Cumulative();
00062 vifa_histogram* NonMaximumSupress(int radius = 1, bool cyclic = false);
00063
00064
00065 void RemoveFlatPeaks(int nbins, float* cnts, bool cyclic);
00066 float CompareToHistogram(vifa_histogram* h);
00067
00068
00069 void UpCount(float newval);
00070 void UpCount(float newval,bool useNewIndexMethod);
00071 int GetNumSamples() const;
00072 float GetCount(float uval) const;
00073 float SetCount(float pixelval, float count);
00074
00075 float GetMinVal() const;
00076 float GetMaxVal() const;
00077 float GetMaxCount() const;
00078 float GetMean() const;
00079 float GetStandardDev() const;
00080 float GetMedian() const;
00081 int GetValIndex(float val) const;
00082
00083 float* GetVals() const
00084 {
00085 stats_consistent = 0;
00086 return vals;
00087 }
00088
00089 float* GetCounts() const
00090 {
00091 stats_consistent = 0;
00092 return counts;
00093 }
00094
00095 int GetRes() const { return num; }
00096
00097 float GetBucketSize() const { return delta; }
00098
00099 float* GetMinValAddr() const { return vals+GetIndex(GetMinVal()); }
00100
00101 float* GetMinCountAddr() const { return counts+GetIndex(GetMinVal()); }
00102
00103
00104 char GetDelimiter() const {return delimiter;}
00105 void SetDelimiter(char d) {delimiter = d;}
00106 float ComputeArea(float low, float high) const;
00107 float ComputeArea() const;
00108
00109
00110 float LowClipVal(float clip_fraction);
00111 float HighClipVal(float clip_fraction);
00112
00113 void Print();
00114 void Dump(char *);
00115 int WritePlot(const char* fname);
00116
00117 private:
00118 mutable int stats_consistent;
00119 };
00120
00121 typedef vbl_smart_ptr<vifa_histogram> vifa_histogram_sptr;
00122
00123
00124 #endif // VIFA_HISTOGRAM_H