 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
23 "Usage: baddmask [options] input.images",
24 "--------------------------------------",
25 "Adds multiple masks to generate a new composite mask.",
26 "Any number of input images may be given and may include the wild card \"*\".",
29 "-type bit Type of composite mask: uniform/bit/level.",
32 "-verbose 7 Verbosity of output.",
33 "-datatype u Force writing of a new data type.",
34 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; a single value can be given).",
35 "-origin 0.8,-10,15.7 Set the origin (default from input image).",
38 "-output output.img Output image (default sum.map).",
43 int main(
int argc,
char **argv)
56 for ( curropt = option; curropt; curropt = curropt->
next ) {
57 if ( curropt->
tag ==
"type" ) {
58 if ( curropt->
value[0] ==
'u' ) mask_type = 1;
59 if ( curropt->
value[0] ==
'b' ) mask_type = 2;
60 if ( curropt->
value[0] ==
'l' ) mask_type = 3;
62 if ( curropt->
tag ==
"datatype" )
64 if ( curropt->
tag ==
"sampling" )
65 sam = curropt->
scale();
66 if ( curropt->
tag ==
"origin" ) {
67 if ( curropt->
value[0] ==
'c' ) {
70 origin = curropt->
origin();
74 if ( curropt->
tag ==
"output" )
80 cerr <<
"Error: No input files given!" << endl;
86 if ( optind >= argc ) {
87 cerr <<
"No input files!" << endl;
94 while ( optind < argc ) {
100 vector<double> weight;
102 switch ( mask_type ) {
119 else pmask->
origin(origin);
123 if ( maskfile.
length() ) {
152 if ( !pmask )
return NULL;
158 int val, bit, base_bit;
159 long i, j, n, nf, nfiles(0), base_level, max_level;
161 for ( nfiles=0, filename = file_list; filename; filename = filename->
next ) nfiles++;
164 if ( mask_type == 2 )
165 cout <<
"Generating a multi-bit mask from " << nfiles <<
" images:" << endl;
167 cout <<
"Generating a multi-level mask from " << nfiles <<
" images:" << endl;
171 cout <<
"New mask size: " << pmask->
size() << endl;
175 for ( nf=0, base_bit=0, base_level=max_level=0, filename = file_list;
176 filename && nf<nfiles; filename = filename->
next, nf++ ) {
180 cout <<
"Adding mask " << nf << endl;
182 for ( n=j=0; n<p->
images(); n++ ) {
184 for ( i=0; i<imgsize; i++, j++ ) {
185 if ( (*p)[j] > 0.5 ) {
186 val = (int) ((*p)[j] + 0.5);
187 if ( mask_type == 2 ) {
189 if ( base_bit > 0 ) bit <<= base_bit;
190 pmask->
set(j, (
char)(*pmask)[j] | bit);
192 pmask->
set(j, base_level + val);
194 if ( max_level < (*pmask)[j] ) max_level = (
int) (*pmask)[j];
199 for ( base_bit = 0, val = max_level; val > 0; val >>= 1, base_bit++ ) ;
200 base_level = max_level;
A class for a command line input option.
Vector3< double > scale()
int main(int argc, char **argv)
int string_kill(Bstring *list)
Kills a string linked list.
void set(long j, double v)
Sets a single value at the given index.
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.
Vector3< long > size() const
Header file for option handlers.
Vector3< double > origin()
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
void origin(double x, double y, double z)
Bimage * img_setup_combined(Bstring *file_list, long &nimg, int cat=0)
Sets up a list of images for concatenation or summation.
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.
long mask_stats()
Calculates statistics for a mask.
General image parameter class.
Utilities for timing functions.
int truncate_to_min_max(double minim, double maxim)
Truncates image data to a given minimum and maximum.
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.
Bimage * img_composite_mask(Bstring *file_list, int mask_type)
Generates a composite of multiple masks.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
long statistics()
Calculates the statistics for an image.