23 "Usage: blevel [options] input.img output.img",
24 "--------------------------------------------",
25 "Manipulates level masks.",
26 "The input image is considered to have multiple integer levels (even for floating point).",
28 "Actions for mask creation:",
29 "-invert Invert density before other operations.",
30 "-threshold 1.34 Generate a level mask from disjoint regions (inverted threshold with -invert).",
31 "-bands 250,-1,150,1,30,0 Banded mask for reciprocal space (pairs of numbers: angstrom,value).",
32 " Band with 0: Not used.",
33 " Band with 1: Use for orientation determination.",
34 " Band with -1: Use for cross-validation.",
36 "Actions for mask modification:",
37 "-level 134 Convert a mask to multiple levels, with the given voxels per level.",
38 "-symmetry C5 Set all symmetry-related segments to the same index.",
39 "-color size Generate a RGBA image (random/size).",
40 "-size Convert level mask to region size map.",
41 "-dilate 2 Dilate the level mask.",
42 "-add mask.pif,3 Add a bilevel mask to the indicated level (default 1).",
43 "-select 1,5-7 Select levels in a multi-level mask.",
44 "-voxel 23,241,193 Select the level including this voxel.",
45 "-collapse Convert a multi-level mask to a binary mask.",
48 "-verbose 1 Verbosity of output.",
49 "-datatype u Force writing of a new data type.",
50 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; a single value can be given).",
51 "-origin 110,50,44 Origin for the mask (default from input image).",
55 "-Mask file.img Template mask to select levels.",
58 "-Postscript his.ps Output plot file of level size histogram.",
63 int main(
int argc,
char **argv)
67 double threshold(-1e37);
90 for ( curropt = option; curropt; curropt = curropt->
next ) {
91 if ( curropt->
tag ==
"invert" )
93 if ( curropt->
tag ==
"threshold" )
94 if ( ( threshold = curropt->
value.
real() ) < -1e30 )
95 cerr <<
"-threshold: A threshold value must be specified!" << endl;
96 if ( curropt->
tag ==
"color" )
97 color = curropt->
value;
98 if ( curropt->
tag ==
"size" )
100 if ( curropt->
tag ==
"dilate" )
102 cerr <<
"-dilate: A number of times to dilate must be specified!" << endl;
103 if ( curropt->
tag ==
"collapse" )
105 if ( curropt->
tag ==
"add" ) {
109 if ( curropt->
tag ==
"select" ) {
110 level_select = curropt->
value;
111 if ( level_select.
length() < 1 )
112 cerr <<
"-select: Level numbers must be specified!" << endl;
114 if ( curropt->
tag ==
"voxel" )
115 voxel = curropt->
size();
116 if ( curropt->
tag ==
"level" )
118 cerr <<
"-level: The voxels per level must be specified!" << endl;
119 if ( curropt->
tag ==
"bands" ) {
121 if ( band.size() < 2 )
122 cerr <<
"-bands: At least two pairs of numbers must be specified!" << endl;
123 band[band.size()] = 0;
125 if ( curropt->
tag ==
"symmetry" )
127 if ( curropt->
tag ==
"datatype" )
129 if ( curropt->
tag ==
"sampling" )
130 sam = curropt->
scale();
131 if ( curropt->
tag ==
"origin" ) {
132 if ( curropt->
value[0] ==
'c' ) {
135 origin = curropt->
origin();
139 if ( curropt->
tag ==
"Mask" )
141 if ( curropt->
tag ==
"Postscript" )
149 if ( p == NULL )
bexit(-1);
158 if ( invert ) p->
invert();
162 if ( threshold > -1e30 ) {
163 pmask = p->
regions(threshold, 1);
168 if ( add_mask.
length() ) {
187 if ( mask_file.
length() ) {
211 if ( optind < argc ) {
void change_type(char letter)
Get the data type indicated by a single letter code.
DataType
Base data type specifier.
void invert()
Inverts the data in the image.
Header file for general symmetry functions.
long mask_stats()
Calculates statistics for a mask.
Bimage * regions(double threshold, int sign)
Segments an image into contiguous regions.
int levelmask_region_size()
Convert a mask to reflect region sizes.
Header file for general utilities.
long levelmask_add(Bimage *pmask, int add_level=1)
Adds a bilevel mask to a level mask.
int mask_fspace_banded(vector< double > &band)
Generate reciprocal space mask based on a specification of bands.
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
string get_cmd_line(int argc, char **argv)
Returns the command line as a string.
Utilities for timing functions.
long levelmask_collapse()
Collapse a multi-level mask to a binary mask.
General image parameter class.
int main(int argc, char **argv)
bool contains(const Bstring &s)
A class for a command line input option.
Header file for combining two images in various ways.
long mask_symmetrize(Bsymmetry *sym)
Symetrizes a mask.
Vector3< double > scale()
long levelmask_select(Bstring &select_list)
Retains the selected levels in a multi-level mask.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
vector< double > split_into_doubles(const Bstring &delim)
long mask_split(long voxels_per_level)
Converts a mask to a multilevel mask with a given number of voxels per level.
Bimage * levelmask_color_by_size()
Color a multi-level mask based on the volumes of regions.
void sampling(long nn, Vector3< double > u)
Vector3< double > default_origin()
Vector3< double > origin()
double timer_report(double lasttime)
Reports the time elapsed since a given time.
long levelmask_dilate(int times)
Dilates a level mask.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Header file for 2D and 3D image I/O.
Header file for option handlers.
Bplot * levelmask_size_histogram()
Color a multi-level mask based on the volumes of regions.
int bexit(int value)
Exit function for cleanup and debugging.
double timer_start()
Starts timer and prints the time.
void origin(double ox, double oy, double oz)
void simple_to_rgba()
A simple image is converted to a color image.