31 if ( p->
sizeZ() < 2 )
return NULL;
33 if ( first < 0 ) first = 0;
34 if ( first > p->
sizeZ() ) first = p->
sizeZ() - 1;
36 unsigned long incr = 1;
37 if ( skip > 0 ) incr = skip + 1;
39 unsigned long i, j, x, y, c, z, z1, ix, iy, nx, ny;
42 cols = (int) (sqrt((1.0*p->
sizeZ() - first)/incr) + 0.99);
43 if ( cols*p->
sizeX() > 1500 ) cols = 1500/p->
sizeX();
44 if ( cols < 1 ) cols = 1;
45 if ( cols > (p->
sizeZ() - first)/incr ) cols = (p->
sizeZ() - first)/incr;
48 rows = ((p->
sizeZ() - first)/incr - 1)/cols + 1;
51 cout <<
"Creating a montage of " << cols <<
" x " << rows <<
" slices" << endl << endl;
56 for ( z=first, z1=cols*rows*incr + first; z<z1 && z<p->
sizeZ(); z+=incr ) {
57 ny = ((z - first)/incr)/cols;
58 if ( flipy ) ny = rows - ny - 1;
59 nx = (z - first)/incr - ny*cols;
60 for ( y=0; y<p->
sizeY(); y++ ) {
61 iy = y + p->
sizeY()*ny;
62 for ( x=0; x<p->
sizeX(); x++ ) {
63 ix = x + p->
sizeX()*nx;
66 for ( c=0; c<p->
channels(); c++, i++, j++ ) pm->
set(i, (*p)[j]);
92 if ( p->
sizeZ() > 1 || p->
images() < 2 )
return NULL;
94 if ( first < 0 ) first = 0;
97 unsigned long incr = 1;
98 if ( skip > 0 ) incr = skip + 1;
100 unsigned long i, j, x, y, c, n, n1, ix, iy, nx, ny;
103 cols = (int) (sqrt((1.0*p->
images() - first)/incr) + 0.99);
104 if ( cols*p->
sizeX() > 1500 ) cols = 1500/p->
sizeX();
105 if ( cols < 1 ) cols = 1;
106 if ( cols > (p->
images() - first)/incr ) cols = (p->
images() - first)/incr;
109 rows = ((p->
images() - first)/incr - 1)/cols + 1;
112 cout <<
"Creating a montage of " << cols <<
" x " << rows <<
" images" << endl << endl;
117 for ( n=first, n1=cols*rows*incr + first; n<n1 && n<p->
images(); n+=incr ) {
118 ny = ((n - first)/incr)/cols;
119 if ( flipy ) ny = rows - ny - 1;
120 nx = (n - first)/incr - ny*cols;
121 for ( y=0; y<p->
sizeY(); y++ ) {
122 iy = y + p->
sizeY()*ny;
123 for ( x=0; x<p->
sizeX(); x++ ) {
124 ix = x + p->
sizeX()*nx;
127 for ( c=0; c<p->
channels(); c++, i++, j++ ) pm->
set(i, (*p)[j]);
void sizeX(unsigned long nx)
CompoundType compound_type()
Functions to check and convert datatypes.
size_t statistics()
Calculates the statistics for an image.
Bimage * img_montage_images(Bimage *p, int first, int cols, int rows, int skip, int flipy)
Rearranges a 2D images into a 2D montage.
General image parameter class.
Functions to montage images for display.
void set(unsigned long j, double v)
Sets a single value at the given index.
Bimage * img_montage_slices(Bimage *p, int first, int cols, int rows, int skip, int flipy)
Rearranges a 3D image into a montage of 2D slices for display.
void sizeZ(unsigned long nz)
void sizeY(unsigned long ny)