 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
21 "Usage: bsplit [options] input.img output.img",
22 "--------------------------------------------",
23 "Splits multi-image files of the following formats:",
24 "Digital Instruments (di), Imagic (img), Image Magick (miff), PIF (pif)",
25 "SPIDER (spi), TIFF (tif), RAW (raw).",
26 "Files of single image 3D image formats can be split with the -images option.",
29 "-images Interpret slices of a single 3D image as 2D images.",
30 "-invert Invert density in the image.",
"-reslice -z+xy Reslice = switch axes (default xyz).",
31 "-select 1,5-13,122 Sub-images to select (first image = 0, default all).",
34 "-verbose 7 Verbosity of output.",
35 "-datatype u Force writing of a new data type.",
36 "-first 5 Number given to the first file (default 0).",
37 "-digits 3 Number of digits inserted before the last period in the output file name.",
42 int main(
int argc,
char **argv)
57 for ( curropt = option; curropt; curropt = curropt->
next ) {
58 if ( curropt->
tag ==
"images" )
60 if ( curropt->
tag ==
"invert" )
62 if ( curropt->
tag ==
"reslice" ) {
64 cerr <<
"-reslice: The order of x, y and z must be specified!" << endl;
66 order = curropt->
value;
70 if ( curropt->
tag ==
"select" ) {
71 select_list = curropt->
value;
72 if ( select_list.
length() < 1 )
73 cerr <<
"-select: Image numbers must be specified!" << endl;
75 if ( curropt->
tag ==
"datatype" )
77 if ( curropt->
tag ==
"first" )
79 cerr <<
"-first: A number must be specified!" << endl;
80 if ( curropt->
tag ==
"digits" )
82 cerr <<
"-digits: A number of digits must be specified!" << endl;
89 Bstring inputfile = argv[optind++];
92 cerr <<
"Error: No input file read!" << endl;
96 if ( optind >= argc )
bexit(0);
99 cout <<
"Splitting " << inputfile <<
" into " << p->
images() <<
" files" << endl;
102 Bstring outputfile = argv[optind];
104 if ( digits < 0.44*log(1.0*p->
images()) + 1 ) digits = (int) (0.44*log(1.0*p->
images()) + 1);
109 if ( setinvert ) p->
invert();
115 snprintf(format, 32,
"_%%0%dd.", digits);
116 for ( i=0; i<p->
images(); i++ )
if ( imgnum[i] ) {
121 if ( setreslice ) pone->
reslice(order);
124 cout <<
"Image " << i <<
": " << filename << endl;
A class for a command line input option.
void reslice(const char *order)
int bexit(int value)
Exit function for cleanup and debugging.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Header file for option handlers.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int main(int argc, char **argv)
int slices_to_images()
Changes the slices in a 3D image into a set of 2D images.
General image parameter class.
Utilities for timing functions.
Header file for the string class.
double timer_start()
Starts timer and prints the time.
Header file for general utilities.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for 2D and 3D image I/O.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
void invert()
Inverts the data in the image.
DataType
Base data type specifier.
int select_numbers(Bstring &string, int n, int *numsel)
Converts a string with a selection specification into an integer array.