6 #ifndef CNOID_UTIL_GAUSSIAN_FILTER_H_INCLUDED
7 #define CNOID_UTIL_GAUSSIAN_FILTER_H_INCLUDED
17 const double mu = 0.0;
19 out_window.resize(range * 2 + 1);
22 for(
int i = 0; i <= range; ++i){
23 out_window[i + range] = exp(- (x - mu) * (x - mu) / (2.0 * sigma * sigma));
26 T area_half = out_window[range] / 2.0;
27 for(
int i=1; i <= range; ++i){
28 area_half += out_window[i + range];
30 const T area = area_half * 2.0;
32 out_window[range] /= area;
33 for(
int i=1; i <= range; ++i){
34 T& v = out_window[i + range];
36 out_window[range - i] = v;
41 template <
class RESULTVECTOR,
class SRCVECTOR,
class ELEMENT,
class T>
42 void applyGaussianFilter(RESULTVECTOR& result,
const SRCVECTOR& src, std::vector<T>& gwin, ELEMENT zero)
44 const int range = (gwin.size() - 1) / 2;
45 const int size = src.size();
48 for(
int i=0; i < range; i++){
49 ELEMENT v = zero; T ave = 0.0;
50 for(
int j = - i; j <= +range; j++){
51 v += src[i+j] * gwin[j+range];
58 for(
int i=range; i < size - range; i++){
60 for(
int j=-range; j <= +range; j++){
61 v += src[i+j] * gwin[j+range];
67 for(
int i = size - range; i < size; i++){
68 ELEMENT v = zero; T ave = 0.0;
69 for(
int j=-range; j < size - i; j++){
70 v += src[i+j] * gwin[j+range];
78 template <
class RESULTVECTOR,
class SRCVECTOR,
class ELEMENT,
class T>
79 void applyGaussianFilter(RESULTVECTOR& result,
const SRCVECTOR& src, T sigma,
int range, ELEMENT zero)