A tlChain object is an arbitrary, dynamic collection of tlPoints. tlChain objects are useful for storing extracted points, but also for continuous edges extraction and other related operations such as angle detections.
Public Member Functions | |
tlChain () | |
tlChain (tlPoint *start) | |
tlChain (int startx, int starty) | |
virtual | ~tlChain () |
int | getLength () |
int | isClosed () |
int | getConnex () |
tlPoint * | getStart () |
tlPoint * | getEnd () |
tlPoint * | getPoint (int index) |
int | reset () |
int | clear () |
int | filter (int radius) |
int | close () |
int | isIn (tlPoint *point) |
int | add (int x, int y) |
int | insert (int index, int x, int y) |
int | remove (int index) |
int | remove (int x, int y) |
int | extract (tlImage *image, int x, int y, tlRect *rect, int connex=TL_CONNEX_8) |
int | blindExtract (tlImage *image, int x, int y, tlRect *rect, int connex=TL_CONNEX_8) |
int | extract (tlMask *mask, int x, int y, tlRect *rect, int connex=TL_CONNEX_8) |
int | blindExtract (tlMask *mask, int x, int y, tlRect *rect, int connex=TL_CONNEX_8) |
int | corners (tlChain *corners) |
int | corners (int res, int alphaMax, tlChain *corners) |
int | corners (int dmin, int dmax, int alphaMax, tlChain *corners) |
tlChain::tlChain | ( | ) |
Constructor, creates an empty tlChain object.
References TL_NO_ERROR, and TL_NOT_CONNEX.
tlChain::tlChain | ( | tlPoint * | startPoint | ) |
Constructor, creates a tlChain with one starting point.
startPoint | starting point for chain extraction |
References TL_NO_ERROR, and TL_NOT_CONNEX.
tlChain::tlChain | ( | int | startx, | |
int | starty | |||
) |
Constructor, creates a tlChain with one starting point.
startx | starting point X coord | |
starty | starting point Y coord |
References TL_NO_ERROR, and TL_NOT_CONNEX.
tlChain::~tlChain | ( | ) | [virtual] |
int tlChain::getLength | ( | ) | [inline] |
Get the chain length.
Referenced by corners(), tlImage::drawChain(), tlImage::drawCross(), and tlColorModel::train().
int tlChain::isClosed | ( | ) | [inline] |
Test whether the chain is closed or not.
int tlChain::getConnex | ( | ) | [inline] |
Test whether the chain connectivity.
tlPoint * tlChain::getStart | ( | ) | [inline] |
Retrieve the first point of the chain.
start
point on success, NULL if the chain is empty.tlPoint * tlChain::getEnd | ( | ) | [inline] |
Retrieve the last point of the chain.
end
point on success, NULL if the chain is empty.tlPoint * tlChain::getPoint | ( | int | index | ) |
Get the point at a given index in the chain (if it exists).
index | point index |
References TL_ERRNO_MSG, and TL_ERROR_INDEX_OUT_OF_BOUNDS.
Referenced by tlImage::drawChain(), tlImage::drawCross(), and tlColorModel::train().
int tlChain::reset | ( | ) |
Reset the chain (remove all points), same as clear().
References clear().
Referenced by blindExtract(), and extract().
int tlChain::clear | ( | ) |
Reset the chain (remove all points), same as reset().
References TL_NOT_CONNEX.
Referenced by reset().
int tlChain::filter | ( | int | radius | ) |
Remove close neighbors to avoid redundancies.
radius | the minimum allowed distance between 2 points |
int tlChain::close | ( | ) |
Close the chain (requires at least 2 points to be in the chain).
References TL_ERRNO_MSG, and TL_ERROR.
Referenced by extract().
int tlChain::isIn | ( | tlPoint * | point | ) | [inline] |
Test for the presence of a point in the chain.
point | point to test for |
References TL_ERRNO_MSG, TL_ERROR_NULL_POINTER, tlLocation::x, and tlLocation::y.
int tlChain::add | ( | int | x, | |
int | y | |||
) |
Insert a point at the end of the chain.
x | the point to add X coord | |
y | the point to add Y coord |
References TL_ERRNO_MSG, and TL_ERROR_ALLOCATION_FAILED.
int tlChain::insert | ( | int | index, | |
int | x, | |||
int | y | |||
) |
Insert a point at a specific index in the chain.
index | the index to insert to point at | |
x | the point to add X coord | |
y | the point to add Y coord |
References TL_ERRNO_MSG, TL_ERROR, and TL_ERROR_ALLOCATION_FAILED.
int tlChain::remove | ( | int | index | ) |
Remove a point at a specific index from the chain.
index | the index of the point to remove |
References TL_ERRNO_MSG, and TL_ERROR.
int tlChain::remove | ( | int | x, | |
int | y | |||
) |
Remove a point from the chain if it exists.
x | point to remove X coord | |
y | point to remove Y coord |
References TL_ERRNO_MSG, and TL_ERROR.
Extract a chain from a binary image.
image | binary image | |
x | X coord to start extraction from | |
y | Y coord to start extraction from | |
connex | connectivity (TL_CONNECT_4 or TL_CONNECT_8) | |
rect | bounding rectangle for extraction |
References BIN, close(), tlPixelArray::format, tlSize::height, tlPixelArray::pixel, reset(), TL_CONNEX_8, TL_ERRNO_MSG, TL_ERROR_GEOMETRY, TL_ERROR_INVALID_FORMAT, TL_ERROR_NULL_POINTER, TL_MAX, TL_MIN, TL_PIXEL, tlSize::width, tlLocation::x, and tlLocation::y.
int tlChain::blindExtract | ( | tlImage * | image, | |
int | x, | |||
int | y, | |||
tlRect * | rect, | |||
int | connex = TL_CONNEX_8 | |||
) |
Extract a chain from a binary image. Looks around a given point for a valid starting point.
image | binary image | |
x | starting point X coord | |
y | starting point Y coord | |
rect | bounding rectangle to limit extraction area | |
connex | connectivity (TL_CONNECT_4 or TL_CONNECT_8) |
x
,y
) until a valid point is found. References BIN, tlPixelArray::format, tlSize::height, tlPixelArray::pixel, reset(), TL_ERRNO_MSG, TL_ERROR, TL_ERROR_INVALID_FORMAT, TL_ERROR_NULL_POINTER, TL_MAX, TL_MIN, TL_PIXEL, tlSize::width, tlLocation::x, and tlLocation::y.
Extract a chain from a mask.
mask | mask to extract from | |
x | X coord to start extraction from | |
y | Y coord to start extraction from | |
connex | connectivity (TL_CONNECT_4 or TL_CONNECT_8) | |
rect | bounding rectangle for extraction |
References close(), tlSize::height, tlPixelArray::pixel, reset(), TL_CONNEX_8, TL_ERRNO_MSG, TL_ERROR, TL_ERROR_NULL_POINTER, TL_MAX, TL_MIN, TL_PIXEL, tlSize::width, tlLocation::x, and tlLocation::y.
Extract a chain from a mask. Looks around a given point for a valid starting point.
mask | mask to extract from | |
x | starting point X coord | |
y | starting point Y coord | |
rect | bounding rectangle to limit extraction area | |
connex | connectivity (TL_CONNECT_4 or TL_CONNECT_8) |
x
,y
) until a valid point is found. References tlSize::height, tlPixelArray::pixel, reset(), TL_ERRNO_MSG, TL_ERROR, TL_ERROR_NULL_POINTER, TL_MAX, TL_MIN, TL_PIXEL, tlSize::width, tlLocation::x, and tlLocation::y.
int tlChain::corners | ( | tlChain * | corners | ) |
Extract chain corners (points of high curvature) using default parameters.
References TL_CHAIN_CORNER_ALPHAMAX, TL_CHAIN_CORNER_DMAX, TL_CHAIN_CORNER_DMIN, TL_ERRNO_MSG, and TL_ERROR_NULL_POINTER.
Referenced by corners().
int tlChain::corners | ( | int | res, | |
int | alphaMax, | |||
tlChain * | corners | |||
) |
Extract chain corners (points of high curvature).
res | triangle segment length [chain elements] | |
alphaMax | max allowed angle (for normal curvature) | |
corners | [out] a chain containing the corner points |
References corners(), TL_ERRNO_MSG, and TL_ERROR_NULL_POINTER.
int tlChain::corners | ( | int | dmin, | |
int | dmax, | |||
int | alphaMax, | |||
tlChain * | corners | |||
) |
Extract chain corners (points of high curvature).
dmin | min triangle segment length [chain elements] | |
dmax | max triangle segment length [chain elements] | |
alphaMax | max allowed angle (for normal curvature) | |
corners | [out] a chain containing the corner points |
References add(), getLength(), TL_ERRNO_MSG, TL_ERROR_NULL_POINTER, and TL_PI.