Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
Region.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_Region_h 00003 #define INCLUDED_Region_h 00004 00005 #include <list> 00006 00007 #include "Shared/Measures.h" 00008 #include "SketchIndices.h" 00009 #include "Point.h" 00010 #include "LineData.h" 00011 00012 namespace DualCoding { 00013 00014 class SketchSpace; 00015 00016 #define MAX_MOMENT 5 00017 00018 class Region : public SketchIndices { 00019 public: 00020 Region(const SketchSpace& _space); //!< initializes all properties to be NOTCOMPUTED 00021 ~Region() {}; 00022 00023 //! Returns a list of the different Regions in labels, sorted by area 00024 //@param labels Each different region in labels should have a different number assigned to it 00025 //@param area_thresh Minimum allowed area of a region 00026 static std::list<Region> extractRegions(const Sketch<uint>& labels, uint area_thresh = 10); 00027 00028 //! Return a single region from a sketch<bool> 00029 static Region extractRegion(const Sketch<bool>& sketch); 00030 00031 //! Compares areas of two Regions; really only used to sort Regions 00032 //! assumes area already calculated 00033 //! Notes that it actually returns greater-than instead of less-than, so 00034 //! that lists are sorted with biggest areas first 00035 bool operator< (const Region& other) const; 00036 00037 00038 //! sets all properties to be NOTCOMPUTED 00039 //! called after making changes (either addition/deletion) to table 00040 void recomputeProperties(); 00041 00042 int findTopBound(); 00043 int findBotBound(); 00044 int findLeftBound(); 00045 int findRightBound(); 00046 00047 Point findTopBoundPoint(); 00048 Point findBotBoundPoint(); 00049 Point findLeftBoundPoint(); 00050 Point findRightBoundPoint(); 00051 bool isContained(const Point&, const uint max_dist=0); 00052 00053 Point mostDistantPtFrom(const LineData&); 00054 00055 //! Calculates the two-dimensional Cartesian moment Mpq 00056 float findMoment(size_t p, size_t q); 00057 float findCentralMoment(size_t p, size_t q); 00058 //! Finds the area-normalized central moment 00059 float findNormCentralMoment(size_t p, size_t q); 00060 00061 int findArea(); 00062 Point findCentroid(); //!< returns coords of center of mass 00063 00064 //! Returns the angle of the orientation of the principal axis in radians 00065 AngPi findPrincipalAxisOrientation(); 00066 00067 //! Returns the length of the semi-major (x) axis of the image ellipse 00068 float findSemiMajorAxisLength(); 00069 00070 //! Returns the length of the semi-minor (y) axis of the image ellipse 00071 float findSemiMinorAxisLength(); 00072 00073 float findRadius() { return findSemiMajorAxisLength(); } //FIX THIS 00074 00075 private: 00076 const SketchSpace& space; 00077 00078 int topBound; 00079 int botBound; 00080 int leftBound; 00081 int rightBound; 00082 00083 float moments[MAX_MOMENT+1][MAX_MOMENT+1]; 00084 float cmoments[MAX_MOMENT+1][MAX_MOMENT+1]; 00085 00086 int area; 00087 00088 int findXcoordFor(const coordinate_t y_coord); 00089 int findYcoordFor(const coordinate_t x_coord); 00090 00091 public: 00092 const SketchSpace& getSpace() const { return space; }; 00093 }; 00094 00095 } // namespace 00096 00097 #endif |
DualCoding 4.0 |
Generated Thu Nov 22 00:52:36 2007 by Doxygen 1.5.4 |