girl::toger Class Reference

Toger class. More...

#include <girl/girlToger.hpp>


Data Structures

class  directionIterator
 Base class of function object used to iterate on face boundaries or segments. More...
class  pointIterator
 Base class of function object used to iterate on region domain. More...
class  sameRegion
 Splitting functor. More...

Public Types

enum  neighbouringMode {
  NEIGHBOUR_NONE = 0, NEIGHBOUR_DIRECT = 1, NEIGHBOUR_INNER = 2, NEIGHBOUR_OUTER = 4,
  NEIGHBOUR_ANY = 7
}
enum  markFlag {
  MARK_NONE = 0, MARK_0 = 1, MARK_1 = 2, MARK_2 = 4,
  MARK_3 = 8, MARK_4 = 16, MARK_5 = 32, MARK_6 = 64,
  MARK_7 = 128, MARK_ANY = 255
}
typedef enum
girl::toger::neighbouringMode 
neighbouringMode
typedef enum girl::toger::markFlag markFlag
typedef void(* f1RegionHook )(girl::region r, void *userData)
 Type of call back function applied on one region.
typedef void(* f2RegionsHook )(girl::region r1, girl::region r2, void *userData)
 Type of call back function applied on two regions.

Public Member Functions

 toger (POINT_TYPE width=1, POINT_TYPE height=1)
 Constructor.
POINT_TYPE width () const
POINT_TYPE height () const
void splitRegion (girl::region r, girl::toger::sameRegion &same_r, girl::regionDeque &regs)
 Splits a given region r of representation, using same_r as a partition criterion.
girl::region mergeRegions (girl::region r1, girl::region r2)
 Merges two regions r1 and r2, in representation.
bool insertPaths (const girl::pathDeque &paths, girl::regionDeque &out_q)
 Inserts a set of paths paths in representation.
void setNewRegionHook (girl::toger::f1RegionHook hook, void *userData)
 Sets callback function to be called just after a region creation.
void setDeleteRegionHook (girl::toger::f1RegionHook hook, void *userData)
 Sets callback function to be called just after a region deletion.
void setMergeRegionsHook (girl::toger::f2RegionsHook hook, void *userData)
 Sets callback function to be called when two regions are merged and before the delete hook.
void setRenameRegionHook (girl::toger::f2RegionsHook hook, void *userData)
 Sets callback function to be called when a region is renammed.
bool belongsTo (const girl::point &p, girl::region r) const
 Checks if a point p belongs to region r, according to representation.
girl::region findRegion (const girl::point &p) const
 Returns the region containing the point p, according to representation.
void findRegions (const girl::point &p1, const girl::point &p2, girl::regionDeque &regions) const
 Returns regions containing the set of points in the box defined by p1 and p2, according to representation.
girl::dart findDart (const girl::point &p) const
 Gives the dart at the right of point p.
girl::point anyPoint (girl::region r) const
 Gives a point/pixel belonging to the region r.
void regionDomain (girl::region r, std::vector< girl::point > &scan) const
 Gives the scanline of the regionr.
void regionBoundary (girl::region r, girl::contourDeque &b) const
 Gives whole boundary of region r, that is both external and internal region boundaries.
void regionOuterBoundary (girl::region r, girl::contour &c) const
 Gives external boundary of region r.
void regionsCommonBoundary (girl::region r1, girl::region r2, pathDeque &commonSegments) const
 Gives the common boundary paths between regions r1 and r2.
void segment (girl::dart d, girl::path &p) const
 Gives the path which describes the geometry of the segment associated with dart d.
size_t segmentLength (girl::dart d) const
 Gives the length of path which describes the geometry of the segment associated with dart d.
girl::face lambda (girl::dart d) const
 Gives face corresponding to dart b in representation.
girl::dart beta (girl::face f) const
 Gives canonical dart corresponding to face f in representation.
girl::dart alpha (girl::dart d) const
 Gives image by alpha of dart d in representation.
girl::dart sigma (girl::dart d) const
 Gives image by sigma of dart d in representation.
girl::dart phi (girl::dart d) const
 Gives image by phi of dart d in representation.
