Hugin trunk 0.1
Loading...
Searching...
No Matches
Sieve.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007-2008 Anael Orlinski
3*
4* This file is part of Panomatic.
5*
6* Panomatic is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation; either version 2 of the License, or
9* (at your option) any later version.
10*
11* Panomatic is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with Panomatic; if not, write to the Free Software
18* <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef __lfeat_sieve_h
22#define __lfeat_sieve_h
23
24#include "BoundedSet.h"
25
26namespace lfeat
27{
28
29template <typename _Key>
31{
32public:
33 virtual void operator()(const _Key& k) = 0;
34};
35
36template <typename _Key, typename _Compare = std::less<_Key> >
37class Sieve
38{
39
40public:
41 Sieve(int iWidth, int iHeight, int iLength);
42 void insert(_Key& iElem, int iWidth, int iHeight);
43
44 // extract
46
47private:
48 std::vector<lfeat::bounded_set< _Key, _Compare > > _buckets;
50
51
52};
53
54template <typename _Key, typename _Compare>
56 _buckets(std::vector<bounded_set< _Key, _Compare > >(iWidth* iHeight)),
57 _width(iWidth), _height(iHeight)
58{
59 typename std::vector<bounded_set< _Key, _Compare > >::iterator aVB, aVE;
60 aVB = _buckets.begin();
61 aVE = _buckets.end();
62 for (; aVB != aVE; ++aVB)
63 {
64 aVB->setMaxSize(iLength);
65 }
66}
67
68template <typename _Key, typename _Compare>
70{
71 _buckets[iWidth * _height + iHeight].insert(iElem);
72}
73
74template <typename _Key, typename _Compare>
76{
77 typename std::vector<bounded_set< _Key, _Compare > >::iterator aVB, aVE;
78 aVB = _buckets.begin();
79 aVE = _buckets.end();
80 for (; aVB != aVE; ++aVB)
81 {
82 typename std::set<_Key, _Compare>::iterator aSB, aSE;
83 std::set<_Key, _Compare>& aS = aVB->getSet();
84 aSB = aS.begin();
85 aSE = aS.end();
86 for (; aSB != aSE; ++aSB)
87 {
88 iEx(*aSB);
89 }
90 }
91}
92
93}
94
95#endif // __lfeat_sieve_h
virtual void operator()(const _Key &k)=0
Sieve(int iWidth, int iHeight, int iLength)
Definition Sieve.h:55
int _height
Definition Sieve.h:49
std::vector< lfeat::bounded_set< _Key, _Compare > > _buckets
Definition Sieve.h:48
int _width
Definition Sieve.h:49
void extract(SieveExtractor< _Key > &iEx)
Definition Sieve.h:75
void insert(_Key &iElem, int iWidth, int iHeight)
Definition Sieve.h:69
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41