00001 # ifndef Conjecture_PixFilt_h
00002 # define Conjecture_PixFilt_h Conjecture_PixFilt_h
00003
00004
00005
00006
00007
00008 # include "Root.h"
00009 # include <vector>
00010
00011 namespace Conjecture {
00012 class OptIm;
00013
00069 class PixFilt : public Root {
00070 public:
00071
00072 PixFilt(u1 yoffset);
00073 PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1);
00074 PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1, u1 mask2, int offset2);
00075 PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1, u1 mask2, int offset2, u1 mask3, int offset3);
00076
00077
00078 inline const u2* data() const { return this->_data; }
00079 inline const u1 & rows() const { return this->_rows; }
00080 inline const u1 & yoffset() const { return this->_yoffset; }
00081
00082
00083
00084
00085 void add(u1 mask, int offset);
00086
00087 std::string str() const;
00088
00089 u1 mask(u1 index) const { return ((this->_data[index]) >> 8); }
00090 int offset(u1 index) const { return ((this->_data[index] >> 4)&0xf)-8; }
00091 u1 size(u1 index) const { return ((this->_data[index]) & 0xf); }
00092
00097 bool match(const std::vector<u4>& rows, u1 width, u1 x, u1 y);
00098 bool match(const OptIm& im, u1 x, u1 y);
00099
00109 int filter(std::vector<u4>& im, u1 width, bool set = true);
00110 int filter(OptIm& im, bool set = true);
00111
00112 static void test(int argc = 0, const char* argv[] = NULL);
00113
00114 protected:
00115
00116 inline void rowsIs(const u1 & rows) { this->_rows = rows; }
00117 inline void yoffsetIs(const u1 & yoffset) { this->_yoffset = yoffset; }
00118
00119
00120
00130 static int ffs(u1 val);
00131
00132 private:
00133
00134 inline u1 & rowsRef() { return this->_rows; }
00135 inline u1 & yoffsetRef() { return this->_yoffset; }
00136
00137
00138
00139
00140
00145 u1 _rows;
00146
00152 u1 _yoffset;
00153
00163 u2 _data[8];
00164 };
00165 }
00166
00167 # endif // Conjecture_PixFilt_h
00168