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 namespace firevision {
36 
37 /** a "slice" is a row of consecutive pixels
38  (horizontal) */
39 struct ZSlice
40 {
41  int leftX; /**< left X */
42  int rightX; /**< right X */
43  int y; /**< Y value */
44 };
45 
46 /** a region is a stack of slices,
47  together with the y-position of the slice at the top */
48 //struct ZRegion {
49 // std::vector<ZSlice*> *slices; /**< slices */
50 // int topSliceY; /**< top slice Y */
51 //};
52 
53 /** a region is a stack of slices,
54  together with the y-position of the slice at the top */
55 class ZRegion
56 {
57 public:
58  std::vector<ZSlice *> *slices; /**< slices */
59  int topSliceY; /**< top slice Y */
60 
61  ZRegion();
62  virtual ~ZRegion();
63  void clear();
64 };
65 
67 {
68 public:
69  Zauberstab();
70  ~Zauberstab();
71 
72  void setThreshold(unsigned int t);
73  unsigned int getThreshold();
74  void setBuffer(unsigned char *b, unsigned int w, unsigned int h);
75  void findRegion(unsigned int seedX, unsigned int seedY);
76  void addRegion(unsigned int seedX, unsigned int seedY);
77  void addRegion(ZRegion *region2);
78  void deleteRegion();
79  void deleteRegion(unsigned int seedX, unsigned int seedY);
80  void deleteRegion(ZRegion *region2);
81  bool isEmptyRegion();
82 
83  ZRegion * getRegion() const;
84  std::vector<fawkes::rectangle_t> getSelection();
85 
86 private:
87  unsigned int threshold;
88  ZRegion * region;
89  unsigned char *buffer;
90  unsigned int width;
91  unsigned int height;
92 
93  ZRegion *privFindRegion(unsigned int seedX, unsigned int seedY);
94  ZSlice * findSlice(unsigned int x, unsigned int y, unsigned int vSeed, int uSeed = -1);
95  bool isSimilarV(unsigned int v1, unsigned int v2);
96  bool isSimilarU(unsigned int u1, unsigned int u2);
97  bool isSimilarUV(unsigned int u1, unsigned int u2, unsigned int v1, unsigned int v2);
98 };
99 
100 } // end namespace firevision
101 
102 #endif
a region is a stack of slices, together with the y-position of the slice at the top
Definition: zauberstab.h:56
std::vector< ZSlice * > * slices
slices
Definition: zauberstab.h:58
void clear()
Clears all slices.
Definition: zauberstab.cpp:65
ZRegion()
Constructor.
Definition: zauberstab.cpp:45
virtual ~ZRegion()
Constructor.
Definition: zauberstab.cpp:53
int topSliceY
top slice Y
Definition: zauberstab.h:59
Zaubertab selection utility.
Definition: zauberstab.h:67
ZRegion * getRegion() const
Get region.
Definition: zauberstab.cpp:518
void findRegion(unsigned int seedX, unsigned int seedY)
Find region.
Definition: zauberstab.cpp:343
void setThreshold(unsigned int t)
Set threshold.
Definition: zauberstab.cpp:103
std::vector< fawkes::rectangle_t > getSelection()
Get selection.
Definition: zauberstab.cpp:527
void deleteRegion()
Delete all regions.
Definition: zauberstab.cpp:141
void addRegion(unsigned int seedX, unsigned int seedY)
Add region.
Definition: zauberstab.cpp:361
unsigned int getThreshold()
Get threshold.
Definition: zauberstab.cpp:112
~Zauberstab()
Destructor.
Definition: zauberstab.cpp:94
Zauberstab()
Constructor.
Definition: zauberstab.cpp:79
void setBuffer(unsigned char *b, unsigned int w, unsigned int h)
Set buffer to work on.
Definition: zauberstab.cpp:123
bool isEmptyRegion()
Check if region is empty.
Definition: zauberstab.cpp:134
a "slice" is a row of consecutive pixels (horizontal)
Definition: zauberstab.h:40
int y
Y value.
Definition: zauberstab.h:43
int rightX
right X
Definition: zauberstab.h:42
int leftX
left X
Definition: zauberstab.h:41