SMIL  0.9.1
DCompositeSE.h
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 
30 #ifndef _COMPOSITE_SE_HPP
31 #define _COMPOSITE_SE_HPP
32 
33 #include "DStructuringElement.h"
34 #include <list>
35 
36 
37 namespace smil
38 {
45  class CompStrEltList;
46 
50  class CompStrElt : public BaseObject
51  {
52  public:
53  StrElt fgSE;
54  StrElt bgSE;
55 
56  CompStrElt() : BaseObject("CompStrElt") {}
57  ~CompStrElt() {}
58  CompStrElt(const CompStrElt &rhs);
59  CompStrElt(const StrElt &fg, const StrElt &bg);
63  CompStrElt &rotate(int steps=1);
64  CompStrEltList operator | (const CompStrElt &rhs);
66  CompStrEltList operator () (UINT nrot);
67  virtual void printSelf(ostream &os = std::cout, string indent="") const;
68  };
69 
74  class CompStrEltList : public BaseObject
75  {
76  public:
77  std::vector<CompStrElt> compSeList;
78  CompStrEltList() : BaseObject("CompStrEltList") {}
79  CompStrEltList(const CompStrEltList &rhs);
80  CompStrEltList(const CompStrElt &compSe);
81  CompStrEltList(const CompStrElt &compSe, UINT nrot);
83 
85  CompStrEltList operator | (const CompStrEltList &rhs);
87  CompStrElt &operator [] (const UINT n)
88  {
89  return compSeList[n];
90  }
91 
92  void add(const CompStrElt &cse);
93  void add(const StrElt &fgse, const StrElt &bgse);
94 
98  void add(const StrElt &fgse, const StrElt &bgse, UINT nrot);
99  void add(const CompStrElt &cse, UINT nrot);
100  CompStrEltList &rotate(int steps=1);
101 
102  virtual void printSelf(ostream &os = std::cout, string indent="") const;
103  };
104 
105 
107  class HMT_sL1 : public CompStrEltList
108  {
109  public:
110  HMT_sL1(UINT nrot=1)
111  {
112  this->add(StrElt(false, 3, 8,1,2), StrElt(false, 3, 4,5,6), nrot);
113  }
114  };
115 
117  class HMT_sL2 : public CompStrEltList
118  {
119  public:
120  HMT_sL2(UINT nrot=1)
121  {
122  this->add(StrElt(false, 2, 1,3), StrElt(false, 3, 5,6,7), nrot);
123  }
124  };
125 
127  class HMT_hL : public CompStrEltList
128  {
129  public:
130  HMT_hL(UINT nrot=1)
131  {
132  this->add(StrElt(true, 2, 1,2), StrElt(true, 2, 4,5), nrot);
133  }
134  };
135 
136 
138  class HMT_sM : public CompStrEltList
139  {
140  public:
141  HMT_sM(UINT nrot=1)
142  {
143  add(StrElt(false, 2, 1,8), StrElt(false, 4, 3,4,5,6), nrot);
144  }
145  };
146 
148  class HMT_hM : public CompStrEltList
149  {
150  public:
151  HMT_hM(UINT nrot=1)
152  {
153  add(StrElt(true, 1, 1), StrElt(true, 3, 3,4,5), nrot);
154  }
155  };
156 
158  class HMT_sD : public CompStrEltList
159  {
160  public:
161  HMT_sD(UINT nrot=1)
162  {
163  add(StrElt(false, 4, 3,4,5,6), StrElt(false, 2, 1,8), nrot);
164  }
165  };
166 
168  class HMT_hD : public CompStrEltList
169  {
170  public:
171  HMT_hD(UINT nrot=1)
172  {
173  add(StrElt(true, 3, 3,4,5), StrElt(true, 1, 1), nrot);
174  }
175  };
176 
178  class HMT_sE : public CompStrEltList
179  {
180  public:
181  HMT_sE(UINT nrot=1)
182  {
183  add(StrElt(false, 5, 3,4,5,6,7), StrElt(false, 1, 0), nrot);
184  }
185  };
186 
188  class HMT_hE : public CompStrEltList
189  {
190  public:
191  HMT_hE(UINT nrot=1)
192  {
193  add(StrElt(true, 4, 3,4,5,6), StrElt(true, 1, 0), nrot);
194  }
195  };
196 
197 
198  // # Some other specific structuring elements used for multiple points extraction
200  class HMT_sS1 : public CompStrEltList
201  {
202  public:
203  HMT_sS1(UINT nrot=1)
204  {
205  add(StrElt(false, 2, 3,7), StrElt(false, 3, 0,1,5), nrot);
206  }
207  };
208 
210  class HMT_hS1 : public CompStrEltList
211  {
212  public:
213  HMT_hS1(UINT nrot=1)
214  {
215  add(StrElt(true, 4, 2,3,5,6), StrElt(true, 3, 0,1,4), nrot);
216  }
217  };
218 
220  class HMT_sS2 : public CompStrEltList
221  {
222  public:
223  HMT_sS2(UINT nrot=1)
224  {
225  add(StrElt(false, 4, 2,5,6,7), StrElt(false, 3, 0,1,3), nrot);
226  }
227  };
228 
230  class HMT_hS2 : public CompStrEltList
231  {
232  public:
233  HMT_hS2(UINT nrot=1)
234  {
235  add(StrElt(true, 4, 2,4,5,6), StrElt(false, 3, 0,1,3), nrot);
236  }
237  };
238 
239  // # Special pattern used to perform SKIZ
241  class HMT_sS3 : public CompStrEltList
242  {
243  public:
244  HMT_sS3(UINT nrot=1)
245  {
246  add(StrElt(false, 5, 3,4,5,6,7), StrElt(false, 1, 1), nrot);
247  }
248  };
249 
250  // Isolated points detection
252  class HMT_sI : public CompStrEltList
253  {
254  public:
255  HMT_sI()
256  {
257  add(StrElt(false, 1, 0), StrElt(false, 8, 1,2,3,4,5,6,7,8));
258  }
259  };
260 
262  class HMT_hI : public CompStrEltList
263  {
264  public:
265  HMT_hI()
266  {
267  add(StrElt(true, 1, 0), StrElt(true, 6, 1,2,3,4,5,6));
268  }
269  };
270 
273  {
274  public:
275  HMT_sLineEnd(UINT nrot=1)
276  {
277  add(StrElt(false, 2, 0,1), StrElt(false, 5, 3,4,5,6,7), nrot);
278  }
279  };
280 
283  {
284  public:
285  HMT_sLineJunc(UINT nrot=1)
286  {
287  add(StrElt(false, 4, 0,1,4,6), StrElt(false, 1, 5), nrot);
288  add(StrElt(false, 4, 0,1,3,5), StrElt(false, 2, 2,4), nrot);
289  }
290  };
291 
294 } // namespace smil
295 
296 
297 #endif // _COMPOSITE_SE_HPP
298 
Definition: DColorConvert.h:38
Square S1 ([3,7], [0,1,5])
Definition: DCompositeSE.h:200
CompStrElt operator~()
Switch foreground/background SE.
Definition: DCompositeSE.cpp:83
Square M ([1,8], [3,4,5,6])
Definition: DCompositeSE.h:138
Square L2 ([1,3], [5,6,7])
Definition: DCompositeSE.h:117
Hexagonal M ([1], [3,4,5])
Definition: DCompositeSE.h:148
Square S3 ([3,4,5,6,7], [1])
Definition: DCompositeSE.h:241
CompStrEltList operator()(UINT nrot)
Return a CompStrEltList containing the nrot rotations of the CompStrElt.
Definition: DCompositeSE.cpp:109
Square S2 ([2,5,6,7], [0,1,3])
Definition: DCompositeSE.h:220
Composite structuring element list.
Definition: DCompositeSE.h:74
RES_T add(const Image< T > &imIn1, const Image< T > &imIn2, Image< T > &imOut)
Addition.
Definition: DImageArith.hpp:393
CompStrElt & rotate(int steps=1)
Counterclockwise rotate SE points.
Definition: DCompositeSE.cpp:92
Composite structuring element.
Definition: DCompositeSE.h:50
Base Smil Object.
Definition: DBaseObject.h:53
Square D ([3,4,5,6], [1,8])
Definition: DCompositeSE.h:158
Base structuring element.
Definition: DStructuringElement.h:51
Hexagonal S1 ([2,3,5,6], [0,1,4])
Definition: DCompositeSE.h:210
Hexagonal D ([3,4,5], [1])
Definition: DCompositeSE.h:168
Square line end ([0,1], [3,4,5,6,7])
Definition: DCompositeSE.h:272
Square line junction ([0,1,4,6],[] and [0,1,3,5],[])
Definition: DCompositeSE.h:282
Square I ([0], [1,2,3,4,5,6,7,8])
Definition: DCompositeSE.h:252
Hexagonal S2 ([2,4,5,6], [0,1,3])
Definition: DCompositeSE.h:230
Hexagonal I ([0], [1,2,3,4,5,6])
Definition: DCompositeSE.h:262
Square E ([3,4,5,6,7], [0])
Definition: DCompositeSE.h:178
Hexagonal L ([1,2], [4,5])
Definition: DCompositeSE.h:127
Hexagonal E ([3,4,5,6], [0])
Definition: DCompositeSE.h:188
Square L1 ([8,1,2], [4,5,6])
Definition: DCompositeSE.h:107