Skip to content
Snippets Groups Projects
Commit c146920a authored by Mark Jenkinson's avatar Mark Jenkinson
Browse files

Added histogram feature

parent a9e1fe0b
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
Mark Jenkinson, FMRIB Image Analysis Group
Copyright (C) 2003 University of Oxford */
Copyright (C) 2003-2005 University of Oxford */
/* CCOPYRIGHT */
......@@ -44,6 +44,8 @@ void print_usage(const string& progname) {
cout << "-P <n> : output nth percentile (for nonzero voxels)" << endl;
cout << "-a : use absolute values of all image intensities"<< endl;
cout << "-k <mask> : use the specified image (filename) for masking - overrides lower and upper thresholds" << endl;
cout << "-h <nbins> : output a histogram (for the thresholded/masked voxels only) with nbins" << endl;
cout << "-H <nbins> <min> <max> : output a histogram (for the thresholded/masked voxels only) with nbins and histogram limits of min and max" << endl;
cout << endl;
cout << "Note - thresholds are not inclusive ie lthresh<allowed<uthresh" << endl;
}
......@@ -408,6 +410,60 @@ int fmrib_main_float(int argc, char* argv[])
vol = vin * mask;
}
cout << vol.percentile((float) n/100.0,masknz) << " ";
} else if (sarg=="-h") {
float n;
narg++;
if (narg<argc) {
n = atof(argv[narg]);
} else {
cerr << "Must specify the number of bins" << endl;
exit(2);
}
int nbins = (int) n;
if (nbins<1) {
cerr << "Must specify at least 1 bin" << endl;
exit(1);
}
if (masks_used) {
cout << vol.histogram(nbins,vol.min(),vol.max(),mask) << " ";
} else {
cout << vol.histogram(nbins,vol.min(),vol.max()) << " ";
}
} else if (sarg=="-H") {
float n;
narg++;
if (narg<argc) {
n = atof(argv[narg]);
} else {
cerr << "Must specify the number of bins" << endl;
exit(2);
}
int nbins = (int) n;
if (nbins<1) {
cerr << "Must specify at least 1 bin" << endl;
exit(1);
}
float min=0;
narg++;
if (narg<argc) {
min = atof(argv[narg]);
} else {
cerr << "Must specify the histogram minimum intensity" << endl;
exit(2);
}
float max=0;
narg++;
if (narg<argc) {
max = atof(argv[narg]);
} else {
cerr << "Must specify the histogram maximum intensity" << endl;
exit(2);
}
if (masks_used) {
cout << vol.histogram(nbins,min,max,mask) << " ";
} else {
cout << vol.histogram(nbins,min,max) << " ";
}
} else {
cerr << "Unrecognised option: " << sarg << endl;
exit(3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment