2
* Copyright (C) 2007-2008 Anael Orlinski
4
* This file is part of Panomatic.
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.
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.
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
21
#ifndef __lfeat_wavefilter_h
22
#define __lfeat_wavefilter_h
31
WaveFilter(double iBaseSize, Image& iImage);
33
double getWx(unsigned int x, unsigned int y);
34
double getWy(unsigned int x, unsigned int y);
36
bool checkBounds(int x, int y) const;
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);
42
bool checkBounds(int x, int y, int scale) const;
48
unsigned int _im_width;
49
unsigned int _im_height;
56
inline WaveFilter::WaveFilter(double iBaseSize, Image& iImage)
58
_ii = iImage.getIntegralImage();
59
_im_width = iImage.getWidth();
60
_im_height = iImage.getHeight();
62
_wave_1 = (int)iBaseSize;
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])
68
inline double WaveFilter::getWx(unsigned int x, unsigned int y)
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 );
74
inline double WaveFilter::getWy(unsigned int x, unsigned int y)
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 );
80
inline bool WaveFilter::checkBounds(int x, int y) const
82
return ( x > _wave_1 && x + _wave_1 < (int)_im_width - 1
83
&& y > _wave_1 && y + _wave_1 < (int)_im_height - 1);
86
// versions without precomputed width
87
inline double WaveFilter::getSum(unsigned int x, unsigned int y, int s)
89
return CALC_INTEGRAL_SURFACE(_ii, x - s, x + s, y - s, y + s );
92
inline double WaveFilter::getWx(unsigned int x, unsigned int y, int _wave_1)
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 );
98
inline double WaveFilter::getWy(unsigned int x, unsigned int y, int _wave_1)
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 );
104
inline bool WaveFilter::checkBounds(int x, int y, int _wave_1) const
106
return ( x > _wave_1 && x + _wave_1 < (int)_im_width - 1
107
&& y > _wave_1 && y + _wave_1 < (int)_im_height - 1);
112
#endif //__lfeat_wavefilter_h