 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
20 "Usage: bhisto [options] input.img output.img",
21 "--------------------------------------------",
22 "Calculates the histogram of an image and associated statistics.",
25 "-bins 256 Calculate histogram over a number of bins.",
26 "-fit gauss,2 Do a fit to the histogram (gaussian, poisson).",
27 " Second argument indicates number of gaussians.",
28 "-percentiles Calculate the percentiles for an image.",
31 "-verbose 7 Verbosity of output.",
32 "-datatype u Force writing of a new data type.",
33 "-select 1 Select an image (default all).",
34 "-sampling 2,3.5,1 Sampling (angstrom/voxel, a single value sets all three).",
37 "-Postscript histo.ps Postscript output file name.",
42 int main(
int argc,
char **argv)
57 for ( curropt = option; curropt; curropt = curropt->
next ) {
58 if ( curropt->
tag ==
"bins" ) {
60 cerr <<
"-bins: The number of bins must be specified!" << endl;
61 else if ( bins < 2 ) {
63 cerr <<
"-bins: Too few bins, changed to 10!" << endl;
64 }
else if ( bins > 100000 ) {
66 cerr <<
"-bins: Too many bins, changed to 1000!" << endl;
69 if ( curropt->
tag ==
"fit" ) {
70 setfit = curropt->
value;
72 setfit = setfit.
pre(
',');
76 if ( curropt->
tag ==
"percentiles" ) percentiles = 1;
77 if ( curropt->
tag ==
"datatype" )
79 if ( curropt->
tag ==
"select" )
81 cerr <<
"-select: An image number must be specified!" << endl;
82 if ( curropt->
tag ==
"sampling" )
83 sam = curropt->
scale();
84 if ( curropt->
tag ==
"Postscript" )
93 if ( bins || percentiles || optind < argc - 1 ) dataflag = 1;
96 cerr <<
"Error: No input file read!" << endl;
106 if ( setfit[0] ==
'g' )
108 else if ( setfit[0] ==
'p' )
110 else if ( setfit[0] ==
'c' )
113 cerr <<
"Incorrect fitting specification: " << setfit << endl;
117 }
else if ( percentiles ) {
121 if ( psfile.
length() && plot )
124 if ( optind < argc ) {
129 if ( plot )
delete plot;
A class for a command line input option.
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
Vector3< double > scale()
int bexit(int value)
Exit function for cleanup and debugging.
Bplot * histogram_counts(int flags=0)
Finds the peaks in a quantized image from the histogram.
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.
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.
General image parameter class.
Utilities for timing functions.
Bplot * histogram_poisson_fit(long bins, int flag=0)
Fits a poisson function to a histogram of an image.
double timer_start()
Starts timer and prints the time.
Bplot * percentiles()
Calculates the percentiles from the histogram of an image.
Header file for general utilities.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Bplot * histogram_gauss_plot(long bins, long ngauss=1)
Fits a gaussian function to a histogram of an image.
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.
int main(int argc, char **argv)
void sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
bool contains(const Bstring &s)
vector< long > histogram(long bins, double &scale, double &offset)
Calculates the histogram of an image.