#include <processor.h>
Inheritance diagram for EMAN::HistogramBin:
Public Member Functions | |
HistogramBin () | |
void | process_inplace (EMData *image) |
To process an image in-place. | |
string | get_name () const |
Get the processor's name. | |
TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
Static Public Member Functions | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "histogram.bin" |
Protected Attributes | |
int | default_bins |
The histogram is comprised of 'nbins' bins, and the value assigned to each pixel in the bin is the midpoint of the bin's upper and lower limits. Defaults to 256 bins
nbins | The number of bins the pixel values will be compressed into | |
debug | Outputs debugging information (number of pixels per bin) |
Definition at line 6812 of file processor.h.
|
Definition at line 6815 of file processor.h. References default_bins. Referenced by NEW(). 06815 : default_bins(1024) {}
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6837 of file processor.h. 06838 { 06839 return "Bins pixel values, similar to calculating a histogram. The histogram is comprised of 'nbins' bins, and the value assigned to each pixel in the bin is the midpoint of the bin's upper and lower limits. Defaults to 256 bins"; 06840 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6819 of file processor.h. 06820 {
06821 return NAME;
06822 }
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 6829 of file processor.h. References EMAN::TypeDict::put(). 06830 { 06831 TypeDict d; 06832 d.put("nbins", EMObject::INT, "The number of bins the pixel values will be compressed into"); 06833 d.put("debug", EMObject::BOOL, "Outputs debugging information (number of pixels per bin)"); 06834 return d; 06835 }
|
|
Definition at line 6824 of file processor.h. References HistogramBin(). 06825 { 06826 return new HistogramBin(); 06827 }
|
|
To process an image in-place. For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.
Implements EMAN::Processor. Definition at line 9043 of file processor.cpp. References default_bins, EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_size(), InvalidParameterException, max, min, and EMAN::Dict::set_default(). 09044 { 09045 float min = image->get_attr("minimum"); 09046 float max = image->get_attr("maximum"); 09047 float nbins = (float)params.set_default("nbins",default_bins); 09048 bool debug = params.set_default("debug",false); 09049 09050 vector<int> debugscores; 09051 if ( debug ) { 09052 debugscores = vector<int>((int)nbins, 0); 09053 } 09054 09055 if ( nbins < 0 ) throw InvalidParameterException("nbins must be greater than 0"); 09056 09057 float bin_width = (max-min)/nbins; 09058 float bin_val_offset = bin_width/2.0f; 09059 09060 size_t size = image->get_size(); 09061 float* dat = image->get_data(); 09062 09063 for(size_t i = 0; i < size; ++i ) { 09064 float val = dat[i]; 09065 val -= min; 09066 int bin = (int) (val/bin_width); 09067 09068 // This makes the last interval [] and not [) 09069 if (bin == nbins) bin -= 1; 09070 09071 dat[i] = min + bin*bin_width + bin_val_offset; 09072 if ( debug ) { 09073 debugscores[bin]++; 09074 } 09075 } 09076 09077 if ( debug ) { 09078 int i = 0; 09079 for( vector<int>::const_iterator it = debugscores.begin(); it != debugscores.end(); ++it, ++i) 09080 cout << "Bin " << i << " has " << *it << " pixels in it" << endl; 09081 } 09082 09083 }
|
|
Definition at line 6845 of file processor.h. Referenced by HistogramBin(), and process_inplace(). |
|
Definition at line 216 of file processor.cpp. |