EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
EMAN::NormalizeHistPeakProcessor Class Reference

Normalize such that the estimated histogram peak value is zero. More...

#include <processor.h>

Inheritance diagram for EMAN::NormalizeHistPeakProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::NormalizeHistPeakProcessor:
Collaboration graph
[legend]

Public Member Functions

string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
- Public Member Functions inherited from EMAN::NormalizeProcessor
void process_inplace (EMData *image)
 To process an image in-place. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::NormalizeProcessor
static string get_group_desc ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "normalize.histpeak"
 

Protected Member Functions

float calc_mean (EMData *image) const
 
- Protected Member Functions inherited from EMAN::NormalizeProcessor
virtual float calc_sigma (EMData *image) const
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Normalize such that the estimated histogram peak value is zero.

Only works if the histogram peak is within +- 2*sigma of the mean.

Definition at line 5928 of file processor.h.

Member Function Documentation

◆ calc_mean()

float NormalizeHistPeakProcessor::calc_mean ( EMData image) const
protectedvirtual

Implements EMAN::NormalizeProcessor.

Definition at line 5018 of file processor.cpp.

5019{
5020 if (!image) {
5021 LOGWARN("NULL Image");
5022 return 0;
5023 }
5024 float mean = image->get_attr("mean");
5025 float sig = image->get_attr("sigma");
5026 size_t n=image->get_size();
5027
5028 // We want at least 100 values per bin on average
5029 int hist_size = image->get_size()/100;
5030 if (hist_size>1000) hist_size=1000;
5031 if (hist_size<5) hist_size=5;
5032 vector<float> hist(hist_size,0.0f);
5033
5034 float histmin=mean-2.0f*sig;
5035 float histmax=mean+2.0f*sig;
5036 float step=(histmax-histmin)/(hist_size-1);
5037 for (size_t i=0; i<n; i++) {
5038 int bin = (image->get_value_at_index(i)-histmin)/step;
5039 bin=bin<0?0:(bin>=hist_size?hist_size-1:bin);
5040 hist[bin]++;
5041 }
5042
5043 // yes, probably could use fancy vector methods...
5044 int maxv=hist[1],maxn=1;
5045 for (int i=2; i<hist_size-1; i++) {
5046 if (hist[i]>maxv) { maxv=hist[i]; maxn=i; }
5047 }
5048
5049 // weighted average position of the peak and nearest neighbors
5050 float v1=hist[maxn-1],v2=hist[maxn],v3=hist[maxn+1];
5051 float ret= (v1*(maxn-1)+v2*maxn+v3*(maxn+1))/(v1+v2+v3)*step+histmin;
5052 printf("%f %f %f %f %f %f\n",v1,v2,v3,mean,sig,ret);
5053
5054 return ret;
5055}
#define LOGWARN
Definition: log.h:53

References LOGWARN.

◆ get_desc()

string EMAN::NormalizeHistPeakProcessor::get_desc ( ) const
inlinevirtual

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns
The description of this processor.

Implements EMAN::Processor.

Definition at line 5941 of file processor.h.

5942 {
5943 return "Normalize an image so the estimated histogram peak is zero and sigma=1. Only works if the histogram peak is within +-2*sigma of the mean";
5944 }

◆ get_name()

string EMAN::NormalizeHistPeakProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 5931 of file processor.h.

5932 {
5933 return NAME;
5934 }
static const string NAME
Definition: processor.h:5946

References NAME.

◆ NEW()

static Processor * EMAN::NormalizeHistPeakProcessor::NEW ( )
inlinestatic

Definition at line 5936 of file processor.h.

5937 {
5938 return new NormalizeHistPeakProcessor();
5939 }
Normalize such that the estimated histogram peak value is zero.
Definition: processor.h:5929

Member Data Documentation

◆ NAME

const string NormalizeHistPeakProcessor::NAME = "normalize.histpeak"
static

Definition at line 5946 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: