$search
00001 #ifndef __MicroEdgeCorrectionTable_H__ 00002 #define __MicroEdgeCorrectionTable_H__ 00003 00004 #include "Edge.h" 00005 #include "Rectangle.h" 00006 #include "MicroEdgeMap.h" 00007 00008 #include <vector> 00009 #include <sstream> 00010 #include <cmath> 00011 00012 using namespace std; 00013 00014 namespace EdgeDetection 00015 { 00016 // Corrects the errors made on two-dimensional edge detection. 00017 class MicroEdgeCorrectionTable 00018 { 00019 private: Rectangle area; 00020 private: int offsetCount; 00021 private: int angleCount; 00022 private: vector<Edge> entries; 00023 00024 private: double GetOffsetOffset() { return area.GetLeft(); } 00025 private: double GetOffsetStep() { return area.GetWidth() / (offsetCount - 1); } 00026 private: double GetAngleOffset() { return area.GetTop(); } 00027 private: double GetAngleStep() { return area.GetHeight() / (angleCount - 1); } 00028 00029 public: MicroEdgeCorrectionTable(MicroEdgeMap* microEdgeMap, Rectangle area, int offsetCount, int angleCount) 00030 { 00031 if (microEdgeMap == 0) throw "The parameter 'microEdgeMap' cannot be NULL."; 00032 00033 Initialize(area, offsetCount, angleCount); 00034 PopulateTable(microEdgeMap); 00035 } 00036 private: MicroEdgeCorrectionTable(Rectangle area, int offsetCount, int angleCount) 00037 { 00038 Initialize(area, offsetCount, angleCount); 00039 } 00040 public: ~MicroEdgeCorrectionTable() { } 00041 00042 public: Edge Correct(Edge measuredEdge); 00043 00044 private: void Initialize(Rectangle area, int offsetCount, int angleCount); 00045 private: void PopulateTable(MicroEdgeMap* microEdgeMap); 00046 00047 public: static istream* Serialize(MicroEdgeCorrectionTable* microEdgeCorrectionTable); 00048 public: static MicroEdgeCorrectionTable* Deserialize(istream* data); 00049 }; 00050 }; 00051 00052 #endif