#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 6897 of file processor.h.
|
Definition at line 6900 of file processor.h. References default_bins. Referenced by NEW(). 06900 : default_bins(1024) {}
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6922 of file processor.h. 06923 { 06924 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"; 06925 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6904 of file processor.h. 06905 {
06906 return NAME;
06907 }
|
|
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 6914 of file processor.h. References EMAN::TypeDict::put(). 06915 { 06916 TypeDict d; 06917 d.put("nbins", EMObject::INT, "The number of bins the pixel values will be compressed into"); 06918 d.put("debug", EMObject::BOOL, "Outputs debugging information (number of pixels per bin)"); 06919 return d; 06920 }
|
|
Definition at line 6909 of file processor.h. References HistogramBin(). 06910 { 06911 return new HistogramBin(); 06912 }
|
|
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 9341 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(). 09342 { 09343 float min = image->get_attr("minimum"); 09344 float max = image->get_attr("maximum"); 09345 float nbins = (float)params.set_default("nbins",default_bins); 09346 bool debug = params.set_default("debug",false); 09347 09348 vector<int> debugscores; 09349 if ( debug ) { 09350 debugscores = vector<int>((int)nbins, 0); 09351 } 09352 09353 if ( nbins < 0 ) throw InvalidParameterException("nbins must be greater than 0"); 09354 09355 float bin_width = (max-min)/nbins; 09356 float bin_val_offset = bin_width/2.0f; 09357 09358 size_t size = image->get_size(); 09359 float* dat = image->get_data(); 09360 09361 for(size_t i = 0; i < size; ++i ) { 09362 float val = dat[i]; 09363 val -= min; 09364 int bin = (int) (val/bin_width); 09365 09366 // This makes the last interval [] and not [) 09367 if (bin == nbins) bin -= 1; 09368 09369 dat[i] = min + bin*bin_width + bin_val_offset; 09370 if ( debug ) { 09371 debugscores[bin]++; 09372 } 09373 } 09374 09375 if ( debug ) { 09376 int i = 0; 09377 for( vector<int>::const_iterator it = debugscores.begin(); it != debugscores.end(); ++it, ++i) 09378 cout << "Bin " << i << " has " << *it << " pixels in it" << endl; 09379 } 09380 09381 }
|
|
Definition at line 6930 of file processor.h. Referenced by HistogramBin(), and process_inplace(). |
|
Definition at line 216 of file processor.cpp. |