45 #include <visp3/core/vpColVector.h>
46 #include <visp3/core/vpMath.h>
47 #include <visp3/core/vpScale.h>
52 #define DEBUG_LEVEL2 0
59 : bandwidth(0.02), dimension(1)
62 std::cout <<
"vpScale constructor reached" << std::endl;
65 std::cout <<
"vpScale constructor finished" << std::endl;
72 : bandwidth(kernel_bandwidth), dimension(dim)
76 std::cout <<
"vpScale constructor reached" << std::endl;
79 std::cout <<
"vpScale constructor finished" << std::endl;
94 unsigned int n = error.
getRows()/dimension;
99 unsigned int increment=1;
103 while(error[i]<0 && error[i]<error[i+1])
107 while(increment >= 1 && i<n)
112 mean_shift[i]=
vpMath::sqr(bandwidth)*density_gradient[i]/((dimension+2)*density[i]);
114 double tmp_shift = mean_shift[i];
117 while(tmp_shift>0 && tmp_shift>error[i]-error[i+1])
121 tmp_shift-=(error[i]-error[i-1]);
135 unsigned int n = error.
getRows()/dimension;
138 unsigned int j=position;
147 while(std::fabs(Ke) > std::numeric_limits<double>::epsilon() && j<=n)
150 for(
unsigned int i=0; i<dimension; i++)
152 X[i]=(error[position]-error[j])/bandwidth;
166 while(std::fabs(Ke) > std::numeric_limits<double>::epsilon() && j>=dimension)
169 for(
unsigned int i=0; i<dimension; i++)
171 X[i]=(error[position]-error[j])/bandwidth;
181 density*=1/(n*bandwidth);
191 unsigned int n = error.
getRows()/dimension;
192 double density_gradient=0;
197 double inside_kernel = 1;
198 unsigned int j=position;
203 while(std::fabs(inside_kernel) > std::numeric_limits<double>::epsilon() && j<=n)
205 delta = error[position]-error[j];
209 sum_delta+=error[j]-error[position];
221 while(std::fabs(inside_kernel) > std::numeric_limits<double>::epsilon() && j>=dimension)
223 delta = error[position]-error[j];
227 sum_delta+=error[j]-error[position];
238 return density_gradient;
263 std::cout <<
"ERROR in vpScale::Kernel_EPANECHNIKOV : wrong dimension" << std::endl;
268 return 1/(2*c)*(dimension+2)*(1-XtX);
294 std::cout <<
"ERROR in vpScale::Kernel_EPANECHNIKOV : wrong dimension" << std::endl;
299 return sumX*(dimension+2)/(n*bandwidth*c*
vpMath::sqr(bandwidth));
double KernelDensityGradient_EPANECHNIKOV(double X, unsigned int n)
double KernelDensityGradient(vpColVector &error, unsigned int position)
static double sqr(double x)
unsigned int getRows() const
Return the number of rows of the 2D array.
virtual ~vpScale(void)
Destructor.
Implementation of column vector and the associated operations.
double MeanShift(vpColVector &error)
double KernelDensity(vpColVector &error, unsigned int position)
double KernelDensity_EPANECHNIKOV(vpColVector &X)