DGtal 1.4.0
|
#include <DGtal/geometry/curves/FreemanChain.h>
Data Structures | |
class | CodesRange |
Aim: model of CRange that provides services to (circularly)iterate over the letters of the freeman chain. More... | |
class | ConstIterator |
Public Types | |
typedef TInteger | Integer |
typedef FreemanChain< Integer > | Self |
typedef PointVector< 2, Integer > | Point |
typedef PointVector< 2, Integer > | Vector |
typedef unsigned int | Size |
typedef unsigned int | Index |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CInteger< TInteger >)) | |
CodesRange | getCodesRange () |
~FreemanChain () | |
FreemanChain (const std::string &s="", TInteger x=0, TInteger y=0) | |
FreemanChain (const std::vector< Point > &vectPoints) | |
FreemanChain (std::istream &in) | |
FreemanChain (const FreemanChain &other) | |
FreemanChain & | operator= (const FreemanChain &other) |
bool | operator== (const FreemanChain &other) const |
bool | operator!= (const FreemanChain &other) const |
char | code (Index pos) const |
Size | size () const |
FreemanChain | subChain (Index pos, Size n) const |
FreemanChain | operator+ (const FreemanChain &other) const |
FreemanChain & | operator+= (const FreemanChain &other) |
void | computeBoundingBox (TInteger &min_x, TInteger &min_y, TInteger &max_x, TInteger &max_y) const |
Self::ConstIterator | findQuadrantChange (OrderedAlphabet &A) const |
Self::ConstIterator | findQuadrantChange4 (OrderedAlphabet &A) const |
int | isClosed () const |
int | ccwLoops () const |
Point | getPoint (Index pos) const |
Point | firstPoint () const |
Point | lastPoint () const |
Vector | totalDisplacement () const |
FreemanChain & | extend (char code) |
FreemanChain & | retract (Size n=1) |
ConstIterator | begin () const |
ConstIterator | end () const |
Index | next (Index pos) const |
Index | previous (Index pos) const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
std::string | className () const |
Static Public Member Functions | |
static void | write (std::ostream &out, const FreemanChain &c) |
static void | read (std::istream &in, FreemanChain &c) |
template<typename TConstIterator > | |
static void | readFromPointsRange (const TConstIterator &itBegin, const TConstIterator &itEnd, FreemanChain &c) |
template<typename TRange > | |
static void | readFromPointsRange (const TRange &aRange, FreemanChain &c) |
static void | getContourPoints (const FreemanChain &fc, std::vector< Point > &aVContour) |
static void | getInterPixelLinels (const KhalimskySpaceND< 2, TInteger > &aKSpace, const FreemanChain &fc, typename KhalimskySpaceND< 2, TInteger >::SCellSet &aSCellContour, bool aFlagForAppend=false) |
static void | movePointFromFC (Point &aPoint, char aCode) |
static char | movement (char aCode1, char aCode2, bool ccw=true) |
static char | addToCode (char code, int n) |
static short | freemanCode4C (int dx, int dy) |
static void | displacement (int &dx, int &dy, char aCode) |
static Point | displacement (char aCode) |
static char | turnedCode (char aCode, bool ccw=true) |
static void | pointel2pixel (FreemanChain &aPixChain, std::vector< unsigned int > &aPl2pix, std::vector< unsigned int > &aPix2pl, const FreemanChain &aPlChain) |
static void | innerContour (FreemanChain &aInnerChain, std::vector< unsigned int > &aOuter2inner, std::vector< unsigned int > &aInner2outer, const FreemanChain &aOuterChain, bool ccw=true) |
static bool | cleanOuterSpikes (FreemanChain &aCleanC, std::vector< unsigned int > &aC2clean, std::vector< unsigned int > &aClean2c, const FreemanChain &c, bool ccw=true) |
Data Fields | |
std::string | chain |
Integer | x0 |
Integer | y0 |
Integer | xn |
Integer | yn |
Private Member Functions | |
void | computeLastPoint () |
Aim: Describes a digital 4-connected contour as a string of '0', '1', '2', and '3' and the coordinate of the first point. When it is a loop, it is the clockwise boundary of the shape.
Example :
TInteger | type of the coordinates of the starting point |
Definition at line 113 of file FreemanChain.h.
typedef unsigned int DGtal::FreemanChain< TInteger >::Index |
Definition at line 126 of file FreemanChain.h.
typedef TInteger DGtal::FreemanChain< TInteger >::Integer |
Definition at line 119 of file FreemanChain.h.
typedef PointVector<2, Integer> DGtal::FreemanChain< TInteger >::Point |
Definition at line 122 of file FreemanChain.h.
typedef FreemanChain<Integer> DGtal::FreemanChain< TInteger >::Self |
Definition at line 120 of file FreemanChain.h.
typedef unsigned int DGtal::FreemanChain< TInteger >::Size |
Definition at line 125 of file FreemanChain.h.
typedef PointVector<2, Integer> DGtal::FreemanChain< TInteger >::Vector |
Definition at line 123 of file FreemanChain.h.
|
inline |
DGtal::FreemanChain< TInteger >::FreemanChain | ( | const std::string & | s = "", |
TInteger | x = 0, | ||
TInteger | y = 0 ) |
Constructor.
s | the chain code. |
x | the x-coordinate of the first point. |
y | the y-coordinate of the first point. |
DGtal::FreemanChain< TInteger >::FreemanChain | ( | const std::vector< Point > & | vectPoints | ) |
Constructor.
vectPoints | the vector containing all the points. |
DGtal::FreemanChain< TInteger >::FreemanChain | ( | std::istream & | in | ) |
Constructor.
in | any input stream, |
DGtal::FreemanChain< TInteger >::FreemanChain | ( | const FreemanChain< TInteger > & | other | ) |
Copy constructor.
other | the object to clone. |
|
static |
Increment (or decrement if negative) the code by 'n'. '0' + 1 = '1', '1' + 1 = '2', ... , '3' + 1 = '0'
code | the initial code. |
n | the number to add/remove to the code |
Referenced by testStaticServices().
ConstIterator DGtal::FreemanChain< TInteger >::begin | ( | ) | const |
Iterator service on points.
Referenced by CompareToArithmetical(), main(), main(), testAlphaThickSegmentFreeman(), testConstructors(), testOneBalancedWordComputer(), testPointsIterators(), and testPublicSercives().
DGtal::FreemanChain< TInteger >::BOOST_CONCEPT_ASSERT | ( | (concepts::CInteger< TInteger >) | ) |
int DGtal::FreemanChain< TInteger >::ccwLoops | ( | ) | const |
This method takes O(n) operations. It determines if the FreemanChain corresponds to a closed contour, and if this is the case, determines how many counterclockwise loops the contour has done. Of course, it the contour has done clockwise loops, then the given number is accordingly negative.
Referenced by testPublicSercives().
std::string DGtal::FreemanChain< TInteger >::className | ( | ) | const |
Default drawing style object.
Referenced by main(), and testComputeInterior().
|
static |
Removes outer spikes along a 4-connected contour, meaning steps "02", "13", "20" or "31", which point outside the shape. The inside is given by parameter [ccw]. Note that 4-connected pointel contours should not have any outer spikes, while 4-connected pixel contours should not have any inner spikes.
aCleanC | (output) the cleaned 4-connected contour. |
aC2clean | (output) the mapping associating an element to its clean element. |
aClean2c | (output) the inverse mapping associating a clean element to its non-clean element. |
c | the input code of the 4-connected contour (should be a loop !). |
ccw | 'true' if the contour is seen counterclockwise with its inside to the left. |
Referenced by testStaticServices().
char DGtal::FreemanChain< TInteger >::code | ( | Index | pos | ) | const |
pos | a position in the chain code. |
Note, it is assumed that 0 <= pos < this->size()
Referenced by DGtal::FreemanChain< TInteger >::ConstIterator::getCode(), and testPublicSercives().
void DGtal::FreemanChain< TInteger >::computeBoundingBox | ( | TInteger & | min_x, |
TInteger & | min_y, | ||
TInteger & | max_x, | ||
TInteger & | max_y ) const |
Computes a bounding box for the Freeman chain code.
min_x | (returns) the minimal x-coordinate. |
min_y | (returns) the minimal y-coordinate. |
max_x | (returns) the maximal x-coordinate. |
max_y | (returns) the maximal y-coordinate. |
Referenced by testComputeInterior(), and testPublicSercives().
|
private |
Default constructor Not valid. Computes the coordinates of the last point. nb: in O(n)
|
static |
aCode | a Freeman code (between 0-3). Returns the displacement vector of the Freeman code. |
|
static |
Returns the displacement vector of a Freeman code.
dx | (returns) the x-displacement. |
dy | (returns) the y-displacement. |
aCode | the code. |
Referenced by testStaticServices().
ConstIterator DGtal::FreemanChain< TInteger >::end | ( | ) | const |
Iterator service on points.
Referenced by main(), main(), testAlphaThickSegmentFreeman(), testConstructors(), and testPointsIterators().
FreemanChain & DGtal::FreemanChain< TInteger >::extend | ( | char | code | ) |
Add one symbol at the end of the FreemanChain
Referenced by testPublicSercives().
Self::ConstIterator DGtal::FreemanChain< TInteger >::findQuadrantChange | ( | OrderedAlphabet & | A | ) | const |
Finds a quadrant change in 'this' Freeman chain and returns the position as an iterator. A quadrant change is some
The alphabet is possibly re-ordered so that a > b > c.
A | (possibly updated) a Freeman chain alphabet, possibly re-ordered so that a > b > c. |
Referenced by testPublicSercives().
Self::ConstIterator DGtal::FreemanChain< TInteger >::findQuadrantChange4 | ( | OrderedAlphabet & | A | ) | const |
Finds a quadrant change in 'this' Freeman chain and returns the position as an iterator. A quadrant change is some
This quadrant change also guarantees that is not a place where a convexity change occurs in the combinatorial MLP algorithm.
The alphabet is possibly re-ordered so that b > c > d > a.
A | (possibly updated) a Freeman chain alphabet, possibly re-ordered so that b > c > d > a. |
Referenced by testPublicSercives().
|
inline |
Definition at line 767 of file FreemanChain.h.
References DGtal::FreemanChain< TInteger >::x0, and DGtal::FreemanChain< TInteger >::y0.
Referenced by testOneBalancedWordComputer(), testPublicSercives(), and DGtal::FreemanChain< TInteger >::totalDisplacement().
|
static |
[in] | dx | the x-displacement. |
[in] | dy | the y-displacement. |
|
inline |
Definition at line 546 of file FreemanChain.h.
Referenced by testCodesIterators().
|
static |
Return a vector containing all the integer points of the freemanchain.
fc | the FreemanChain |
aVContour | (returns) the vector containing all the integer contour points. |
Referenced by testStaticServices().
|
static |
Return a set containing all the linels (given as Signed SCell in a KhalimskySpaceND) of a FreemanChain (given Z2). Since by definition the interpixel elements cannot be represented in Z2, we use a proper KhalimskySpaceND with a shift defined by convention to (-0.5, 0.5). Notes that this shift is the same that the one used to display FreemanChain object in interpixel mode.
aKSpace | the KSpace |
fc | the FreemanChain |
aSCellContour | (returns) the set containing all the linels of the inter-pixels contour. |
aFlagForAppend | if set to true the resulting set is appended to initial set. |
Referenced by main(), and testComputeInterior().
Point DGtal::FreemanChain< TInteger >::getPoint | ( | Index | pos | ) | const |
Computes the point where starts the step at position 'pos' of the FreemanChain. If 'pos' is equal to the length of the FreemanChain then the last point is returned.
Note: for a chain of length 'n' the computation time in O( min( pos, n-pos ) ).
pos | the position of the point in the FreemanChain |
Referenced by testPublicSercives().
|
static |
From the Freeman chain [outer_chain] representing a 4-connected contour, constructs the Freeman chain [inner_chain] that represents its inner 4-connected contour (which lies in its interpixel space). The boolean [ccw] specifies if the inside is to the left (ccw) or to the right (cw).
Note that chain codes going back and forth are never considered useless: it means that the chain is always supposed to have its interior to the left (ccw) or right (cw) even at configurations "02", "13", "20", "31".
aInnerChain | (output) the code of the 4-connected inner border, with starting coordinates that are floored to the closest integer. |
aOuter2inner | (output) the mapping associating outer to inner elements as indices in their respective Freeman chain. |
aInner2outer | (output) the mapping associating inner to outer elements as indices in their respective Freeman chain. |
aOuterChain | the input code of the 4-connected contour. |
ccw | 'true' if the contour is seen counterclockwise with its inside to the left. |
Referenced by DGtal::FreemanChain< TInteger >::pointel2pixel(), and testStaticServices().
int DGtal::FreemanChain< TInteger >::isClosed | ( | ) | const |
Test if the FreemanChain ends at the same point it starts. Take (1) operation since the last point has been stored at initialization.
Referenced by testPublicSercives().
bool DGtal::FreemanChain< TInteger >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
|
inline |
Definition at line 776 of file FreemanChain.h.
References DGtal::FreemanChain< TInteger >::xn, and DGtal::FreemanChain< TInteger >::yn.
Referenced by testPublicSercives(), and DGtal::FreemanChain< TInteger >::totalDisplacement().
|
static |
Given two consecutive moves on a Freeman chain code, this method returns the type of movement: 0: return move, 1: turning toward the interior, 2: going straight, 3: turning toward exterior. Interior/exterior is specified by [ccw].
aCode1 | the code of the first step as an integer in 0..3. |
aCode2 | the code of the second step as an integer in 0..3. |
ccw | 'true' if the contour is seen counterclockwise with its inside to the left. |
Referenced by testStaticServices().
|
static |
Translate a point by the displacement given a code from a FreemanChain
aPoint | the point to translate |
aCode | a FreemanChain code |
Referenced by testStaticServices().
Index DGtal::FreemanChain< TInteger >::next | ( | Index | pos | ) | const |
Returns the next position in the chain code. The path coded by the chain code is assumed to be closed so that the position after the last letter is the first one.
pos | a position in the chain code. |
|
inline |
Comparaison operator
other | the object to compare to. |
Definition at line 617 of file FreemanChain.h.
FreemanChain DGtal::FreemanChain< TInteger >::operator+ | ( | const FreemanChain< TInteger > & | other | ) | const |
Concatenation services.
Note: the starting point of 'other' is not considered.
other | the chain to concatenate at the end of this. |
FreemanChain & DGtal::FreemanChain< TInteger >::operator+= | ( | const FreemanChain< TInteger > & | other | ) |
Concatenation services.
Note: the starting point of 'other' is not considered.
other | the chain to concatenate at the end of this. |
FreemanChain & DGtal::FreemanChain< TInteger >::operator= | ( | const FreemanChain< TInteger > & | other | ) |
Assignment.
other | the object to copy. |
|
inline |
Comparaison operator
other | the object to compare to. |
Definition at line 606 of file FreemanChain.h.
References DGtal::FreemanChain< TInteger >::chain, DGtal::FreemanChain< TInteger >::x0, DGtal::FreemanChain< TInteger >::xn, DGtal::FreemanChain< TInteger >::y0, and DGtal::FreemanChain< TInteger >::yn.
|
inlinestatic |
From the Freeman chain [pl_chain] representing a pointel 4-connected contour, constructs the Freeman chain [pix_chain] that represents its inner 4-connected border of pixels. The Freeman chain [pl_chain] has its inside to the left (ie. ccw).
Note that chain codes going back and forth are never considered useless: it means that the chain is always supposed to have its interior to the left (ccw) or right (cw) even at configurations "02", "13", "20", "31".
aPixChain | (output) the code of the 4-connected inner border. |
aPl2pix | (output) the mapping associating pointels to pixels as indices in their respective Freeman chain. |
aPix2pl | (output) the inverse mapping associating pixels to pointels as indices in their respective Freeman chain. |
aPlChain | the input code of the 4-connected pointel contour. |
Definition at line 1034 of file FreemanChain.h.
References DGtal::FreemanChain< TInteger >::innerContour().
Referenced by testStaticServices().
Index DGtal::FreemanChain< TInteger >::previous | ( | Index | pos | ) | const |
Returns the previous position in the chain code. The path coded by the chain code is assumed to be closed so that the position before the first letter is the first last one.
pos | a position in the chain code. |
|
static |
Reads a chain from the stream [in] and updates [c].
in | any input stream, |
c | (returns) the Freeman chain. |
Referenced by testStaticServices().
|
static |
Reads a chain from the points range [ itBegin , itEnd ) and updates c.
itBegin | begin iterator, |
itEnd | end iterator, |
c | the returned Freeman chain. |
TConstIterator | type of iterator |
Referenced by main().
|
static |
Reads a chain from the points range aRange and updates c.
aRange | any points range |
c | the returned Freeman chain |
TRange | type of points range |
FreemanChain & DGtal::FreemanChain< TInteger >::retract | ( | Size | n = 1 | ) |
Removes 'n' symbols at the end of the FreemanChain.
Referenced by testPublicSercives().
void DGtal::FreemanChain< TInteger >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Size DGtal::FreemanChain< TInteger >::size | ( | ) | const |
Referenced by testCodesIterators(), testPointsIterators(), and testPublicSercives().
FreemanChain DGtal::FreemanChain< TInteger >::subChain | ( | Index | pos, |
Size | n ) const |
Returns the subchain of the chain starting at position 'pos' and has 'n' letters long.
pos | position of a character in the current FreemanChain object to be used as starting character for the subchain. |
n | length of the subchain. |
Referenced by testPublicSercives().
|
inline |
Definition at line 786 of file FreemanChain.h.
References DGtal::FreemanChain< TInteger >::firstPoint(), and DGtal::FreemanChain< TInteger >::lastPoint().
Referenced by testPublicSercives().
|
static |
Computes the code obtain from another one after a rotation by pi/2.
aCode | any Freeman code. |
ccw | when 'true' turns counterclockwise (or left), otherwise turns clockwise (right). |
|
inlinestatic |
Outputs the chain [c] to the stream [out].
out | any output stream, |
c | a Freeman chain. |
Definition at line 855 of file FreemanChain.h.
Referenced by testStaticServices().
std::string DGtal::FreemanChain< TInteger >::chain |
The chain code.
Definition at line 1148 of file FreemanChain.h.
Referenced by CompareToArithmetical(), DGtal::FreemanChain< TInteger >::operator==(), showGreedySegmantation(), testInGreedySegmentation(), testOneBalancedWordComputer(), and testPointListReader().
Integer DGtal::FreemanChain< TInteger >::x0 |
the x-coordinate of the first point.
Definition at line 1153 of file FreemanChain.h.
Referenced by DGtal::FreemanChain< TInteger >::firstPoint(), DGtal::FreemanChain< TInteger >::operator==(), and testPointListReader().
Integer DGtal::FreemanChain< TInteger >::xn |
the x-coordinate of the last point.
Definition at line 1163 of file FreemanChain.h.
Referenced by DGtal::FreemanChain< TInteger >::lastPoint(), and DGtal::FreemanChain< TInteger >::operator==().
Integer DGtal::FreemanChain< TInteger >::y0 |
the y-coordinate of the first point.
Definition at line 1158 of file FreemanChain.h.
Referenced by DGtal::FreemanChain< TInteger >::firstPoint(), DGtal::FreemanChain< TInteger >::operator==(), and testPointListReader().
Integer DGtal::FreemanChain< TInteger >::yn |
the y-coordinate of the last point.
Definition at line 1168 of file FreemanChain.h.
Referenced by DGtal::FreemanChain< TInteger >::lastPoint(), and DGtal::FreemanChain< TInteger >::operator==().