#include <DLComponent.h>
Public Member Functions | |
DLComponent () | |
DLComponent (const DLComponent &orig) | |
virtual | ~DLComponent () |
int | dlGetWidth () const |
int | dlGetHeight () const |
int | dlGetMass () const |
float | dlGetRowCentroid () const |
float | dlGetColCentroid () const |
int | dlGetPerimeter () const |
int | dlGetRowMin () const |
int | dlGetRowMax () const |
int | dlGetColMin () const |
int | dlGetColMax () const |
int | dlGetRowSeed () const |
int | dlGetColSeed () const |
int | dlGetNumHoles () const |
int | dlGetNumRuns () const |
vector< DLDatarun > | dlGetRuns () const |
int | dlGetNumConcavitiesUp () const |
vector< DLDatarun > | dlGetConcavitiesUp () const |
int | dlGetNumConcavitiesDown () const |
vector< DLDatarun > | dlGetConcavitiesDown () const |
float | dlGetMoment (int idx) const |
const DLComponent & | operator= (const DLComponent &right) |
const DLColor | dlGetComponentColor () |
Set-attribute functions | |
These functions can be used to overwrite various attributes with new values, but note that they do not cause recalculation of the other attributes, and do not affect any of the DLComponent's internal information other than that single attribute being set. | |
void | dlSetArea (int newArea) |
void | dlSetRowCentriod (float newRcentroid) |
void | dlSetColCentroid (float newCCentroid) |
void | dlSetPerimeter (int newPerimeter) |
void | dlSetRowMin (int newRmin) |
void | dlSetRowMax (int newRmax) |
void | dlSetColMin (int newCmin) |
void | dlSetColMax (int newCmax) |
void | dlSetRowSeed (int newRseed) |
void | dlSetColSeed (int newCseed) |
void | dlSetNumHoles (int holes) |
void | dlSetNumConcavitiesUp (int num) |
void | dlSetNumConcavitiesDown (int num) |
void | dlAddConcavityUp (DLDatarun conc) |
void | dlAddConcavityDown (DLDatarun conc) |
void | dlSetNumConvexHulls (int num) |
void | dlAddConvexHull (DLPoint convexHull) |
void | dlSetAreaConvexHulls (float convexHull) |
void | dlSetPerimeterConvexHulls (float perimeterConvexHull) |
void | dlSetComponentColor (const DLColor &newColor) |
DLImage Rendering Functions | |
DLImage | dlGetImage () const |
DLImage | dlGetColorImage () const |
DLImage | dlGetBinaryImage () const |
DLComponent is a data object which stores all the information needed to describe a connected component. A connected component is a contiguous region of black pixels. Here, contiguous means 8-connected, so that the image below (each pixel represented by an X) contains a single connected component, since the black pixels are adjacent horizontally, vertically, or across a diagonal.
XX XX X X XX XX XX
The DLConnectedComponents class stores a list of DLComponents calculated from an entire image. An individual DLComponent can be accessed by getting the vector of DLComponents using DLConnectedComponents::dlGetConnectedComponents() or using the various DLConnectedComponents iterators to traverse the DLConnectedComponents object.
Examples:
DLImage i("test.tif"); // load an image DLConnectedComponents cc; cc.dlCreateConnectedComponents(i); // calculate connected components std::vector<DLComponent> cv = cc.dlGetConnectedComponents(); cout << "First component's width: " << cv[0].dlGetWidth() << endl; DLConnectedComponents::iterator ii = cc.begin(); cout << "First component's width: " << ii->dlGetWidth() << endl; ii++; // advance iterator cout << "Second component's width: " << ii->dlGetWidth() << endl;
The various dlGet...() functions are used to get information about an individual connected component. The various dlSet...() functions can be used to overwrite various attributes with new values, but note that they do not cause recalculation of the other attributes, and do not affect any of the DLComponent's internal information other than that single attribute being set.
Definition at line 52 of file DLComponent.h.
DLComponent::DLComponent | ( | ) |
Default DLComponent constructor
DLComponent::DLComponent | ( | const DLComponent & | orig | ) |
Default DLComponent copy constructor
orig | orginal image to be copied |
virtual DLComponent::~DLComponent | ( | ) | [virtual] |
Default DLComponent destructor
int DLComponent::dlGetWidth | ( | ) | const [inline] |
int DLComponent::dlGetHeight | ( | ) | const [inline] |
int DLComponent::dlGetMass | ( | ) | const [inline] |
Get the area of the component: the mass is the number of dark pixels in the connected component (previously called "area")
Definition at line 94 of file DLComponent.h.
float DLComponent::dlGetRowCentroid | ( | ) | const [inline] |
Gets the row centroid of the component
Definition at line 100 of file DLComponent.h.
float DLComponent::dlGetColCentroid | ( | ) | const [inline] |
Get the column centroid of the component
Definition at line 106 of file DLComponent.h.
int DLComponent::dlGetPerimeter | ( | ) | const [inline] |
Get the length of the perimeter of the component
Definition at line 112 of file DLComponent.h.
int DLComponent::dlGetRowMin | ( | ) | const [inline] |
Get the bounding box extents: uppermost row of the component
Definition at line 118 of file DLComponent.h.
int DLComponent::dlGetRowMax | ( | ) | const [inline] |
Get the bounding box extents: lowermost row of the component
Definition at line 124 of file DLComponent.h.
int DLComponent::dlGetColMin | ( | ) | const [inline] |
Get the bounding box extents: leftmost column of the component
Definition at line 130 of file DLComponent.h.
int DLComponent::dlGetColMax | ( | ) | const [inline] |
Get the bounding box extents: rightmost column of the component
Definition at line 136 of file DLComponent.h.
int DLComponent::dlGetRowSeed | ( | ) | const [inline] |
Get the row index of seed pixel of the component. The seed pixel is the pixel which forms the core of the connected component; other pixels in the component were discovered through their adjacency to the seed pixel.
Definition at line 145 of file DLComponent.h.
int DLComponent::dlGetColSeed | ( | ) | const [inline] |
Get the column index of the seed pixel of the component. The seed pixel is the pixel which forms the core of the connected component; other pixels in the component were discovered through their adjacency to the seed pixel.
Definition at line 154 of file DLComponent.h.
int DLComponent::dlGetNumHoles | ( | ) | const [inline] |
Get the number of holes of the component. A hole is an area of 4-connected white pixels entirely within the interior of a connected component.
The following connected component has one hole:
XXXXXXXXXXXX XXXXXX XXX XXXXXXX XXX XXXXX XXX XXXXXXXXX XX XXXX XX XX X
XXXXXX X XXX XXX X XXXXXX
Definition at line 180 of file DLComponent.h.
int DLComponent::dlGetNumRuns | ( | ) | const [inline] |
Get the number of runs in the component. A run is a contiguous horizontal row of black pixels. So the following connected component has 6 runs:
XXXX XXXXXX XXXX XXXXXXXXXXXXXXXX XXXXXX XXXXX
Definition at line 193 of file DLComponent.h.
vector<DLDatarun> DLComponent::dlGetRuns | ( | ) | const [inline] |
Get the vector of the component's runs. A run is a contiguous horizontal row of black pixels within the component.
Definition at line 200 of file DLComponent.h.
int DLComponent::dlGetNumConcavitiesUp | ( | ) | const [inline] |
Get the number of up-concavities in the component. The following connected component has three up-concavities:
X XXXXXX XXXX XX XXXXXXXXXXXXXX XXX XXXXXXXXXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXXXXXXXXXXXXX
Definition at line 214 of file DLComponent.h.
vector<DLDatarun> DLComponent::dlGetConcavitiesUp | ( | ) | const [inline] |
Get the vector of the component's up-concavities. The DLDatarun representation of the up-concavity will indicate the run of white pixels farthest down in the concavity.
Definition at line 223 of file DLComponent.h.
int DLComponent::dlGetNumConcavitiesDown | ( | ) | const [inline] |
Get the number of down-concavities in the component. The following connected component has three down-concavities:
XXXXXXXXXXXXXXXXXXX XXXXXXXX XXXXXXXX XXX XXXXXXXXXXXXXXX XX XXXXXXXXXXXXXX X XXXXXX XXXX
Definition at line 237 of file DLComponent.h.
vector<DLDatarun> DLComponent::dlGetConcavitiesDown | ( | ) | const [inline] |
Get the vector of the component's down-concavities. The DLDatarun representation of the down-concavity will indicate the run of white pixels farthest up in the concavity.
Definition at line 246 of file DLComponent.h.
float DLComponent::dlGetMoment | ( | int | idx | ) | const [inline] |
Get the Moment of the Component at index
Definition at line 279 of file DLComponent.h.
void DLComponent::dlSetArea | ( | int | newArea | ) | [inline] |
Sets the area of the component.
newArea | new area |
Definition at line 292 of file DLComponent.h.
void DLComponent::dlSetRowCentriod | ( | float | newRcentroid | ) | [inline] |
Set the row centroid of the component
newRcentroid | new row centroid |
Definition at line 298 of file DLComponent.h.
void DLComponent::dlSetColCentroid | ( | float | newCCentroid | ) | [inline] |
Set the column centroid of the Component
newCCentroid | int col centroid |
Definition at line 304 of file DLComponent.h.
void DLComponent::dlSetPerimeter | ( | int | newPerimeter | ) | [inline] |
Set the length of perimeter of the component
newPerimeter | new length of perimeter |
Definition at line 310 of file DLComponent.h.
void DLComponent::dlSetRowMin | ( | int | newRmin | ) | [inline] |
Set the bounding box extents: uppermost row of the component
newRmin | new uppermost row |
Definition at line 316 of file DLComponent.h.
void DLComponent::dlSetRowMax | ( | int | newRmax | ) | [inline] |
Set the bounding box extents: lowermost row of the component
newRmax | new lowermost row |
Definition at line 322 of file DLComponent.h.
void DLComponent::dlSetColMin | ( | int | newCmin | ) | [inline] |
Set the bounding box extents: leftmost column of the component
newCmin | new leftmost column |
Definition at line 328 of file DLComponent.h.
void DLComponent::dlSetColMax | ( | int | newCmax | ) | [inline] |
Set the bounding box extents of the Component
newCmax | int |
Definition at line 334 of file DLComponent.h.
void DLComponent::dlSetRowSeed | ( | int | newRseed | ) | [inline] |
Set the row index of seed pixel of the Component
newRseed | int |
Definition at line 340 of file DLComponent.h.
void DLComponent::dlSetColSeed | ( | int | newCseed | ) | [inline] |
Set the column index of the seed pixel of the component
newCseed | new seed pixel column index |
Definition at line 346 of file DLComponent.h.
void DLComponent::dlSetNumHoles | ( | int | holes | ) | [inline] |
Set the number of holes of the component
holes | new number of holes |
Definition at line 352 of file DLComponent.h.
void DLComponent::dlSetNumConcavitiesUp | ( | int | num | ) | [inline] |
Set the number of up concavities of the Component
num | int |
Definition at line 375 of file DLComponent.h.
void DLComponent::dlSetNumConcavitiesDown | ( | int | num | ) | [inline] |
Set the number of down concavities of the Component
num | int |
Definition at line 381 of file DLComponent.h.
void DLComponent::dlAddConcavityUp | ( | DLDatarun | conc | ) | [inline] |
Add an up concavity to the Component
conc | DLDatarun |
Definition at line 387 of file DLComponent.h.
void DLComponent::dlAddConcavityDown | ( | DLDatarun | conc | ) | [inline] |
Add a down concavity to the component's list of concavities.
conc | DLDatarun |
Definition at line 393 of file DLComponent.h.
void DLComponent::dlSetNumConvexHulls | ( | int | num | ) | [inline] |
Set the number convex hull of the Component
num | number of hulls |
Definition at line 399 of file DLComponent.h.
void DLComponent::dlAddConvexHull | ( | DLPoint | convexHull | ) | [inline] |
Add a convexHull to the Component
convexHull | DLPoint |
Definition at line 405 of file DLComponent.h.
void DLComponent::dlSetAreaConvexHulls | ( | float | convexHull | ) | [inline] |
Set the area convex hull of the Component
convexHull | float area |
Definition at line 411 of file DLComponent.h.
void DLComponent::dlSetPerimeterConvexHulls | ( | float | perimeterConvexHull | ) | [inline] |
Set the Area of the Component
perimeterConvexHull | float perimeter |
Definition at line 417 of file DLComponent.h.
void DLComponent::dlSetComponentColor | ( | const DLColor & | newColor | ) | [inline] |
Set the component's color, for use when rendering a color image of a set of connected components.
newColor | set to this color |
Definition at line 437 of file DLComponent.h.
DLImage DLComponent::dlGetImage | ( | ) | const |
Render a grayscale image of the connected component. Note that the component itself contains only black and white pixels, and therefore the grayscale image will have only grayscale values of 0x00 or 0xFF. The image will be the size of the bounding box of the component.
DLImage DLComponent::dlGetColorImage | ( | ) | const |
Return the image of the connected component but set the color of the image with the color value set in the component's color variable. The default is BLACK. The color for an individual DLComponent can be set by using dlSetComponentColor(). See DLConnectedComponents::dlSetFilteredCCColor() for a way to set the color of many components at once. The image will be the size of the bounding box of the component.
DLImage DLComponent::dlGetBinaryImage | ( | ) | const |
Render a binary image of the connected component. The image will be the size of the bounding box of the component.
const DLComponent& DLComponent::operator= | ( | const DLComponent & | right | ) |
Assignment operator
right | DLComponent |
const DLColor DLComponent::dlGetComponentColor | ( | ) | [inline] |