#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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 6813 of file processor.h.
|
Definition at line 6816 of file processor.h. Referenced by NEW(). 06816 : default_bins(1024) {}
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6838 of file processor.h. 06839 { 06840 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"; 06841 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6820 of file processor.h. References NAME. 06821 { 06822 return NAME; 06823 }
|
|
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 6830 of file processor.h. References EMAN::EMObject::BOOL, EMAN::EMObject::INT, and EMAN::TypeDict::put(). 06831 { 06832 TypeDict d; 06833 d.put("nbins", EMObject::INT, "The number of bins the pixel values will be compressed into"); 06834 d.put("debug", EMObject::BOOL, "Outputs debugging information (number of pixels per bin)"); 06835 return d; 06836 }
|
|
Definition at line 6825 of file processor.h. References HistogramBin(). 06826 { 06827 return new HistogramBin(); 06828 }
|
|
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 9074 of file processor.cpp. References default_bins, EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_size(), InvalidParameterException, max, min, EMAN::Processor::params, and EMAN::Dict::set_default(). 09075 { 09076 float min = image->get_attr("minimum"); 09077 float max = image->get_attr("maximum"); 09078 float nbins = (float)params.set_default("nbins",default_bins); 09079 bool debug = params.set_default("debug",false); 09080 09081 vector<int> debugscores; 09082 if ( debug ) { 09083 debugscores = vector<int>((int)nbins, 0); 09084 } 09085 09086 if ( nbins < 0 ) throw InvalidParameterException("nbins must be greater than 0"); 09087 09088 float bin_width = (max-min)/nbins; 09089 float bin_val_offset = bin_width/2.0f; 09090 09091 size_t size = image->get_size(); 09092 float* dat = image->get_data(); 09093 09094 for(size_t i = 0; i < size; ++i ) { 09095 float val = dat[i]; 09096 val -= min; 09097 int bin = (int) (val/bin_width); 09098 09099 // This makes the last interval [] and not [) 09100 if (bin == nbins) bin -= 1; 09101 09102 dat[i] = min + bin*bin_width + bin_val_offset; 09103 if ( debug ) { 09104 debugscores[bin]++; 09105 } 09106 } 09107 09108 if ( debug ) { 09109 int i = 0; 09110 for( vector<int>::const_iterator it = debugscores.begin(); it != debugscores.end(); ++it, ++i) 09111 cout << "Bin " << i << " has " << *it << " pixels in it" << endl; 09112 } 09113 09114 }
|
|
Definition at line 6846 of file processor.h. Referenced by process_inplace(). |
|
Definition at line 6843 of file processor.h. Referenced by get_name(). |