~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin_cpfind/localfeatures/WaveFilter.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
*/
 
20
 
 
21
#ifndef __lfeat_wavefilter_h
 
22
#define __lfeat_wavefilter_h
 
23
 
 
24
namespace lfeat {
 
25
 
 
26
class Image;
 
27
 
 
28
class WaveFilter
 
29
{
 
30
public:
 
31
        WaveFilter(double iBaseSize, Image& iImage);
 
32
 
 
33
        double getWx(unsigned int x, unsigned int y);
 
34
        double getWy(unsigned int x, unsigned int y);
 
35
 
 
36
        bool checkBounds(int x, int y) const;
 
37
 
 
38
        double getSum(unsigned int x, unsigned int y, int scale);
 
39
        double getWx(unsigned int x, unsigned int y, int scale);
 
40
        double getWy(unsigned int x, unsigned int y, int scale);
 
41
 
 
42
        bool checkBounds(int x, int y, int scale) const;
 
43
 
 
44
private:
 
45
        
 
46
        // orig image info
 
47
        double**                _ii;
 
48
        unsigned int    _im_width;
 
49
        unsigned int    _im_height;
 
50
 
 
51
        // internal values
 
52
        int _wave_1;
 
53
 
 
54
};
 
55
 
 
56
inline WaveFilter::WaveFilter(double iBaseSize, Image& iImage)
 
57
{
 
58
        _ii = iImage.getIntegralImage();
 
59
        _im_width = iImage.getWidth();
 
60
        _im_height = iImage.getHeight();
 
61
 
 
62
        _wave_1 = (int)iBaseSize;
 
63
}
 
64
 
 
65
#define CALC_INTEGRAL_SURFACE(II, STARTX, ENDX, STARTY, ENDY) \
 
66
        (II[ENDY+1][ENDX+1] + II[STARTY][STARTX] - II[ENDY+1][STARTX] - II[STARTY][ENDX+1])
 
67
 
 
68
inline double WaveFilter::getWx(unsigned int x, unsigned int y)
 
69
{
 
70
        return  -       CALC_INTEGRAL_SURFACE(_ii, x - _wave_1, x,                              y - _wave_1,    y + _wave_1     )
 
71
                +       CALC_INTEGRAL_SURFACE(_ii,      x,                              x + _wave_1,    y - _wave_1,    y + _wave_1     );
 
72
}
 
73
 
 
74
inline double WaveFilter::getWy(unsigned int x, unsigned int y)
 
75
{
 
76
        return  +       CALC_INTEGRAL_SURFACE(_ii,x - _wave_1,  x + _wave_1,    y - _wave_1,    y                       )
 
77
                -       CALC_INTEGRAL_SURFACE(_ii,x - _wave_1,  x + _wave_1,    y,                              y + _wave_1     );
 
78
}
 
79
 
 
80
inline bool WaveFilter::checkBounds(int x, int y) const
 
81
{
 
82
        return (        x > _wave_1 && x + _wave_1 < (int)_im_width - 1
 
83
                        &&      y > _wave_1 && y + _wave_1 < (int)_im_height - 1);
 
84
}
 
85
 
 
86
// versions without precomputed width
 
87
inline double WaveFilter::getSum(unsigned int x, unsigned int y, int s)
 
88
{
 
89
        return  CALC_INTEGRAL_SURFACE(_ii, x - s, x + s, y - s, y + s );
 
90
}
 
91
 
 
92
inline double WaveFilter::getWx(unsigned int x, unsigned int y, int _wave_1)
 
93
{
 
94
        return  -       CALC_INTEGRAL_SURFACE(_ii, x - _wave_1, x,                              y - _wave_1,    y + _wave_1     )
 
95
                +       CALC_INTEGRAL_SURFACE(_ii,      x,                              x + _wave_1,    y - _wave_1,    y + _wave_1     );
 
96
}
 
97
 
 
98
inline double WaveFilter::getWy(unsigned int x, unsigned int y, int _wave_1)
 
99
{
 
100
        return  +       CALC_INTEGRAL_SURFACE(_ii,x - _wave_1,  x + _wave_1,    y - _wave_1,    y                       )
 
101
                -       CALC_INTEGRAL_SURFACE(_ii,x - _wave_1,  x + _wave_1,    y,                              y + _wave_1     );
 
102
}
 
103
 
 
104
 inline bool WaveFilter::checkBounds(int x, int y, int _wave_1) const
 
105
{
 
106
        return (        x > _wave_1 && x + _wave_1 < (int)_im_width - 1
 
107
                        &&      y > _wave_1 && y + _wave_1 < (int)_im_height - 1);
 
108
}
 
109
 
 
110
} // namespace lfeat
 
111
 
 
112
#endif //__lfeat_wavefilter_h