00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __Histogram_h__
00010 #define __Histogram_h__
00011
00012 #include "Tools/Streams/InOut.h"
00013 #include <string.h>
00014 #include "Tools/Debugging/Debugging.h"
00015 #include "Platform/GTAssert.h"
00016
00017
00018
00019
00020 class Histogram
00021 {
00022 public:
00023 enum HistogramID
00024 {
00025 noID,
00026 imageIntensityY,
00027 imageIntensityU,
00028 imageIntensityV,
00029 scanLineIntensityY,
00030 scanLineIntensityU,
00031 scanLineIntensityV,
00032 colorFrequency,
00033 lengthOfSegments,
00034 numberOfHistogramIDs
00035 };
00036
00037 static const char* getName(HistogramID histogramID)
00038 {
00039 switch(histogramID)
00040 {
00041 case noID: return "no histogram";
00042 case imageIntensityY: return "image intensity y";
00043 case imageIntensityU: return "image intensity u";
00044 case imageIntensityV: return "image intensity v";
00045 case scanLineIntensityY: return "scan line intensity y";
00046 case scanLineIntensityU: return "scan line intensity u";
00047 case scanLineIntensityV: return "scan line intensity v";
00048 case colorFrequency: return "color frequency";
00049 case lengthOfSegments: return "length of segments";
00050 default: return "Please edit Histogram::getName() !";
00051 }
00052 }
00053
00054 static DebugKeyTable::debugKeyID getDebugKeyID(HistogramID histogramID)
00055 {
00056 switch(histogramID)
00057 {
00058 case imageIntensityY: return DebugKeyTable::sendHistogram_imageIntensityY;
00059 case imageIntensityU: return DebugKeyTable::sendHistogram_imageIntensityU;
00060 case imageIntensityV: return DebugKeyTable::sendHistogram_imageIntensityV;
00061 case scanLineIntensityY: return DebugKeyTable::sendHistogram_scanLineIntensityY;
00062 case scanLineIntensityU: return DebugKeyTable::sendHistogram_scanLineIntensityU;
00063 case scanLineIntensityV: return DebugKeyTable::sendHistogram_scanLineIntensityV;
00064 case colorFrequency: return DebugKeyTable::sendHistogram_colorFrequency;
00065 case lengthOfSegments: return DebugKeyTable::sendHistogram_lengthOfSegments;
00066 default:
00067 {
00068 ASSERT(false);
00069 return (DebugKeyTable::debugKeyID)0;
00070 }
00071 }
00072 }
00073
00074
00075 Histogram() { histogramID = noID; init(); }
00076 Histogram(HistogramID id) { histogramID = id; init(); }
00077
00078 void init();
00079 void init(int numberOfEntries);
00080 void add(int index);
00081 void setID(HistogramID id) { histogramID = id; }
00082
00083 int getValue(int index);
00084 int getNumberOfEntries();
00085
00086 HistogramID getHistogramID();
00087
00088 Histogram& operator=(const Histogram& other)
00089 {
00090 memcpy(value, other.value, sizeof(value));
00091 numberOfEntries = other.numberOfEntries;
00092 histogramID = other.histogramID;
00093 sum = other.sum;
00094 numberOfAddedEntries = other.numberOfAddedEntries;
00095 return *this;
00096 }
00097
00098 double getAverage();
00099 double getAverageFrequencyOverAllEntries();
00100 double getAverageFrequencyOverUsedEntries();
00101
00102 void analyseClusters();
00103 int getNumberOfClusters();
00104 int getBeginOfCluster(int index);
00105 int getEndOfCluster(int index);
00106
00107 private:
00108 enum{maxNumberOfEntries = 256};
00109 int value[maxNumberOfEntries];
00110 int numberOfEntries;
00111 HistogramID histogramID;
00112
00113 int numberOfAddedEntries;
00114 int sum;
00115
00116 int numberOfClusters;
00117 int beginOfCluster[maxNumberOfEntries];
00118 int endOfCluster[maxNumberOfEntries];
00119 };
00120
00121
00122
00123
00124
00125
00126
00127 In& operator>>(In& stream, Histogram& histogram);
00128
00129
00130
00131
00132
00133
00134
00135 Out& operator<<(Out& stream, Histogram& histogram);
00136
00137
00138 #endif // __Histogram_h__