#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 6850 of file processor.h.
|
Definition at line 6853 of file processor.h. References default_bins. Referenced by NEW(). 06853 : default_bins(1024) {}
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6875 of file processor.h. 06876 { 06877 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"; 06878 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6857 of file processor.h. 06858 {
06859 return NAME;
06860 }
|
|
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 6867 of file processor.h. References EMAN::TypeDict::put(). 06868 { 06869 TypeDict d; 06870 d.put("nbins", EMObject::INT, "The number of bins the pixel values will be compressed into"); 06871 d.put("debug", EMObject::BOOL, "Outputs debugging information (number of pixels per bin)"); 06872 return d; 06873 }
|
|
Definition at line 6862 of file processor.h. References HistogramBin(). 06863 { 06864 return new HistogramBin(); 06865 }
|
|
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 9254 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(). 09255 { 09256 float min = image->get_attr("minimum"); 09257 float max = image->get_attr("maximum"); 09258 float nbins = (float)params.set_default("nbins",default_bins); 09259 bool debug = params.set_default("debug",false); 09260 09261 vector<int> debugscores; 09262 if ( debug ) { 09263 debugscores = vector<int>((int)nbins, 0); 09264 } 09265 09266 if ( nbins < 0 ) throw InvalidParameterException("nbins must be greater than 0"); 09267 09268 float bin_width = (max-min)/nbins; 09269 float bin_val_offset = bin_width/2.0f; 09270 09271 size_t size = image->get_size(); 09272 float* dat = image->get_data(); 09273 09274 for(size_t i = 0; i < size; ++i ) { 09275 float val = dat[i]; 09276 val -= min; 09277 int bin = (int) (val/bin_width); 09278 09279 // This makes the last interval [] and not [) 09280 if (bin == nbins) bin -= 1; 09281 09282 dat[i] = min + bin*bin_width + bin_val_offset; 09283 if ( debug ) { 09284 debugscores[bin]++; 09285 } 09286 } 09287 09288 if ( debug ) { 09289 int i = 0; 09290 for( vector<int>::const_iterator it = debugscores.begin(); it != debugscores.end(); ++it, ++i) 09291 cout << "Bin " << i << " has " << *it << " pixels in it" << endl; 09292 } 09293 09294 }
|
|
Definition at line 6883 of file processor.h. Referenced by HistogramBin(), and process_inplace(). |
|
Definition at line 216 of file processor.cpp. |