CVR-Lib last update 20 Sep 2009

cvr::chainCode Class Reference
[Shape Analysis]

Elements of a Chaincode. More...

#include <cvrChainCode.h>

List of all members.

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
chainCodeoperator= (const direction &other)
chainCodecopy (const direction &other)
chainCodecopy (const chainCode &other)
chainCodeoperator= (const chainCode &other)
bool compare (const chainCode &other)
bool operator== (const chainCode &other)
bool compare (const direction &other)
bool operator== (const direction &other)
chainCodesubtract (const chainCode &first, const chainCode &second)
chainCode operator- (const chainCode &other) const
chainCodesubtract (const chainCode &other)
chainCodeoperator-= (const chainCode &other)
chainCodeadd (const chainCode &first, const chainCode &second)
chainCode operator+ (const chainCode &other) const
chainCodeadd (const chainCode &other)
chainCodeoperator+= (const chainCode &other)
chainCodedivide (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


Detailed Description

Elements of a Chaincode.

The used directions follows the next diagram:

 NW   N   NE
    \ | /
 W -  x - E
    / | \
 SW   S   SE

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()).


Member Enumeration Documentation

Directions used in chain codes The used directions follows the next diagram:.

 NW   N   NE
    \ | /
 W -  x - E
    / | \
 SW   S   SE

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()).

Enumerator:
UNKNOWN  Unknown.
NOMOVE  No Move.
E  East (or Right).
NE  North-East (or Right-Up).
N  North (or Up).
NW  North-West (or North-West).
W  West (or West).
SW  South-West (or Left-Down).
S  South (or Down).
SE  South-East (or Right-Down).


Constructor & Destructor Documentation

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().

cvr::chainCode::chainCode ( const ipoint here,
const ipoint next 
) [inline]

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.


Member Function Documentation

chainCode& cvr::chainCode::add ( const chainCode other  )  [inline]

add the angles of the other chain code to this chainCode and leave the result in this instance.

Returns a reference to the instance

chainCode& cvr::chainCode::add ( const chainCode first,
const chainCode second 
) [inline]

add the angles of the first and second chain codes

Referenced by operator+().

bool cvr::chainCode::compare ( const direction other  )  [inline]

compare with another object

bool cvr::chainCode::compare ( const chainCode other  )  [inline]

compare with another object

Referenced by operator==().

chainCode& cvr::chainCode::copy ( const chainCode other  )  [inline]

become other object

chainCode& cvr::chainCode::copy ( const direction other  )  [inline]

become other object

Referenced by operator=().

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]

compute chain code from x and y deltas

Referenced by chainCode().

ubyte cvr::chainCode::getCanzlerCode ( const chainCode nextChainCode  )  const [inline]

return the Canzler Code for the pixel pointed by this chainCode if the second chainCode is the one given as parameter.

The result a the bitwise OR of some of the codes Top, Bottom, Left and Right.

Parameters:
nextChainCode the next chain code of this one in the chain code sequence.
Returns:
the canzler bit-coding for the edges of the pixel pointed by this chainCode which are part of the boundary. The values returned are bit or of the constants Left, Top, Right and Bottom.

direction cvr::chainCode::getDirection (  )  const [inline]

returns direction of this chain element

ipoint cvr::chainCode::getNext ( const ipoint here  )  const [inline]

returns next point with start point "here" and using this chainCode.

ipoint cvr::chainCode::getPrevious ( const ipoint here  )  const [inline]

returns previous point with start point "here" and using this chainCode.

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 chainCode other  )  const [inline]

add the angles of this and the other chain code

References add().

chainCode& cvr::chainCode::operator+= ( const chainCode other  )  [inline]

add another chain code

chainCode cvr::chainCode::operator- ( const chainCode other  )  const [inline]

subtract the angle equivalent of the other chainCode from *this

References subtract().

chainCode& cvr::chainCode::operator-= ( const chainCode other  )  [inline]

subtract another chain code

References subtract().

chainCode cvr::chainCode::operator/ ( const int  other  )  [inline]

divide chain code angle with integer.

References divide().

chainCode& cvr::chainCode::operator= ( const chainCode other  )  [inline]

become other object

References copy().

chainCode& cvr::chainCode::operator= ( const direction other  )  [inline]

become other object

References copy().

bool cvr::chainCode::operator== ( const direction other  )  [inline]

compare with another object

References compare().

bool cvr::chainCode::operator== ( const chainCode other  )  [inline]

compare with another object

References compare().

chainCode& cvr::chainCode::subtract ( 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.

chainCode& cvr::chainCode::subtract ( const chainCode first,
const chainCode second 
) [inline]

subtract the angles of the first and second chain code elements and leave the result here!

Referenced by operator-(), and operator-=().


Member Data Documentation

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).

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.

Attribute containing the chain code.

Referenced by divide().


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:08:43 2009 for CVR-Lib by Doxygen 1.5.8