#include <qgarlib/Component.H>
Representation of a component:
Definition at line 88 of file Component.H.
Labels | |
| label_type | label () const |
| Get component label. | |
| label_type | inLabel () const |
| Get label of comprising component. | |
| static const label_type | _MAX_LABEL = std::numeric_limits<Component::label_type>::max() |
| Maximum label. | |
| static const label_type | _NO_LABEL = -1 |
| Label to express that an object is not yet labelled. | |
Public Types | |
Types related to a component | |
| typedef short | label_type |
| Type of a component label. | |
Public Member Functions | |
Constructors | |
| Component () | |
| Default constructor. | |
| Component (GenImage< label_type > *aPCompImg, int aLabel, int anInLabel, QGEbw aBW, int aXTopLeftPix, int aYTopLeftPix, int aXTopLeft, int aYTopLeft, int aXBottomRight, int aYBottomRight, int anAreaPixels) | |
| Create from full data. | |
| Component (const Component &aCComp) | |
| Copy constructor. | |
Destructor | |
| virtual | ~Component () |
| Virtual destructor. | |
Color | |
| QGEbw | color () const |
| Get color. | |
Coordinates | |
| int | xTopLeftPix () const |
| Get X coordinate of the top left pixel of the component. | |
| int | yTopLeftPix () const |
| Get Y coordinate of the top left pixel of the component. | |
| const BoundingBox & | accessBoundingBox () const |
| Get bounding box. | |
| BoundingBox | boundingBox () const |
| Get a copy of the bounding box. | |
| double | densityBox () const |
| Get density with regard to the bounding box. | |
Area | |
| int | areaPixels () const |
| Get component area (in pixels). | |
Access to the MAER (Minimum-Area Encasing Rectangle) | |
| const Maer & | accessMaer () |
| Get the MAER. | |
| Maer | maer () |
| Get a copy of the MAER. | |
| int | maerAreaPixels () |
| Get MAER area in pixels. | |
| double | densityMaer () |
| Get density with regard to the MAER. | |
Contour | |
| const std::list< DPoint > & | accessContour () |
| Get a pointer to the component contour. | |
| std::list< DPoint > | contour () |
| Get a copy of the component contour. | |
Operators | |
| Component & | operator= (const Component &aCComp) |
| Assignment. | |
Protected Attributes | |
Pixel map of the corresponding component image | |
| GenImage< label_type > * | _pCompImg |
| Pointer to the corresponding component image. | |
Labels | |
| label_type | _label |
| Label of the component. | |
| label_type | _inLabel |
| Label of the comprising component. | |
Color | |
| QGEbw | _color |
| Color. | |
Coordinates | |
| int | _xTopLeftPix |
| X coordinate of the top left pixel of the component. | |
| int | _yTopLeftPix |
| Y coordinate of the top left pixel of the component. | |
| BoundingBox | _boundingBox |
| Bounding box. | |
Area | |
| int | _areaPixels |
| Component effective area (in pixels). | |
MAER (Minimum-Area Encasing Rectangle) | |
| Maer * | _maer |
| Minimum-Area Enclosing Rectangle (MAER). | |
| int | _maerAreaPixels |
| Minimum-Area Enclosing Rectangle (MAER). | |
Contour | |
| std::list< DPoint > | _contour |
| List of the points of the contour component. | |
Private Member Functions | |
Auxiliary functions | |
| void | PRIVATEcomputeContour () |
| Compute the external contour (hull) of the component. | |
| void | PRIVATEcomputeMaer () |
| Compute the MAER (Minimum-Area Encasing Rectangle). | |
Static Private Attributes | |
Tables to compute coordinates during contour following | |
+---+---+---+ | | 1 | 2 | +---+---+---+ | 7 | *-->3 | +---+---+---+ | 6 | 5 | 4 | +---+---+---+ The outside of the component is always on the left when moving along the contour direction. The figure above gives an example: when following a contour in the EAST direction, the first new possible contour point (1) is at NORTH of the current point (*), the second (2) at NORTH-EAST, and so on.
new contour directions (see table _s_new_dir)
W NW N NE E SE S SW W NW N NE E SE
indexes 0 1 2 3 4 5 6 7 8 9 10 11 12 13
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
_s_incr_x | -1| -1| 0 | 1 | 1 | 1 | 0 | -1| -1| -1| 0 | 1 | 1 | 1 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
_s_incr_y | 0 | -1| -1| -1| 0 | 1 | 1 | 1 | 0 | -1| -1| -1| 0 | 1 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
N NE E SE S SW W NW
entries corresponding to current contour directions
The _s_incr_x (resp. y) table (see figure above) contains the X (resp. Y) increment to get the X (resp. Y) coordinates of the 7 possible next contour points (points 1 to 7 on 1st figure) from the X (resp. Y) coordinate of the current point (*). The current contour direction (EAST on 1st figure) determines the first index to enter the tables.
new contour directions
W NW N NE E SE S SW W NW N NE E SE
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
_s_new_dir | 6 | 7 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 0 | 1 | 2 | 3 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Once a new contour point is found, table _s_new_dir gives the corresponding new contour direction, using the index corresponding to the new contour point in table _s_incr_x or _s_incr_y. | |
| static const int | _s_incr_x [14] |
| Table for X coordinates increments. | |
| static const int | _s_incr_y [14] |
| Table for Y coordinates increments. | |
| static const int | _s_new_dir [14] |
| Table for new contour directions. | |
|
|
Type of a component label.
Definition at line 102 of file Component.H. |
|
|
Default constructor.
Definition at line 158 of file Component.C. |
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Create from full data.
|
|
|
Copy constructor.
Definition at line 193 of file Component.C. References _maer. |
|
|
Virtual destructor.
Definition at line 219 of file Component.C. References _maer. |
|
|
Get bounding box.
Definition at line 239 of file Component.C. References _boundingBox. Referenced by qgar::TgifFile::PRIVATEwriteComponent(), qgar::TTBinaryImage::TTBinaryImage(), and qgar::TgifFile::write(). |
|
|
Get a pointer to the component contour.
Definition at line 342 of file Component.C. References _contour, and PRIVATEcomputeContour(). Referenced by PRIVATEcomputeMaer(), qgar::TgifFile::PRIVATEwriteComponent(), and qgar::TgifFile::write(). |
|
|
Get the MAER.
Definition at line 282 of file Component.C. References _maer, and PRIVATEcomputeMaer(). |
|
|
Get component area (in pixels).
Definition at line 644 of file Component.H. References _areaPixels. Referenced by qgar::TgifFile::PRIVATEwriteComponent(), and qgar::TgifFile::write(). |
|
|
Get a copy of the bounding box.
Definition at line 247 of file Component.C. References _boundingBox. |
|
|
Get color.
Definition at line 614 of file Component.H. References _color. Referenced by qgar::TgifFile::PRIVATEwriteComponent(), qgar::TTBinaryImage::TTBinaryImage(), and qgar::TgifFile::write(). |
|
|
Get a copy of the component contour.
Definition at line 355 of file Component.C. References _contour, and PRIVATEcomputeContour(). |
|
|
Get density with regard to the bounding box. The density is the ratio between the area (number of pixels) of the component and the area of its bounding box. Definition at line 255 of file Component.C. References _areaPixels, _boundingBox, and qgar::BoundingBox::area(). |
|
|
Get density with regard to the MAER. The density is the ratio between the area (number of pixels) of the component and the area of its MAER.
Definition at line 321 of file Component.C. References _areaPixels, _maer, _maerAreaPixels, and PRIVATEcomputeMaer(). |
|
|
Get label of comprising component.
Definition at line 602 of file Component.H. References _inLabel. |
|
|
Get component label.
Definition at line 595 of file Component.H. References _label. Referenced by qgar::ConnectedComponents::PRIVATEcopyCC(). |
|
|
Get a copy of the MAER.
Definition at line 295 of file Component.C. References _maer, and PRIVATEcomputeMaer(). |
|
|
Get MAER area in pixels.
Definition at line 308 of file Component.C. References _maer, _maerAreaPixels, and PRIVATEcomputeMaer(). |
|
|
Assignment.
Definition at line 374 of file Component.C. References _areaPixels, _boundingBox, _color, _inLabel, _label, _maer, _pCompImg, _xTopLeftPix, and _yTopLeftPix. |
|
|
Compute the external contour (hull) of the component.
. . . . . . . . . . . . . . . . . .
. . . . * . . . . . . . . C . . . .
. . . * . * . . . . . . C . C . . .
. . * . * . * . . . . C . * . C . .
. * . * * * . * . . C . * * * . C .
. . * . * . * . . . . C . * . C . .
. . . * . * . . . . . . C . C . . .
. . . . * . . . . . . . . C . . . .
. . . . . . . . . . . . . . . . . .
In the example above, '*' is a black pixel, '.' is a white pixel, and 'C' is a pixel of the resulting contour. Definition at line 409 of file Component.C. References _areaPixels, _boundingBox, _contour, _label, _NO_LABEL, _pCompImg, _s_incr_x, _s_incr_y, _s_new_dir, _xTopLeftPix, _yTopLeftPix, qgar::GenImage< T, CheckPolicy >::pPixMap(), qgar::GenImage< T, CheckPolicy >::width(), qgar::BoundingBox::xBottomRight(), qgar::BoundingBox::xTopLeft(), qgar::BoundingBox::yBottomRight(), and qgar::BoundingBox::yTopLeft(). Referenced by accessContour(), and contour(). |
|
|
Compute the MAER (Minimum-Area Encasing Rectangle).
Definition at line 662 of file Component.C. References _maer, _maerAreaPixels, accessContour(), and qgar::Maer::accessVertices(). Referenced by accessMaer(), densityMaer(), maer(), and maerAreaPixels(). |
|
|
Get X coordinate of the top left pixel of the component.
Definition at line 625 of file Component.H. References _xTopLeftPix. Referenced by qgar::TTBinaryImage::TTBinaryImage(). |
|
|
Get Y coordinate of the top left pixel of the component.
Definition at line 632 of file Component.H. References _yTopLeftPix. Referenced by qgar::TTBinaryImage::TTBinaryImage(). |
|
|
Component effective area (in pixels).
Definition at line 429 of file Component.H. Referenced by areaPixels(), densityBox(), densityMaer(), operator=(), and PRIVATEcomputeContour(). |
|
|
Bounding box.
Definition at line 417 of file Component.H. Referenced by accessBoundingBox(), boundingBox(), densityBox(), operator=(), and PRIVATEcomputeContour(). |
|
|
Color.
Definition at line 395 of file Component.H. Referenced by color(), and operator=(). |
|
|
List of the points of the contour component. Each point corresponds to a change in the current contour direction, based on 8-connexity. Definition at line 461 of file Component.H. Referenced by accessContour(), contour(), and PRIVATEcomputeContour(). |
|
|
Label of the comprising component.
Definition at line 383 of file Component.H. Referenced by inLabel(), and operator=(). |
|
|
Label of the component.
Definition at line 378 of file Component.H. Referenced by label(), operator=(), and PRIVATEcomputeContour(). |
|
|
Minimum-Area Enclosing Rectangle (MAER).
Definition at line 441 of file Component.H. Referenced by accessMaer(), Component(), densityMaer(), maer(), maerAreaPixels(), operator=(), PRIVATEcomputeMaer(), and ~Component(). |
|
|
Minimum-Area Enclosing Rectangle (MAER).
Definition at line 446 of file Component.H. Referenced by densityMaer(), maerAreaPixels(), and PRIVATEcomputeMaer(). |
|
|
Maximum label.
Definition at line 70 of file Component.C. Referenced by qgar::ConnectedComponentsImpl::run(). |
|
|
Label to express that an object is not yet labelled.
Definition at line 76 of file Component.C. Referenced by qgar::ConnectedComponents::makeBinaryImg(), qgar::ConnectedComponentsImpl::mergePrevAndCurrComponents(), qgar::ConnectedComponentsImpl::nextCurrRun(), PRIVATEcomputeContour(), qgar::ConnectedComponentsImpl::run(), and qgar::ConnectedComponentsImpl::validLabel(). |
|
|
Pointer to the corresponding component image.
Definition at line 364 of file Component.H. Referenced by operator=(), and PRIVATEcomputeContour(). |
|
|
Initial value:
{
-1,
-1,
0,
1,
1,
1,
0,
-1,
-1,
-1,
0,
1,
1,
1
}
Definition at line 88 of file Component.C. Referenced by PRIVATEcomputeContour(). |
|
|
Initial value:
{
0,
-1,
-1,
-1,
0,
1,
1,
1,
0,
-1,
-1,
-1,
0,
1
}
Definition at line 109 of file Component.C. Referenced by PRIVATEcomputeContour(). |
|
|
Initial value:
{
6,
7,
0,
1,
2,
3,
4,
5,
6,
7,
0,
1,
2,
3
}
Definition at line 130 of file Component.C. Referenced by PRIVATEcomputeContour(). |
|
|
X coordinate of the top left pixel of the component.
Definition at line 407 of file Component.H. Referenced by operator=(), PRIVATEcomputeContour(), and xTopLeftPix(). |
|
|
Y coordinate of the top left pixel of the component.
Definition at line 412 of file Component.H. Referenced by operator=(), PRIVATEcomputeContour(), and yTopLeftPix(). |