14 int Bimage::montage_one(
Bimage* pm,
long zz,
long mi,
long cols,
long rows,
int flip)
16 long i, j, xx, yy, ix, iy, cc;
18 long nx = mi - ny*cols;
20 if ( flip & 1 ) nx = cols - nx - 1;
21 if ( flip & 2 ) ny = rows - ny - 1;
26 for ( j=zz*y*x*c, yy=0, iy=ny*pm->x; yy<y; yy++, iy+=pm->x ) {
27 for ( xx=0, ix=nx; xx<x; xx++, ix++ ) {
29 for ( cc=0; cc<c; cc++, i++, j++ ) pm->
set(i, (*
this)[j]);
51 if ( first < 0 ) first = 0;
52 if ( first > n*z ) first = n*z - 1;
55 if ( skip > 0 ) incr = skip + 1;
58 cols = (int) (sqrt((1.0*n*z - first)/incr) + 0.99);
59 if ( cols*x > 1500 ) cols = 1500/x;
60 if ( cols < 1 ) cols = 1;
61 if ( cols > (n*z - first)/incr ) cols = (n*z - first)/incr;
64 rows = ((n*z - first)/incr - 1)/cols + 1;
67 cout <<
"Creating a montage of " << cols <<
" x " << rows <<
" slices" << endl << endl;
69 Bimage* pm =
new Bimage(datatype, compoundtype, cols*x, rows*y, 1, 1);
74 dispatch_apply(cols*rows, dispatch_get_global_queue(0, 0), ^(
size_t i){
75 long zz(first+i*incr);
76 if ( zz < n*z ) montage_one(pm, zz, i, cols, rows, flip);
79 #pragma omp parallel for
80 for (
long i=0; i<cols*rows; i++ ) {
81 long zz(first+i*incr);
82 if ( zz < n*z ) montage_one(pm, zz, i, cols, rows, flip);