00001 # ifndef PixFilt_h
00002 # define PixFilt_h PixFilt_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 # include "Root.h"
00021 # include <vector>
00022
00023 namespace Conjecture {
00024 class OptIm;
00025
00026
00078
00079
00080 class PixFilt : public Root {
00081 public:
00082
00083 PixFilt(u1 yoffset);
00084 PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1);
00085 PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1, u1 mask2, int offset2);
00086 PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1, u1 mask2, int offset2, u1 mask3, int offset3);
00087
00088
00089
00090 inline const u2* data() const { return this->_data; }
00091 inline const u1 & rows() const { return this->_rows; }
00092 inline const u1 & yoffset() const { return this->_yoffset; }
00093
00094
00095
00096
00097
00098
00099 void add(u1 mask, int offset);
00100
00101 std::string str() const;
00102
00103 u1 mask(u1 index) const { return ((this->_data[index]) >> 8); }
00104 int offset(u1 index) const { return ((this->_data[index] >> 4)&0xf)-8; }
00105 u1 size(u1 index) const { return ((this->_data[index]) & 0xf); }
00106
00108 bool match(const std::vector<u4>& rows, u1 width, u1 x, u1 y);
00109 bool match(const OptIm& im, u1 x, u1 y);
00110
00117 int filter(std::vector<u4>& im, u1 width, bool set = true);
00118 int filter(OptIm& im, bool set = true);
00119
00120 static void test(int argc = 0, const char* argv[] = NULL);
00121
00122 protected:
00123
00124
00125 inline void rowsIs(const u1 & rows) { this->_rows = rows; }
00126 inline void yoffsetIs(const u1 & yoffset) { this->_yoffset = yoffset; }
00127
00128
00129
00130
00137 static int ffs(u1 val);
00138
00139 private:
00140
00141
00142 inline u1 & rowsRef() { return this->_rows; }
00143 inline u1 & yoffsetRef() { return this->_yoffset; }
00144
00145
00146
00147
00148
00149
00150
00152 u1 _rows;
00153
00156 u1 _yoffset;
00157
00164 u2 _data[8];
00165 };
00166 }
00167
00168 # endif // PixFilt_h
00169