MTF
histUtils.h
1 #ifndef MTF_HIST_UTILS_H
2 #define MTF_HIST_UTILS_H
3 
4 //------ Functions for computing histograms, joint histograms and their derivatives------//
5 
6 #include "mtf/Macros/common.h"
7 #include "mtf/Utilities/excpUtils.h"
8 
9 // precomputed constants for BSpl function
10 #define _1_BY_3 0.33333333333
11 #define _2_BY_3 0.66666666666
12 #define _1_BY_6 0.16666666666
13 #define _eig_set_zero(eig_mat, scalar_type) eig_mat.setZero()
14 //#define _eig_set_zero(eig_mat, scalar_type) \
15 // memset(eig_mat.data(), 0, eig_mat.size()*sizeof(scalar_type))
16 
17 
18 _MTF_BEGIN_NAMESPACE
19 
20 namespace utils{
21 
22  inline void getLog(MatrixXd &eig_log,
23  const MatrixXd &eig_mat, int n_rows, int n_cols){
24  for(int i = 0; i < n_rows; i++) {
25  for(int j = 0; j < n_cols; j++) {
26  if(eig_mat(i, j)<=0){
27  eig_log(i, j) = 0;
28  }else{
29  eig_log(i, j) = log(eig_mat(i, j));
30  }
31  }
32  }
33  }
34 
35  inline void getLog(VectorXd &eig_log,
36  const VectorXd &eig_vec, int vec_size){
37  for(int i = 0; i < vec_size; i++) {
38  if(eig_vec(i)<=0){
39  eig_log(i) = 0;
40  }else{
41  eig_log(i) = log(eig_vec(i));
42  }
43  }
44  }
45 
46  inline double cumBSpl3(double x){
47  //fprintf(stdout, "x=%f\t", x);
48  if(x<=-2){
49  return 1;
50  } else if((x>-2) && (x <= -1)){
51  double temp = 2 + x;
52  double temp2 = temp*temp;
53  return 1.0 - (temp2*temp2) / 24;
54  } else if((x>-1) && (x <= 0)){
55  return 0.5 + x*(x*x*(1.0/3.0 + x / 8) - 2.0 / 3.0);
56  } else if((x>0) && (x <= 1)){
57  return 0.5 + x*(x*x*(1.0 / 3.0 - x / 8) - 2.0 / 3.0);
58  } else if((x>1) && (x<2)){
59  double temp = 2-x;
60  double temp2 = temp*temp;
61  return (temp2*temp2) / 24;
62  }
63  return 0;
64  }
65 
66  template<int bspl_id>
67  inline void cumBSpl3WithGradFast(double &val, double &diff, double x){
68  printf("bspl_id: %d\n", bspl_id);
69  throw utils::InvalidArgument("cumBSpl3WithGradFast :: Invalid bspl_id specified");
70  }
71  template<>
72  inline void cumBSpl3WithGradFast<0>(double &val, double &diff, double x){
73  double temp = 2 + x;
74  diff = -(temp*temp*temp) / 6;
75  val = 1 + (diff * temp) / 4;
76  }
77  template<>
78  inline void cumBSpl3WithGradFast<1>(double &val, double &diff, double x){
79  double x2 = x*x;
80  val = 0.5 + x*(x2*(_1_BY_3 + x / 8) - _2_BY_3);
81  diff = x2*(1 + x / 2) - _2_BY_3;
82  }
83  template<>
84  inline void cumBSpl3WithGradFast<2>(double &val, double &diff, double x){
85  double x2 = x*x;
86  val = 0.5 + x*(x2*(_1_BY_3 - x / 8) - _2_BY_3);
87  diff = x2*(1 - x / 2) - _2_BY_3;
88  }
89  template<>
90  inline void cumBSpl3WithGradFast<3>(double &val, double &diff, double x){
91  double temp = x - 2;
92  diff = (temp*temp*temp) / 6;
93  val = (diff * temp) / 4;
94  }
95 
96  inline void cumBSpl3WithGrad(double &val, double &diff, double x){
97  if(x <= -2){
98  diff = 0;
99  val = 1;
100  } else if((x>-2) && (x <= -1)){
101  double temp = 2 + x;
102  diff = -(temp*temp*temp) / 6;
103  val = 1 + (diff * temp) / 4;
104  } else if((x>-1) && (x <= 0)){
105  double x2 = x*x;
106  val = 0.5 + x*(x2*(_1_BY_3 + x / 8) - _2_BY_3);
107  diff = x2*(1 + x / 2) - _2_BY_3;
108  } else if((x>0) && (x <= 1)){
109  double x2 = x*x;
110  val = 0.5 + x*(x2*(_1_BY_3 - x / 8) - _2_BY_3);
111  diff = x2*(1 - x/2) - _2_BY_3;
112  } else if((x>1) && (x<2)){
113  double temp = x-2;
114  diff = (temp*temp*temp) / 6;
115  val = (diff * temp) / 4;
116  } else{
117  val = diff = 0;
118  }
119  }
120 
121  template<int bspl_id>
122  inline double cumBSpl3HessFast(double x){
123  printf("bspl_id: %d\n", bspl_id);
124  throw utils::InvalidArgument("cumBSpl3HessFast :: Invalid bspl_id specified");
125  }
126  template<>
127  inline double cumBSpl3HessFast<0>(double x){
128  double temp = 2 + x;
129  return -(temp*temp) / 2;
130  }
131  template<>
132  inline double cumBSpl3HessFast<1>(double x){
133  return x*(3 * x + 4) / 2;
134  }
135  template<>
136  inline double cumBSpl3HessFast<2>(double x){
137  return -x*(3 * x - 4) / 2;
138  }
139  template<>
140  inline double cumBSpl3HessFast<3>(double x){
141  double temp = 2 - x;
142  return (temp * temp) / 2;
143  }
144 
145  inline double cumBSpl3Hess(double x){
146  //fprintf(stdout, "x=%f\t", x);
147  if((x>-2) && (x <= -1)){
148  double temp = 2 + x;
149  return -(temp*temp) / 2;
150  } else if((x>-1) && (x <= 0)){
151  return x*(3 * x + 4) / 2;
152  } else if((x>0) && (x <= 1)){
153  return -x*(3 * x - 4) / 2;
154  } else if((x>1) && (x<2)){
155  double temp = 2 - x;
156  return (temp * temp) / 2;
157  }
158  return 0;
159  }
160 
161  inline double bSpl3(double x){
162  //fprintf(stdout, "x=%f\t", x);
163  if((x>-2) && (x<=-1)){
164  double temp = 2 + x;
165  return (temp*temp*temp) / 6;
166  } else if((x>-1) && (x<=0)){
167  return (4 - 3*x*x*(2+x)) / 6;
168  } else if((x>0) && (x<=1)){
169  return (4 - 3*x*x*(2-x)) / 6;
170  } else if((x>1) && (x<2)){
171  double temp = 2-x;
172  return (temp*temp*temp) / 6;
173  }
174  return 0;
175  }
176  template<int bspl_id>
177  void bSpl3WithGradFast(double &val, double &diff, double x){
178  printf("bspl_id: %d\n", bspl_id);
179  throw utils::InvalidArgument("bSpl3WithGradFast :: Invalid bspl_id specified");
180  }
181  template<>
182  inline void bSpl3WithGradFast<0>(double &val, double &diff, double x){
183  double temp = 2 + x;
184  diff = (temp * temp) / 2;
185  val = (diff * temp) / 3;
186  }
187  template<>
188  inline void bSpl3WithGradFast<1>(double &val, double &diff, double x){
189  double temp = x / 2;
190  val = _2_BY_3 - x*x*(1 + temp);
191  diff = -x * (temp + x + 2);
192  }
193  template<>
194  inline void bSpl3WithGradFast<2>(double &val, double &diff, double x){
195  double temp = x / 2;
196  val = _2_BY_3 - x*x*(1 - temp);
197  diff = x * (temp + x - 2);
198  }
199  template<>
200  inline void bSpl3WithGradFast<3>(double &val, double &diff, double x){
201  double temp = 2 - x;
202  diff = -(temp * temp) / 2;
203  val = -(diff * temp) / 3;
204  }
205 
206  inline void bSpl3WithGrad(double &val, double &diff, double x){
207  if((x>-2) && (x<=-1)){
208  double temp = 2 + x;
209  diff = (temp * temp) / 2;
210  val = (diff * temp) / 3;
211  } else if((x>-1) && (x<=0)){
212  double temp = x / 2;
213  val =_2_BY_3 - x*x*(1 + temp);
214  diff = -x * (temp + x + 2);
215  } else if((x>0) && (x<=1)){
216  double temp = x / 2;
217  val =_2_BY_3 - x*x*(1 - temp);
218  diff = x * (temp + x -2);
219  } else if((x>1) && (x<2)){
220  double temp = 2 - x;
221  diff = - (temp * temp) / 2;
222  val = - (diff * temp) / 3 ;
223  }
224  }
228  inline double bSpl3Grad(double x){
229  //fprintf(stdout, "x=%f\t", x);
230  if((x>-2) && (x<=-1)){
231  double temp = 2 + x;
232  return (temp*temp) / 2;
233  } else if((x>-1) && (x<=0)){
234  return -x*(3*x + 4) / 2;
235  } else if((x>0) && (x<=1)){
236  return x*(3*x - 4) / 2;
237  } else if((x>1) && (x<2)){
238  double temp = 2 - x;
239  return -(temp * temp) / 2;
240  }
241  return 0;
242  }
243 
244  template<int bspl_id>
245  inline double bSpl3HessFast(double x){
246  printf("bspl_id: %d\n", bspl_id);
247  throw utils::InvalidArgument("bSpl3HessFast :: Invalid bspl_id specified");
248  }
249  template<>
250  inline double bSpl3HessFast<0>(double x){
251  return 2 + x;
252  }
253  template<>
254  inline double bSpl3HessFast<1>(double x){
255  return -(3 * x + 2);
256  }
257  template<>
258  inline double bSpl3HessFast<2>(double x){
259  return 3 * x - 2;
260  }
261  template<>
262  inline double bSpl3HessFast<3>(double x){
263  return 2 - x;
264  }
265 
269  inline double bSpl3Hess(double x){
270  //fprintf(stdout, "x=%f\t", x);
271  if((x>-2) && (x <= -1)){
272  return 2 + x;
273  } else if((x > -1) && (x <= 0)){
274  return -(3 * x + 2);
275  } else if((x > 0) && (x <= 1)){
276  return 3 * x - 2;
277  } else if((x > 1) && (x < 2)){
278  return 2 - x;
279  }
280  return 0;
281  }
282 
283 
284  typedef void(*BSpl3WithGradPtr)(double &, double &, double);
285  inline void bSpl3WithGrad0(double &val, double &diff, double x){
286  double temp = 2 + x;
287  diff = (temp * temp) / 2;
288  val = (diff * temp) / 3;
289  }
290  inline void bSpl3WithGrad1(double &val, double &diff, double x){
291  double temp = 2 + x;
292  diff = (temp * temp) / 2;
293  val = (diff * temp) / 3;
294  }
295  inline void bSpl3WithGrad2(double &val, double &diff, double x){
296  double temp = x / 2;
297  val = _2_BY_3 - x*x*(1 + temp);
298  diff = -x * (temp + x + 2);
299  }
300  inline void bSpl3WithGrad3(double &val, double &diff, double x){
301  double temp = 2 - x;
302  diff = -(temp * temp) / 2;
303  val = -(diff * temp) / 3;
304  }
310  void getDiracHist(VectorXd &hist, VectorXi &pix_vals_int,
311  const VectorXd &pix_vals, double hist_pre_seed, int n_pix);
315  void getDiracHist(VectorXi &hist, const VectorXi &vals, int n_vals);
320  void getDiracJointHist(MatrixXd &joint_hist, VectorXd &hist1,
321  const VectorXd &pix_vals1, const VectorXi &pix_vals2_int,
322  double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins);
323  void getDiracJointHist(MatrixXd &joint_hist, VectorXd &hist1, VectorXd &hist2,
324  const VectorXd &pix_vals1, const VectorXd &pix_vals2,
325  double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins);
327  void getDiracJointHist(MatrixXd &joint_hist, VectorXd &hist1, VectorXd &hist2,
328  const MatrixXdMr &patch1, const MatrixXdMr &patch2,
329  int start_x, int end_x, int start_y, int end_y,
330  double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins);
335  void getBilinearHist(
336  // output arguments
337  VectorXd &hist, VectorXi &pix_vals_int,
338  // input arguments
339  const VectorXd &pix_vals, double hist_pre_seed, int n_pix
340  );
346  // output arguments
347  MatrixXd &joint_hist, VectorXd &hist1, VectorXd &hist2,
348  // input arguments
349  const VectorXd &pix_vals1, const VectorXd &pix_vals2,
350  double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins
351  );
361  void getBSplHist(VectorXd &hist, MatrixXd &hist_mat, MatrixX2i &bspl_ids,
362  const VectorXd &pix_vals, const MatrixX2i &std_bspl_ids,
363  double pre_seed, int n_pix);
364 
365  void getBSplJointHist(MatrixXd &joint_hist, VectorXd &hist1, VectorXd &hist2,
366  const VectorXd &pix_vals1, const VectorXd &pix_vals2,
367  double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins);
368  void getBSplJointHist(MatrixXd &joint_hist, VectorXd &hist1, VectorXd &hist2,
369  MatrixXd &hist1_mat, MatrixXd &hist2_mat,
370  MatrixX2i &bspl_ids1, MatrixX2i &bspl_ids2,
371  const VectorXd &pix_vals1, const VectorXd &pix_vals2,
372  const MatrixX2i &std_bspl_ids, double hist_pre_seed,
373  double joint_hist_pre_seed, int n_pix);
374 
380  void getBSplJointHist(MatrixXd &joint_hist, VectorXd &hist1,
381  MatrixXd &hist1_mat, MatrixX2i &bspl_ids1,
382  const VectorXd &pix_vals1, const MatrixX2i &bspl_ids2,
383  const MatrixXd &hist2_mat, const MatrixX2i &std_bspl_ids,
384  double hist_pre_seed, double joint_hist_pre_seed, int n_pix);
385 
386  // computes the joint histogram of an image with itself
387  void getBSplJointHist(MatrixXd &joint_hist,
388  const MatrixXd &hist_mat, const MatrixX2i &bspl_ids,
389  double pre_seed, int n_pix);
390 
394  // which are therefore required to be between 0 and n_bins-1
408  void getBSplHistGrad(
409  MatrixXd &hist_grad,
410  // input arguments
411  const VectorXd &pix_vals, const MatrixX2i &bspl_ids, int n_pix
412  );
413  void getBSplHistHess(
414  MatrixXd &hist_hess,
415  // input arguments
416  const VectorXd &pix_vals, const MatrixX2i &bspline_ids,
417  int n_pix, double hist_norm_mult
418  );
419 
443  void getBSplJointHistGrad(MatrixXd &joint_hist_grad, MatrixXd &hist1_grad,
444  const VectorXd &pix_vals1, const MatrixXd &hist2_mat,
445  const MatrixX2i &bspl_ids1, const MatrixX2i &bspl_ids2,
446  const MatrixXi &linear_idx, int n_pix);
447  void getBSplJointHistGrad(MatrixXd &joint_hist_grad,
448  const MatrixXd &hist1_grad, const MatrixXd &hist2_mat,
449  const MatrixX2i &bspl_ids1, const MatrixX2i &bspl_ids2,
450  const MatrixXi &linear_idx, int n_pix);
451 
453  void getBSplHistWithGrad(
454 
455  VectorXd &hist, MatrixXd &hist_mat,
456  MatrixXd &hist_grad, MatrixX2i &bspl_ids,
457 
458  const VectorXd &pix_vals, const MatrixX2i &std_bspl_ids,
459  double pre_seed, int n_pix, double hist_norm_mult
460  );
464 
465  MatrixXd &joint_hist, VectorXd &hist1,
466  MatrixXd &hist1_mat, MatrixXd &hist1_grad,
467  MatrixXd &joint_hist_grad, MatrixX2i &bspl_ids1,
468 
469  const VectorXd &pix_vals1, const MatrixX2i &bspl_ids2,
470  const MatrixXd &hist2_mat, const MatrixX2i &std_bspl_ids, const MatrixXi &linear_idx,
471  double hist_pre_seed, double joint_hist_pre_seed, int n_pix,
472  double hist_norm_mult=1
473  );
474 
475  void getBSplJointHistWithGradFast(
476  // output arguments
477  MatrixXd &joint_hist, VectorXd &hist1,
478  MatrixXd &hist1_mat, MatrixXd &hist1_grad,
479  MatrixXd &joint_hist_grad, MatrixX2i &bspl_ids1,
480  // input arguments
481  const VectorXd &pix_vals1, const MatrixX2i &bspl_ids2,
482  const MatrixXd &hist2_mat, const MatrixX2i &std_bspl_ids,
483  const MatrixXi &linear_idx, double hist_pre_seed,
484  double joint_hist_pre_seed, int n_pix, double hist_norm_mult
485  );
486 
487 
491  void getEntropyVec(VectorXd &entropy_vec, const VectorXd &norm_hist, int n_bins);
492 
495  void getEntropyVec( VectorXd &entropy_vec,
496  const VectorXd &norm_hist, const VectorXd &norm_hist_log, int n_bins
497  );
498 
502  void getMIVec(VectorXd &mi_vec, VectorXd &log_hist_ratio,
503  const MatrixXd &joint_hist, const VectorXd &norm_hist1, const VectorXd &norm_hist2,
504  const MatrixXi &linear_idx, int n_bins);
505 
508  void getMIVec(VectorXd &mi_vec, VectorXd &log_hist_ratio,
509  const MatrixXd &joint_hist, const MatrixXd &joint_hist_log,
510  const VectorXd &hist1_log, const VectorXd &hist2_log, const MatrixXi &linear_idx, int n_bins);
511 
533  void getMIVecGrad(MatrixXd &mi_vec_grad,
534  const MatrixXd &joint_hist_grad, const VectorXd &log_hist_ratio,
535  const MatrixXd &hist1_grad_ratio, const MatrixXd &joint_hist, const MatrixX2i &bspl_ids,
536  const MatrixXi &linear_idx, int n_bins, int n_pix);
537 
538 
539  //---------------------------------------------------------------------------------------------------//
540  //------------------------ Functions for Cumulative Cubic BSpline Histograms ------------------------//
541  //---------------------------------------------------------------------------------------------------//
542 
545  // output arguments
546  VectorXd &cum_hist, MatrixXd &cum_hist_mat,
547  MatrixXd &cum_hist_grad, MatrixX2i &bspline_ids,
548  // input arguments
549  const VectorXd &pix_vals, const MatrixX2i &std_bspline_ids,
550  double pre_seed, int n_bins,
551  int n_pix, double hist_norm_mult
552  );
553  // cumulative joint histogram from precomputed cumulative and marginal histogram matrices
554  // which may be either from the same image or from two different images
555  void getCumBSplJointHistWithGrad(
556  // output arguments
557  MatrixXd &cum_joint_hist, MatrixXd &cum_joint_hist_grad,
558  // input arguments
559  const MatrixXd &cum_hist_mat, const MatrixXd &hist_mat,
560  const MatrixXd &cum_hist_grad, const MatrixX2i &cum_bspl_ids,
561  const MatrixX2i &bspl_ids, const MatrixXi &linear_idx,
562  double pre_seed, int n_bins, int n_pix
563  );
564  // computes the marginal histogram and its matrix too
565  void getCumBSplJointHistWithGrad(
566  // output arguments
567  MatrixXd &cum_joint_hist, MatrixXd &cum_joint_hist_grad,
568  VectorXd &hist, MatrixXd &hist_mat,
569  // input arguments
570  const VectorXd &pix_vals, const MatrixXd &cum_hist_mat,
571  const MatrixXd &cum_hist_grad, const MatrixX2i &cum_bspl_ids,
572  const MatrixX2i &bspline_ids, const MatrixXi &linear_idx,
573  double pre_seed, double joint_pre_seed, int n_bins, int n_pix
574  );
575  void getCumBSplJointHistWithGrad(
576  MatrixXd &cum_joint_hist, VectorXd &cum_hist,
577  MatrixXd &cum_hist_mat, MatrixXd &cum_hist_grad,
578  MatrixXd &cum_joint_hist_grad, MatrixX2i &bspline_ids1,
579  // input arguments
580  const VectorXd &pix_vals1, const MatrixX2i &bspline_ids2,
581  const MatrixXd &hist2_mat, const MatrixX2i &std_bspline_ids, const MatrixXi &linear_idx,
582  double hist_pre_seed, double joint_hist_pre_seed,
583  int n_bins, int n_pix, double hist_norm_mult
584  );
585  // derivative of the cumulative joint histogram w.r.t.
586  // pixels used in the non cumulative component
587  void getInvCumBSplJointHistGrad(
588  // output arguments
589  MatrixXd &cum_joint_hist_grad,
590  // input arguments
591  const MatrixXd &hist_grad, const MatrixXd &cum_hist_mat,
592  const MatrixX2i &cum_bspl_ids, const MatrixX2i &bspl_ids,
593  const MatrixXi &linear_idx, int n_bins, int n_pix
594  );
595  void getCumBSplHistHess(
596  // output arguments
597  MatrixXd &cum_hist_hess,
598  // input arguments
599  const VectorXd &pix_vals,
600  const MatrixX2i &bspline_ids,
601  int n_pix, double hist_norm_mult
602  );
603 
604  // histogram validation functions for debugging
605 
606  void validateJointHist(const MatrixXd &joint_hist,
607  const VectorXd &hist1, const VectorXd &hist2);
608 
609  void validateJointHistGrad(const MatrixXd &joint_hist_grad,
610  const MatrixXd &hist1_grad, const MatrixXd &hist2_grad,
611  const MatrixXi &linear_idx, int n_bins, int n_pix);
612 }
613 _MTF_END_NAMESPACE
614 #endif
void getBSplJointHistWithGrad(MatrixXd &joint_hist, VectorXd &hist1, MatrixXd &hist1_mat, MatrixXd &hist1_grad, MatrixXd &joint_hist_grad, MatrixX2i &bspl_ids1, const VectorXd &pix_vals1, const MatrixX2i &bspl_ids2, const MatrixXd &hist2_mat, const MatrixX2i &std_bspl_ids, const MatrixXi &linear_idx, double hist_pre_seed, double joint_hist_pre_seed, int n_pix, double hist_norm_mult=1)
computes both the histogram and gradient of the first image as well as the joint histogram and its gr...
void getBSplJointHistGrad(MatrixXd &joint_hist_grad, MatrixXd &hist1_grad, const VectorXd &pix_vals1, const MatrixXd &hist2_mat, const MatrixX2i &bspl_ids1, const MatrixX2i &bspl_ids2, const MatrixXi &linear_idx, int n_pix)
computes a matrix with (n_bins*n_bins) rows and n_pix columns that contains the gradient of each entr...
void getDiracJointHist(MatrixXd &joint_hist, VectorXd &hist1, const VectorXd &pix_vals1, const VectorXi &pix_vals2_int, double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins)
assumes that the histogram for the second image has already been computed along with the floors of it...
void getMIVec(VectorXd &mi_vec, VectorXd &log_hist_ratio, const MatrixXd &joint_hist, const VectorXd &norm_hist1, const VectorXd &norm_hist2, const MatrixXi &linear_idx, int n_bins)
computes a vector of size n_bins x n_bins whose sum gives the MI of the two images whose normalized h...
void getBSplHist(VectorXd &hist, MatrixXd &hist_mat, MatrixX2i &bspl_ids, const VectorXd &pix_vals, const MatrixX2i &std_bspl_ids, double pre_seed, int n_pix)
computes the histogram for the given image specified as a vector of pixel values. ...
void getEntropyVec(VectorXd &entropy_vec, const VectorXd &norm_hist, int n_bins)
computes a vector of size &#39;n_bins&#39; whose sum is equal to the entropy of the image whose normalized hi...
void getMIVecGrad(MatrixXd &mi_vec_grad, const MatrixXd &joint_hist_grad, const VectorXd &log_hist_ratio, const MatrixXd &hist1_grad_ratio, const MatrixXd &joint_hist, const MatrixX2i &bspl_ids, const MatrixXi &linear_idx, int n_bins, int n_pix)
computes the gradient of each entry of the MI vector w.r.t.
void getBSplHistWithGrad(VectorXd &hist, MatrixXd &hist_mat, MatrixXd &hist_grad, MatrixX2i &bspl_ids, const VectorXd &pix_vals, const MatrixX2i &std_bspl_ids, double pre_seed, int n_pix, double hist_norm_mult)
computes both the histogram and its gradient simultaneously to take advantage of the common computati...
double bSpl3Hess(double x)
second order derivative of the BSpline function of order 3
Definition: histUtils.h:269
basic functions for preprocessing the raw input image using filtering, resizing and histogram equaliz...
Definition: histUtils.h:20
void getDiracHist(VectorXd &hist, VectorXi &pix_vals_int, const VectorXd &pix_vals, double hist_pre_seed, int n_pix)
computes histogram using the Dirac delta function to determine the bins to which each pixel contribut...
void getCumBSplHistWithGrad(VectorXd &cum_hist, MatrixXd &cum_hist_mat, MatrixXd &cum_hist_grad, MatrixX2i &bspline_ids, const VectorXd &pix_vals, const MatrixX2i &std_bspline_ids, double pre_seed, int n_bins, int n_pix, double hist_norm_mult)
computes the cumulative cubic BSpline histogram and its gradient
void getBilinearHist(VectorXd &hist, VectorXi &pix_vals_int, const VectorXd &pix_vals, double hist_pre_seed, int n_pix)
computes histogram using the bilinear interpolation to determine contributions for the bins correspon...
void getBSplHistGrad(MatrixXd &hist_grad, const VectorXd &pix_vals, const MatrixX2i &bspl_ids, int n_pix)
computes a matrix with &#39;n_bins&#39; rows and &#39;n_pix&#39; columns that contains the gradient of each bin of th...
void getBilinearJointHist(MatrixXd &joint_hist, VectorXd &hist1, VectorXd &hist2, const VectorXd &pix_vals1, const VectorXd &pix_vals2, double hist_pre_seed, double joint_hist_pre_seed, int n_pix, int n_bins)
computes joint histogram using the bilinear interpolation to determine contributions for the bins cor...
double bSpl3Grad(double x)
first order derivative of the BSpline function of order 3
Definition: histUtils.h:228