bool isFaceInfinite (girl::face f) const
 Checks if the given face f is infinite.
girl::face parent (girl::face f) const
 Gives the finite face containing the infinite face f.
girl::face firstChild (girl::face f) const
 Gives the first face contained in f.
girl::face nextSibling (girl::face fi) const
 Gives the next sibling of face fi in the inclusion tree.
girl::dart getDart (const girl::point &pt, girl::direction dir) const
 Gives dart at geometrical node (pt, dir).
bool areNeighbours (girl::region r1, girl::region r2, girl::toger::neighbouringModes mode, girl::toger::markFlags m) const
 Checks if two regions r1 and r2 are neighbours, according to neighbourhood mode mode and mark flags f, in the representation.
void regionNeighbourhood (girl::region r, girl::toger::neighbouringModes mode, girl::toger::markFlags m, regionDeque &regs) const
 Gives all regions neighbour of a region r according to the given neighbouring mode kind and flags f, in the representation.
girl::region anyRegionNeighbour (girl::region r, girl::toger::neighbouringModes mode, girl::toger::markFlags m) const
 Gives one region neighbour of a region r according to the given neighbouring mode kind and flags f, in the representation.
void allRegions (regionDeque &regs) const
 Gives all regions of the representation.
size_t numRegions () const
 Gives the number of regions in the representation.
void innerRegions (girl::region r, regionDeque &regs) const
 Gives all regions touching the inner boundary of region r in representation.
void iterateOnRegionDomain (girl::region r, girl::toger::pointIterator &fct) const
 Allows to iterate on pixels of region r.
void iterateOnFaceBoundary (girl::face f, girl::toger::directionIterator &fct) const
 Allows to iterate on boundary of face f.
void iterateOnSegment (girl::dart d, girl::toger::directionIterator &fct) const
 Allows to iterate on segment of dart d.
void xMarkRegionBoundary (girl::region r, girl::toger::markFlags m)
 Inverts mark of region r's boundary, in representation, with mark f.
void unmarkRegionBoundary (girl::region r, girl::toger::markFlags m)
 Unmarks region r's boundary, in representation, with mark f.
void xMarkOuterBoundary (girl::region r, girl::toger::markFlags m)
 Inverts mark of region r's outer boundary only, in representation, with mark f.
void unmarkOuterBoundary (girl::region r, girl::toger::markFlags m)
 Unmarks region r's outer boundary only, in representation, with mark f.
bool isRegionMarked (girl::region r, girl::toger::markFlags m) const
 Tells if any dart of region r is marked with mark m.
bool isRegionOuterBoundaryMarked (girl::region r, girl::toger::markFlags m) const
 Tells if any dart of outer boundary of region r is marked with mark m.
bool isFaceMarked (girl::face f, girl::toger::markFlags m) const
 Tells if face f is marked with mark m.
void markAllDarts (girl::toger::markFlags m)
 Marks all darts, in representation, with mark f.
void unmarkAllDarts (girl::toger::markFlags m)
 Unmarks all darts, in representation, with mark f.
bool isDartMarked (girl::dart d, girl::toger::markFlags m) const
 Checks if dart d is marked with mark f, in representation.
void markCommonBoundary (girl::region r1, girl::region r2, girl::toger::markFlags m)
 Marks regions r1 and r2 common boundary, in representation, with mark f.
void unmarkCommonBoundary (girl::region r1, girl::region r2, girl::toger::markFlags m)
 Unmarks regions r1 and r2 common boundary, in representation, with mark f.
void saveBitmap (const std::string &f) const
 Save representation to file f. For debug purpose only.
bool checkConsistency () const
 Check overall representation consistency. Will print found errors, if any, to stderr.
void shrink ()
 Shrink representation to use the less memory possible.
void write (girl::io::Writer &w, girl::io::Type ioType) const
 Write toger with function fct.
bool read (girl::io::Reader &r, girl::io::Type ioType)
 Read toger with function fct.
bool swapable (const girl::point &p) const
 Tells if borders of pixel are swapable in geometric representation of toger.
