| Bsoft 2.0.5 Bernard's software package

Bimage_rescale.cpp
Go to the documentation of this file.
1
9 #include "Bimage.h"
10 #include "utilities.h"
11
12 // Declaration of global variables
13 extern int verbose; // Level of output to the screen
14
27 int Bimage::rescale(double scale, double shift)
28 {
29 int err(0);
30 long i;
31 double v1;
32
33 if ( verbose & VERB_FULL )
34 cout << "Scale and shift: " << scale << " " << shift << endl << endl;
35
36 // Adjust the background values
37 for ( i=0; i<n; i++ )
38 background(i, background(i)*scale + shift);
39 // image[i].background(image[i].background()*scale + shift);
40
41 for ( i=0; i<datasize; i++ ) {
42 v1 = (*this)[i]*scale + shift;
43 set(i, v1);
44 }
45
46 if ( ( err = statistics() ) )
47 cerr << tab << "in Bimage::rescale" << endl;
48
49 return err;
50 }
51
62 int Bimage::rescale(long nn, double scale, double shift)
63 {
64 int err(0);
65 long i, j, imgsize(c*image_size());
66 double v1;
67
68 if ( verbose & VERB_FULL )
69 cout << "Scale and shift: " << scale << " " << shift << endl << endl;
70
71 // Adjust the background value
72 // image[nn].background(image[nn].background()*scale + shift);
73 image[nn].background(background(nn)*scale + shift);
74
75 for ( i=0, j=nn*imgsize; i<imgsize; i++, j++ ) {
76 v1 = (*this)[j] * scale + shift;
77 set(j, v1);
78 }
79
80 // if ( ( err = statistics() ) )
81 // cerr << tab << "in Bimage::rescale" << endl;
82
83 return err;
84 }
85
100 int Bimage::rescale_to_min_max(double numin, double numax)
101 {
102 if ( numin >= numax ) {
103 cerr << "Error in rescaling: minimum (" << numin << ") is greater than maximum ("
104 << numax << ") for " << file_name() << endl;
105 return -1;
106 }
107
108 double scale = (numax - numin)/(max - min);
109 double shift = numin - min*scale;
110
111 if ( verbose & VERB_FULL )
112 cout << "Rescaling to: " << numin << " " << numax << endl;
113
114 return rescale(scale, shift);
115 }
116
132 int Bimage::rescale_to_min_max(long nn, double numin, double numax)
133 {
134 if ( numin >= numax ) {
135 cerr << "Error in rescaling: minimum (" << numin << ") is greater than maximum ("
136 << numax << ") for " << file_name() << endl;
137 return -1;
138 }
139
140 double scale = (numax - numin)/(image[nn].maximum() - image[nn].minimum());
141 double shift = numin - image[nn].minimum()*scale;
142
143 if ( verbose & VERB_FULL )
144 cout << "Rescaling to: " << numin << " " << numax << endl;
145
146 return rescale(nn, scale, shift);
147 }
148
163 int Bimage::rescale_to_avg_std(double nuavg, double nustd)
164 {
165 if ( nustd < 0 ) {
166 cerr << "Warning: Cannot use a negative standard deviation to scale to! (" << nustd << ")" << endl;
167 return -1;
168 }
169
170 if ( std < 1e-30 ) if ( statistics() ) {
171 cerr << tab << "in Bimage::rescale_to_avg_std" << endl;
172 return -1;
173 }
174
175 double scale = (std>1e-30)? nustd/std: 1;
176 double shift = nuavg - avg*scale;
177
178 if ( verbose & VERB_FULL )
179 cout << "Rescaling to average and stdev: " << nuavg << " " << nustd << endl;
180
181 return rescale(scale, shift);
182 }
183
199 int Bimage::rescale_to_avg_std(long nn, double nuavg, double nustd)
200 {
201 if ( nustd < 0 ) {
202 cerr << "Warning: Cannot use a negative standard deviation to scale to! (" << nustd << ")" << endl;
203 return -1;
204 }
205
206 if ( std < 1e-30 ) if ( statistics() ) {
207 cerr << tab << "in Bimage::rescale_to_avg_std" << endl;
208 return -1;
209 }
210
211 double scale = (image[nn].standard_deviation()>1e-30)? nustd/image[nn].standard_deviation(): 1;
212 double shift = nuavg - image[nn].average()*scale;
213
214 if ( verbose & VERB_FULL )
215 cout << "Rescaling to average and stdev: " << nuavg << " " << nustd << endl;
216
217 return rescale(nn, scale, shift);
218 }
219
235 int Bimage::rescale_to_avg_std(double nuavg, double nustd, Bimage* pmask)
236 {
237 if ( nustd < 0 ) {
238 cerr << "Warning: Cannot use a negative standard deviation to scale to! (" << nustd << ")" << endl;
239 return -1;
240 }
241
242 double regavg(0), regstd(0);
243
244 statistics(pmask, regavg, regstd);
245
246 if ( regstd == 0 ) {
247 cerr << "Error in Bimage::rescale_to_avg_std: Region standard deviation is zero for "
248 << file_name() << "!" << endl;
249 return -1;
250 }
251
252 double scale = nustd/regstd;
253 double shift = nuavg - regavg*scale;
254
255 if ( verbose & VERB_FULL )
256 cout << "Rescaling to average and stdev: " << nuavg << " " << nustd << endl;
257
258 return rescale(scale, shift);
259 }
260
277 int Bimage::truncate(double minim, double maxim, double setmin, double setmax)
278 {
279 if ( !data_pointer() ) return -1;
280
281 long i;
282 double v1;
283
284 // Make sure the extremes don't exceed the data
285 if ( setmin < min ) setmin = min;
286 if ( setmax > max ) setmax = max;
287 if ( minim < dtmin ) minim = dtmin;
288 if ( maxim > dtmax ) maxim = dtmax;
289 if ( setmin < dtmin ) setmin = dtmin;
290 if ( setmax > dtmax ) setmax = dtmax;
291
292 // Adjust the background values
293 for ( i=0; i<n; i++ ) {
294 // if ( image[i].background() < minim ) image[i].background(setmin);
295 // if ( image[i].background() > maxim ) image[i].background(setmax);
296 if ( background(i) < minim ) background(i, setmin);
297 if ( background(i) > maxim ) background(i, setmax);
298 }
299
300 if ( verbose & VERB_PROCESS ) {
301 cout << "Truncating to: " << minim << " " << maxim << endl;
302 cout << "Min and max replacement values: " << setmin << " " << setmax << endl << endl;
303 }
304
305 for ( i=0; i<datasize; i++ ) {
306 v1 = (*this)[i];
307 if ( v1 < minim ) v1 = setmin;
308 if ( v1 > maxim ) v1 = setmax;
309 set(i, v1);
310 }
311
312 statistics();
313
314 return 0;
315 }
316
331 int Bimage::truncate_to_min_max(double minim, double maxim)
332 {
333 return truncate(minim, maxim, minim, maxim);
334 }
335
349 int Bimage::truncate_to_avg(double minim, double maxim)
350 {
351 return truncate(minim, maxim, avg, avg);
352 }
353
367 int Bimage::truncate_to_background(double minim, double maxim)
368 {
369 if ( !data_pointer() ) return -1;
370
371 long i, nn, n1, imgsize = x*y*z*n;
372 double v1, bkg;
373
374 // Make sure the extremes don't exceed the data
375 if ( minim < dtmin ) minim = dtmin;
376 if ( maxim > dtmax ) maxim = dtmax;
377
378 if ( verbose & VERB_PROCESS ) {
379 cout << "Truncating to background:" << endl;
380 cout << "Range: " << minim << " " << maxim << endl;
381 cout << "Image\tBackground" << endl;
382 }
383
384 // Adjust the background values
385 for ( nn=0; nn<n; nn++ ) {
386 // if ( image[nn].background() < minim ) image[nn].background(minim);
387 // if ( image[nn].background() > maxim ) image[nn].background(maxim);
388 // if ( verbose & VERB_PROCESS )
389 // cout << nn+1 << tab << image[nn].background() << endl;
390 bkg = background(nn);
391 if ( bkg < minim ) image[nn].background(minim);
392 if ( bkg > maxim ) image[nn].background(maxim);
393 if ( verbose & VERB_PROCESS )
394 cout << nn+1 << tab << background(nn) << endl;
395 }
396 if ( verbose & VERB_PROCESS )
397 cout << endl;
398
399 for ( nn=0; nn<n; nn++ ) {
400 // bkg = image[nn].background();
401 bkg = background(nn);
402 for ( i=nn*imgsize, n1=nn+imgsize; i<n1; i++ ) {
403 v1 = (*this)[i];
404 if ( v1 < minim ) v1 = bkg;
405 if ( v1 > maxim ) v1 = bkg;
406 set(i, v1);
407 }
408 }
409
410 statistics();
411
412 return 0;
413 }
414
426 int Bimage::limit_levels(int nlevels)
427 {
428 if ( !data_pointer() ) return -1;
429
430 if ( nlevels > 255 ) {
431 cerr << "Error: There should be less than 255 gray levels (" << nlevels << ")" << endl;
432 return -1;
433 }
434
435 if ( verbose & VERB_PROCESS )
436 cout << "Limiting levels to: " << nlevels << endl << endl;
437
438 long i;
439 double unit = 255.0/(nlevels - 1);
440 double scale = 0.999*nlevels/(max - min);
441
442 unsigned char* nudata = new unsigned char[datasize];
443
444 if ( verbose & VERB_LABEL )
445 cout << "Restricting to " << nlevels << " levels." << endl << endl;
446
447 for ( i=0; i<datasize; i++ )
448 nudata[i] = (unsigned char) (unit*floor(((*this)[i] - min)*scale));
449
450 data_type(UCharacter);
451
452 data_assign((unsigned char *) nudata);
453
454 statistics();
455
456 return 0;
457 }
458
481 int Bimage::normalize(long imgnum, double average, double stdev, int norm_type, long bins)
482 {
483 Bplot* plot = NULL;
484
485 Bimage* ptemp = extract(imgnum);
486
487 ptemp->statistics();
488
489 ptemp->truncate_to_min_max(ptemp->average() - 10*ptemp->standard_deviation(), ptemp->average() + 10*ptemp->standard_deviation());
490
491 switch ( norm_type ) {
492 case 1:
493 plot = ptemp->histogram_gauss_plot(bins, 1);
494 break;
495 case 2:
496 plot = ptemp->histogram_poisson_fit(bins, 1);
497 break;
498 default:
499 ptemp->statistics();
500 }
501
502 ptemp->rescale_to_avg_std(average, stdev);
503
504 // if ( img_rescale_to_avg_std(ptemp, average, stdev) )
505 // cerr << "Error: The extrema for image " << imgnum+1 << " are the same: " <<
506 // ptemp->minimum() << " " << ptemp->maximum() << endl;
507
508 replace(imgnum, ptemp);
509
510 delete ptemp;
511 if ( plot ) delete plot;
512
513 return 0;
514 }
515
536 int Bimage::normalize(double average, double stdev, int norm_type)
537 {
538 int bins = (int) max;
539 if ( bins < 256 ) bins = 256;
540 if ( bins > 1024 ) bins = 1024;
541
542 if ( stdev <= 0 ) { // Defaults
543 switch ( datatype ) {
544 case UCharacter: average = 127; stdev = 40; break;
545 case SCharacter: average = 0; stdev = 40; break;
546 case UShort: average = USHRT_MAX/2; stdev = 256; break;
547 case Short: average = 0; stdev = 256; break;
548 case UInteger: average = 100000; stdev = 1000; break;
549 case Integer: average = 0; stdev = 1000; break;
550 case ULong: average = 100000; stdev = 1000; break;
551 case Long: average = 0; stdev = 1000; break;
552 default: average = 0; stdev = 1; break;
553 }
554 }
555
556 change_type(Float);
557
558 if ( verbose & VERB_PROCESS ) {
559 cout << "Mass normalizing ";
560 if ( file_name().length() ) cout << file_name() << endl;
561 else cout << endl;
562 cout << "Normalizing type: ";
563 switch ( norm_type ) {
564 case 1: cout << "Gaussian"; break;
565 case 2: cout << "Poisson"; break;
566 default: cout << "Simple";
567 }
568 cout << endl << "Average and standard deviation: " << average << " " << stdev << endl;
569 }
570
571 #ifdef HAVE_GCD
572 // dispatch_queue_t myq = dispatch_queue_create(NULL, NULL);
573 dispatch_apply(n, dispatch_get_global_queue(0, 0), ^(size_t nn){
574 normalize(nn, average, stdev, norm_type, bins);
575 // dispatch_sync(myq, ^{
576 // if ( verbose & VERB_FULL )
577 // cout << "Image " << nn << " normalized" << endl;
578 // });
579 });
580 #else
581 #pragma omp parallel for
582 for ( long nn=0; nn<n; nn++ ) {
583 normalize(nn, average, stdev, norm_type, bins);
584 // #pragma omp critical
585 // {
586 // if ( verbose & VERB_FULL )
587 // cout << "Image " << nn << " normalized" << endl;
588 // }
589 }
590 #endif
591
592 calculate_background();
593 statistics();
594
595 return 0;
596 }
597
608 int Bimage::normalize_local(long kernel_size)
609 {
610 Vector3<long> kernel(kernel_size, kernel_size, kernel_size);
611
612 return normalize_local(kernel);
613 }
614
625 int Bimage::normalize_local(Vector3<long> kernel)
626 {
627 change_type(Float);
628
629 kernel = kernel.max(1);
630 kernel = kernel.min(size());
631
632 Bimage* pc = copy();
633
634 if ( verbose )
635 cout << "Normalizing with a kernel size of " << kernel.volume() << endl << endl;
636
637 long i, nn;
638 pc->next = new Bimage(Float, TSimple, size(), n);
639
640 // Set up the square block
641 for ( i=0; i<datasize; i++ ) pc->next->set(i, (*pc)[i] * (*pc)[i]);
642
643 for ( nn=0; nn<n; nn++ ) {
644 if ( verbose & VERB_PROCESS )
645 cout << "Image " << nn << endl;
646 for ( i=0; i<3; i++ )
647 pc->line_sums(nn, i, kernel[i]);
648 }
649
650 if ( verbose & VERB_PROCESS )
651 cout << endl;
652
653 double v, s;
654 for ( i=0; i<datasize; i++ ) {
655 v = (*pc)[i];
656 s = (*pc->next)[i] - v*v;
657 if ( s > 0 ) {
658 s = sqrt(s);
659 v = ((*this)[i] - v)/s;
660 } else v = 0;
661 set(i, v);
662 }
663
664 delete pc;
665
666 statistics();
667
668 return 0;
669 }
670
678 void Bimage::square()
679 {
680 double v;
681
682 for ( long j=0; j<datasize; j++ ) {
683 v = (*this)[j];
684 v *= v;
685 set(j, v);
686 }
687
688 statistics();
689 }
690
698 void Bimage::square_root()
699 {
700 double v;
701
702 for ( long j=0; j<datasize; j++ ) {
703 v = (*this)[j];
704 if ( v > 0 ) v = sqrt(v);
705 else v = 0;
706 set(j, v);
707 }
708
709 statistics();
710 }
711
728 void Bimage::logarithm()
729 {
730 if ( compoundtype == TComplex ) complex_to_intensities();
731
732 if ( datatype < Float ) change_type(Float);
733
734 double fudge = (avg - min)/1000;
735 double norm = 1.0/(avg - min + fudge);
736
737 for ( long i=0; i<datasize; i++ )
738 set(i, log(((*this)[i] - min + fudge)*norm));
739
740 statistics();
741 }
742
752 int Bimage::gradient_correction()
753 {
754 change_type(Float);
755
756 long i, j, nn, xx, yy, zz;
757 double v;
758 vector<double> b(4);
759 Matrix a(4,4), a2(4,4);
760
761 if ( verbose & VERB_PROCESS ) {
762 cout << "Correcting the image linear gradient:" << endl;
763 cout << "Image\tb0\tb1\tb2\tb3" << endl;
764 }
765
766 // Precalculate the a matrix which depends only on the size
767 // Keep it like this in case we want to use a mask later
768 for ( zz=0; zz<z; zz++ ) {
769 for ( yy=0; yy<y; yy++ ) {
770 for ( xx=0; xx<x; xx++ ) {
771 a[0][0] += 1;
772 a[0][1] += xx;
773 a[0][2] += yy;
774 a[0][3] += zz;
775 a[1][1] += xx*xx;
776 a[1][2] += xx*yy;
777 a[1][3] += xx*zz;
778 a[2][2] += yy*yy;
779 a[2][3] += yy*zz;
780 a[3][3] += zz*zz;
781 }
782 }
783 }
784 for ( i=1; i<4; i++ ) {
785 for ( j=0; j<i; j++ )
786 a[i][j] = a[j][i];
787 if ( a[i][i] < 1 ) a[i][i] = 1; // The diagonals cannot be zero
788 }
789
790 for ( nn=0; nn<n; nn++ ) {
791 for ( i=0; i<4; i++ ) b[i] = 0;
792 a2 = a;
793 for ( i = nn*x*y*z, zz=0; zz<z; zz++ ) {
794 for ( yy=0; yy<y; yy++ ) {
795 for ( xx=0; xx<x; xx++, i++ ) {
796 v = (*this)[i];
797 b[0] += v;
798 b[1] += v*xx;
799 b[2] += v*yy;
800 b[3] += v*zz;
801 }
802 }
803 }
804 a2.LU_decomposition(b);
805 if ( verbose & VERB_PROCESS )
806 cout << n << tab << b[0] << tab << b[1] << tab << b[2] << tab << b[3] << endl;
807 for ( i = nn*x*y*z, zz=0; zz<z; zz++ ) {
808 for ( yy=0; yy<y; yy++ ) {
809 for ( xx=0; xx<x; xx++, i++ ) {
810 v = (*this)[i] - (b[0] + b[1]*xx + b[2]*yy + b[3]*zz);
811 set(i, v);
812 }
813 }
814 }
815 }
816
817 return 0;
818 }
819
826 int Bimage::quadric_correct(vector<double> param)
827 {
828 long i, xx, yy, zz, nn;
829 double dx, dy, dz, v;
830
831 param[0] -= average();
832
833 for ( i=nn=0; nn<n; nn++ ) {
834 for ( zz=0; zz<z; zz++ ) {
835 // dz = -image[nn].origin()[2] + zz;
836 dz = -image[nn].origin()[2] + zz;
837 for ( yy=0; yy<y; yy++ ) {
838 // dy = -image[nn].origin()[1] + yy;
839 dy = -image[nn].origin()[1] + yy;
840 for ( xx=0; xx<x; xx++, i++ ) {
841 // dx = -image[nn].origin()[0] + xx;
842 dx = -image[nn].origin()[0] + xx;
843 v = param[0] + dx*param[1] + dy*param[2] + dz*param[3]
844 + dx*dx*param[4] + dy*dy*param[5] + dz*dz*param[6];
845 add(i, -v);
846 }
847 }
848 }
849 }
850
851 return 0;
852 }
853
862 vector<double> Bimage::quadric_fit()
863 {
864 long i, j, nn, nterm(7);
865 long xx, yy, zz;
866 double dx, dy, dz;
867 Matrix a(nterm,nterm);
868 vector<double> b(nterm);
869 vector<double> vec(nterm);
870
871 for ( nn=0; nn<n; nn++ ) {
872 for ( i=0; i<nterm; i++ ) { // Clear the matrix and vector
873 for ( j=0; j<nterm; j++ ) a[i][j] = 0;
874 b[i] = 0;
875 }
876 vec[0] = 1;
877 for ( zz=0; zz<z; zz++ ) {
878 dz = -image[nn].origin()[2] + zz;
879 vec[3] = dz;
880 vec[6] = dz*dz;
881 for ( yy=0; yy<y; yy++ ) {
882 dy = -image[nn].origin()[1] + yy;
883 vec[2] = dy;
884 vec[5] = dy*dy;
885 for ( xx=0; xx<x; xx++ ) {
886 dx = -image[nn].origin()[0] + xx;
887 vec[1] = dx;
888 vec[4] = dx*dx;
889 i = index(0,xx,yy,zz,nn);
890 for ( j=0; j<nterm; j++ ) b[j] += vec[j]*(*this)[i];
891 for ( i=0; i<nterm; i++ )
892 for ( j=0; j<=i; j++ ) a[i][j] += vec[i]*vec[j];
893 }
894 }
895 }
896 for ( i=0; i<nterm-1; i++ )
897 for ( j=i+1; j<nterm; j++ ) a[i][j] = a[j][i];
898 for ( i=0; i<nterm; i++ )
899 if ( fabs(a[i][i]) < 1e-37 ) a[i][i] = 1;
900 a.LU_decomposition(b);
901 if ( verbose & VERB_PROCESS )
902 cout << "Quadric coefficients: " <<
903 b[0] << tab << b[1] << tab << b[2] << tab << b[3] << tab << b[4] << tab << b[5] << tab << b[6] << endl << endl;
904 }
905
906 return b;
907 }
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1743
Bimage::replace
int replace(Bimage *img)
Replaces the data with that from the given image.
Definition: Bimage.cpp:2828
Bimage::square
void square()
Calculates the square of an image.
Definition: Bimage_rescale.cpp:678
Bimage::quadric_fit
vector< double > quadric_fit()
Fits the whole image to a quadric surface.
Definition: Bimage_rescale.cpp:862
Bimage.h
Header file for image class.
Bimage::rescale_to_min_max
int rescale_to_min_max(double numin, double numax)
Rescales the image data to a given minimum and maximum.
Definition: Bimage_rescale.cpp:100
Bimage::add
void add(long j, double v)
Definition: Bimage.h:308
Bimage::file_name
string & file_name()
Definition: Bimage.h:231
Bimage::normalize
int normalize(long imgnum, double average, double stdev, int norm_type, long bins)
Normalizes a sub-image to a desired average and standard deviation.
Definition: Bimage_rescale.cpp:481
Bimage::image_size
long image_size()
Definition: Bimage.h:267
utilities.h
Header file for general utilities.
Bsub_image::background
double background()
Definition: Bimage.h:121
Integer
Definition: utilities.h:154
Bimage::index
long index(long nx, long ny) const
Definition: Bimage.h:383
SCharacter
Definition: utilities.h:150
Bimage::logarithm
void logarithm()
Calculates the logarithm of the image data.
Definition: Bimage_rescale.cpp:728
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
Bimage::truncate_to_min_max
int truncate_to_min_max(double minim, double maxim)
Truncates image data to a given minimum and maximum.
Definition: Bimage_rescale.cpp:331
verbose
int verbose
Long
Definition: utilities.h:156
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
Bimage::histogram_gauss_plot
Bplot * histogram_gauss_plot(long bins, long ngauss=1)
Fits a gaussian function to a histogram of an image.
Definition: Bimage_histogram.cpp:695
Bimage::rescale
int rescale(double scale, double shift)
Rescales the image data with a given multiplier and offset.
Definition: Bimage_rescale.cpp:27
Bimage
General image parameter class.
Definition: Bimage.h:163
UInteger
Definition: utilities.h:153
Matrix::LU_decomposition
double LU_decomposition()
Matrix inversion by LU decomposition.
Definition: matrix.cpp:78
Bimage::extract
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Definition: Bimage_extract.cpp:21
Bimage::shift
int shift(Vector3< double > vec, int fill_type=0, double fill=0)
Shifts an image.
Definition: Bimage_transform.cpp:587
Bimage::maximum
double maximum()
Definition: Bimage.h:535
Bimage::statistics
long statistics()
Calculates the statistics for an image.
Definition: Bimage_stats.cpp:22
Bimage::histogram_poisson_fit
Bplot * histogram_poisson_fit(long bins, int flag=0)
Fits a poisson function to a histogram of an image.
Definition: Bimage_histogram.cpp:965
Bimage::data_assign
unsigned char * data_assign(unsigned char *nudata)
Assign image data.
Definition: Bimage.cpp:852
ULong
Definition: utilities.h:155
length
double length(vector< T > v)
Definition: Vector3.h:528
Bimage::rescale_to_avg_std
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.
Definition: Bimage_rescale.cpp:163
Bimage::limit_levels
int limit_levels(int nlevels)
Converts a full gray scale image to a limited level image.
Definition: Bimage_rescale.cpp:426
Bimage::complex_to_intensities
void complex_to_intensities()
The intensities from a complex image is written to a simple image.
Definition: Bimage_complex.cpp:92
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:373
Bimage::calculate_background
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Definition: Bimage_background.cpp:27
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:127
Bimage::standard_deviation
double standard_deviation()
Definition: Bimage.h:537
Bimage::average
double average()
Definition: Bimage.h:536
Bimage::set
void set(long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:1096
Bimage::next
Bimage * next
Definition: Bimage.h:165
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:261
Matrix
Definition: Matrix.h:21
UCharacter
Definition: utilities.h:149
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2695
Bimage::truncate_to_background
int truncate_to_background(double minim, double maxim)
Sets voxels in image data exceeding a given minimum and maximum to the image background.
Definition: Bimage_rescale.cpp:367
Bsub_image::minimum
double minimum()
Definition: Bimage.h:113
Bimage::gradient_correction
int gradient_correction()
Calculates and corrects for a linear gradient across an image.
Definition: Bimage_rescale.cpp:752
Vector3< long >
Bimage::truncate
int truncate(double minim, double maxim, double setmin, double setmax)
Truncates image data to a given minimum and maximum.
Definition: Bimage_rescale.cpp:277
Bimage::truncate_to_avg
int truncate_to_avg(double minim, double maxim)
Sets voxels in image data exceeding a given minimum and maximum to the average.
Definition: Bimage_rescale.cpp:349
Bimage::average
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Definition: Bimage.cpp:1349
Short
Definition: utilities.h:152
Bsub_image::average
double average()
Definition: Bimage.h:115
kernel
Definition: kernlut.h:13
UShort
Definition: utilities.h:151
Bimage::plot
Bplot * plot()
Converts a one-dimensional image into a plot.
Definition: Bimage.cpp:3836
Bimage::quadric_correct
int quadric_correct(vector< double > param)
Corrects for a quadric surface.
Definition: Bimage_rescale.cpp:826
VERB_FULL
#define VERB_FULL
Definition: utilities.h:109
Bimage::background
double background(long nn)
Definition: Bimage.h:542
VERB_LABEL
#define VERB_LABEL
Definition: utilities.h:106
Bimage::data_type
DataType data_type()
Definition: Bimage.h:349
Bimage::square_root
void square_root()
Calculates the square root of an image.
Definition: Bimage_rescale.cpp:698
Bsub_image::standard_deviation
double standard_deviation()
Definition: Bimage.h:116
Bimage::normalize_local
int normalize_local(long kernel_size)
Normalizes by subtracting local average and dividing by local standard deviation.
Definition: Bimage_rescale.cpp:608
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:21
Bimage::image
Bsub_image * image
Definition: Bimage.h:188
Bplot
Definition: Bplot.h:146