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