Hugin trunk 0.1
Loading...
Searching...
No Matches
BoxFilter.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_boxfilter_h
22#define __lfeat_boxfilter_h
23
24#include "MathStuff.h"
26
27namespace lfeat
28{
29
30class Image;
31
33{
34public:
36
37 void setY(unsigned int y);
38 double getDxxWithX(unsigned int x) const;
39 double getDyyWithX(unsigned int x) const;
40 double getDxyWithX(unsigned int x) const;
41 double getDetWithX(unsigned int x) const;
42
43 bool checkBounds(int x, int y) const;
44
45 // orig image info
46 double** _ii;
47 unsigned int _im_width;
48 unsigned int _im_height;
49
51
52 // precomp values for det
54
55
56 // the relative values of rectangle position for the first derivatives on x
58
59 // new ones
63
64 // stored Y
65
69 unsigned int _y_plus_lxx_x_right;
70 unsigned int _y_minus_lxx_x_mid;
71 unsigned int _y_plus_lxx_x_mid;
72 unsigned int _y_minus_lxy_d2;
73 unsigned int _y_plus_lxy_d2;
74 unsigned int _y;
75
76};
77
79{
80 _ii = iImage.getIntegralImage();
81 _im_width = iImage.getWidth();
82 _im_height = iImage.getHeight();
83
84 _basesize = hugin_utils::roundi(iBaseSize); // convert to integer
85
86
87 // precomputed values for det
88 double aCorrectFactor = 9.0 / (iBaseSize * iBaseSize);
90
91 // the values for lxy are all positive. will negate in the getDxy
92 _lxy_d2 = ((int)(iBaseSize * 3) - 1) / 2 - 1;
93
94 // new ones
98 setY(0);
99
100}
101
102#define CALC_INTEGRAL_SURFACE(II, STARTX, ENDX, STARTY, ENDY) \
103 (II[ENDY+1][ENDX+1] + II[STARTY][STARTX] - II[ENDY+1][STARTX] - II[STARTY][ENDX+1])
104
110
111inline double BoxFilter::getDyyWithX(unsigned int x) const
112{
113 // calculates the Lyy convolution a point x,y with filter base size, using integral image
114 // use the values of Lxx, but rotate them.
117
118}
119
120inline double BoxFilter::getDxyWithX(unsigned int x) const
121{
122 // calculates the Lxy convolution a point x,y with filter base size, using integral image
123
128}
129
130#undef CALC_INTEGRAL_SURFACE
131
132inline double BoxFilter::getDetWithX(unsigned int x) const
133{
134 double aDxy = getDxyWithX(x) * 0.9 * 2 / 3.0;
135 double aDxx = getDxxWithX(x);
136 double aDyy = getDyyWithX(x);
137
138 return ((aDxx * aDyy) - (aDxy * aDxy)) * _sqCorrectFactor;
139}
140
154
155inline bool BoxFilter::checkBounds(int x, int y) const
156{
157 return ( x > _lxx_x_right && x + _lxx_x_right < (int)_im_width - 1
158 && y > _lxx_x_right && y + _lxx_x_right < (int)_im_height - 1);
159}
160
161} // namespace lfeat
162
163#endif //__lfeat_boxfilter_h
#define CALC_INTEGRAL_SURFACE(II, STARTX, ENDX, STARTY, ENDY)
Definition BoxFilter.h:102
void setY(unsigned int y)
Definition BoxFilter.h:141
double getDxyWithX(unsigned int x) const
Definition BoxFilter.h:120
unsigned int _y_plus_lxx_x_right
Definition BoxFilter.h:69
double getDetWithX(unsigned int x) const
Definition BoxFilter.h:132
double ** _ii
Definition BoxFilter.h:46
unsigned int _y_plus_lxx_y_bottom
Definition BoxFilter.h:67
double getDxxWithX(unsigned int x) const
Definition BoxFilter.h:105
double _sqCorrectFactor
Definition BoxFilter.h:53
unsigned int _y_minus_lxx_y_bottom
Definition BoxFilter.h:66
bool checkBounds(int x, int y) const
Definition BoxFilter.h:155
BoxFilter(double iBaseSize, Image &iImage)
Definition BoxFilter.h:78
unsigned int _im_height
Definition BoxFilter.h:48
unsigned int _y_plus_lxy_d2
Definition BoxFilter.h:73
unsigned int _y_plus_lxx_x_mid
Definition BoxFilter.h:71
unsigned int _y_minus_lxx_x_mid
Definition BoxFilter.h:70
unsigned int _y_minus_lxy_d2
Definition BoxFilter.h:72
double getDyyWithX(unsigned int x) const
Definition BoxFilter.h:111
unsigned int _im_width
Definition BoxFilter.h:47
unsigned int _y
Definition BoxFilter.h:74
unsigned int _y_minus_lxx_x_right
Definition BoxFilter.h:68
misc math function & classes used by other parts of the program
int roundi(T x)
Definition hugin_math.h:73
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