#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 6781 of file processor.h.
|
Definition at line 6784 of file processor.h. References default_bins. Referenced by NEW(). 06784 : default_bins(1024) {}
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6806 of file processor.h. 06807 { 06808 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"; 06809 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6788 of file processor.h. 06789 {
06790 return NAME;
06791 }
|
|
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 6798 of file processor.h. References EMAN::TypeDict::put(). 06799 { 06800 TypeDict d; 06801 d.put("nbins", EMObject::INT, "The number of bins the pixel values will be compressed into"); 06802 d.put("debug", EMObject::BOOL, "Outputs debugging information (number of pixels per bin)"); 06803 return d; 06804 }
|
|
Definition at line 6793 of file processor.h. References HistogramBin(). 06794 { 06795 return new HistogramBin(); 06796 }
|
|
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 9136 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(). 09137 { 09138 float min = image->get_attr("minimum"); 09139 float max = image->get_attr("maximum"); 09140 float nbins = (float)params.set_default("nbins",default_bins); 09141 bool debug = params.set_default("debug",false); 09142 09143 vector<int> debugscores; 09144 if ( debug ) { 09145 debugscores = vector<int>((int)nbins, 0); 09146 } 09147 09148 if ( nbins < 0 ) throw InvalidParameterException("nbins must be greater than 0"); 09149 09150 float bin_width = (max-min)/nbins; 09151 float bin_val_offset = bin_width/2.0f; 09152 09153 size_t size = image->get_size(); 09154 float* dat = image->get_data(); 09155 09156 for(size_t i = 0; i < size; ++i ) { 09157 float val = dat[i]; 09158 val -= min; 09159 int bin = (int) (val/bin_width); 09160 09161 // This makes the last interval [] and not [) 09162 if (bin == nbins) bin -= 1; 09163 09164 dat[i] = min + bin*bin_width + bin_val_offset; 09165 if ( debug ) { 09166 debugscores[bin]++; 09167 } 09168 } 09169 09170 if ( debug ) { 09171 int i = 0; 09172 for( vector<int>::const_iterator it = debugscores.begin(); it != debugscores.end(); ++it, ++i) 09173 cout << "Bin " << i << " has " << *it << " pixels in it" << endl; 09174 } 09175 09176 }
|
|
Definition at line 6814 of file processor.h. Referenced by HistogramBin(), and process_inplace(). |
|
Definition at line 216 of file processor.cpp. |