 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
25 "Usage: bnorm [options] input.star/input.img [input2.star/output.img]",
26 "--------------------------------------------------------------------",
27 "Normalizes a set of images based on their histograms.",
30 "-replacemaxima 57.5 Replace maxima above the given threshold with surrounding average.",
31 "-type simple Normalization type: simple, Gaussian or Poisson.",
32 "-local 25 Normalization using local average and standard deviation.",
33 "-truncate -0.5,1.2 Truncate data to minimum and maximum before mass normalization.",
34 "-rescale 0.5,1.5 Average and standard deviation for output.",
35 "-images Input slices of a single 3D image as 2D images.",
36 "-slices Output 2D images as z-slices of a single 3D image.",
39 "-verbose 7 Verbosity of output.",
40 "-datatype u Force writing of a new data type.",
43 "-output file.star Output parameter file.",
48 int main(
int argc,
char **argv)
54 double replace_threshold(0);
56 int setinputZslices(0);
57 int setoutputZslices(0);
58 double cutmin(0), cutmax(0);
59 double avg(0), std(0);
65 for ( curropt = option; curropt; curropt = curropt->
next ) {
66 if ( curropt->
tag ==
"replacemaxima" ) {
67 if ( ( replace_threshold = curropt->
value.
real() ) < 0.0000001 )
68 cerr <<
"-replacemaxima: A threshold must be specified!" << endl;
72 if ( curropt->
tag ==
"type" ) {
73 if ( curropt->
value[0] ==
's' || curropt->
value[0] ==
'S' ) norm_type = 0;
74 if ( curropt->
value[0] ==
'g' || curropt->
value[0] ==
'G' ) norm_type = 1;
75 if ( curropt->
value[0] ==
'p' || curropt->
value[0] ==
'P' ) norm_type = 2;
77 if ( curropt->
tag ==
"local" )
79 cerr <<
"-local: A kernel size must be specified!" << endl;
80 if ( curropt->
tag ==
"datatype" )
82 if ( curropt->
tag ==
"truncate" ) {
83 if ( curropt->
values(cutmin, cutmax) < 2 )
84 cerr <<
"-truncate: Both min and max must be specified!" << endl;
85 if ( cutmin > cutmax ) swap(cutmin, cutmax);
87 if ( curropt->
tag ==
"rescale" )
88 if ( curropt->
values(avg, std) < 2 ) {
89 cerr <<
"-rescale: Both the average and standard deviation must be specified!" << endl;
92 if ( curropt->
tag ==
"images" ) setinputZslices = 1;
93 if ( curropt->
tag ==
"slices" ) setoutputZslices = 1;
94 if ( curropt->
tag ==
"output" )
103 Bstring filename = argv[optind];
107 while ( optind < argc )
string_add(&file_list, argv[optind++]);
111 nudatatype, setinputZslices, setoutputZslices,
112 cutmin, cutmax, replace_threshold);
115 if ( p == NULL )
bexit(-1);
122 if ( setinputZslices )
132 else if ( norm_type >= 0 )
135 if ( setoutputZslices )
138 if ( optind < argc ) {
139 filename = argv[++optind];
148 file_list = &filename;
155 cout <<
"Writing " << paramfile << endl;
A class for a command line input option.
int project_kill(Bproject *project)
Frees a whole project.
int string_kill(Bstring *list)
Kills a string linked list.
Header file for file checking functions.
int project_mass_normalize(Bproject *project, double avg, double std, int norm_type, DataType datatype, int setinputZslices, int setoutputZslices, double cutmin, double cutmax, double replace_threshold)
Normalizes a set of images in a project to a desired average and standard deviation.
int bexit(int value)
Exit function for cleanup and debugging.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
int normalize(long imgnum, double average, double stdev, int norm_type, long bins)
Normalizes a sub-image to a desired average and standard deviation.
Header file for option handlers.
int images_to_slices()
Changes the 2D images to slices in a 3D image.
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.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int main(int argc, char **argv)
int slices_to_images()
Changes the slices in a 3D image into a set of 2D images.
int normalize_local(long kernel_size)
Normalizes by subtracting local average and dividing by local standard deviation.
Bproject * project_create_from_images(Bstring *file_list, Bstring type)
Creates a project structure using image file names.
General image parameter class.
Utilities for timing functions.
Header file for image processing from micrograph structures.
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.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Header file for general utilities.
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 write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Header file for micrograph processing.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
DataType
Base data type specifier.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Header file for single particle image processing in Bsoft.
FileType file_type(const char *filename)
Checks the file type using the extension and contents.
long replace_maxima(double threshold)
Replaces maxima above a threshold using local averages.