#include #include #include #include #include #ifndef COLOR_BLOB_SEARCHER_H #define COLOR_BLOB_SEARCHER_H namespace icl{ using std::vector; /// interface for a single color blob searcher /** 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: typedef FoundBlob foundblob; typedef vector FoundBlobVector; typedef PixelRating pixelrating; typedef std::vector PixelRatingVector; virtual ~ColorBlobSearcher(); virtual const FoundBlobVector &search(Img *poImage, Img8u *poMask); virtual void addPR(pixelrating *p); virtual void removePR(int index); protected: virtual void prepareForNewImage(Img *poImage, Img8u *poMask); virtual void storeResult(int iPRIndex, int x, int y, RatingType rating)=0; virtual void evaluateResults(FoundBlobVector &destination)=0; virtual void feedback(const FoundBlobVector &results, Img *poImage); virtual void pixelRatingAdded(pixelrating *pr); virtual void pixelRatingRemoved(int index); private: FoundBlobVector m_vecFoundBlobs; }; } #endif