00001 #include "DLPoint.h" 00002 #include "DLDatarun.h" 00003 #include "DLImage.h" 00004 #include "DLColor.h" 00005 00006 #include <vector> 00007 00008 using namespace std; 00009 00010 #ifndef _DLCOMPONENT_H_ 00011 #define _DLCOMPONENT_H_ 00012 00052 class DLComponent 00053 { 00057 friend class DLConnectedComponents; 00058 00059 public: 00060 00064 DLComponent(); 00065 00070 DLComponent( const DLComponent & orig); 00071 00075 virtual ~DLComponent(); 00076 00081 int dlGetWidth() const { return cmax-cmin + 1;} 00082 00087 int dlGetHeight() const { return rmax-rmin + 1;} 00088 00094 int dlGetMass() const {return area;} 00095 00100 float dlGetRowCentroid() const {return rcentroid;} 00101 00106 float dlGetColCentroid() const {return ccentroid;} 00107 00112 int dlGetPerimeter() const {return perimeter;} 00113 00118 int dlGetRowMin() const {return rmin;} 00119 00124 int dlGetRowMax() const {return rmax;} 00125 00130 int dlGetColMin() const {return cmin;} 00131 00136 int dlGetColMax() const {return cmax;} 00137 00145 int dlGetRowSeed() const {return rseed;} 00146 00154 int dlGetColSeed() const {return cseed;} 00155 00180 int dlGetNumHoles() const {return number_of_holes;} 00181 00193 int dlGetNumRuns() const {return num_runs;} 00194 00200 vector <DLDatarun> dlGetRuns() const {return runs;} 00201 00214 int dlGetNumConcavitiesUp() const {return num_conc_up;} 00215 00223 vector <DLDatarun> dlGetConcavitiesUp() const {return conc_up;} 00224 00237 int dlGetNumConcavitiesDown() const {return num_conc_down;} 00238 00246 vector <DLDatarun> dlGetConcavitiesDown() const {return conc_down;} 00247 00253 int dlGetNumConvexHulls() const {return num_points_convex_hull;} 00254 00259 vector <DLPoint> dlGetConvexHulls() const {return convex_hull;} 00260 00265 float dlGetAreaConvexHulls() const {return area_of_convex_hull;} 00266 00271 float dlGetPerimeterConvexHulls() const {return perimeter_of_convex_hull;} 00272 00279 float dlGetMoment(int idx) const {return moments[idx];} 00280 00286 00287 00292 void dlSetArea(int newArea){area = newArea;} 00293 00298 void dlSetRowCentriod(float newRcentroid){rcentroid = newRcentroid;} 00299 00304 void dlSetColCentroid(float newCCentroid){ccentroid=newCCentroid;} 00305 00310 void dlSetPerimeter(int newPerimeter){perimeter = newPerimeter;} 00311 00316 void dlSetRowMin(int newRmin){rmin = newRmin;} 00317 00322 void dlSetRowMax(int newRmax){rmax = newRmax;} 00323 00328 void dlSetColMin(int newCmin){cmin = newCmin;} 00329 00334 void dlSetColMax(int newCmax){cmax = newCmax;} 00335 00340 void dlSetRowSeed(int newRseed){rseed = newRseed;} 00341 00346 void dlSetColSeed(int newCseed){cseed = newCseed;} 00347 00352 void dlSetNumHoles(int holes){number_of_holes = holes;} 00353 00354 00361 void dlSetNumRuns(int num){num_runs = num;} 00362 00367 void dlAddRun(DLDatarun& run){runs.push_back(run);} 00368 00375 void dlSetNumConcavitiesUp(int num){num_conc_up = num;} 00376 00381 void dlSetNumConcavitiesDown(int num){num_conc_down = num;} 00382 00387 void dlAddConcavityUp(DLDatarun conc){conc_up.push_back(conc);} 00388 00393 void dlAddConcavityDown(DLDatarun conc){conc_down.push_back(conc);} 00394 00399 void dlSetNumConvexHulls(int num){num_points_convex_hull = num;} 00400 00405 void dlAddConvexHull(DLPoint convexHull){convex_hull.push_back(convexHull);} /* points on convex_hull */ 00406 00411 void dlSetAreaConvexHulls(float convexHull){area_of_convex_hull = convexHull;} 00412 00417 void dlSetPerimeterConvexHulls(float perimeterConvexHull){perimeter_of_convex_hull = perimeterConvexHull;} 00418 00419 00427 void dlSetMoment(int idx, float value){moments[idx] = value;} 00428 00437 void dlSetComponentColor(const DLColor &newColor){color = newColor;}; 00438 00439 00441 00443 00444 00453 DLImage dlGetImage() const; 00454 00455 00466 DLImage dlGetColorImage() const; 00467 00473 DLImage dlGetBinaryImage( ) const; 00474 00476 00482 const DLComponent& operator=( const DLComponent & right ); 00483 00488 const DLColor dlGetComponentColor(){return color;}; 00489 00490 private: 00494 int area; 00498 float rcentroid; 00502 float ccentroid; 00506 int perimeter; 00510 int rmin ; 00514 int rmax ; 00518 int cmin ; 00522 int cmax ; 00526 int rseed; 00530 int cseed ; 00534 int number_of_holes; 00538 int num_runs; 00542 vector <DLDatarun> runs; 00546 int num_conc_up; 00550 vector <DLDatarun> conc_up; 00554 int num_conc_down; 00558 vector <DLDatarun> conc_down; 00562 int num_points_convex_hull; 00566 vector <DLPoint> convex_hull; 00570 float area_of_convex_hull; 00574 float perimeter_of_convex_hull; 00578 float moments[14]; 00582 int *user_data; 00583 00587 DLColor color; 00588 }; 00589 00590 00591 #endif // _DLCOMPONENT_H_