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

Set any values in a range to zero. More...

#include <processor.h>

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

Public Member Functions

 RangeZeroProcessor ()
 
string get_name () const
 Get the processor's name. More...
 
virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
string get_desc () const
 Get the descrition of this specific processor. 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...
 

Static Public Member Functions

static ProcessorNEW ()
 
- 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 = "threshold.rangetozero"
 

Protected Attributes

float minval
 
float maxval
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

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...
 

Detailed Description

Set any values in a range to zero.

Opposite of threshold.clampminmax

Parameters
minvalminimum value of the range
maxvalmaximum value of the range

Definition at line 2665 of file processor.h.

Constructor & Destructor Documentation

◆ RangeZeroProcessor()

EMAN::RangeZeroProcessor::RangeZeroProcessor ( )
inline

Definition at line 2668 of file processor.h.

2668 :minval(0),maxval(0)
2669 {
2670 }

Referenced by NEW().

Member Function Documentation

◆ get_desc()

string EMAN::RangeZeroProcessor::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 2701 of file processor.h.

2702 {
2703 return "Sets values in a range to zero. Opposite of threshold.clampminmax. \nf(x) = x if x > maxval or x < minval; f(x) = 0 for min <= x <= max. If gauss_width set nozero, applies a radial correction factor to both min and max.";
2704 }

◆ get_name()

string EMAN::RangeZeroProcessor::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 2672 of file processor.h.

2673 {
2674 return NAME;
2675 }
static const string NAME
Definition: processor.h:2706

References NAME.

◆ get_param_types()

TypeDict EMAN::RangeZeroProcessor::get_param_types ( ) const
inlinevirtual

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 2685 of file processor.h.

2686 {
2687 TypeDict d;
2688 d.put("minval", EMObject::FLOAT, "Lower threshold (required)");
2689 d.put("maxval", EMObject::FLOAT, "Upper threshold (required)");
2690 d.put("gauss_width", EMObject::FLOAT, "Range will be narrowed around zero based on a radial Gaussian falloff modeled on math.gausskernelfix. Disabled if set to 0.");
2691 return d;
2692 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 2677 of file processor.h.

2678 {
2679 return new RangeZeroProcessor();
2680 }

References RangeZeroProcessor().

◆ process_inplace()

void RangeZeroProcessor::process_inplace ( EMData image)
virtual

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.

Parameters
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 2202 of file processor.cpp.

2203{
2204 if (!image) {
2205 LOGWARN("NULL Image");
2206 return;
2207 }
2208
2209 float gauss_width = params.set_default("gauss_width",0.0f);
2210
2211 if (gauss_width<=0) {
2212 size_t size = (size_t)image->get_xsize() *
2213 (size_t)image->get_ysize() *
2214 (size_t)image->get_zsize();
2215 float *data = image->get_data();
2216
2217 for (size_t i = 0; i < size; ++i) {
2218 if (data[i]>=minval && data[i]<=maxval) data[i]=0.0f;
2219 }
2220 image->update();
2221 }
2222 else {
2223 int nx = image->get_xsize();
2224 int ny = image->get_ysize();
2225 int nz = image->get_zsize();
2226 float wid=gauss_width/(ny*ny);
2227
2228 for (int z=0; z<nz; z++) {
2229 for (int y=0; y<ny; y++) {
2230 for (int x=0; x<nx; x++) {
2231 float cor=exp(-Util::hypot3sq(x-nx/2,y-ny/2,z-nz/2)*wid);
2232 if (image->get_value_at(x,y,z)>=minval*cor && image->get_value_at(x,y,z)<=maxval*cor) image->set_value_at(x,y,z,0.0f);
2233 }
2234 }
2235 }
2236 image->update();
2237 }
2238
2239}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
static int hypot3sq(int x, int y, int z)
Euclidean distance function squared in 3D: f(x,y,z) = (x*x + y*y + z*z);.
Definition: util.h:805
#define LOGWARN
Definition: log.h:53
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::hypot3sq(), LOGWARN, maxval, minval, EMAN::Processor::params, EMAN::Dict::set_default(), x, and y.

◆ set_params()

void EMAN::RangeZeroProcessor::set_params ( const Dict new_params)
inlinevirtual

Set the processor parameters using a key/value dictionary.

Parameters
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 2694 of file processor.h.

2695 {
2696 params = new_params;
2697 minval = params["minval"]; // using existing variable as a convenience
2698 maxval = params["maxval"];
2699 }

References maxval, minval, and EMAN::Processor::params.

Member Data Documentation

◆ maxval

float EMAN::RangeZeroProcessor::maxval
protected

Definition at line 2709 of file processor.h.

Referenced by process_inplace(), and set_params().

◆ minval

float EMAN::RangeZeroProcessor::minval
protected

Definition at line 2709 of file processor.h.

Referenced by process_inplace(), and set_params().

◆ NAME

const string RangeZeroProcessor::NAME = "threshold.rangetozero"
static

Definition at line 2706 of file processor.h.

Referenced by get_name().


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