[bf78f2]: src / libpanomatic / localfeatures / WaveFilter.h Maximize Restore History

Download this file

WaveFilter.h    113 lines (88 with data), 3.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright (C) 2007-2008 Anael Orlinski
*
* This file is part of Panomatic.
*
* Panomatic is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Panomatic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Panomatic; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __lfeat_wavefilter_h
#define __lfeat_wavefilter_h
namespace lfeat {
class Image;
class WaveFilter
{
public:
WaveFilter(double iBaseSize, Image& iImage);
double getWx(unsigned int x, unsigned int y);
double getWy(unsigned int x, unsigned int y);
bool checkBounds(int x, int y) const;
double getSum(unsigned int x, unsigned int y, int scale);
double getWx(unsigned int x, unsigned int y, int scale);
double getWy(unsigned int x, unsigned int y, int scale);
bool checkBounds(int x, int y, int scale) const;
private:
// orig image info
double** _ii;
unsigned int _im_width;
unsigned int _im_height;
// internal values
int _wave_1;
};
inline WaveFilter::WaveFilter(double iBaseSize, Image& iImage)
{
_ii = iImage.getIntegralImage();
_im_width = iImage.getWidth();
_im_height = iImage.getHeight();
_wave_1 = (int)iBaseSize;
}
#define CALC_INTEGRAL_SURFACE(II, STARTX, ENDX, STARTY, ENDY) \
(II[ENDY+1][ENDX+1] + II[STARTY][STARTX] - II[ENDY+1][STARTX] - II[STARTY][ENDX+1])
inline double WaveFilter::getWx(unsigned int x, unsigned int y)
{
return - CALC_INTEGRAL_SURFACE(_ii, x - _wave_1, x, y - _wave_1, y + _wave_1 )
+ CALC_INTEGRAL_SURFACE(_ii, x, x + _wave_1, y - _wave_1, y + _wave_1 );
}
inline double WaveFilter::getWy(unsigned int x, unsigned int y)
{
return + CALC_INTEGRAL_SURFACE(_ii,x - _wave_1, x + _wave_1, y - _wave_1, y )
- CALC_INTEGRAL_SURFACE(_ii,x - _wave_1, x + _wave_1, y, y + _wave_1 );
}
inline bool WaveFilter::checkBounds(int x, int y) const
{
return ( x > _wave_1 && x + _wave_1 < (int)_im_width - 1
&& y > _wave_1 && y + _wave_1 < (int)_im_height - 1);
}
// versions without precomputed width
inline double WaveFilter::getSum(unsigned int x, unsigned int y, int s)
{
return CALC_INTEGRAL_SURFACE(_ii, x - s, x + s, y - s, y + s );
}
inline double WaveFilter::getWx(unsigned int x, unsigned int y, int _wave_1)
{
return - CALC_INTEGRAL_SURFACE(_ii, x - _wave_1, x, y - _wave_1, y + _wave_1 )
+ CALC_INTEGRAL_SURFACE(_ii, x, x + _wave_1, y - _wave_1, y + _wave_1 );
}
inline double WaveFilter::getWy(unsigned int x, unsigned int y, int _wave_1)
{
return + CALC_INTEGRAL_SURFACE(_ii,x - _wave_1, x + _wave_1, y - _wave_1, y )
- CALC_INTEGRAL_SURFACE(_ii,x - _wave_1, x + _wave_1, y, y + _wave_1 );
}
inline bool WaveFilter::checkBounds(int x, int y, int _wave_1) const
{
return ( x > _wave_1 && x + _wave_1 < (int)_im_width - 1
&& y > _wave_1 && y + _wave_1 < (int)_im_height - 1);
}
} // namespace lfeat
#endif //__lfeat_wavefilter_h