Fawkes API  Fawkes Development Version
zauberstab.h
1 
2 /***************************************************************************
3  * zauberstab.h - Header of class "Zauberstab"
4  * which offers methods for finding
5  * maximal, color-contiguous region
6  * around a seed pixel
7  *
8  * Generated: Mon Jul 02 2005
9  * Copyright 2005 Martin Heracles <Martin.Heracles@rwth-aachen.de>
10  * 2005-2006 Tim Niemueller [www.niemueller.de]
11  *
12  ****************************************************************************/
13 
14 /* This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version. A runtime exception applies to
18  * this software (see LICENSE.GPL_WRE file mentioned below for details).
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU Library General Public License for more details.
24  *
25  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
26  */
27 
28 #ifndef __FIREVISION_FVUTILS_ZAUBERSTAB_H_
29 #define __FIREVISION_FVUTILS_ZAUBERSTAB_H_
30 
31 #include <fvutils/base/types.h>
32 
33 #include <vector>
34 
35 
36 namespace firevision {
37 #if 0 /* just to make Emacs auto-indent happy */
38 }
39 #endif
40 
41 /** a "slice" is a row of consecutive pixels
42  (horizontal) */
43 struct ZSlice {
44  int leftX; /**< left X */
45  int rightX; /**< right X */
46  int y; /**< Y value */
47 };
48 
49 /** a region is a stack of slices,
50  together with the y-position of the slice at the top */
51 //struct ZRegion {
52 // std::vector<ZSlice*> *slices; /**< slices */
53 // int topSliceY; /**< top slice Y */
54 //};
55 
56 /** a region is a stack of slices,
57  together with the y-position of the slice at the top */
58 class ZRegion {
59  public:
60  std::vector<ZSlice*> *slices; /**< slices */
61  int topSliceY; /**< top slice Y */
62 
63  ZRegion();
64  virtual ~ZRegion();
65  void clear();
66 };
67 
68 class Zauberstab {
69  public:
70  Zauberstab();
71  ~Zauberstab();
72 
73  void setThreshold(unsigned int t);
74  unsigned int getThreshold();
75  void setBuffer(unsigned char *b, unsigned int w, unsigned int h);
76  void findRegion(unsigned int seedX, unsigned int seedY);
77  void addRegion(unsigned int seedX, unsigned int seedY);
78  void addRegion(ZRegion *region2);
79  void deleteRegion();
80  void deleteRegion(unsigned int seedX, unsigned int seedY);
81  void deleteRegion(ZRegion *region2);
82  bool isEmptyRegion();
83 
84  ZRegion * getRegion() const;
85  std::vector< fawkes::rectangle_t > getSelection();
86 
87  private:
88  unsigned int threshold;
89  ZRegion *region;
90  unsigned char *buffer;
91  unsigned int width;
92  unsigned int height;
93 
94  ZRegion* privFindRegion(unsigned int seedX, unsigned int seedY);
95  ZSlice* findSlice(unsigned int x, unsigned int y,
96  unsigned int vSeed, int uSeed = -1);
97  bool isSimilarV(unsigned int v1, unsigned int v2);
98  bool isSimilarU(unsigned int u1, unsigned int u2);
99  bool isSimilarUV(unsigned int u1, unsigned int u2,
100  unsigned int v1, unsigned int v2);
101 };
102 
103 } // end namespace firevision
104 
105 
106 #endif
107 
int y
Y value.
Definition: zauberstab.h:46
std::vector< ZSlice * > * slices
slices
Definition: zauberstab.h:60
int topSliceY
top slice Y
Definition: zauberstab.h:61
a region is a stack of slices, together with the y-position of the slice at the top ...
Definition: zauberstab.h:58
Zaubertab selection utility.
Definition: zauberstab.h:68
int leftX
left X
Definition: zauberstab.h:44
int rightX
right X
Definition: zauberstab.h:45
a "slice" is a row of consecutive pixels (horizontal)
Definition: zauberstab.h:43