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