 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
21 "Usage: badd [options] input.images",
22 "----------------------------------",
23 "Adds multiple images to generate a new composite image.",
24 "Any number of input images may be given and may include the wild card \"*\".",
25 "All images are converted to floating point.",
28 "-rescale -0.1,5.2 Rescale input images to average and standard deviation.",
29 "-average Output average image rather than the sum.",
30 "-std Output standard deviation image rather than variance image.",
31 "-center Center images before summation.",
34 "-verbose 7 Verbosity of output.",
35 "-datatype u Force writing of a new data type.",
36 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; a single value can be given).",
37 "-origin 0.8,-10,15.7 Set the origin (default from input image).",
38 "-weights 0.1,0.3,0.9 Weights for input files (default 1 for every file).",
41 "-output output.img Output image (default sum.map).",
42 "-fom fom.img Output variance/standard deviation image.",
45 "To sum three images with different weights:",
46 "badd -v 7 -rescale 0,1 -weights 0.5,1.2,0.87 -output new.pif in1.map in2.map in3.map",
48 "To output the standard deviation of the summed input images:",
49 "badd -v 7 -fom stdev.map -output sum.pif *.spi",
54 int main(
int argc,
char **argv)
62 double nuavg(0), nustd(0);
71 for ( curropt = option; curropt; curropt = curropt->
next ) {
72 if ( curropt->
tag ==
"rescale" )
73 if ( curropt->
values(nuavg, nustd) < 2 )
74 cerr <<
"-rescale: Both average and standard deviation must be specified" << endl;
75 if ( curropt->
tag ==
"average" ) flags |= 1;
76 if ( curropt->
tag ==
"std" ) flags |= 4;
77 if ( curropt->
tag ==
"center" ) flags |= 8;
78 if ( curropt->
tag ==
"datatype" )
80 if ( curropt->
tag ==
"sampling" )
81 sam = curropt->
scale();
82 if ( curropt->
tag ==
"origin" ) {
83 if ( curropt->
value[0] ==
'c' ) {
86 origin = curropt->
origin();
90 if ( curropt->
tag ==
"weights" ) {
91 weight_string = curropt->
value;
92 if ( weight_string.
length() < 1 )
93 cerr <<
"-weights: Weights for all files must be specified" << endl;
97 if ( curropt->
tag ==
"output" )
99 if ( curropt->
tag ==
"fom" ) {
107 cerr <<
"Error: No input files given!" << endl;
113 if ( optind >= argc ) {
114 cerr <<
"No input files!" << endl;
121 while ( optind < argc ) {
126 vector<double> weight;
129 if ( weight.size() < nfiles ) {
130 cerr <<
"Error: The number of weights must equal the number of input files" << endl;
141 else psum->
origin(origin);
A class for a command line input option.
Vector3< double > scale()
int string_kill(Bstring *list)
Kills a string linked list.
int bexit(int value)
Exit function for cleanup and debugging.
Vector3< double > default_origin()
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.
Vector3< double > origin()
long values(T1 &v1, T2 &v2)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Bimage * img_add_weighed(Bstring *file_list, vector< double > weight, double newavg=0, double newstd=0, int flags=0)
Adds multiple images together with given weights.
General image parameter class.
Utilities for timing functions.
int main(int argc, char **argv)
vector< double > split_into_doubles(const Bstring &delim)
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 origin(double ox, double oy, double oz)
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for 2D and 3D image I/O.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Header file for combining two images in various ways.
void sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.