Bsoft  2.1.0
Bernard's software package
Bimage_stats.cpp
Go to the documentation of this file.
1 
9 #include "Bimage.h"
10 #include "matrix_linear.h"
11 #include "Complex.h"
12 #include "Vector3.h"
13 #include "utilities.h"
14 
15 // Declaration of global variables
16 extern int verbose; // Level of output to the screen
17 
23 {
24  if ( !d.uc ) return 0;
25 
26  long nn, notfin(0);
27 
28  if ( verbose & VERB_DEBUG ) {
29  cout << "DEBUG Bimage::statistics: Data size: " << c << " x " << x <<
30  " x " << y << " x " << z << " x " << n << " = " << datasize << endl;
31  cout << "DEBUG Bimage::statistics: datatype=" << datatype << endl;
32  cout << "DEBUG Bimage::statistics: min=" << min << " max=" << max << endl;
33  cout << "DEBUG Bimage::statistics: ave=" << avg << " std=" << std << endl;
34  }
35 
36 #ifdef HAVE_GCD
37  dispatch_apply(n, dispatch_get_global_queue(0, 0), ^(size_t i){
38  statistics(i);
39  });
40 #else
41 #pragma omp parallel for
42  for ( long i=0; i<n; i++ )
43  statistics(i);
44 #endif
45 
46  if ( notfin ) {
47  cerr << "Error in Bimage:statistics: " << notfin << " values not finite!" << endl;
48  cerr << tab << "Image: " << file_name() << endl;
49  }
50 
51  min = image->minimum();
52  max = image->maximum();
53  avg = std = 0;
54  for ( nn=0; nn<n; nn++ ) {
55  avg += image[nn].average();
56  std += image[nn].standard_deviation()
58  if ( min > image[nn].minimum() ) min = image[nn].minimum();
59  if ( max < image[nn].maximum() ) max = image[nn].maximum();
60  if ( verbose & VERB_DEBUG )
61  cout << "DEBUG Bimage::statistics: avg[" << nn << "] = " << image[nn].average() << " std[" << nn << "] = " << image[nn].standard_deviation() << endl;
62  }
63 
64  // Dubious fix!!!
65  if ( datatype <= Short && compoundtype == TRGB ) {
66  min = dtmin;
67  max = dtmax;
68  }
69 
70  avg = avg/n;
71  std = std/n;
72  if ( std > 0 ) std = sqrt(std);
73  else std = 0;
76 
77  if ( verbose & VERB_STATS ) {
78  cout << "Data size: " << c << " x " << x <<
79  " x " << y << " x " << z << " x " << n << " = " << datasize << endl;
80  cout << "Min, max, avg, std: " << min << " " << max << " " << avg << " " << std << endl;
81  if ( next ) cout << "FOM maximum: " << next->maximum() << endl;
82  cout << endl << "Image\tMin\tMax\tAvg\tStd" << endl;
83  for ( nn=0; nn<n; nn++ )
84  cout << nn+1 << tab << image[nn].minimum() << tab <<
85  image[nn].maximum() << tab <<
86  image[nn].average() << tab <<
87  image[nn].standard_deviation() << endl;
88  cout << endl;
89  }
90 
91  if ( next ) next->statistics();
92 
93  return notfin;
94 }
95 
101 long Bimage::statistics(long img_num)
102 {
103  if ( !d.uc ) return 0;
104 
105  long j, k, notfin(0);
106  double imin(DBL_MAX), imax(-DBL_MAX), iavg(0), istd(0), v, pwr;
107  Complex<double> cv;
108  long imagesize = x*y*z;
109  if ( compoundtype > TComplex ) imagesize *= c;
110 
111  if ( verbose & VERB_DEBUG )
112  cout << "DEBUG Bimage::statistics: image = " << img_num << endl;
113 
114  for ( j=0, k=img_num*imagesize; j<imagesize; k++, j++ ) {
115  if ( compoundtype != TComplex ) {
116  v = (*this)[k];
117  if ( isfinite(v) ) {
118  if ( v < imin ) imin = v;
119  if ( v > imax ) imax = v;
120  iavg += v;
121  istd += v*v;
122  } else {
123 // cerr << "Error in Bimage::statistics: value not finite: k=" << k << endl;
124  notfin++;
125  set(k, 0);
126  }
127  } else if ( compoundtype == TComplex ) {
128  cv = complex(k);
129  pwr = cv.power();
130  if ( isfinite(pwr) ) {
131  if ( pwr < imin ) imin = pwr;
132  if ( pwr > imax ) imax = pwr;
133  iavg += sqrt(pwr);
134  istd += pwr;
135  } else {
136 // cerr << "Error in Bimage::statistics: complex value not finite: k=" << k << endl;
137  notfin++;
138  cv = 0;
139  set(k, cv);
140  }
141  }
142  }
143  if ( imin < dtmin ) imin = dtmin;
144  if ( imax > dtmax ) imax = dtmax;
145  iavg /= imagesize;
146  istd = istd/imagesize - iavg*iavg;
147  if ( istd > 0 ) istd = sqrt(istd);
148  else istd = 0;
149  image[img_num].average(iavg);
150  image[img_num].standard_deviation(istd);
151  image[img_num].minimum(imin);
152  image[img_num].maximum(imax);
153  if ( verbose & VERB_DEBUG )
154  cout << "DEBUG Bimage::statistics: min[" << img_num << "] = "
155  << imin << " max[" << img_num << "] = " << imax << endl;
156 
157  return notfin;
158 }
159 
167 long Bimage::statistics(Bimage* pmask, double& regavg, double& regstd)
168 {
169  if ( !d.uc ) return 0;
170 
171  regavg = regstd = 0;
172 
173  long i, nv(0);
174 
175  for ( i=0; i<datasize; i++ ) if ( (*pmask)[i] > 0.5 ) {
176  regavg += (*this)[i];
177  regstd += (*this)[i] * (*this)[i];
178  nv++;
179  }
180 
181  regavg /= nv;
182  regstd /= nv;
183  if ( regstd - regavg*regavg > 0 )
184  regstd = sqrt(regstd - regavg*regavg);
185  else
186  regstd = 0;
187 
188  return nv;
189 }
190 
206  double rad_min, double rad_max, double& vavg, double& vstd)
207 {
208  if ( !d.uc ) {
209  cerr << "Error: No data for image " << file_name() << " in memory!" << endl;
210  return 0;
211  }
212 
213  long i, xx, yy, zz, cc, npx(0);
214  double dx, dy, dz, d2, rmax2(rad_max*rad_max), rmin2(rad_min*rad_min);
215  double value, sum(0), ssum(0), w(0), vmin(1e37), vmax(-1e37);
216 
217  if ( verbose & VERB_DEBUG ) {
218  cout << "DEBUG Bimage::stats_within_radii: Data size: " << size() << "x" << c << "x" << n << "=" << datasize << endl;
219  cout << "DEBUG Bimage::stats_within_radii: datatype=" << datatype << endl;
220  cout << "DEBUG Bimage::stats_within_radii: min=" << min << " max=" << max << endl;
221  cout << "DEBUG Bimage::stats_within_radii: ave=" << avg << " std=" << std << endl;
222  }
223 
224  vavg = vstd = 0;
225 
226  for ( zz=0; zz<z; zz++ ) {
227  dz = (double)zz - loc[2];
228  dz *= dz;
229  if ( dz <= rmax2 ) for ( yy=0; yy<y; yy++ ) {
230  dy = (double)yy - loc[1];
231  dy *= dy;
232  if ( dy <= rmax2 ) for ( xx=0; xx<x; xx++ ) {
233  dx = (double)xx - loc[0];
234  dx *= dx;
235  d2 = dx + dy + dz;
236  if ( d2 <= rmax2 && d2 >= rmin2 ) {
237  value = 0;
238  i = index(xx,yy,zz,nn);
239  for ( cc=0; cc<c; cc++, i++ ) {
240  value = (*this)[i];
241  sum += value;
242  ssum += value*value;
243  npx += 1;
244  if ( vmin > value ) vmin = value;
245  if ( vmax < value ) vmax = value;
246  }
247  }
248  }
249  }
250  }
251 
252  if ( npx ) {
253  vavg = sum/npx;
254  vstd = ssum/npx - vavg*vavg;
255  if ( vstd > 0 ) vstd = sqrt(vstd);
256  else vstd = 0;
257  }
258 
259  if ( verbose & VERB_STATS ) {
260  cout << "Data size: " << size() << "x" << c << "x" << n << "=" << w << endl;
261  cout << "Min, max, avg, std: " <<
262  vmin << " " << vmax << " " << vavg << " " << vstd << endl << endl;
263  }
264 
265  return npx;
266 }
267 
282 long Bimage::stats_in_shape(long nn, int type, Vector3<long> start,
283  Vector3<long> end, double& vavg, double& vstd)
284 {
285  int inc;
286  long i, xx, yy, zz, npx(0);
287  double a(1), b(1), c(1), fx, fy, fz;
288  double value, sum(0), sum2(0);
289 
290  if ( verbose & VERB_DEBUG ) {
291  cout << "DEBUG Bimage::stats_in_shape: start=" << start << endl;
292  cout << "DEBUG Bimage::stats_in_shape: end=" << end << endl;
293  }
294 
295  avg = std = 0;
296  if ( ( start[0] >= x ) && ( end[0] >= x ) ) return 0;
297  if ( ( start[1] >= y ) && ( end[1] >= y ) ) return 0;
298 // if ( ( start[2] >= z ) && ( end[2] >= z ) ) return 0;
299  start = start.max(0);
300  end = end.max(0);
301  if ( start[0] >= x ) start[0] = x - 1;
302  if ( start[1] >= y ) start[1] = y - 1;
303  if ( start[2] >= z ) start[2] = z - 1;
304  if ( end[0] >= x ) end[0] = x - 1;
305  if ( end[1] >= y ) end[1] = y - 1;
306  if ( end[2] >= z ) end[2] = z - 1;
307  if ( start[0] > end[0] ) swap(start[0], end[0]);
308  if ( start[1] > end[1] ) swap(start[1], end[1]);
309  if ( start[2] > end[2] ) swap(start[2], end[2]);
310 
311  Vector3<long> box = end - start;
313  if ( type == 2 ) {
314  if ( box[0] ) end[0] += 1;
315  if ( box[1] ) end[1] += 1;
316  if ( box[2] ) end[2] += 1;
317  }
318  box = end - start;
319  center = start + box/2.0;
320  if ( box[0] ) a = 2.0/box[0];
321  if ( box[1] ) b = 2.0/box[1];
322  if ( box[2] ) c = 2.0/box[2];
323 
324  if ( verbose & VERB_DEBUG ) {
325  cout << "DEBUG Bimage::stats_in_shape: start=" << start << endl;
326  cout << "DEBUG Bimage::stats_in_shape: end=" << end << endl;
327  cout << "DEBUG Bimage::stats_in_shape: center=" << center << endl;
328  }
329 
330  for ( npx=0, zz=start[2]; zz<=end[2]; zz++ ) {
331  fz = (zz - center[2]) * c;
332  fz *= fz;
333  for ( yy=start[1]; yy<=end[1]; yy++ ) {
334  fy = (yy - center[1]) * b;
335  fy *= fy;
336  for ( xx=start[0]; xx<=end[0]; xx++ ) {
337  fx = (xx - center[0]) * a;
338  fx *= fx;
339  inc = 1;
340  if ( type == 2 && fx + fy + fz > 1 ) inc = 0;
341  if ( inc ) {
342  i = index(0,xx,yy,zz,nn);
343  value = (*this)[i];
344  sum += value;
345  sum2 += value*value;
346  npx++;
347  }
348  }
349  }
350  }
351 
352  if ( npx ) {
353  vavg = sum/npx;
354  vstd = (sum2 - sum*sum/npx)/npx;
355  if ( vstd > 0 ) vstd = sqrt(vstd);
356  else vstd = 0;
357  }
358 
359  if ( verbose & VERB_DEBUG )
360  cout << "DEBUG Bimage::stats_in_shape: npx=" << npx << " avg=" << vavg << " vstd=" << std << endl;
361 
362  return npx;
363 }
364 
365 
366 
367 /*
368 @brief Determines if a vector is inside or outside a polyhedral structure.
369 @param vec vector to test for.
370 @param ndim number of dimensions.
371 @param nvert number of vertices.
372 @param *poly set of vertices.
373 @return double distance from closest edge (inside positive).
374 
375  Whether a point is inside or outside is based on the polygon edges.
376  First the normal to an edge is calculated and tested whether it points
377  inside or outside the polygon by finding the distance to the center:
378  dist_cent = normal . edge_vertex
379  which must be positive. Then the distance to the given point is:
380  dist = normal . (edge_vertex - point)
381  The minimum distance gives the distance of the point to the closest edge.
382  If this distance is positive, the point is inside the polygon.
383  Requirement: The polygon vertices must be given in order of connectivity.
384 **/
385 double vector3_inside_outside(Vector3<double> vec, int ndim, int nvert, Vector3<double>* poly)
386 {
387  int i, j;
388  double d, dmin;
389  Vector3<double> normal;
390 
391  // Find the closest edge
392  dmin = 1e30;
393  for ( i=0, j=1; i<nvert; i++, j++ ) {
394  if ( j >= nvert ) j = 0;
395  normal = poly[i] - poly[j];
396  normal = Vector3<double>(-normal[1], normal[0], 0);
397  normal.normalize();
398  if ( normal.scalar(poly[i]) < 0 ) normal = -normal;
399  d = normal.scalar(poly[i] - vec);
400  if ( dmin > d ) dmin = d;
401  }
402 
403  return dmin;
404 }
405 
419 long Bimage::stats_in_poly(long nn, int nvert, Vector3<double>* poly,
420  double& vavg, double& vstd)
421 {
422  int ndim, inc;
423  long i, xx, yy, zz, cc, npx(0);
424  long imgsize(x*y*z*c);
425  double value, d, dmin(1e30), dmax(0), sum(0), sum2(0);
426  Vector3<double> center, var, vec;
427 
428  for ( i=0; i<nvert; i++ ) center += poly[i];
429 
430  center /= nvert;
431 
432  for ( i=0; i<nvert; i++ ) {
433  poly[i] -= center;
434  var += poly[i]*poly[i];
435  d = poly[i].length();
436  if ( dmin > d ) dmin = d;
437  if ( dmax < d ) dmax = d;
438  }
439 
440  for ( i=0, ndim=0; i<3; i++ ) if ( var[i] > 0 ) ndim++;
441 
442  if ( verbose & VERB_DEBUG ) {
443  cout << "DEBUG Bimage::stats_in_poly: center=" << center << endl;
444  cout << "DEBUG Bimage::stats_in_poly: ndim=" << ndim << " dmin=" << dmin << " dmax=" << dmax << endl;
445  }
446 
447  for ( i = nn*imgsize, zz=0; zz<z; zz++ ) {
448  vec[2] = zz - center[2];
449  for ( yy=0; yy<y; yy++ ) {
450  vec[1] = yy - center[1];
451  for ( xx=0; xx<x; x++ ) {
452  vec[0] = xx - center[0];
453  d = vec.length();
454  inc = 0;
455  if ( d <= dmax ) {
456  if ( dmax == 0 ) inc = 1;
457  else if ( vector3_inside_outside(vec, ndim, nvert, poly) > 0 )
458  inc = 1;
459  }
460  for ( cc=0; cc<c; cc++, i++ ) if ( inc ) {
461  value = (*this)[i];
462  sum += value;
463  sum2 += value*value;
464  npx++;
465  }
466  }
467  }
468  }
469 
470  vavg = vstd = 0;
471  if ( npx ) {
472  vavg = sum/npx;
473  vstd = (sum2 - sum*sum/npx)/npx;
474  if ( vstd > 0 ) vstd = sqrt(vstd);
475  else vstd = 0;
476  }
477 
478  if ( verbose & VERB_DEBUG )
479  cout << "DEBUG Bimage::stats_in_poly: npx=" << npx << " vavg=" << vavg << " vstd=" << vstd << endl;
480 
481  return npx;
482 }
483 
490 long Bimage::stats_in_mask(long nn, Bimage* pmask)
491 {
492  if ( !pmask ) return 0;
493 
494  long nlevel = (long) (pmask->maximum() + 1.5);
495  long lev, i, j, imgsize(image_size());
496  double vavg, vstd;
497  long* cnt = new long[nlevel];
498  double* sum = new double[nlevel];
499  double* sum2 = new double[nlevel];
500 
501  for ( lev=0; lev<nlevel; lev++ ) sum[lev] = sum2[lev] = cnt[lev] = 0;
502 
503  for ( i=0, j=nn*imgsize; i<imgsize; i++, j++ ) {
504  lev = (long) ((*pmask)[i] + 0.5);
505  cnt[lev]++;
506  sum[lev] += (*this)[j];
507  sum2[lev] += (*this)[j] * (*this)[j];
508  }
509 
510  cout << "Level\tCount\tSum\tAverage\tStDev" << endl;
511  for ( lev=0; lev<nlevel; lev++ ) {
512  vavg = vstd = 0;
513  if ( cnt[lev] ) {
514  vavg = sum[lev]/cnt[lev];
515  vstd = sum2[lev]/cnt[lev] - vavg*vavg;
516  if ( vstd > 0 ) vstd = sqrt(vstd);
517  else vstd = 0;
518  }
519  cout << lev << tab << cnt[lev] << tab << sum[lev] << tab << vavg << tab << vstd << endl;
520  }
521 
522  return nlevel;
523 }
524 
525 int Bimage::kernel_sums(long nn, long i, long ik, long nk)
526 {
527  if ( size()[ik] < 2 ) return 0;
528 
529  if ( !next )
530  next = new Bimage(Float, TSimple, size(), n);
531 
532  long ii(i*x), j, j1, j2, inc(1);
533  long nl(size()[ik]), hk(nk/2), nv(0);
534  double s(0), s2(0);
535 
536  if ( ik == 1 ) {
537  ii = (i%x) + (i/x) * x * y;
538  inc = x;
539  } else if ( ik == 2 ) {
540  ii = i;
541  inc = x * y;
542  }
543 
544  ii += nn * x * y * z;
545 
546  double step = inc*hk;
547  vector<double> v(nl);
548  vector<double> v2(nl);
549 
550  // Initial sums
551  for ( j=ii, j1=0; j1<hk; j+=inc, j1++, nv++ ) {
552  s += (*this)[j];
553  s2 += (*next)[j];
554  }
555 
556  // Main sums
557  for ( j=ii, j1=0; j1<nl; j+=inc, j1++ ) {
558  if ( j1 < nl-hk ) { // Add the leading values
559  j2 = j + (long) step;
560  s += (*this)[j2];
561  s2 += (*next)[j2];
562  nv++;
563  }
564  v[j1] = s/nv;
565  v2[j1] = s2/nv;
566 // cout << j << " " << s << " " << s2 << endl;
567  if ( j1 >= hk ) { // Subtract the trailing values
568  j2 = j - (long) step;
569  s -= (*this)[j2];
570  s2 -= (*next)[j2];
571  nv--;
572  }
573  }
574 
575  for ( j=ii, j1=0; j1<nl; j+=inc, j1++ ) {
576  set(j, v[j1]);
577  next->set(j, v2[j1]);
578  }
579 
580 // cout << i << ": " << ii << " " << inc << " " << n << " " << s << " " << s2 << endl;
581 
582  return 0;
583 }
584 
585 int Bimage::line_sums(long nn, long ik, long nk)
586 {
587  if ( size()[ik] < 2 ) return 0;
588 
589  long i, nls(1);
590 
591  // Count the number of lines
592  for ( i=0; i<3; i++ ) if ( i != ik ) nls *= size()[i];
593 
594  if ( verbose & VERB_PROCESS )
595  cout << tab << "Axis " << ik << " of size " << nls << endl;
596 
597  // Do each line
598 #ifdef HAVE_GCD
599  dispatch_apply(nls, dispatch_get_global_queue(0, 0), ^(size_t i){
600  kernel_sums(nn, i, ik, nk);
601  });
602 #else
603 #pragma omp parallel for
604  for ( i=0; i<nls; i++ )
605  kernel_sums(nn, i, ik, nk);
606 #endif
607 
608  return 0;
609 }
610 
625 int Bimage::variance(long kernel_size, int flag)
626 {
627  if ( kernel_size < 3 ) kernel_size = 3;
628  if ( kernel_size > 999 ) kernel_size = 999;
629 
630  Vector3<long> hk(kernel_size/2, kernel_size/2, kernel_size/2);
631  if ( kernel_size > x ) hk[0] = x/2;
632  if ( kernel_size > y ) hk[1] = y/2;
633  if ( kernel_size > z ) hk[2] = z/2;
634  Vector3<long> k = hk*2 + 1;
635 
636  return variance(k, flag);
637 }
638 
653 int Bimage::variance(Vector3<long> kernel_size, int flag)
654 {
656 
657  kernel_size = kernel_size.max(1);
658  kernel_size = kernel_size.min(size());
659 
660  if ( verbose & VERB_PROCESS ) {
661  cout << "Calculating local variance:" << endl;
662  cout << "Kernel size: " << kernel_size << endl << endl;
663  }
664 
665  long i, nn;
666  next = new Bimage(Float, TSimple, size(), n);
667 
668  // Set up the square block
669  for ( i=0; i<datasize; i++ ) next->set(i, (*this)[i] * (*this)[i]);
670 
671  for ( nn=0; nn<n; nn++ ) {
672  if ( verbose & VERB_PROCESS )
673  cout << "Image " << nn << endl;
674  for ( i=0; i<3; i++ )
675  line_sums(nn, i, kernel_size[i]);
676  }
677 
678  if ( verbose & VERB_PROCESS )
679  cout << endl;
680 
681  double v;
682  for ( i=0; i<datasize; i++ ) {
683  v = (*this)[i];
684  if ( flag < 2 ) {
685  v = (*next)[i] - v*v;
686  if ( v < 0 ) v = 0;
687  if ( flag == 1 ) v = sqrt(v);
688  } else {
689  v = (*next)[i] - v*v - v;
690  }
691  set(i, v);
692  }
693 
694  delete next;
695  next = NULL;
696 
697  statistics();
698 
699  return 0;
700 }
701 
702 int Bimage::kernel_sums(long nn, long i, Bimage* pweight)
703 {
704  i += nn*image_size();
705 
706  long j, k, xx, yy, zz, kx, ky, kz;
707  double v, s(0), s2(0), w, ws(0);
708  Vector3<long> hk(pweight->size()/2);
709  Vector3<long> lo = kernel_low(i, hk);
710  Vector3<long> hi = kernel_high(i, hk);
711  Vector3<long> start = hk + lo - coordinates(i);
712  start = start.max(0);
713 
714 // cout << coordinates(i) << tab << lo << tab << hi << tab << start << endl;
715 
716  for ( zz=lo[2], kz=start[2]; zz<=hi[2]; zz++, kz++ ) {
717  for ( yy=lo[1], ky=start[1]; yy<=hi[1]; yy++, ky++ ) {
718  kx = start[0];
719  k = pweight->index(kx,ky,kz);
720  xx = lo[0];
721  j = index(0,xx,yy,zz,nn);
722  for ( ; xx<=hi[0]; xx++, k++, j++ ) {
723  w = (*pweight)[k];
724  if ( w > 1e-30 ) {
725  v = (*next)[j];
726  ws += w;
727  s += w*v;
728  s2 += w*v*v;
729  }
730  }
731  }
732  }
733 
734  if ( ws ) {
735  s /= ws;
736  s2 /= ws;
737  v = s2 - s*s;
738  if ( v < 0 ) v = 0;
739  } else v = 0;
740 
741  set(i, v);
742 
743  return 0;
744 }
745 
756 {
757  if ( !pweight ) return -1;
758 
760 
761  if ( verbose & VERB_PROCESS ) {
762  cout << "Calculating local variance:" << endl;
763  cout << "Weight image size: " << pweight->size() << endl << endl;
764  }
765 
766  long nn, imgsize(x*y*z);
767  next = copy();
768 
769  for ( nn=0; nn<n; nn++ ) {
770  if ( verbose & VERB_PROCESS )
771  cout << "Image " << nn << endl;
772  // Do each voxel
773 #ifdef HAVE_GCD
774  dispatch_apply(imgsize, dispatch_get_global_queue(0, 0), ^(size_t i){
775  kernel_sums(nn, i, pweight);
776  });
777 #else
778 #pragma omp parallel for
779  for ( long i=0; i<imgsize; i++ )
780  kernel_sums(nn, i, pweight);
781 #endif
782  }
783 
784  if ( verbose & VERB_PROCESS )
785  cout << endl;
786 
787  delete next;
788  next = NULL;
789 
790  statistics();
791 
792  return 0;
793 }
794 
795 
Bimage::coordinates
void coordinates(long i, long &nx, long &ny, long &nz)
Definition: Bimage.h:429
Bsub_image::average
double average()
Definition: Bimage.h:119
matrix_linear.h
Header file for matrix functions.
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:116
Complex
Definition: Complex.h:23
Bimage::set
void set(long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:1118
Bimage::next
Bimage * next
Definition: Bimage.h:179
Bsub_image::standard_deviation
double standard_deviation()
Definition: Bimage.h:120
Bimage::Bimage
Bimage()
Initializes an image.
Definition: Bimage.cpp:43
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2702
Bimage::center
int center(int fill_type=0, double fill=0)
Centers an image.
Definition: Bimage_transform.cpp:694
Bimage::variance
int variance(long kernel_size, int flag=0)
Calculates the local variance within the given kernel.
Definition: Bimage_stats.cpp:625
Vector3< double >
TypePointer::uc
unsigned char * uc
Definition: Bimage.h:70
Bimage::sum
void sum(long m, Bimage **p)
Sums an array of images with their FOM blocks.
Definition: Bimage_combine.cpp:23
Complex.h
Class for complex numbers.
TComplex
@ TComplex
Definition: Bimage.h:60
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:386
Vector3::scalar
double scalar(const Vector3 &v) const
Definition: Vector3.h:249
Bimage::image
Bsub_image * image
Definition: Bimage.h:202
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
Bimage::maximum
double maximum()
Definition: Bimage.h:542
Bsub_image::maximum
double maximum()
Definition: Bimage.h:118
Short
@ Short
Definition: utilities.h:156
TSimple
@ TSimple
Definition: Bimage.h:59
Vector3::normalize
double normalize()
Definition: Vector3.h:238
Bimage::file_name
string & file_name()
Definition: Bimage.h:246
Bimage::image_size
long image_size()
Definition: Bimage.h:290
Bimage::stats_in_poly
long stats_in_poly(long nn, int nvert, Vector3< double > *poly, double &vavg, double &vstd)
Calculates the statistics for an image within the given polyhedron.
Definition: Bimage_stats.cpp:419
TRGB
@ TRGB
Definition: Bimage.h:63
Bimage
General image parameter class.
Definition: Bimage.h:177
Vector3.h
Class for 3-value vectors.
Bimage::complex
Complex< double > complex(long j)
Returns a complex value at the given index.
Definition: Bimage.cpp:1027
Bimage.h
Header file for image class.
utilities.h
Header file for general utilities.
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:22
Complex::power
double power()
Definition: Complex.h:103
isfinite
bool isfinite(complex< T > &value)
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1765
Bimage::index
long index(long nx, long ny) const
Definition: Bimage.h:396
Bimage::stats_in_mask
long stats_in_mask(long nn, Bimage *pmask)
Calculates the statistics for an image for each level in a mask.
Definition: Bimage_stats.cpp:490
Bimage::kernel_high
Vector3< long > kernel_high(long i, long k=1)
Definition: Bimage.h:476
Bimage::show_minimum
double show_minimum()
Definition: Bimage.h:565
VERB_STATS
#define VERB_STATS
Definition: utilities.h:112
Vector3::min
Type min()
Definition: Vector3.h:169
Bimage::minimum
double minimum()
Definition: Bimage.h:541
vector3_inside_outside
double vector3_inside_outside(Vector3< double > vec, int ndim, int nvert, Vector3< double > *poly)
Definition: Bimage_stats.cpp:385
Bimage::show_maximum
double show_maximum()
Definition: Bimage.h:566
Vector3::length
double length()
Definition: Vector3.h:222
Bimage::kernel_low
Vector3< long > kernel_low(long i, long k=1)
Definition: Bimage.h:470
verbose
int verbose
Float
@ Float
Definition: utilities.h:161
Bsub_image::minimum
double minimum()
Definition: Bimage.h:117
Bimage::stats_within_radii
long stats_within_radii(long nn, Vector3< double > loc, double rad_min, double rad_max, double &vavg, double &vstd)
Calculates the statistics for an image within given radii from a location.
Definition: Bimage_stats.cpp:205
Bimage::statistics
long statistics()
Calculates the statistics for an image.
Definition: Bimage_stats.cpp:22
Bimage::stats_in_shape
long stats_in_shape(long nn, int type, Vector3< long > start, Vector3< long > end, double &vavg, double &vstd)
Calculates the statistics for an image within the given box.
Definition: Bimage_stats.cpp:282
Vector3::max
Type max()
Definition: Vector3.h:175