33 long i, j, xx, yy, zz, cc, nm(0);
34 double x2(0), y2(0), z2(0), r;
39 i = (long) (nn*x*y*z);
40 for ( zz=0; zz<z; zz++ ) {
42 z2 = (zz - ori[2])/h[2];
45 for ( yy=0; yy<y; yy++ ) {
47 y2 = (yy - ori[1])/h[1];
50 for ( xx=0; xx<x; xx++, i++ ) {
52 x2 = (xx - ori[0])/h[0];
56 if ( flag == 2 ) r = -r;
57 else if ( flag == 3 ) r = -r - 0.5;
63 for ( cc=0, j=i*c; cc<c; cc++, j++ ) {
76 cout <<
"DEBUG Bimage::calculate_background: img=" << nn <<
" nm=" << nm <<
98 cout <<
"Calculating the background values of all images" << endl << endl;
101 dispatch_apply(n, dispatch_get_global_queue(0, 0), ^(
size_t nn){
105 #pragma omp parallel for
106 for (
long nn=0; nn<n; nn++ )
128 if ( !pmask )
return -1;
132 long i(nn*x*y*z), j, k, m(0), cc, nm(0);
135 if ( pmask->n == n ) m = i;
138 for ( k=0; k<
image_size(); ++k, ++i, ++m )
if ( (*pmask)[m] > 0.5 ) {
139 for ( cc=0, j=i*c; cc<c; cc++, j++ ) bkg += (*
this)[j];
143 for ( k=0; k<
image_size(); ++k, ++i, ++m )
if ( (*pmask)[m] < 0.5 ) {
144 for ( cc=0, j=i*c; cc<c; cc++, j++ ) bkg += (*
this)[j];
152 cout <<
"DEBUG img_calculate_background: img=" << nn <<
" nm=" << nm <<
" bkg=" <<
image[nn].
background() << endl;
172 if ( !pmask )
return -1;
177 cout <<
"Calculating the background values of all images" << endl << endl;
180 dispatch_apply(n, dispatch_get_global_queue(0, 0), ^(
size_t nn){
184 #pragma omp parallel for
185 for (
long nn=0; nn<n; nn++ )
210 long i, j, xx, yy, zz, cc, nm(0);
211 double x2(0), y2(0), z2(0);
216 i = (long) (nn*x*y*z);
217 for ( zz=0; zz<z; zz++ ) {
219 z2 = (zz - ori[2])/h[2];
222 for ( yy=0; yy<y; yy++ ) {
224 y2 = (yy - ori[1])/h[1];
227 for ( xx=0; xx<x; xx++, i++ ) {
229 x2 = (xx - ori[0])/h[0];
232 if ( x2 + y2 + z2 > 1 ) {
233 for ( cc=0, j=i*c; cc<c; cc++, j++ ) {
243 cout <<
"DEBUG Bimage::correct_background: img=" << nn <<
" bkg=" << bkg << endl;
265 cout <<
"Correcting the background values of all images" << endl << endl;
268 dispatch_apply(n, dispatch_get_global_queue(0, 0), ^(
size_t nn){
272 #pragma omp parallel for
273 for (
long nn=0; nn<n; nn++ )
278 cerr <<
tab <<
"in Bimage::correct_background" << endl;
300 if ( !pmask )
return -1;
307 long i, j, k, m(0), nn, cc, nm;
311 cout <<
"Correcting the background values of all images" << endl << endl;
313 for ( i=nn=0; nn<n; nn++ ) {
314 if ( pmask->n == n ) m = i;
318 for ( k=0; k<
image_size(); ++k, ++i, ++m )
if ( (*pmask)[m] < 0.5 ) {
319 for ( cc=0, j=i*c; cc<c; cc++, j++ )
set(j, bkg);
325 cerr <<
tab <<
"in Bimage::correct_background" << endl;
357 long i, j, nn, imagesize = x*y*z;
364 cout <<
"Shifting the background values of all images to " << bkg << endl;
366 for ( nn=i=0; nn<n; nn++ ) {
371 for ( j=0; j<imagesize; i++, j++ ) {
385 cerr <<
tab <<
"in Bimage::shift_background" << endl;