void swap (const girl::point &p)
 Swap pixel borders in geometric representation of toger.


Detailed Description

Toger class.

Region based topological and geometrical image representation.


Member Typedef Documentation

Marks used to mark darts.

  • MARK_NONE is used to specify no mark,
  • MARK_i, with i in [O;7] defines 8 differents marks.
  • MARK_ANY is an OR'ed combination of all MARK_i.

Neighbourhing modes :

  • NEIGHBOUR_NONE: two regions are not neighbours.
  • NEIGHBOUR_DIRECT: a region r2 is a direct neighbour of a region r1 if the intersection of their outer boundaries is not empty.
  • NEIGHBOUR_INNER: a region r2 is an inner neighbour of a region r1 if the outer boundary of r2 intersects the internal boundary of r1.
  • NEIGHBOUR_OUTER: a region r2 is an outer neighbour of region r1 if r1 is an inner neighbour of r2.
  • NEIGHBOUR_ANY: is an OR'ed combination of NEIGHBOUR_DIRECT, NEIGHBOUR_INNER and NEIGHBOUR_OUTER.


Member Enumeration Documentation

Marks used to mark darts.

  • MARK_NONE is used to specify no mark,
  • MARK_i, with i in [O;7] defines 8 differents marks.
  • MARK_ANY is an OR'ed combination of all MARK_i.

Neighbourhing modes :

  • NEIGHBOUR_NONE: two regions are not neighbours.
  • NEIGHBOUR_DIRECT: a region r2 is a direct neighbour of a region r1 if the intersection of their outer boundaries is not empty.
  • NEIGHBOUR_INNER: a region r2 is an inner neighbour of a region r1 if the outer boundary of r2 intersects the internal boundary of r1.
  • NEIGHBOUR_OUTER: a region r2 is an outer neighbour of region r1 if r1 is an inner neighbour of r2.
  • NEIGHBOUR_ANY: is an OR'ed combination of NEIGHBOUR_DIRECT, NEIGHBOUR_INNER and NEIGHBOUR_OUTER.


Constructor & Destructor Documentation

girl::toger::toger ( POINT_TYPE  width = 1,
POINT_TYPE  height = 1 
)

Constructor.

Initialize the representation with one region, labelled 1, that fill the box defined by width & height.

width and height are the size of the image.


Member Function Documentation

void girl::toger::allRegions ( regionDeque &  regs  )  const

Gives all regions of the representation.

Gives regions in regs.

Warning:
nothing must be inferred on the order of regions in regs.
See also:
numRegions.

girl::point girl::toger::anyPoint ( girl::region  r  )  const

Gives a point/pixel belonging to the region r.

While there is no side effect on region r, the point is assured to stay the same.

girl::region girl::toger::anyRegionNeighbour ( girl::region  r,
girl::toger::neighbouringModes  mode,
girl::toger::markFlags  m 
) const

Gives one region neighbour of a region r according to the given neighbouring mode kind and flags f, in the representation.

kind is an OR'ed combination of the neighbouring modes. m is an OR'ed combination of markFlag. If f is different than MARK_NONE, two regions, neighbours according to specified neighbouring mode m, are reported as neighbours only if their common boundary is NOT marked by f.

Returns:
the found region if any or 0.

bool girl::toger::areNeighbours ( girl::region  r1,
girl::region  r2,
girl::toger::neighbouringModes  mode,
girl::toger::markFlags  m 
) const

Checks if two regions r1 and r2 are neighbours, according to neighbourhood mode mode and mark flags f, in the representation.

mode is an OR'ed combination of girl::toger::neighbouringMode values. m is an OR'ed combination of markFlag. If f is different than MARK_NONE, region r1 and r2, neighbours according to specified neighbouring mode m, are reported as neighbours only if their common boundary is NOT marked by f.

See also:
regionNeighbourhood().

bool girl::toger::checkConsistency (  )  const

Check overall representation consistency. Will print found errors, if any, to stderr.

Warning:
this function can be costly.

girl::dart girl::toger::findDart ( const girl::point p  )  const

Gives the dart at the right of point p.

