Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __parallelsurf_wavefilter_h
00025 #define __parallelsurf_wavefilter_h
00026
00027 #include "Image.h"
00028
00029 namespace parallelsurf
00030 {
00031
00032 class WaveFilter
00033 {
00034 public:
00035
00036 WaveFilter ( double iBaseSize, Image& iImage );
00037
00038 double getWx ( unsigned int x, unsigned int y );
00039 double getWy ( unsigned int x, unsigned int y );
00040
00041 bool checkBounds ( int x, int y ) const;
00042
00043 private:
00044
00045
00046 double** _ii;
00047 unsigned int _im_width;
00048 unsigned int _im_height;
00049
00050
00051 int _wave_1;
00052 };
00053
00054
00055 inline WaveFilter::WaveFilter ( double iBaseSize, Image& iImage )
00056 {
00057 _ii = iImage.getIntegralImage();
00058 _im_width = iImage.getWidth();
00059 _im_height = iImage.getHeight();
00060
00061 _wave_1 = ( int ) iBaseSize;
00062 }
00063
00064
00065 #define CALC_INTEGRAL_SURFACE(II, STARTX, ENDX, STARTY, ENDY) \
00066 (II[ENDY+1][ENDX+1] + II[STARTY][STARTX] - II[ENDY+1][STARTX] - II[STARTY][ENDX+1])
00067
00068
00069 inline double WaveFilter::getWx ( unsigned int x, unsigned int y )
00070 {
00071 return - CALC_INTEGRAL_SURFACE ( _ii, x - _wave_1, x, y - _wave_1, y + _wave_1 )
00072 + CALC_INTEGRAL_SURFACE ( _ii, x, x + _wave_1, y - _wave_1, y + _wave_1 );
00073 }
00074
00075
00076 inline double WaveFilter::getWy ( unsigned int x, unsigned int y )
00077 {
00078 return + CALC_INTEGRAL_SURFACE ( _ii, x - _wave_1, x + _wave_1, y - _wave_1, y )
00079 - CALC_INTEGRAL_SURFACE ( _ii, x - _wave_1, x + _wave_1, y, y + _wave_1 );
00080 }
00081
00082 inline bool WaveFilter::checkBounds ( int x, int y ) const
00083 {
00084 return ( x > _wave_1 && x + _wave_1 < ( int ) _im_width - 1
00085 && y > _wave_1 && y + _wave_1 < ( int ) _im_height - 1 );
00086 }
00087
00088 }
00089
00090 #endif //__parallelsurf_wavefilter_h