00001
00002 #ifndef brip_interp_kernel_h
00003 #define brip_interp_kernel_h
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include<brip/brip_gaussian_kernel.h>
00016 #include <vnl/vnl_math.h>
00017 #include <vnl/vnl_erf.h>
00018
00019
00020
00021
00022
00023
00024 class brip_h0_G_kernel : public brip_gaussian_kernel
00025 {
00026 public:
00027 vcl_vector<double> G_x, G_y;
00028
00029 brip_h0_G_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00030 ~brip_h0_G_kernel(){}
00031
00032
00033 virtual void compute_kernel()
00034 {
00035
00036 int khs = (int) vcl_ceil(4*sigma);
00037 G_x.resize(2*khs+1);
00038 G_y.resize(2*khs+1);
00039
00040 double c = vcl_sqrt(2.0)*sigma;
00041
00042 for (int x = -khs; x <= khs; x++)
00043 G_x[x+khs] = (vnl_erf((x+0.5-dx)/c) - vnl_erf((x-0.5-dx)/c))/2.0;
00044 for (int y = -khs; y <= khs; y++)
00045 G_y[y+khs] = (vnl_erf((y+0.5-dy)/c) - vnl_erf((y-0.5-dy)/c))/2.0;
00046
00047 for (unsigned i=0; i<ni_; i++){
00048 for (unsigned j=0; j<nj_; j++){
00049 top_left_[i*istep_+j*jstep_] = G_x[i]*G_y[j];
00050 }
00051 }
00052 }
00053 };
00054
00055
00056 class brip_h0_Gx_kernel : public brip_gaussian_kernel
00057 {
00058 public:
00059 vcl_vector<double> dG_x, G_y;
00060
00061 brip_h0_Gx_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00062 ~brip_h0_Gx_kernel(){}
00063
00064
00065 virtual void compute_kernel()
00066 {
00067
00068 int khs = (int) vcl_ceil(4*sigma);
00069 dG_x.resize(2*khs+1);
00070 G_y.resize(2*khs+1);
00071
00072 double ssq = sigma*sigma;
00073 double c = vcl_sqrt(2.0)*sigma;
00074 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00075
00076 for (int x = -khs; x <= khs; x++)
00077 dG_x[x+khs] = (vcl_exp(-(x+0.5-dx)*(x+0.5-dx)/(2*ssq)) - vcl_exp(-(x-0.5-dx)*(x-0.5-dx)/(2*ssq)))/sq2pisig;
00078 for (int y = -khs; y <= khs; y++)
00079 G_y[y+khs] = (vnl_erf((y+0.5-dy)/c) - vnl_erf((y-0.5-dy)/c))/2.0;
00080
00081 for (unsigned i=0; i<ni_; i++){
00082 for (unsigned j=0; j<nj_; j++){
00083 top_left_[i*istep_+j*jstep_] = dG_x[i]*G_y[j];
00084 }
00085 }
00086 }
00087 };
00088
00089
00090 class brip_h0_Gy_kernel : public brip_gaussian_kernel
00091 {
00092 public:
00093 vcl_vector<double> G_x, dG_y;
00094
00095 brip_h0_Gy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00096 ~brip_h0_Gy_kernel(){}
00097
00098
00099 virtual void compute_kernel()
00100 {
00101
00102 int khs = (int) vcl_ceil(4*sigma);
00103 G_x.resize(2*khs+1);
00104 dG_y.resize(2*khs+1);
00105
00106 double ssq = sigma*sigma;
00107 double c = vcl_sqrt(2.0)*sigma;
00108 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00109
00110 for (int x = -khs; x <= khs; x++)
00111 G_x[x+khs] = (vnl_erf((x+0.5-dx)/c) - vnl_erf((x-0.5-dx)/c))/2.0;
00112 for (int y = -khs; y <= khs; y++)
00113 dG_y[y+khs] = (vcl_exp(-(y+0.5-dy)*(y+0.5-dy)/(2*ssq)) - vcl_exp(-(y-0.5-dy)*(y-0.5-dy)/(2*ssq)))/sq2pisig;
00114
00115 for (unsigned i=0; i<ni_; i++){
00116 for (unsigned j=0; j<nj_; j++){
00117 top_left_[i*istep_+j*jstep_] = G_x[i]*dG_y[j];
00118 }
00119 }
00120 }
00121 };
00122
00123
00124 class brip_h0_Gxx_kernel : public brip_gaussian_kernel
00125 {
00126 public:
00127 vcl_vector<double> d2G_x, G_y;
00128
00129 brip_h0_Gxx_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00130 ~brip_h0_Gxx_kernel(){}
00131
00132
00133 virtual void compute_kernel()
00134 {
00135
00136 int khs = (int) vcl_ceil(4*sigma);
00137 d2G_x.resize(2*khs+1);
00138 G_y.resize(2*khs+1);
00139
00140 double ssq = sigma*sigma;
00141 double c = vcl_sqrt(2.0)*sigma;
00142 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00143
00144 for (int x = -khs; x <= khs; x++)
00145 d2G_x[x+khs] = (-(x+0.5-dx)*vcl_exp(-(x+0.5-dx)*(x+0.5-dx)/(2*ssq)) + (x-0.5-dx)*vcl_exp(-(x-0.5-dx)*(x-0.5-dx)/(2*ssq)))/(sq2pisig*ssq);
00146 for (int y = -khs; y <= khs; y++)
00147 G_y[y+khs] = (vnl_erf((y+0.5-dy)/c) - vnl_erf((y-0.5-dy)/c))/2.0;
00148
00149 for (unsigned i=0; i<ni_; i++){
00150 for (unsigned j=0; j<nj_; j++){
00151 top_left_[i*istep_+j*jstep_] = d2G_x[i]*G_y[j];
00152 }
00153 }
00154 }
00155 };
00156
00157
00158 class brip_h0_Gxy_kernel : public brip_gaussian_kernel
00159 {
00160 public:
00161 vcl_vector<double> dG_x, dG_y;
00162
00163 brip_h0_Gxy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00164 ~brip_h0_Gxy_kernel(){}
00165
00166
00167 virtual void compute_kernel()
00168 {
00169
00170 int khs = (int) vcl_ceil(4*sigma);
00171 dG_x.resize(2*khs+1);
00172 dG_y.resize(2*khs+1);
00173
00174 double ssq = sigma*sigma;
00175 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00176
00177 for (int x = -khs; x <= khs; x++)
00178 dG_x[x+khs] = (vcl_exp(-(x+0.5-dx)*(x+0.5-dx)/(2*ssq)) - vcl_exp(-(x-0.5-dx)*(x-0.5-dx)/(2*ssq)))/sq2pisig;
00179 for (int y = -khs; y <= khs; y++)
00180 dG_y[y+khs] = (vcl_exp(-(y+0.5-dy)*(y+0.5-dy)/(2*ssq)) - vcl_exp(-(y-0.5-dy)*(y-0.5-dy)/(2*ssq)))/sq2pisig;
00181
00182 for (unsigned i=0; i<ni_; i++){
00183 for (unsigned j=0; j<nj_; j++){
00184 top_left_[i*istep_+j*jstep_] = dG_x[i]*dG_y[j];
00185 }
00186 }
00187 }
00188 };
00189
00190
00191 class brip_h0_Gyy_kernel : public brip_gaussian_kernel
00192 {
00193 public:
00194 vcl_vector<double> G_x, d2G_y;
00195
00196 brip_h0_Gyy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00197 ~brip_h0_Gyy_kernel(){}
00198
00199
00200 virtual void compute_kernel()
00201 {
00202
00203 int khs = (int) vcl_ceil(4*sigma);
00204 G_x.resize(2*khs+1);
00205 d2G_y.resize(2*khs+1);
00206
00207 double ssq = sigma*sigma;
00208 double c = vcl_sqrt(2.0)*sigma;
00209 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00210
00211 for (int x = -khs; x <= khs; x++)
00212 G_x[x+khs] = (vnl_erf((x+0.5-dx)/c) - vnl_erf((x-0.5-dx)/c))/2.0;
00213 for (int y = -khs; y <= khs; y++)
00214 d2G_y[y+khs] = (-(y+0.5-dy)*vcl_exp(-(y+0.5-dy)*(y+0.5-dy)/(2*ssq)) + (y-0.5-dy)*vcl_exp(-(y-0.5-dy)*(y-0.5-dy)/(2*ssq)))/(sq2pisig*ssq);
00215
00216 for (unsigned i=0; i<ni_; i++){
00217 for (unsigned j=0; j<nj_; j++){
00218 top_left_[i*istep_+j*jstep_] = G_x[i]*d2G_y[j];
00219 }
00220 }
00221 }
00222 };
00223
00224
00225 class brip_h0_Gxxx_kernel : public brip_gaussian_kernel
00226 {
00227 public:
00228 vcl_vector<double> d3G_x, G_y;
00229
00230 brip_h0_Gxxx_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00231 ~brip_h0_Gxxx_kernel(){}
00232
00233
00234 virtual void compute_kernel()
00235 {
00236
00237 int khs = (int) vcl_ceil(4*sigma);
00238 d3G_x.resize(2*khs+1);
00239 G_y.resize(2*khs+1);
00240
00241 double ssq = sigma*sigma;
00242 double c = vcl_sqrt(2.0)*sigma;
00243 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00244
00245 for (int x = -khs; x <= khs; x++)
00246 d3G_x[x+khs] = (((x+0.5-dx)*(x+0.5-dx)-ssq)*vcl_exp(-(x+0.5-dx)*(x+0.5-dx)/(2*ssq)) - ((x-0.5-dx)*(x-0.5-dx)-ssq)*vcl_exp(-(x-0.5-dx)*(x-0.5-dx)/(2*ssq)))/(sq2pisig*ssq*ssq);
00247 for (int y = -khs; y <= khs; y++)
00248 G_y[y+khs] = (vnl_erf((y+0.5-dy)/c) - vnl_erf((y-0.5-dy)/c))/2.0;
00249
00250 for (unsigned i=0; i<ni_; i++){
00251 for (unsigned j=0; j<nj_; j++){
00252 top_left_[i*istep_+j*jstep_] = d3G_x[i]*G_y[j];
00253 }
00254 }
00255 }
00256 };
00257
00258
00259 class brip_h0_Gxxy_kernel : public brip_gaussian_kernel
00260 {
00261 public:
00262 vcl_vector<double> d2G_x, dG_y;
00263
00264 brip_h0_Gxxy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00265 ~brip_h0_Gxxy_kernel(){}
00266
00267
00268 virtual void compute_kernel()
00269 {
00270
00271 int khs = (int) vcl_ceil(4*sigma);
00272 d2G_x.resize(2*khs+1);
00273 dG_y.resize(2*khs+1);
00274
00275 double ssq = sigma*sigma;
00276 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00277
00278 for (int x = -khs; x <= khs; x++)
00279 d2G_x[x+khs] = (-(x+0.5-dx)*vcl_exp(-(x+0.5-dx)*(x+0.5-dx)/(2*ssq)) + (x-0.5-dx)*vcl_exp(-(x-0.5-dx)*(x-0.5-dx)/(2*ssq)))/(sq2pisig*ssq);
00280 for (int y = -khs; y <= khs; y++)
00281 dG_y[y+khs] = (vcl_exp(-(y+0.5-dy)*(y+0.5-dy)/(2*ssq)) - vcl_exp(-(y-0.5-dy)*(y-0.5-dy)/(2*ssq)))/sq2pisig;
00282
00283 for (unsigned i=0; i<ni_; i++){
00284 for (unsigned j=0; j<nj_; j++){
00285 top_left_[i*istep_+j*jstep_] = d2G_x[i]*dG_y[j];
00286 }
00287 }
00288 }
00289 };
00290
00291
00292 class brip_h0_Gxyy_kernel : public brip_gaussian_kernel
00293 {
00294 public:
00295 vcl_vector<double> dG_x, d2G_y;
00296
00297 brip_h0_Gxyy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00298 ~brip_h0_Gxyy_kernel(){}
00299
00300
00301 virtual void compute_kernel()
00302 {
00303
00304 int khs = (int) vcl_ceil(4*sigma);
00305 dG_x.resize(2*khs+1);
00306 d2G_y.resize(2*khs+1);
00307
00308 double ssq = sigma*sigma;
00309 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00310
00311 for (int x = -khs; x <= khs; x++)
00312 dG_x[x+khs] = (vcl_exp(-(x+0.5-dx)*(x+0.5-dx)/(2*ssq)) - vcl_exp(-(x-0.5-dx)*(x-0.5-dx)/(2*ssq)))/sq2pisig;
00313 for (int y = -khs; y <= khs; y++)
00314 d2G_y[y+khs] = (-(y+0.5-dy)*vcl_exp(-(y+0.5-dy)*(y+0.5-dy)/(2*ssq)) + (y-0.5-dy)*vcl_exp(-(y-0.5-dy)*(y-0.5-dy)/(2*ssq)))/(sq2pisig*ssq);
00315
00316 for (unsigned i=0; i<ni_; i++){
00317 for (unsigned j=0; j<nj_; j++){
00318 top_left_[i*istep_+j*jstep_] = dG_x[i]*d2G_y[j];
00319 }
00320 }
00321 }
00322 };
00323
00324
00325 class brip_h0_Gyyy_kernel : public brip_gaussian_kernel
00326 {
00327 public:
00328 vcl_vector<double> G_x, d3G_y;
00329
00330 brip_h0_Gyyy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00331 ~brip_h0_Gyyy_kernel(){}
00332
00333
00334 virtual void compute_kernel()
00335 {
00336
00337 int khs = (int) vcl_ceil(4*sigma);
00338 G_x.resize(2*khs+1);
00339 d3G_y.resize(2*khs+1);
00340
00341 double ssq = sigma*sigma;
00342 double c = vcl_sqrt(2.0)*sigma;
00343 double sq2pisig = vcl_sqrt(2*vnl_math::pi)*sigma;
00344
00345 for (int x = -khs; x <= khs; x++)
00346 G_x[x+khs] = (vnl_erf((x+0.5-dx)/c) - vnl_erf((x-0.5-dx)/c))/2.0;
00347 for (int y = -khs; y <= khs; y++)
00348 d3G_y[y+khs] = (((y+0.5-dy)*(y+0.5-dy)-ssq)*vcl_exp(-(y+0.5-dy)*(y+0.5-dy)/(2*ssq)) - ((y-0.5-dy)*(y-0.5-dy)-ssq)*vcl_exp(-(y-0.5-dy)*(y-0.5-dy)/(2*ssq)))/(sq2pisig*ssq*ssq);
00349
00350 for (unsigned i=0; i<ni_; i++){
00351 for (unsigned j=0; j<nj_; j++){
00352 top_left_[i*istep_+j*jstep_] = G_x[i]*d3G_y[j];
00353 }
00354 }
00355 }
00356 };
00357
00358
00359
00360
00361
00362
00363 class brip_h1_G_kernel : public brip_gaussian_kernel
00364 {
00365 public:
00366 vcl_vector<double> G_x, G_y;
00367
00368 brip_h1_G_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00369 ~brip_h1_G_kernel(){}
00370
00371
00372 virtual void compute_kernel()
00373 {
00374
00375 int khs = (int) vcl_ceil(4*sigma);
00376 G_x.resize(2*khs+1);
00377 G_y.resize(2*khs+1);
00378
00379 double ssq = sigma*sigma;
00380 double c = vcl_sqrt(2.0)*sigma;
00381 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00382
00383 for (int x = -khs; x <= khs; x++)
00384 G_x[x+khs] = ((x-1-dx)*vnl_erf((x-1-dx)/c) - 2*(x-dx)*vnl_erf((x-dx)/c) +(x+1-dx)*vnl_erf((x+1-dx)/c))/2.0 +
00385 sigma*(vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) - 2*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) + vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/sq2pi;
00386 for (int y = -khs; y <= khs; y++)
00387 G_y[y+khs] = ((y-1-dy)*vnl_erf((y-1-dy)/c) - 2*(y-dy)*vnl_erf((y-dy)/c) +(y+1-dy)*vnl_erf((y+1-dy)/c))/2.0 +
00388 sigma*(vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) - 2*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) + vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/sq2pi;
00389
00390 for (unsigned i=0; i<ni_; i++){
00391 for (unsigned j=0; j<nj_; j++){
00392 top_left_[i*istep_+j*jstep_] = G_x[i]*G_y[j];
00393 }
00394 }
00395 }
00396 };
00397
00398
00399 class brip_h1_Gx_kernel : public brip_gaussian_kernel
00400 {
00401 public:
00402 vcl_vector<double> dG_x, G_y;
00403
00404 brip_h1_Gx_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00405 ~brip_h1_Gx_kernel(){}
00406
00407
00408 virtual void compute_kernel()
00409 {
00410
00411 int khs = (int) vcl_ceil(4*sigma);
00412 dG_x.resize(2*khs+1);
00413 G_y.resize(2*khs+1);
00414
00415 double ssq = sigma*sigma;
00416 double c = vcl_sqrt(2.0)*sigma;
00417 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00418
00419 for (int x = -khs; x <= khs; x++)
00420 dG_x[x+khs] = (vnl_erf((x-1-dx)/c) - 2*vnl_erf((x-dx)/c) + vnl_erf((x+1-dx)/c))/2.0;
00421 for (int y = -khs; y <= khs; y++)
00422 G_y[y+khs] = ((y-1-dy)*vnl_erf((y-1-dy)/c) - 2*(y-dy)*vnl_erf((y-dy)/c) +(y+1-dy)*vnl_erf((y+1-dy)/c))/2.0 +
00423 sigma*(vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) - 2*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) + vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/sq2pi;
00424
00425 for (unsigned i=0; i<ni_; i++){
00426 for (unsigned j=0; j<nj_; j++){
00427 top_left_[i*istep_+j*jstep_] = dG_x[i]*G_y[j];
00428 }
00429 }
00430 }
00431 };
00432
00433
00434 class brip_h1_Gy_kernel : public brip_gaussian_kernel
00435 {
00436 public:
00437 vcl_vector<double> G_x, dG_y;
00438
00439 brip_h1_Gy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00440 ~brip_h1_Gy_kernel(){}
00441
00442
00443 virtual void compute_kernel()
00444 {
00445
00446 int khs = (int) vcl_ceil(4*sigma);
00447 G_x.resize(2*khs+1);
00448 dG_y.resize(2*khs+1);
00449
00450 double ssq = sigma*sigma;
00451 double c = vcl_sqrt(2.0)*sigma;
00452 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00453
00454 for (int x = -khs; x <= khs; x++)
00455 G_x[x+khs] = ((x-1-dx)*vnl_erf((x-1-dx)/c) - 2*(x-dx)*vnl_erf((x-dx)/c) +(x+1-dx)*vnl_erf((x+1-dx)/c))/2.0 +
00456 sigma*(vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) - 2*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) + vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/sq2pi;
00457 for (int y = -khs; y <= khs; y++)
00458 dG_y[y+khs] = (vnl_erf((y-1-dy)/c) - 2*vnl_erf((y-dy)/c) + vnl_erf((y+1-dy)/c))/2.0;
00459
00460 for (unsigned i=0; i<ni_; i++){
00461 for (unsigned j=0; j<nj_; j++){
00462 top_left_[i*istep_+j*jstep_] = G_x[i]*dG_y[j];
00463 }
00464 }
00465 }
00466 };
00467
00468
00469 class brip_h1_Gxx_kernel : public brip_gaussian_kernel
00470 {
00471 public:
00472 vcl_vector<double> d2G_x, G_y;
00473
00474 brip_h1_Gxx_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00475 ~brip_h1_Gxx_kernel(){}
00476
00477
00478 virtual void compute_kernel()
00479 {
00480
00481 int khs = (int) vcl_ceil(4*sigma);
00482 d2G_x.resize(2*khs+1);
00483 G_y.resize(2*khs+1);
00484
00485 double ssq = sigma*sigma;
00486 double c = vcl_sqrt(2.0)*sigma;
00487 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00488
00489 for (int x = -khs; x <= khs; x++)
00490 d2G_x[x+khs] = (vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) - 2*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) + vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/(sq2pi*sigma);
00491 for (int y = -khs; y <= khs; y++)
00492 G_y[y+khs] = ((y-1-dy)*vnl_erf((y-1-dy)/c) - 2*(y-dy)*vnl_erf((y-dy)/c) +(y+1-dy)*vnl_erf((y+1-dy)/c))/2.0 +
00493 sigma*(vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) - 2*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) + vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/sq2pi;
00494
00495 for (unsigned i=0; i<ni_; i++){
00496 for (unsigned j=0; j<nj_; j++){
00497 top_left_[i*istep_+j*jstep_] = d2G_x[i]*G_y[j];
00498 }
00499 }
00500 }
00501 };
00502
00503
00504 class brip_h1_Gxy_kernel : public brip_gaussian_kernel
00505 {
00506 public:
00507 vcl_vector<double> dG_x, dG_y;
00508
00509 brip_h1_Gxy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00510 ~brip_h1_Gxy_kernel(){}
00511
00512
00513 virtual void compute_kernel()
00514 {
00515
00516 int khs = (int) vcl_ceil(4*sigma);
00517 dG_x.resize(2*khs+1);
00518 dG_y.resize(2*khs+1);
00519
00520 double c = vcl_sqrt(2.0)*sigma;
00521
00522 for (int x = -khs; x <= khs; x++)
00523 dG_x[x+khs] = (vnl_erf((x-1-dx)/c) - 2*vnl_erf((x-dx)/c) + vnl_erf((x+1-dx)/c))/2.0;
00524 for (int y = -khs; y <= khs; y++)
00525 dG_y[y+khs] = (vnl_erf((y-1-dy)/c) - 2*vnl_erf((y-dy)/c) + vnl_erf((y+1-dy)/c))/2.0;
00526
00527 for (unsigned i=0; i<ni_; i++){
00528 for (unsigned j=0; j<nj_; j++){
00529 top_left_[i*istep_+j*jstep_] = dG_x[i]*dG_y[j];
00530 }
00531 }
00532 }
00533 };
00534
00535
00536 class brip_h1_Gyy_kernel : public brip_gaussian_kernel
00537 {
00538 public:
00539 vcl_vector<double> G_x, d2G_y;
00540
00541 brip_h1_Gyy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00542 ~brip_h1_Gyy_kernel(){}
00543
00544
00545 virtual void compute_kernel()
00546 {
00547
00548 int khs = (int) vcl_ceil(4*sigma);
00549 G_x.resize(2*khs+1);
00550 d2G_y.resize(2*khs+1);
00551
00552 double ssq = sigma*sigma;
00553 double c = vcl_sqrt(2.0)*sigma;
00554 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00555
00556 for (int x = -khs; x <= khs; x++)
00557 G_x[x+khs] = ((x-1-dx)*vnl_erf((x-1-dx)/c) - 2*(x-dx)*vnl_erf((x-dx)/c) +(x+1-dx)*vnl_erf((x+1-dx)/c))/2.0 +
00558 sigma*(vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) - 2*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) + vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/sq2pi;
00559 for (int y = -khs; y <= khs; y++)
00560 d2G_y[y+khs] = (vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) - 2*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) + vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/(sq2pi*sigma);
00561
00562 for (unsigned i=0; i<ni_; i++){
00563 for (unsigned j=0; j<nj_; j++){
00564 top_left_[i*istep_+j*jstep_] = G_x[i]*d2G_y[j];
00565 }
00566 }
00567 }
00568 };
00569
00570
00571 class brip_h1_Gxxx_kernel : public brip_gaussian_kernel
00572 {
00573 public:
00574 vcl_vector<double> d3G_x, G_y;
00575
00576 brip_h1_Gxxx_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00577 ~brip_h1_Gxxx_kernel(){}
00578
00579
00580 virtual void compute_kernel()
00581 {
00582
00583 int khs = (int) vcl_ceil(4*sigma);
00584 d3G_x.resize(2*khs+1);
00585 G_y.resize(2*khs+1);
00586
00587 double ssq = sigma*sigma;
00588 double c = vcl_sqrt(2.0)*sigma;
00589 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00590
00591 for (int x = -khs; x <= khs; x++)
00592 d3G_x[x+khs] = (-(x-1-dx)*vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) + 2*(x-dx)*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) - (x+1-dx)*vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/(sq2pi*sigma*ssq);
00593 for (int y = -khs; y <= khs; y++)
00594 G_y[y+khs] = ((y-1-dy)*vnl_erf((y-1-dy)/c) - 2*(y-dy)*vnl_erf((y-dy)/c) +(y+1-dy)*vnl_erf((y+1-dy)/c))/2.0 +
00595 sigma*(vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) - 2*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) + vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/sq2pi;
00596
00597 for (unsigned i=0; i<ni_; i++){
00598 for (unsigned j=0; j<nj_; j++){
00599 top_left_[i*istep_+j*jstep_] = d3G_x[i]*G_y[j];
00600 }
00601 }
00602 }
00603 };
00604
00605
00606 class brip_h1_Gxxy_kernel : public brip_gaussian_kernel
00607 {
00608 public:
00609 vcl_vector<double> d2G_x, dG_y;
00610
00611 brip_h1_Gxxy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00612 ~brip_h1_Gxxy_kernel(){}
00613
00614
00615 virtual void compute_kernel()
00616 {
00617
00618 int khs = (int) vcl_ceil(4*sigma);
00619 d2G_x.resize(2*khs+1);
00620 dG_y.resize(2*khs+1);
00621
00622 double ssq = sigma*sigma;
00623 double c = vcl_sqrt(2.0)*sigma;
00624 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00625
00626 for (int x = -khs; x <= khs; x++)
00627 d2G_x[x+khs] = (vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) - 2*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) + vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/(sq2pi*sigma);
00628 for (int y = -khs; y <= khs; y++)
00629 dG_y[y+khs] = (vnl_erf((y-1-dy)/c) - 2*vnl_erf((y-dy)/c) + vnl_erf((y+1-dy)/c))/2.0;
00630
00631 for (unsigned i=0; i<ni_; i++){
00632 for (unsigned j=0; j<nj_; j++){
00633 top_left_[i*istep_+j*jstep_] = d2G_x[i]*dG_y[j];
00634 }
00635 }
00636 }
00637 };
00638
00639
00640 class brip_h1_Gxyy_kernel : public brip_gaussian_kernel
00641 {
00642 public:
00643 vcl_vector<double> dG_x, d2G_y;
00644
00645 brip_h1_Gxyy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00646 ~brip_h1_Gxyy_kernel(){}
00647
00648
00649 virtual void compute_kernel()
00650 {
00651
00652 int khs = (int) vcl_ceil(4*sigma);
00653 dG_x.resize(2*khs+1);
00654 d2G_y.resize(2*khs+1);
00655
00656 double ssq = sigma*sigma;
00657 double c = vcl_sqrt(2.0)*sigma;
00658 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00659
00660 for (int x = -khs; x <= khs; x++)
00661 dG_x[x+khs] = (vnl_erf((x-1-dx)/c) - 2*vnl_erf((x-dx)/c) + vnl_erf((x+1-dx)/c))/2.0;
00662 for (int y = -khs; y <= khs; y++)
00663 d2G_y[y+khs] = (vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) - 2*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) + vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/(sq2pi*sigma);
00664
00665 for (unsigned i=0; i<ni_; i++){
00666 for (unsigned j=0; j<nj_; j++){
00667 top_left_[i*istep_+j*jstep_] = dG_x[i]*d2G_y[j];
00668 }
00669 }
00670 }
00671 };
00672
00673
00674 class brip_h1_Gyyy_kernel : public brip_gaussian_kernel
00675 {
00676 public:
00677 vcl_vector<double> G_x, d3G_y;
00678
00679 brip_h1_Gyyy_kernel(double sigma_, double dx_=0.0, double dy_=0.0): brip_gaussian_kernel(sigma_, dx_, dy_){}
00680 ~brip_h1_Gyyy_kernel(){}
00681
00682
00683 virtual void compute_kernel()
00684 {
00685
00686 int khs = (int) vcl_ceil(4*sigma);
00687 G_x.resize(2*khs+1);
00688 d3G_y.resize(2*khs+1);
00689
00690 double ssq = sigma*sigma;
00691 double c = vcl_sqrt(2.0)*sigma;
00692 double sq2pi = vcl_sqrt(2*vnl_math::pi);
00693
00694 for (int x = -khs; x <= khs; x++)
00695 G_x[x+khs] = ((x-1-dx)*vnl_erf((x-1-dx)/c) - 2*(x-dx)*vnl_erf((x-dx)/c) +(x+1-dx)*vnl_erf((x+1-dx)/c))/2.0 +
00696 sigma*(vcl_exp(-(x-1-dx)*(x-1-dx)/(2*ssq)) - 2*vcl_exp(-(x-dx)*(x-dx)/(2*ssq)) + vcl_exp(-(x+1-dx)*(x+1-dx)/(2*ssq)))/sq2pi;
00697 for (int y = -khs; y <= khs; y++)
00698 d3G_y[y+khs] = (-(y-1-dy)*vcl_exp(-(y-1-dy)*(y-1-dy)/(2*ssq)) + 2*(y-dy)*vcl_exp(-(y-dy)*(y-dy)/(2*ssq)) - (y+1-dy)*vcl_exp(-(y+1-dy)*(y+1-dy)/(2*ssq)))/(sq2pi*sigma*ssq);
00699
00700 for (unsigned i=0; i<ni_; i++){
00701 for (unsigned j=0; j<nj_; j++){
00702 top_left_[i*istep_+j*jstep_] = G_x[i]*d3G_y[j];
00703 }
00704 }
00705 }
00706 };
00707
00708 #endif // brip_interp_kernel_h