Will sound the internal image representation from left to right, starting at given point p, in order to find a contour point that belongs to a region.

See also:
girlToger_findRegion.

girlToger_segment.

girl::region girl::toger::findRegion ( const girl::point p  )  const

Returns the region containing the point p, according to representation.

Will sound the internal image representation from left to right, starting at given point p, in order to find a contour point that belongs to a region.

void girl::toger::findRegions ( const girl::point p1,
const girl::point p2,
girl::regionDeque &  regions 
) const

Returns regions containing the set of points in the box defined by p1 and p2, according to representation.

Warning:
We must have p1.x()<=p2.x() && p1.y()<=p2.y().
All point (; y) such as p1.x()<=x<=p2.x() and p1.y()<=y<=p2.y() will be traversed.

Warning:
Returned regions are in no particular order. Each returned region is unique, no matter how many pixels belonged to this region in the specified box. If the method is called with a non empty regions, new regions will be added and all will be unique.

girl::face girl::toger::firstChild ( girl::face  f  )  const

Gives the first face contained in f.

Allows to traverse children of a face with girlToger_nextSibling.

girl::dart girl::toger::getDart ( const girl::point pt,
girl::direction  dir 
) const

Gives dart at geometrical node (pt, dir).

pt must be an inter-pixel point.

Returns:
0 if there is no dart at this point and/or direction.

POINT_TYPE girl::toger::height (  )  const

Returns:
toger height.

void girl::toger::innerRegions ( girl::region  r,
regionDeque &  regs 
) const

Gives all regions touching the inner boundary of region r in representation.

Gives the regions in regs.

Warning:
nothing must be inferred on the order of regions in regs.

bool girl::toger::insertPaths ( const girl::pathDeque &  paths,
girl::regionDeque &  out_q 
)

Inserts a set of paths paths in representation.

Returns:
true if insertion was successfull, else false.

bool girl::toger::isDartMarked ( girl::dart  d,
girl::toger::markFlags  m 
) const

Checks if dart d is marked with mark f, in representation.

m is an OR'ed combination of markFlag.

Returns:
true if dart d is marked by at least one mark of m.

bool girl::toger::isFaceMarked ( girl::face  f,
girl::toger::markFlags  m 
) const

Tells if face f is marked with mark m.

m is an OR'ed combination of markFlag.

Returns:
true if at least one dart of face f is marked by one of the mark of m.
Warning:
consider face symmetrically marked.

do not take any eventual child of face f into account.

See also:
isDartMarked.

bool girl::toger::isRegionMarked ( girl::region  r,
girl::toger::markFlags  m 
) const

Tells if any dart of region r is marked with mark m.

m is an OR'ed combination of markFlag.

Returns:
true if at least one dart of region r is marked by one of the mark of m.
Warning:
consider boundaries symmetrically marked.

bool girl::toger::isRegionOuterBoundaryMarked ( girl::region  r,
girl::toger::markFlags  m 
) const

Tells if any dart of outer boundary of region r is marked with mark m.

m is an OR'ed combination of markFlag.

Returns:
true if at least one dart of outer boundary of region r is marked by one of the mark of m.
Warning:
consider boundary symmetrically marked.

void girl::toger::iterateOnFaceBoundary ( girl::face  f,
girl::toger::directionIterator fct 
) const

Allows to iterate on boundary of face f.

This function allow to iterate on a face boundary with a limited number of allocations, and so decent performances.

processFirstPoint() of fct will be called on first point of boundary. processDirection() of fct will be called on each direction of contour of face f. processLastPoint() of fct will be called on last point of boundary (which is the same as the first for a closed contour).

Warning:
process*() function of fct must not modify toger.
See also:
regionBoundary, regionOuterBoundary.

void girl::toger::iterateOnRegionDomain ( girl::region  r,
girl::toger::pointIterator fct 
) const

Allows to iterate on pixels of region r.

processPoint() of fct will be called on each pixel of domain of region r. processLastPoint() of fct will not be called.

This function allow to iterate on domain of a region with a limited number of allocations, and so decent performances.

