 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
21 "Usage: bgraphseg [options] input.img output.img",
22 "-----------------------------------------------",
23 "Segment images into density regions using a nondirected graph.",
26 "-invert Invert density in the image before other operations.",
27 "-rescale -0.1,5.2 Rescale data to average and standard deviation before other operations.",
28 "-smooth 0.8 Smooth using a gaussian kernel with the given width.",
29 "-type srm Type of segmentation (simple, srm).",
30 "-minimum 2300 Join segments smaller than this size.",
31 "-voxel 23,241,193,1 Select the segment containing this voxel with an optional inversion flag.",
32 "-colorize Generate random segment colors.",
35 "-verbose 7 Verbose output.",
36 "-datatype u Force writing of a new data type.",
37 "-origin 0.8,-10,15.7 Set the origin (default from input image).",
38 "-connectivity Flag to use full neighbor connectivity (default 2*dimension).",
39 "-complexity 1.6 Segmentation complexity: larger value gives more regions (default 1).",
42 "-Mask mask.tif Mask to limit segmentation.",
47 int main(
int argc,
char* argv[])
52 double nuavg(0), nustd(0);
69 for ( curropt = option; curropt; curropt = curropt->
next ) {
70 if ( curropt->
tag ==
"datatype" )
72 if ( curropt->
tag ==
"invert" )
74 if ( curropt->
tag ==
"rescale" )
75 if ( curropt->
values(nuavg, nustd) < 2 )
76 cerr <<
"-rescale: Both average and standard deviation must be specified!" << endl;
77 if ( curropt->
tag ==
"smooth" )
78 if ( ( sigma = curropt->
value.
real() ) < 0.001 )
79 cerr <<
"-smooth: A sigma value must be specified!" << endl;
80 if ( curropt->
tag ==
"type" ) {
84 if ( curropt->
tag ==
"connectivity" )
86 if ( curropt->
tag ==
"minimum" )
88 cerr <<
"-minimum: A minimu segment size must be specified!" << endl;
89 if ( curropt->
tag ==
"voxel" )
90 if ( curropt->
values(voxel[0], voxel[1], voxel[2], mask_invert) < 3 )
91 cerr <<
"-voxel: A voxel must be specified!" << endl;
92 if ( curropt->
tag ==
"colorize" )
94 if ( curropt->
tag ==
"complexity" )
95 if ( ( complexity = curropt->
value.
real() ) < 0.001 )
96 cerr <<
"-complexity: A complexity value must be specified!" << endl;
97 if ( curropt->
tag ==
"origin" ) {
98 if ( curropt->
value[0] ==
'c' ) {
101 origin = curropt->
origin();
105 if ( curropt->
tag ==
"Mask" )
107 if ( curropt->
tag ==
"Feature" )
130 if ( setinvert ) p->
invert();
135 if ( sigma > 0.001 ) {
136 ksize = 2*( (int) (4*sigma + 0.9) ) + 1;
142 pseg = p->
graph_segment(type, pmask, connect_type, complexity, min_size, 1);
147 if ( voxel[0] >= 0 ) {
155 if ( optind < argc ) {
A class for a command line input option.
int filter_gaussian(long kernel_size, double sigma)
Applies a gaussian filter to an image.
long levelmask_select(Bstring &select_list, int flag=0)
Retains the selected levels in a multi-level mask.
int bexit(int value)
Exit function for cleanup and debugging.
Vector3< double > default_origin()
int main(int argc, char *argv[])
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)
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.
Bimage * graph_segment(int type=1, Bimage *pmask=NULL, int connect_type=0, double complexity=0, long min_size=0, int return_type=0)
Graph-based segmentation of an image.
General image parameter class.
Utilities for timing functions.
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)
long mask_invert()
Inverts a mask.
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.
DataType
Base data type specifier.
bool contains(const Bstring &s)
long levelmask_colorize()
Colorizes a multi-level mask with random color assignments.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.