 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
25 "Usage: bflood [options] input.img/input.star [output.img]",
26 "---------------------------------------------------------",
27 "Segments images using the watershed or flooding algorithm.",
28 "Note: -series, -peaks and -threshold are mutually exclusive.",
31 "-invert Invert density in the image before other operations.",
32 "-list List regions or regions (use with -threshold).",
33 "-color Generate a color image based on region size.",
34 "-series 1.3,4.7,0.05 Segment through a series of thresholds: start,finish,increment.",
36 "Actions for seeding:",
37 "-peaks 12,1.4,1,1 Find peaks within a kernel size, above a threshold,",
38 " with optional flooding and wrapping.",
39 "-threshold 3.4 Segment at a threshold,",
42 "Actions for flooding:",
43 "-flood 0.6,-0.03 Segment by flooding to a low threshold,",
44 " with increment (default increment = range/100).",
47 "-verbose 7 Verbose output.",
48 "-datatype u Force writing of a new data type.",
49 "-fill Fill in borders between regions or regions.",
50 "-multilevel Flag for multi-level output for extracted segments.",
53 "-Map map.pif Replacement for the map specified in the model file.",
54 "-Mask mask.tif Mask for flooding (use with -threshold, must be integer and same size as input image).",
55 "-Model mod.star Seed model for flooding (use with -threshold).",
59 "-Extract mask.pif Extract regions marked by the model (see flag for multi-level).",
60 "-Region region.pif Base name to generate numbered output file names.",
61 "-Postscript his.ps Output plot file of level size histogram.",
66 int main(
int argc,
char* argv[])
72 double threshold_hi(0);
73 double threshold_lo(0);
74 double threshold_inc(0);
95 for ( curropt = option; curropt; curropt = curropt->
next ) {
96 if ( curropt->
tag ==
"datatype" )
98 if ( curropt->
tag ==
"invert" )
100 if ( curropt->
tag ==
"series" ) {
101 if ( ( i = curropt->
values(threshold_hi, threshold_lo, threshold_inc ) ) < 1 )
102 cerr <<
"-series: At least one threshold must be specified!" << endl;
105 if ( i < 2 ) threshold_lo = threshold_hi;
106 if ( i < 3 ) threshold_inc = threshold_lo - threshold_hi;
109 if ( curropt->
tag ==
"peaks" ) {
110 if ( curropt->
values(kernel_size, threshold_hi, flood, wrap ) < 1 )
111 cerr <<
"-peaks: A kernel size must be specified!" << endl;
114 if ( flood ) flood = 1;
117 if ( curropt->
tag ==
"threshold" ) {
121 if ( curropt->
tag ==
"flood" ) {
122 if ( curropt->
values(threshold_lo, threshold_inc ) < 1 )
123 cerr <<
"-threshold: A lower threshold must be specified!" << endl;
127 if ( curropt->
tag ==
"list" ) list = 1;
128 if ( curropt->
tag ==
"color" ) color = 1;
130 if ( curropt->
tag ==
"fill" ) fill_borders = 1;
131 if ( curropt->
tag ==
"multilevel" ) multilevel = 1;
132 if ( curropt->
tag ==
"Model" )
134 if ( curropt->
tag ==
"Map" )
136 if ( curropt->
tag ==
"Mask" )
138 if ( curropt->
tag ==
"output" )
140 if ( curropt->
tag ==
"Extract" )
142 if ( curropt->
tag ==
"Region" )
144 if ( curropt->
tag ==
"Postscript" )
152 Bstring filename(argv[optind++]);
165 if ( map_file.
length() ) filename = map_file;
168 if ( filename.
length() < 1 ) {
169 cerr <<
"Error: No image file name specified!" << endl;
174 cerr <<
"Error: A model file is required to extract segments!" << endl;
180 cerr <<
"Error: No image file " << filename <<
" read!" << endl;
191 if ( setinvert ) p->
invert();
202 if ( mask_file.
length() ) {
204 }
else if ( seed_file.
length() ) {
207 pmask = pseed->
regions(0.5, 1);
209 }
else if ( seg_type == 3 ) {
210 pmask = p->
regions(threshold_hi, 0);
211 }
else if ( seg_type == 2 ) {
212 pmask = p->
region_peaks(kernel_size, threshold_hi, flood, wrap);
218 if ( seg_type == 1 ) {
220 }
else if ( flood == 2 ) {
221 p->
region_flood(pmask, threshold_hi, threshold_lo, threshold_inc, fill_borders);
233 if ( pmask && region_file.
length() ) {
246 if ( p != pmask )
delete p;
253 if ( optind < argc ) {
258 if ( p != pmask )
delete p;
Bimage * regions(double threshold, int sign)
Segments an image into contiguous regions.
A class for a command line input option.
int project_kill(Bproject *project)
Frees a whole project.
int level_masked_stats(Bimage *pmask)
Caclulates statistics for all the regions defined by a multi-level mask.
int region_threshold_series(double threshold_first, double threshold_last, double threshold_step)
Segments a map through a series of thresholds and reports results.
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
Bimage * img_from_model(Bmodel *model, Vector3< double > ori, Vector3< long > size, Vector3< double > sam, double sigma)
Calculates a map from model component coordinates.
Header file for reading and writing atomic model files.
Header file for file checking functions.
Bimage * levelmask_color_by_size()
Color a multi-level mask based on the volumes of regions.
Bimage * level_mask_extract(Bimage *pmask)
Extracts all the regions associated with a multi-level mask.
int bexit(int value)
Exit function for cleanup and debugging.
Header file for model to map conversions.
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.
long region_flood(Bimage *pmask, double threshold_hi, double threshold_lo, double threshold_step, int fill_borders)
Creates and expands a region map from a starting to ending threshold value.
long values(T1 &v1, T2 &v2)
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Header file for reading and writing micrograph parameters.
void origin(double x, double y, double z)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Bimage * img_extract_segments_using_model(Bimage *p, Bmodel *model, int multi_level)
Extracts segmentss from a multi-level mask around points defined by a model.
int model_kill(Bmodel *model)
Deallocates all memory in the list.
General image parameter class.
Utilities for timing functions.
Bplot * levelmask_size_histogram()
Color a multi-level mask based on the volumes of regions.
Bimage * region_peaks(long kernel_size, double threshold, int flood=0, int wrap=0)
Generates a segmented image from peaks above a threshold value.
double timer_start()
Starts timer and prints the time.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Header file for general utilities.
Functions to generate masks from models.
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.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
void invert()
Inverts the data in the image.
Bmodel * read_model(Bstring &filename)
void sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
int main(int argc, char *argv[])
FileType file_type(const char *filename)
Checks the file type using the extension and contents.