LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::chainCode Class Reference
[Shape Analysis]

Elements of a Chaincode. More...

#include <ltiContour.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 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

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

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

lti::chainCode::chainCode ( const point &  here,
const point &  next 
) [inline]

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.


Member Function Documentation

chainCode& lti::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& lti::chainCode::add ( const chainCode &  first,
const chainCode &  second 
) [inline]

add the angles of the first and second chain codes

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

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

compare with another object

bool lti::chainCode::compare ( const chainCode &  other  )  [inline]

compare with another object

Referenced by operator==().

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

become other object

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

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

ubyte lti::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 lti::chainCode::getDirection (  )  const [inline]

returns direction of this chain element

point lti::chainCode::getNext ( const point &  here  )  const [inline]

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

point lti::chainCode::getPrevious ( const ipoint &  here  )  const [inline]

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.

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

add the angles of this and the other chain code

References add().

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

add another chain code

References add().

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

subtract the angle equivalent of the other chainCode from *this

References subtract().

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

subtract another chain code

References subtract().

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

divide chain code angle with integer.

References divide().

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

become other object

References copy().

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

become other object

References copy().

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

compare with another object

References compare().

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

compare with another object

References compare().

chainCode& lti::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& lti::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 lti::chainCode::Bottom [static]

Right has value 2 (the second bit).

const ubyte lti::chainCode::Left [static]

Bottom has value 4 (the third bit).

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.

Attribute containing the chain code.

Referenced by divide().


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

Generated on Sat Apr 10 15:27:09 2010 for LTI-Lib by Doxygen 1.6.1