 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
20 "Usage: bbif [options] input.img output.img",
21 "------------------------------------------",
22 "Denoises by bilateral filtering.",
25 "-rescale -0.1,5.2 Rescale data to average and standard deviation after filtering.",
26 "-kernel gaussian Kernel used for for the intensity space:",
27 " 1=gaussian (default)",
30 "-size 5 kernel size (odd number, default 6*spacesigma)",
31 "-spacesigma 1.5 Standard deviation of spatial filter (pixels, default 1).",
32 "-rangesigma 23.8 Standard deviation of range filter (default image standard deviation).",
35 "-verbose 1 Verbosity of output.",
36 "-datatype u Force writing of a new data type.",
37 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; default from input file; a single value can be given).",
42 int main(
int argc,
char **argv)
47 double nuavg(0), nustd(0);
49 double rangesigma(-1);
57 for ( curropt = option; curropt; curropt = curropt->
next ) {
58 if ( curropt->
tag ==
"datatype" )
60 if ( curropt->
tag ==
"sampling" )
61 sam = curropt->
scale();
62 if ( curropt->
tag ==
"rescale" ) {
63 if ( curropt->
values(nuavg, nustd) < 2 )
64 cerr <<
"-rescale: Both average and standard deviation must be specified!" << endl;
65 else if ( nustd <= 0 )
66 cerr <<
"-rescale: A positive standard deviation must be specified!" << endl;
68 if ( curropt->
tag ==
"kernel" ) {
70 for (
int i=0; i<(int)curropt->
value.
length(); i++ )
71 curropt->
value[i] = tolower(curropt->
value[i]);
72 if ( curropt->
value[0] ==
'g' ) {
74 }
else if ( curropt->
value[0] ==
'l' ) {
76 }
else if ( curropt->
value[0] ==
't' ) {
80 if ( kernel_type < 1 || kernel_type > 3 ) kernel_type = 1;
82 if ( curropt->
tag ==
"spacesigma" )
83 if ( ( spacesigma = curropt->
value.
real() ) < 0.001 )
84 cerr <<
"-spacesigma: a space sigma must be specified!" << endl;
85 if ( curropt->
tag ==
"rangesigma" )
86 if ( ( rangesigma = curropt->
value.
real() ) < 0.001 )
87 cerr <<
"-rangesigma: a range sigma must be specified!" << endl;
88 if ( curropt->
tag ==
"size" )
90 cerr <<
"-size: a kernel size must be specified!" << endl;
98 if ( optind < argc - 1 ) dataflag = 1;
100 if ( p == NULL )
bexit(-1);
111 if ( optind < argc ) {
A class for a command line input option.
Vector3< double > scale()
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.
Header file for option handlers.
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.
int main(int argc, char **argv)
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 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 sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
int filter_bilateral(double sigma1, double sigma2, int kernel_type, long kernel_radius)
Denoise an image with combined gaussian distance and density difference kernel.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.