latest version v1.9 - last update 10 Apr 2010 |
Elements of a Chaincode. More...
#include <ltiContour.h>
Public Types | |
enum | direction { UNKNOWN = -2, NOMOVE = -1, E = 0, NE, N, NW, W, SW, S, SE } |
Public Member Functions | |
chainCode (const direction &v=NOMOVE) | |
chainCode (const int &v) | |
chainCode (const chainCode &other) | |
chainCode (const int &x, const int &y) | |
chainCode (const point &here, const point &next) | |
direction | getDirection () const |
bool | isDirection () const |
point | getNext (const point &here) const |
point | getPrevious (const ipoint &here) const |
int | deltaX () const |
int | deltaY () const |
point | delta () const |
chainCode & | operator= (const direction &other) |
chainCode & | copy (const direction &other) |
chainCode & | copy (const chainCode &other) |
chainCode & | operator= (const chainCode &other) |
bool | compare (const chainCode &other) |
bool | operator== (const chainCode &other) |
bool | compare (const direction &other) |
bool | operator== (const direction &other) |
chainCode & | subtract (const chainCode &first, const chainCode &second) |
chainCode | operator- (const chainCode &other) const |
chainCode & | subtract (const chainCode &other) |
chainCode & | operator-= (const chainCode &other) |
chainCode & | add (const chainCode &first, const chainCode &second) |
chainCode | operator+ (const chainCode &other) const |
chainCode & | add (const chainCode &other) |
chainCode & | operator+= (const chainCode &other) |
chainCode & | divide (const int &other) |
chainCode | operator/ (const int &other) |
ubyte | getCanzlerCode (const chainCode &nextChainCode) const |
Static Public Attributes | |
Canzler Codes | |
Given two chain codes for a sequence of three adjacent pixels, the Canzler-Codes give you information which borders of the middle pixel belong to the boundary. With the getCanzlerCode you can obtain the corresponding coding for the pixel pointed by this chain code, if the next chain code is the one given. They are somehow similar to the so called "chain crack codes", but instead of specifying a direction of the boundary, they code which "crack codes" belong to the middle pixel between two chain codes. There are 16 Canzler-Codes, that can be obtained by the combination of the four values Top, Right, Bottom and Left, which specify that the border runs on the top, right, bottom and/or left edge of the pixel respectively. | |
static const ubyte | Nothing |
static const ubyte | Top |
static const ubyte | Right |
static const ubyte | Bottom |
static const ubyte | Left |
Protected Member Functions | |
void | fromDeltas (const int &x, const int &y) |
Protected Attributes | |
direction | value |
Elements of a Chaincode.
The used directions follows the next diagram:
The "int" value resulting from casting these chain codes is proportional to the angle with a proportionality constant of 45°, i.e. if 'c' is a chainCode object, then the equivalent direction in degrees is 45*int(c.getDirection()).
Directions used in chain codes The used directions follows the next diagram:.
The "int" value resulting from casting these chain codes is proportional to the angle with a proportionality constant of 45°, i.e. if 'c' is a chainCode object, then the equivalent direction in degrees is 45*int(c.getDirection()).
lti::chainCode::chainCode | ( | const direction & | v = NOMOVE |
) | [inline] |
Left has value 8 (the fourth bit).
default constructor
lti::chainCode::chainCode | ( | const int & | v | ) | [inline] |
constructor to cast an integer
lti::chainCode::chainCode | ( | const chainCode & | other | ) | [inline] |
copy constructor
lti::chainCode::chainCode | ( | const int & | x, | |
const int & | y | |||
) | [inline] |
Constrcutor.
This constructor creates a chainCode object using the sign of the parameters to calculate the direction. Image-coordinates are used, i.e. a positive "y" implies a change towards "south", and a positive x implies a change towards "east".
References fromDeltas().
Constructor.This constructor creates a chainCode object using two points.
References fromDeltas(), lti::tpoint< T >::subtract(), lti::tpoint< T >::x, and lti::tpoint< T >::y.
add the angles of the other chain code to this chainCode and leave the result in this instance.
Returns a reference to the instance
add the angles of the first and second chain codes
Referenced by operator+(), and operator+=().
bool lti::chainCode::compare | ( | const chainCode & | other | ) | [inline] |
compare with another object
Referenced by operator==().
become other object
Referenced by operator=().
point lti::chainCode::delta | ( | ) | const [inline] |
returns point with changes in both direction, x and y.
int lti::chainCode::deltaX | ( | ) | const [inline] |
returns change in x.
For example, if the value is NW, deltaX() returns -1.
int lti::chainCode::deltaY | ( | ) | const [inline] |
returns change in y.
For example, if the value is NW, deltaY() returns -1.
chainCode& lti::chainCode::divide | ( | const int & | other | ) | [inline] |
divide chain code equivalent angle with an integer.
The result will be left in this instance and a reference to it will be returned
References value.
Referenced by operator/().
void lti::chainCode::fromDeltas | ( | const int & | x, | |
const int & | y | |||
) | [inline, protected] |
compute chain code from x and y deltas
Referenced by chainCode().
direction lti::chainCode::getDirection | ( | ) | const [inline] |
returns direction of this chain element
returns next point with start point "here" and using this chainCode.
returns previous point with start point "here" and using this chainCode.
bool lti::chainCode::isDirection | ( | ) | const [inline] |
Possible Direction.returns true if this object contains one of the eight posible directions, and false otherwise.
add the angles of this and the other chain code
References add().
add another chain code
References add().
subtract the angle equivalent of the other chainCode from *this
References subtract().
subtract another chain code
References subtract().
chainCode lti::chainCode::operator/ | ( | const int & | other | ) | [inline] |
divide chain code angle with integer.
References divide().
bool lti::chainCode::operator== | ( | const direction & | other | ) | [inline] |
bool lti::chainCode::operator== | ( | const chainCode & | other | ) | [inline] |
subtract the angle equivalent of the other chain code from this one.
The result will be left in this instance, and a reference to it will be returned.
subtract the angles of the first and second chain code elements and leave the result here!
Referenced by operator-(), and operator-=().
const ubyte lti::chainCode::Bottom [static] |
Right has value 2 (the second bit).
const ubyte lti::chainCode::Left [static] |
Bottom has value 4 (the third bit).
const ubyte lti::chainCode::Nothing [static] |
Nothing has the value 0.
const ubyte lti::chainCode::Right [static] |
Top has value 1 (the first bit).
const ubyte lti::chainCode::Top [static] |
Nothing has the value 0.
direction lti::chainCode::value [protected] |
Attribute containing the chain code.
Referenced by divide().