 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
22 "Usage: bnad [options] input.img output.img",
23 "------------------------------------------",
24 "Denoises by nonlinear anisotropic diffusion: Coherence and edge enhancing diffusion.",
25 "The default is edge enhancing diffusion.",
26 "Coherence enhancing diffusion is used if the coherence parameter is specified.",
27 "Diffusion is faster for higher lambda (1e-6 to 10 have been tested).",
30 "-lambda 0.3 Lambda: edge enhancing diffusion (default 0.1).",
31 "-coherence 0.002 Coherence: coherence enhancing diffusion (default 0.001).",
32 "-sigma 2.5 Initial gaussian smoothing coefficient (default no smoothing).",
35 "-verbose 7 Verbosity of output.",
36 "-datatype u Force writing of a new data type.",
37 "-iterations 80 Iterations (default 1).",
38 "-slabsize 20 Slab size for piece-wise processing (default z size).",
39 "-output 5 Number of iterations between writing output maps (default 100).",
41 "Parameters for coherence enhancing diffusion:",
42 "-alpha 0.001 Alpha (default 0.001).",
43 "-rho 4 Gaussian smoothing of structure tensor (default 6).",
48 int main (
int argc,
char **argv)
65 for ( curropt = option; curropt; curropt = curropt->
next ) {
66 if ( curropt->
tag ==
"lambda" )
67 if ( ( lambda = curropt->
value.
real() ) <= 0 )
68 cerr <<
"-lambda: Lambda must be specified" << endl;
69 if ( curropt->
tag ==
"coherence" )
71 cerr <<
"-coherence: Coherence must be specified" << endl;
72 if ( curropt->
tag ==
"sigma" )
73 if ( ( sigma = curropt->
value.
real() ) <= 0 )
74 cerr <<
"-sigma: A value must be specified" << endl;
75 if ( curropt->
tag ==
"datatype" )
77 if ( curropt->
tag ==
"iterations" )
79 cerr <<
"-iterations: A number of iterations must be specified!" << endl;
80 if ( curropt->
tag ==
"slabsize" )
82 cerr <<
"-slabsize: A slab size must be specified!" << endl;
83 if ( curropt->
tag ==
"output" )
85 cerr <<
"-output: A number of iterations must be specified!" << endl;
86 if ( curropt->
tag ==
"alpha" )
87 if ( ( alpha = curropt->
value.
real() ) <= 0 )
88 cerr <<
"-alpha: Alpha must be specified" << endl;
89 if ( curropt->
tag ==
"rho" )
90 if ( ( rho = curropt->
value.
real() ) < 1 )
91 cerr <<
"-rho: A value must be specified" << endl;
98 if ( optind < argc - 1 ) dataflag = 1;
101 cerr <<
"Error: No input file read!" << endl;
110 if ( slabsize < 1 ) slabsize = p->
sizeZ();
112 long memreq(p->
sizeX()*p->
sizeY()*
sizeof(
float));
113 if ( p->
sizeZ() == 1 )
116 memreq *= 6*slabsize;
119 memreq += 2*p->
data_size()*
sizeof(float);
122 cout <<
"Denoising by non-linear anisotropic diffusion: ";
123 if ( C ) cout <<
"Coherence enhancing diffusion" << endl;
124 else cout <<
"Edge enhancing diffusion" << endl;
125 cout <<
"Image size: " << p->
size() << endl;
126 if ( p->
sizeZ() == 1 )
127 cout <<
"Images: " << p->
images() << endl;
129 cout <<
"Slab thickness: " << slabsize << endl;
136 cout <<
"Gaussian filter sigma: " << sigma << endl;
143 time_t t = time(NULL);
146 cout <<
"Iter\tAvg\tStd\tTime" << endl;
150 for ( i=1; i<=imax; i++ ) {
151 if ( p->
sizeZ() == 1 )
152 pd = p->
nad_2D(ht, lambda, C, alpha);
154 pd = p->
nad(ht, slabsize, lambda, C, alpha);
160 cout << i <<
tab << setprecision(4) << p->
average() <<
tab <<
166 if ( i%iout == 0 && i != imax ) {
167 filename = argv[optind];
180 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.
size_t system_processors()
Returns the number of processors.
int main(int argc, char **argv)
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 information()
Prints out header information for an image.
Vector3< long > size() const
Header file for option handlers.
double standard_deviation()
int memory_check(long mem_required)
Checking if there is enough memory, abort if not.
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 * nad_2D(double ht, double lambda, double C, double alpha)
Denoises a 2D image by non-linear anisotropic diffusion.
General image parameter class.
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Utilities for timing functions.
int replace(Bimage *img)
Replaces the data with that from the given image.
double timer_start()
Starts timer and prints the time.
Header file for general utilities.
ostream & tab(ostream &out)
Bimage * nad(double ht, long zw, double lambda, double C, double alpha)
Denoises a 3D density map by non-linear anisotropic diffusion.
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.
DataType
Base data type specifier.
long statistics()
Calculates the statistics for an image.