Bsoft  1.9
Bernard's software package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
img_histogram.cpp
Go to the documentation of this file.
1 
9 #include "rwimg.h"
10 #include "img_histogram.h"
11 #include "simplex.h"
12 //#include "Matrix.h"
13 #include "cluster.h"
14 #include "qsort_functions.h"
15 #include "math_util.h"
16 #include "utilities.h"
17 
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20 
21 // Internal function prototype
22 double img_fit_gauss_to_his_R(Bsimplex* simp);
24 
38 Bplot* img_histogram(Bimage* p, long bins)
39 {
40  unsigned long i, j, k, c, npage, ncol, datasize = p->images()*p->sizeX()*p->sizeY()*p->sizeZ();
41  double Hi, H;
42  double bin_half = (p->maximum() - p->minimum())/(4*bins);
43  double unit_mass = RHO * p->sampling().volume();
44  int* hsum = new int[bins*p->channels()];
45 
46  double scale, offset;
47  int* histo = p->histogram(bins, scale, offset);
48 
49  long max(0);
50  for ( i=0; i<bins; i++ ) if ( max < histo[i] ) max = histo[i];
51 
52  for ( i=0; i<bins*p->channels(); i++ ) hsum[i] = histo[i];
53  for ( i=bins-1; i>0; i-- )
54  for ( c=0; c<p->channels(); c++ )
55  hsum[c*bins+i-1] += hsum[c*bins+i];
56 
57  if ( p->channels() > 1 ) {
58  npage = 1;
59  ncol = p->channels() + 1;
60  } else {
61  npage = 2;
62  ncol = 3;
63  }
64 
65  if ( verbose & VERB_LABEL ) {
66  cout << "Histogram" << endl;
67  if ( p->channels() == 1 )
68  cout << "Bin\tLevel\tNumber\tSum\tVolume\tInformation" << endl;
69  else {
70  cout << "Bin\tLevel";
71  for ( c=0; c<p->channels(); c++ ) cout << "\tChannel" << c+1;
72  cout << endl;
73  }
74  }
75 
76  Bstring title("Histogram");
77  Bplot* plot = new Bplot(npage, bins, ncol);
78  plot->title(title);
79 
80  plot->page(0).title(title);
81  plot->page(0).columns(p->channels()+1);
82  for ( i=0; i<=p->channels(); i++ ) plot->page(0).column(i).number(i);
83  plot->page(0).column(0).label("Bin");
84  plot->page(0).column(0).axis(1);
85  for ( i=1; i<=p->channels(); i++ ) {
86  plot->page(0).column(i).type(1);
87  plot->page(0).column(i).label("Count");
88  plot->page(0).column(i).axis(3);
89  plot->page(0).column(i).element_size(0.5);
90  }
91  if ( p->channels() > 1 ) {
92  plot->page(0).column(1).color(1,0,0);
93  plot->page(0).column(2).color(0,1,0);
94  plot->page(0).column(3).color(0,0,1);
95  }
96  plot->page(0).axis(1).min(p->minimum() - bin_half);
97  plot->page(0).axis(1).max(p->maximum() + bin_half);
98  plot->page(0).axis(3).min(0);
99  plot->page(0).axis(3).max(max);
100 
101  if ( p->channels() < 2 ) {
102  title = "Cumulative mass";
103  plot->page(1).title(title);
104  plot->page(1).columns(2);
105  plot->page(1).column(0).number(0);
106  plot->page(1).column(1).number(2);
107  plot->page(1).column(0).label("Bin");
108  plot->page(1).column(0).axis(1);
109  plot->page(1).column(1).type(1);
110  plot->page(1).column(1).label("Mass(MDa)");
111  plot->page(1).column(1).axis(3);
112  plot->page(1).column(1).element_size(0.5);
113  plot->page(1).axis(1).min(p->minimum() - bin_half);
114  plot->page(1).axis(1).max(p->maximum() + bin_half);
115  plot->page(1).axis(3).min(0);
116  plot->page(1).axis(3).max(hsum[0] * unit_mass);
117  }
118 
119  for ( i=0; i<bins; i++ ) {
120  (*plot)[i] = p->minimum() + i/scale;
121  for ( c=0, j=i, k=bins+i; c<p->channels(); c++, j+=bins, k+=bins ) (*plot)[k] = histo[j];
122  }
123 
124  if ( p->channels() == 1 ) {
125  H = 0;
126  for ( i=0, k=2*bins; i<bins; i++, k++ ) {
127  (*plot)[k] = hsum[i] * unit_mass;
128  Hi = 0;
129  if ( histo[i] )
130  Hi = (-histo[i]*1.0/hsum[0]) * log(histo[i]*1.0/hsum[0]) / log(2.0);
131  H += Hi;
132  cout << i+1 << tab << setw(12) << (*plot)[i] << tab << histo[i] << tab << hsum[i] << tab <<
133  p->sampling().volume()*hsum[i] << tab << Hi << endl;
134  }
135 
136  if ( verbose & VERB_LABEL ) {
137  cout << "Voxels & number in histogram: " << datasize << " "
138  << hsum[0] << " (" << hsum[0]*100.0/datasize << " %)" << endl;
139  cout << "Voxel volume: " << p->sampling().volume() << " A/voxel" << endl;
140  cout << "Informational entropy and rate: " << H << " " << log(1.0*bins)/log(2.0) - H << endl << endl;
141  }
142  } else {
143  for ( i=0; i<bins; i++ ) {
144  cout << i+1 << tab << (*plot)[i];
145  for ( c=0, j=0; c<p->channels(); c++, j+=bins ) cout << tab << histo[j];
146  cout << endl;
147  }
148  }
149 
150 
151  delete[] histo;
152  delete[] hsum;
153 
154  return plot;
155 }
156 
168 {
169  int bins(10000), pbins(101);
170  unsigned long i, j, k, m, hsum;
171  unsigned long datasize = (unsigned long)p->images()*p->sizeX()*p->sizeY()*p->sizeZ();
172  double invsize = 100.0/datasize;
173  double scale, offset, fraction, d;
174 
175  int* histo = p->histogram(bins, scale, offset);
176 
177  double* perc = new double[pbins];
178 
179  perc[0] = p->minimum();
180  perc[100] = p->maximum();
181 
182  unsigned long ncol(3);
183  Bstring title("Percentiles");
184  Bplot* plot = new Bplot(1, pbins, ncol);
185  plot->title(title);
186 
187  plot->page(0).title(title);
188  plot->page(0).columns(ncol);
189  for ( i=0; i<ncol; i++ ) plot->page(0).column(i).number(i);
190  plot->page(0).column(0).label("%");
191  plot->page(0).column(0).axis(1);
192  plot->page(0).column(1).type(1);
193  plot->page(0).column(1).label("Bin");
194  plot->page(0).column(1).axis(3);
195  plot->page(0).column(1).element_size(0.5);
196  plot->page(0).column(2).type(2);
197  plot->page(0).column(2).label("Value");
198  plot->page(0).column(2).axis(3);
199  plot->page(0).column(2).element_size(0.5);
200  plot->page(0).column(2).color(1,0,0);
201 // plot->page(0).axis(1).min(p->minimum() - bin_half);
202 // plot->page(0).axis(1).max(p->maximum() + bin_half);
203 // plot->page(0).axis(3).min(prad->minimum());
204 // plot->page(0).axis(3).max(prad->maximum());
205 
206  if ( verbose ) {
207  cout << "%\tBin\tValue" << endl;
208  cout << 0 << tab << 0 << tab << perc[0] << endl;
209  }
210  (*plot)[2*pbins] = perc[0];
211  for ( i=j=1, hsum = histo[0]; i<bins; hsum += histo[i], i++ ) {
212  fraction = hsum*invsize;
213  for ( d = (fraction>j)? 1.0/(fraction - j): 1; fraction > j; j++ ) {
214  perc[j] = p->minimum() + (i - d*(fraction - j))/scale;
215  cout << j << tab << i << tab << perc[j] << endl;
216  (*plot)[j] = j;
217  (*plot)[pbins+j] = i;
218  (*plot)[2*pbins+j] = perc[j];
219  }
220  }
221  cout << 100 << tab << i << tab << perc[100] << endl;
222  (*plot)[100] = 100;
223  (*plot)[pbins+100] = i;
224  (*plot)[2*pbins+100] = perc[100];
225 
226  delete[] histo;
227  delete[] perc;
228 
229  return plot;
230 }
231 
242 Bplot* img_fit_gauss_to_histogram(Bimage* p, long bins, long n)
243 {
244  p->change_type(Float);
245 
246  unsigned long i, j, k, m, nh(bins), ncol(n+2);
247  unsigned long datasize = p->data_size(), thresh((100*datasize)/bins);
248  double v, max(0), avg[n], std[n], w[n];
249  double bin_half = (p->maximum() - p->minimum())/(4*bins);
250 
251  double scale, offset;
252  int* histo = p->histogram(bins, scale, offset);
253 
254  int* sel = k_means(datasize, (float *)p->data_pointer(), n);
255 
256  for ( j=0; j<n; j++ ) avg[j] = std[j] = w[j] = 0;
257  for ( i=0; i<datasize; i++ ) {
258  avg[sel[i]] += (*p)[i];
259  std[sel[i]] += (*p)[i]*(*p)[i];
260  w[sel[i]] += 1;
261  }
262  for ( j=0; j<n; j++ ) {
263  avg[j] /= w[j];
264  std[j] /= w[j];
265  std[j] -= avg[j]*avg[j];
266  if ( std[j] > 0 ) std[j] = sqrt(std[j]);
267  else std[j] = 0;
268 // cout << j << tab << avg[j] << tab << std[j] << endl;
269  }
270 
271  delete[] sel;
272 
273  sel = new int[bins];
274 
275  // Selection of bins to fit
276  for ( i=nh=0; i<bins; i++ ) {
277  if ( histo[i] < thresh ) {
278  sel[i] = 1;
279  nh++;
280  } else {
281  sel[i] = 0;
282  }
283  }
284 
285  if ( nh < 20 && nh < bins/2 )
286  cerr << "Warning: Too few bins selected for fitting! (" << nh << "/" << bins << ")" << endl;
287 
288  // 3 parameters: amplitude, position, sigma
289  Bsimplex* simp = init_simplex(1, 3*n, 1, nh);
290  simp->constant[0] = n;
291  for ( i=j=0; i<bins; i++ ) if ( sel[i] ) {
292  simp->x[j] = p->minimum() + i/scale;
293  simp->fx[j++] = histo[i];
294  if ( max < histo[i] ) max = histo[i];
295  }
296 
297  for ( i=j=0; j<n; j++, i++ ) {
298  simp->param[i] = max; // Amplitude
299  simp->lolimit[i] = datasize/bins;
300  simp->hilimit[i] = 5*max;
301  i++;
302 // simp->param[i] = (j+0.5)*(p->maximum() - p->minimum())/n; // Position
303  simp->param[i] = avg[j]; // Position
304  if ( std[j] ) {
305  simp->lolimit[i] = avg[j] - 5*std[j];
306  simp->hilimit[i] = avg[j] + 5*std[j];
307  if ( simp->lolimit[i] < p->minimum() ) simp->lolimit[i] = p->minimum();
308  if ( simp->hilimit[i] > p->maximum() ) simp->hilimit[i] = p->maximum();
309  } else {
310  simp->lolimit[i] = p->minimum();
311  simp->hilimit[i] = p->maximum();
312  }
313  i++;
314  if ( std[j] ) {
315  simp->param[i] = std[j]; // Sigma
316  simp->lolimit[i] = std[j]/5;
317  simp->hilimit[i] = 5*std[j];
318  } else {
319  simp->param[i] = p->standard_deviation(); // Sigma
320  simp->lolimit[i] = 1/scale;
321  simp->hilimit[i] = 0.5*(p->maximum() - p->minimum())/n;
322  }
323  }
324 
325  double R = simplex(simp, 1000, 0.001, img_fit_gauss_to_his_R);
326 
327  float* gauss = new float[3*n];
328  for ( j=0; j<3*n; j++ ) gauss[j] = simp->param[j];
329 
330  kill_simplex(simp);
331 
332  if ( verbose & VERB_PROCESS ) {
333  cout << "Gaussian fit over " << nh << " bins:" << endl;
334  cout << "Amp\tOffset\tSigma\tSIP" << endl;
335  for ( j=0; j<n; j++ )
336  cout << gauss[3*j] << tab << gauss[3*j+1] << tab << gauss[3*j+2] << tab << bins*gauss[3*j]/datasize << endl;
337  cout << "Sampling-independent RMSD: " << bins*R/datasize << endl << endl;
338  }
339 
340  // Set the average and standard deviation to the first gaussian parameters
341  p->average(gauss[1]);
342  p->standard_deviation(gauss[2]);
343  p->image->FOM(R);
344 
345  Bstring title("Gaussian fit");
346  Bplot* plot = new Bplot(1, bins, ncol);
347  plot->title(title);
348 
349  plot->page(0).title(title);
350  plot->page(0).columns(ncol);
351  for ( i=0; i<ncol; i++ ) plot->page(0).column(i).number(i);
352  plot->page(0).column(0).label("Bin");
353  plot->page(0).column(0).axis(1);
354  for ( i=1; i<ncol; i++ ) {
355  plot->page(0).column(i).type(2);
356  plot->page(0).column(i).axis(3);
357  plot->page(0).column(i).element_size(0.5);
358  }
359  plot->page(0).column(1).label("Count");
360  for ( i=2; i<ncol; i++ )
361  plot->page(0).column(i).label("Gaussian");
362  plot->page(0).column(1).type(1);
363  plot->page(0).column(2).color(1,0,0);
364  if ( n > 1 ) plot->page(0).column(3).color(0,1,0);
365  if ( n > 2 ) plot->page(0).column(4).color(0,0,1);
366  plot->page(0).axis(1).min(p->minimum() - bin_half);
367  plot->page(0).axis(1).max(p->maximum() + bin_half);
368 // plot->page(0).axis(3).min(p->minimum());
369 // plot->page(0).axis(3).max(p->maximum());
370 
371  Bstring txt;
372  for ( j=0; j<n; j++ ){
373  txt = Bstring(j+1, "Gaussian %d:") + Bstring(gauss[3*j], " a=%g") +
374  Bstring(gauss[3*j+1], " u=%g") + Bstring(gauss[3*j+2], " s=%g");
375  plot->page(0).add_text(txt);
376  }
377  txt = Bstring(R, "R: %g");
378  plot->page(0).add_text(txt);
379 
380  double x;
381 
382  for ( i=0, j=bins; i<bins; i++, j++ ) {
383  (*plot)[i] = p->minimum() + i/scale;
384  (*plot)[j] = histo[i];
385  for ( k=0, m=i+2*bins; k<3*n; k+=3, m+=bins ) {
386  x = ((*plot)[i] - gauss[k+1])/gauss[k+2];
387  (*plot)[m] = gauss[k]*exp(-0.5*x*x);
388  }
389  }
390 
391  delete[] histo;
392  delete[] sel;
393  delete[] gauss;
394 
395  return plot;
396 }
397 
415 {
416  unsigned long i, j, m, n, ni, datasize = p->data_size();
417  double max = 0, sum = 0;
418  double bin_half = (p->maximum() - p->minimum())/(4*bins);
419 
420  double scale, offset;
421  int* histo = p->histogram(bins, scale, offset);
422 
423  // Count the number of positive bins and readjust the histogram to have only positive bins
424  for ( i=0, j=0, n=0, ni=0; i<bins; i++ ) {
425  if ( histo[i] > 0 ) {
426  ni += j;
427  n++;
428  j = 0;
429  }
430  j++;
431  }
432  if ( verbose & VERB_FULL )
433  cout << "Positive bins = " << n << " Interval size = " << ni*1.0/n << endl;
434  delete[] histo;
435 
436  if ( bins < n ) bins = n;
437  else bins = (bins*n)/ni;
438 
439  histo = p->histogram(bins, scale, offset);
440 
441  if ( verbose & VERB_FULL )
442  cout << "Bins reset to " << bins << ", scale = " << scale << ", offset = " << offset << endl << endl;
443 
444  // 3 parameters: amplitude, position, sigma
445  Bsimplex* simp = init_simplex(1, 3, 0, bins);
446  for ( i=0; i<bins; i++ ) simp->x[i] = p->minimum() + i/scale;
447  for ( i=1; i<bins-1; i++ ) {
448  if ( histo[i] < 1 ) simp->fx[i] = log(0.5);
449  else simp->fx[i] = log(1.0*histo[i]);
450  sum += simp->fx[i];
451  if ( max < simp->fx[i] ) max = simp->fx[i];
452  }
453  simp->fx[0] = simp->fx[1];
454  simp->fx[bins-1] = log(0.5);
455 
456  simp->param[0] = log(datasize*1.0); // ln(Amplitude)
457  simp->lolimit[0] = log(datasize/2.0);
458  simp->hilimit[0] = log(datasize+1.0);
459 
460  simp->param[1] = 0; // Position in bins
461  simp->lolimit[1] = 0;
462  simp->hilimit[1] = 0;
463 
464  simp->param[2] = p->standard_deviation()*p->standard_deviation(); // Lambda in bins
465  if ( simp->param[2] < 0.001 ) simp->param[2] = 0.001;
466  simp->lolimit[2] = 0.001;
467  simp->hilimit[2] = 10*p->standard_deviation();
468  if ( simp->hilimit[2] < 1 ) simp->hilimit[2] = 10*p->average();
469 
470  double R = simplex(simp, 1000, 0.001, img_fit_poisson_to_his_R);
471  R = exp(R);
472 
473  float* poisson = new float[3];
474  poisson[0] = exp(simp->param[0]);
475  poisson[1] = simp->param[1];
476  poisson[2] = simp->param[2];
477 
478  kill_simplex(simp);
479 
480  if ( verbose & VERB_PROCESS ) {
481  cout << "Poisson function fit over " << bins << " bins:" << endl;
482  cout << "Lambda: " << poisson[2] << endl;
483 // cout << "Offset: " << poisson[1] << endl;
484  cout << "Included voxels: " << poisson[0] << " (" << 100*poisson[0]/datasize << "%)" << endl;
485  cout << "Sampling-independent RMSD: " << bins*R/datasize << endl << endl;
486  }
487 
488  // Set the average and standard deviation to the poisson parameters
489  p->average(poisson[2]);
490  p->standard_deviation(sqrt(poisson[2]));
491  p->image->FOM(R);
492 
493  unsigned long ncol(3);
494  Bstring title("Poisson fit");
495  Bplot* plot = new Bplot(1, bins, ncol);
496  plot->title(title);
497 
498  plot->page(0).title(title);
499  plot->page(0).columns(ncol);
500  for ( i=0; i<ncol; i++ ) plot->page(0).column(i).number(i);
501  plot->page(0).column(0).label("Bin");
502  plot->page(0).column(0).axis(1);
503  plot->page(0).column(1).type(1);
504  plot->page(0).column(1).label("Count");
505  plot->page(0).column(1).axis(3);
506  plot->page(0).column(1).element_size(0.5);
507  plot->page(0).column(2).type(2);
508  plot->page(0).column(2).label("Count");
509  plot->page(0).column(2).axis(3);
510  plot->page(0).column(2).element_size(0.5);
511  plot->page(0).column(2).color(1,0,0);
512  plot->page(0).axis(1).min(p->minimum() - bin_half);
513  plot->page(0).axis(1).max(p->maximum() + bin_half);
514 // plot->page(0).axis(3).min(prad->minimum());
515 // plot->page(0).axis(3).max(prad->maximum());
516 
517  Bstring txt = Bstring(poisson[0], "Poisson: a=%g") + Bstring(poisson[2], " u=%g");
518  plot->page(0).add_text(txt);
519  txt = Bstring(R, "R: %g");
520  plot->page(0).add_text(txt);
521 
522  for ( i=0, j=bins, m=2*bins; i<bins; i++, j++, m++ ) {
523  (*plot)[i] = i;
524  (*plot)[j] = histo[i];
525  (*plot)[m] = poisson[0]*pow(poisson[2],(float)i)*exp(-poisson[2])/factorial(i);
526  if ( !isfinite((*plot)[m]) ) (*plot)[m] = 0;
527  }
528 
529  delete[] histo;
530  delete[] poisson;
531 
532  return plot;
533 }
534 
536 {
537  int i, j, k;
538  double x, df, R(0);
539 
540  for ( i=0; i<simp->npoint; i++ ) {
541  for ( j=k=0, df=0; j<simp->constant[0]; j++, k+=3 ) {
542  x = (simp->x[i] - simp->param[k+1])/simp->param[k+2];
543  df += simp->param[k]*exp(-0.5*x*x);
544  }
545  df -= simp->fx[i];
546  R += df*df;
547  }
548 
549  R = sqrt(R/i);
550 
551  return R;
552 }
553 
555 {
556  int i, j, n;
557  double x, R(0);
558  float* df = new float[simp->npoint];
559 
560  simp->param[1] = floor(simp->param[1]+0.5); // Enforce integer
561 
562  for ( i=0, n=0; i<simp->npoint; i++ ) {
563  if ( simp->fx[i] >= 0 ) {
564  x = simp->x[i] + simp->param[1];
565  df[i] = fabs(simp->fx[i] - simp->param[0] - x*log(simp->param[2]) +
566  simp->param[2] + lgamma(x+1.0L));
567  if ( !isfinite(df[i]) ) {
568  error_show("Error in img_fit_poisson_to_his_R", __FILE__, __LINE__);
569  cerr << "i=" << i << "\tfx[i]=" << simp->fx[i] << "\tamp=" <<
570  simp->param[0] << "\tpos=" << simp->param[1]
571  << "\tlambda=" << simp->param[2] << endl;
572  return 1e37;
573  }
574  n++;
575  } else df[i] = -1;
576  }
577 
578  qsort((void *) df, simp->npoint, sizeof(float),
579  (int (*)(const void *, const void *)) QsortSmallToLargeFloat);
580 
581 // if ( simp->npoint < 100 ) j = simp->npoint - 3;
582 // else j = (simp->npoint*97)/100;
583  j = simp->npoint - 3;
584 
585  for ( i=0, R=0; i<j; i++ ) if ( df[i] > -1 ) {
586  R += df[i]*df[i];
587  n++;
588  }
589 
590  if ( n ) R = sqrt(R/n);
591  else R = 1e37;
592 
593  delete[] df;
594 
595  return R;
596 }
597 
598 
599 
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1436
void sizeZ(size_t nz)
Definition: Bimage.h:330
Header file for utility functions for use in qsort calls.
Bsimplex * init_simplex(int nvar, int nparam, int nconstant, int npoint)
Initializes a Bsimplex structure.
Definition: simplex.cpp:243
float * fx
Definition: simplex.h:53
Header file for image utilities.
double min()
Definition: ps_plot.h:30
Bstring & title()
Definition: ps_plot.h:188
double element_size()
Definition: ps_plot.h:74
Header file for general utilities.
double img_fit_poisson_to_his_R(Bsimplex *simp)
Bstring & label()
Definition: ps_plot.h:63
float * x
Definition: simplex.h:52
double * param
Definition: simplex.h:48
Definition: Bimage.h:60
int kill_simplex(Bsimplex *simp)
Frees all memory associated with a Bsimplex structure.
Definition: simplex.cpp:289
int error_show(const char *message, const char *file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:652
int verbose
#define VERB_PROCESS
Definition: utilities.h:99
double * color()
Definition: ps_plot.h:76
double average(size_t cc, double xf, double yf, double zf, size_t nn, double iscale)
Averages in the xy plane when scaling is less than 1.
Definition: Bimage.cpp:1147
Bcolumn & column(long i)
Definition: ps_plot.h:110
double max()
Definition: ps_plot.h:32
General image parameter class.
Definition: Bimage.h:153
double factorial(int n)
Calculates the factorial of n.
Definition: math_util.cpp:66
double * hilimit
Definition: simplex.h:50
int npoint
Definition: simplex.h:47
double * lolimit
Definition: simplex.h:49
double maximum()
Definition: Bimage.h:458
long number()
Definition: ps_plot.h:61
size_t channels()
Definition: Bimage.h:323
void sampling(double s)
Definition: Bimage.h:435
Bplot * img_percentiles(Bimage *p)
Calculates the percentiles from the histogram of an image.
long type()
Definition: ps_plot.h:66
double FOM()
Definition: Bimage.h:143
Baxis & axis(long id)
Definition: ps_plot.h:117
Bstring & title()
Definition: ps_plot.h:100
double img_fit_gauss_to_his_R(Bsimplex *simp)
Bplot * img_histogram(Bimage *p, long bins)
Calculates the histogram of an image.
double standard_deviation()
Definition: Bimage.h:460
void add_text(Bstring &s)
Definition: ps_plot.h:122
size_t images()
Definition: Bimage.h:433
unsigned char * data_pointer()
Definition: Bimage.h:232
int QsortSmallToLargeFloat(const void *x, const void *y)
Utility function for sorting floating point values in qsort.
size_t data_size()
Definition: Bimage.h:226
Nelder and Mead downhill simplex method for generalized parameter fitting.
int * k_means(long n, float *data, int k)
Generate clusters using a K-means algorithm.
Definition: cluster.cpp:28
Bplot * img_fit_poisson_to_histogram(Bimage *p, long bins)
Fits a poisson function to a histogram of an image.
void sizeX(size_t nx)
Definition: Bimage.h:328
Bpage & page(long i)
Definition: ps_plot.h:210
void sizeY(size_t ny)
Definition: Bimage.h:329
#define RHO
Definition: utilities.h:83
Header file for clustering functions.
void columns(long ncol)
Definition: ps_plot.h:105
double simplex(Bsimplex *simp, int maxcycles, double tolerance, double(funk)(Bsimplex *))
Definition: simplex.cpp:43
double * constant
Definition: simplex.h:51
Header file for 2D and 3D image I/O.
Bplot * img_fit_gauss_to_histogram(Bimage *p, long bins, long n)
Fits a gaussian function to a histogram of an image.
#define VERB_FULL
Definition: utilities.h:101
#define VERB_LABEL
Definition: utilities.h:98
int * histogram(size_t bins, double &scale, double &offset)
Calculates the histogram of an image.
double minimum()
Definition: Bimage.h:457
ostream & tab(ostream &out)
Definition: utilities.cpp:21
Bsub_image * image
Definition: Bimage.h:184
long axis()
Definition: ps_plot.h:68
Header file for general utilities.
Definition: ps_plot.h:146