Warning:
process function must not modify toger.
See also:
regionDomain.

void girl::toger::iterateOnSegment ( girl::dart  d,
girl::toger::directionIterator fct 
) const

Allows to iterate on segment of dart d.

This function allow to iterate on a dart with a limited number of allocations, and so decent performances.

processFirstPoint() of fct will be called on first point of segment of dart d. processDirection() of fct will be called on each direction of segment of dart d. processLastPoint() of fct will be called on last point of segment of dart d.

Warning:
last point of segment may also be the first point of other darts in Sigma*.

process*() function of fct must not modify toger.

See also:
segment, segmentLength.

void girl::toger::markAllDarts ( girl::toger::markFlags  m  ) 

Marks all darts, in representation, with mark f.

m is an OR'ed combination of markFlag.

void girl::toger::markCommonBoundary ( girl::region  r1,
girl::region  r2,
girl::toger::markFlags  m 
)

Marks regions r1 and r2 common boundary, in representation, with mark f.

m is an OR'ed combination of markFlag.

Warning:
Only darts of r1 are marked. This operation is not symmetrical.

girl::region girl::toger::mergeRegions ( girl::region  r1,
girl::region  r2 
)

Merges two regions r1 and r2, in representation.

If merge is possible, i.e., regions are neighbours, final region, result of the merge, will be labelled as one of the two incoming regions. The region label not reused will be freed.

Merge regions hook then delete region hook will be called if they have been set with, respectively, setMergeRegionsHook & setDeleteRegionHook. Merge regions hook, if set, will be called first with the kept region as first argument and the to-be-deleted region as second argument. Delete region hook, if set, will then be called, with the to-be-deleted region.

Returns:
the kept region or 0 if regions are not neighbours.

girl::face girl::toger::nextSibling ( girl::face  fi  )  const

Gives the next sibling of face fi in the inclusion tree.

Returns:
0 if none.
Warning:
fi must be an infinite face.
See also:
firstChild().

size_t girl::toger::numRegions (  )  const

Gives the number of regions in the representation.

Complexity: O(N) (but no memory allocation).

Returns:
the number of regions (without any allocation)
See also:
allRegions.

girl::face girl::toger::parent ( girl::face  f  )  const

Gives the finite face containing the infinite face f.

regions all have 0 for mother ; infinite faces have a mother != 0.

bool girl::toger::read ( girl::io::Reader &  r,
girl::io::Type  ioType 
)

Read toger with function fct.

user_data allows to pass a context to the read function. ioType is used to know if read is done from memory or disk, and so if portability as to be ensured.

Returns:
true if read was ok, else false.

void girl::toger::regionBoundary ( girl::region  r,
girl::contourDeque &  b 
) const

Gives whole boundary of region r, that is both external and internal region boundaries.

The first one is the external contour.

void girl::toger::regionDomain ( girl::region  r,
std::vector< girl::point > &  scan 
) const

Gives the scanline of the regionr.

return 2*N points, such as two consecutive points, 2*i and 2*i+1, are extremities of a line of the domain. We then have scan[2*i].x()<=scan[2*i+1].x() && scan[2*i].y()==scan[2*i+1].y(). Besides point are ordered in increasing x and y. Thus we have scan[2*i].y()<scan[2*i+2].y() or scan[2*i].y()==scan[2*i+2].y() && scan[2*i].x()<scan[2*i+2].x().

void girl::toger::regionNeighbourhood ( girl::region  r,
girl::toger::neighbouringModes  mode,
girl::toger::markFlags  m,
regionDeque &  regs 
) const

Gives all regions neighbour of a region r according to the given neighbouring mode kind and flags f, in the representation.

kind is an OR'ed combination of the neighbouring modes. m is an OR'ed combination of markFlag. If f is different than MARK_NONE, two regions, neighbours according to specified neighbouring mode m, are reported as neighbours only if their common boundary is NOT marked by f.

regs will hold the found regions

void girl::toger::regionOuterBoundary ( girl::region  r,
girl::contour c 
) const

Gives external boundary of region r.

c is filled with boundary of region r.

