#ifndef COLOR_BLOB_SEARCHER_H #define COLOR_BLOB_SEARCHER_H #include #include #include #include #include namespace icl{ /// abstract interface for a single color blob searcher \ingroup G_CBS /** The ColorBlobSearcher Interface provides as well the functionality for different Blob searching Algorithms (working pixelwise and reference color based), as a dynamic interface for custom implementations.

Slice Model

The detection of image blobs is brocken apart into slice model, for a generalizing abstraction that is as dynamic as possible.
  +--------------------------------------------------------+
  | .. Higher level combination of different               |
  |      ColorBlobSearchers ...                            |
  |                                                        |
  |                                                        |
  |                                                        |
  |                                                        |
  |                                                        |
  |                                                        |
  +========================================================+
  | ColorBlobSearcher:                              |
  | This 3rd layers interface provides functions to evalu- |
  | ate the results of a set of PixelRating(Groups). To    |
  | search for blobs in a given image, it will iterate     |
  | line by line over the images ROI (leaving out masked   |
  | pixels) and store the results of each PixelRating by   | 
  | calling the abstract function: storeResults(...).      |
  | after the iteration cycle over the images pixels,      |
  | another abstract function combineResults is called.    |
  | By implementing these two abstract functions, the pro- |
  | grammer is able to construct a large viriety of diffe- |
  | rent searching algorithms.                             |
  +========================================================+
  | PixelRatingGroup: public PixelRating             |
  | This higher level class defines the interface for      |
  | grouping a set of PixelRatings together and combine |
  | their results with an abritrary combination function.  |
  | As a PixelRatingGroup itself inherits the PixelRating  |
  | interface, PixelRatingGroups may contain other Groups. |
  | When the group is asked for a rating of a given Pixel, |
  | it will collect the results of all contained Pixel-    |
  | Ratings and return the combined Results, computed by   |
  | the defined "combine"-function.                        |
  +========================================================+
  | PixelRating                                         |
  | The abstract PixelRating class defines an interface for|
  | different reference color based rating functions. The  |
  | co-domain of an implemented functions is determined by |
  | the template parameter T. In simple cases T might be   |
  | bool, so the rating implements a binary discriminator, |
  | which decides if pixels are "good" or "not good". By   |
  | using floats as rating types, it is furthermore        |
  | possible to pass a higher level rating to the above    |
  | layers.                                                |
  +--------------------------------------------------------+

  
*/ template class ColorBlobSearcher : public PixelRatingGroup{ public: /// internal type definition typedef FoundBlob foundblob; /// internal type definition typedef std::vector FoundBlobVector; /// internal type definition typedef PixelRating pixelrating; /// internal type definition typedef std::vector PixelRatingVector; /// Destructor virtual ~ColorBlobSearcher(); /// extracts all blobs virtual const FoundBlobVector &search(Img *poImage, Img8u *poMask); /// inserts a new pixel rating a last index (passing ownership of p to this class) virtual void addPR(pixelrating *p); /// removes a pixel rating at given index virtual void removePR(int index); protected: /// internally used function ( can be reimplemented ) virtual void prepareForNewImage(Img *poImage, Img8u *poMask); /// internally used function ( can be reimplemented ) virtual void storeResult(int iPRIndex, int x, int y, RatingType rating)=0; /// internally used function ( can be reimplemented ) virtual void evaluateResults(FoundBlobVector &destination)=0; /// internally used function ( can be reimplemented ) virtual void feedback(const FoundBlobVector &results, Img *poImage); /// internally used function ( can be reimplemented ) virtual void pixelRatingAdded(pixelrating *pr); /// internally used function ( can be reimplemented ) virtual void pixelRatingRemoved(int index); private: /// internal storage of the current set of found blobs FoundBlobVector m_vecFoundBlobs; }; } #endif