last update 20 Sep 2009 |
#include <cvrChainCode.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 ipoint &here, const ipoint &next) | |
direction | getDirection () const |
bool | isDirection () const |
ipoint | getNext (const ipoint &here) const |
ipoint | getPrevious (const ipoint &here) const |
int | deltaX () const |
int | deltaY () const |
ipoint | 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 about 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 |
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()).
cvr::chainCode::chainCode | ( | const direction & | v = NOMOVE |
) | [inline] |
Left has value 8 (the fourth bit).
default constructor
cvr::chainCode::chainCode | ( | const int | v | ) | [inline] |
constructor to cast an integer
cvr::chainCode::chainCode | ( | const chainCode & | other | ) | [inline] |
copy constructor
cvr::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(), cvr::point< T >::subtract(), cvr::point< T >::x, and cvr::point< 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
bool cvr::chainCode::compare | ( | const chainCode & | other | ) | [inline] |
ipoint cvr::chainCode::delta | ( | ) | const [inline] |
returns point with changes in both direction, x and y.
int cvr::chainCode::deltaX | ( | ) | const [inline] |
returns change in x.
For example, if the value is NW, deltaX() returns -1.
int cvr::chainCode::deltaY | ( | ) | const [inline] |
returns change in y.
For example, if the value is NW, deltaY() returns -1.
chainCode& cvr::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 cvr::chainCode::fromDeltas | ( | const int | x, | |
const int | y | |||
) | [inline, protected] |
direction cvr::chainCode::getDirection | ( | ) | const [inline] |
returns direction of this chain element
bool cvr::chainCode::isDirection | ( | ) | const [inline] |
Possible Direction.returns true if this object contains one of the eight posible directions, and false otherwise.
chainCode cvr::chainCode::operator/ | ( | const int | other | ) | [inline] |
bool cvr::chainCode::operator== | ( | const direction & | other | ) | [inline] |
bool cvr::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 cvr::chainCode::Bottom [static] |
Right has value 2 (the second bit).
const ubyte cvr::chainCode::Left [static] |
Bottom has value 4 (the third bit).
const ubyte cvr::chainCode::Nothing [static] |
Nothing has the value 0.
const ubyte cvr::chainCode::Right [static] |
Top has value 1 (the first bit).
const ubyte cvr::chainCode::Top [static] |
Nothing has the value 0.
direction cvr::chainCode::value [protected] |