void girl::toger::regionsCommonBoundary ( girl::region  r1,
girl::region  r2,
pathDeque &  commonSegments 
) const

Gives the common boundary paths between regions r1 and r2.

Paths are oriented from r1.

void girl::toger::segment ( girl::dart  d,
girl::path p 
) const

Gives the path which describes the geometry of the segment associated with dart d.

See also:
segmentLength.

size_t girl::toger::segmentLength ( girl::dart  d  )  const

Gives the length of path which describes the geometry of the segment associated with dart d.

See also:
segment.

void girl::toger::setMergeRegionsHook ( girl::toger::f2RegionsHook  hook,
void *  userData 
)

Sets callback function to be called when two regions are merged and before the delete hook.

The hook will be called with the kept region as first argument r1, and region to be deleted as second argument r2.

See also:
setDeleteRegionHook.

void girl::toger::setRenameRegionHook ( girl::toger::f2RegionsHook  hook,
void *  userData 
)

Sets callback function to be called when a region is renammed.

The hook is called with old region for r1 and new region for r2.

We have the garantee that r1 <= r2 and hook will be called in increasing region order.

See also:
shrink.

void girl::toger::shrink (  ) 

Shrink representation to use the less memory possible.

It may rename some regions.

See also:
setRenameRegionHook.

void girl::toger::splitRegion ( girl::region  r,
girl::toger::sameRegion same_r,
girl::regionDeque &  regs 
)

Splits a given region r of representation, using same_r as a partition criterion.

Will call same() of same_r to decide if two neighbour pixels belong to the same region or not.

Gives the found regions in regs. Given region r is reused and will be the first region in regs. Returned regions are in no specific order (no geometrical or topological information should be inferred of regions order in regs)

New region hook will be called for each created region if it has been set with setNewRegionHook.

void girl::toger::swap ( const girl::point p  ) 

Swap pixel borders in geometric representation of toger.

Warning:
pixel must swapable.
See also:
swapable.

void girl::toger::unmarkAllDarts ( girl::toger::markFlags  m  ) 

Unmarks all darts, in representation, with mark f.

m is an OR'ed combination of markFlag.

void girl::toger::unmarkCommonBoundary ( girl::region  r1,
girl::region  r2,
girl::toger::markFlags  m 
)

Unmarks regions r1 and r2 common boundary, in representation, with mark f.

m is an OR'ed combination of markFlag.

Warning:
Only darts of r1 are marked. This operation is not symmetrical.

void girl::toger::unmarkOuterBoundary ( girl::region  r,
girl::toger::markFlags  m 
)

Unmarks region r's outer boundary only, in representation, with mark f.

m is an OR'ed combination of markFlag. Region boundary is symmetrically unmarked.

See also:
unmarkRegionBoundary.

void girl::toger::unmarkRegionBoundary ( girl::region  r,
girl::toger::markFlags  m 
)

Unmarks region r's boundary, in representation, with mark f.

m is an OR'ed combination of markFlag Region boundary is symmetrically unmarked.

See also:
unmarkOuterBoundary.

POINT_TYPE girl::toger::width (  )  const

Returns:
toger width.

void girl::toger::write ( girl::io::Writer &  w,
girl::io::Type  ioType 
) const

Write toger with function fct.

user_data allows to pass a context to the write function. ioType is used to know if write is done to memory or disk, and so if portability as to be ensured.

void girl::toger::xMarkOuterBoundary ( girl::region  r,
girl::toger::markFlags  m 
)

Inverts mark of region r's outer boundary only, in representation, with mark f.

m is an OR'ed combination of markFlag. Region boundary is symmetrically marked.

See also:
markRegionBoundary.

void girl::toger::xMarkRegionBoundary ( girl::region  r,
girl::toger::markFlags  m 
)

Inverts mark of region r's boundary, in representation, with mark f.

m is an OR'ed combination of markFlag. Region boundary is symmetrically marked.

See also:
unmarkRegionBoundary.

xMarkOuterBoundary.


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

Generated on Thu Jun 4 14:30:33 2009 for GIRL: General Image Representation Library by  doxygen 1.5.7.1