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

Replace a source image as a strict Gaussian. More...

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. 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...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::TestImageProcessor
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 = "testimage.noise.fourier.gaussian"
 

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 Member Functions inherited from EMAN::TestImageProcessor
void preprocess (EMData *image)
 
- Protected Attributes inherited from EMAN::TestImageProcessor
int nx
 
int ny
 
int nz
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Replace a source image as a strict Gaussian.

Parameters
sigmasigma value for this Gaussian blob

Definition at line 8112 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::TestImageFourierNoiseGaussian::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 8122 of file processor.h.

8123 {
8124 return "Replace a source image with pink Fourier noise, based on a Gaussian. Random phase.";
8125 }

◆ get_name()

virtual string EMAN::TestImageFourierNoiseGaussian::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 8117 of file processor.h.

8118 {
8119 return NAME;
8120 }

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::TestImageFourierNoiseGaussian::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 8132 of file processor.h.

8133 {
8134 TypeDict d;
8135 d.put("sigma", EMObject::FLOAT, "sigma value");
8136 return d;
8137 }
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::TestImageFourierNoiseGaussian::NEW ( )
inlinestatic

Definition at line 8127 of file processor.h.

8128 {
8129 return new TestImageFourierNoiseGaussian();
8130 }
Replace a source image as a strict Gaussian.
Definition: processor.h:8113

◆ process_inplace()

void TestImageFourierNoiseGaussian::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 8994 of file processor.cpp.

8995{
8996 if (!image->is_complex()) {
8997 int nx = image->get_xsize();
8998 int offset = 2 - nx%2;
8999
9000 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
9001 image->set_complex(true);
9002 if (1 == offset) image->set_fftodd(true);
9003 else image->set_fftodd(false);
9004 image->set_fftpad(true);
9005 }
9006 image->ri2ap();
9007
9008 float sigma = params.set_default("sigma",.25f);
9009
9010 float * d = image->get_data();
9011 int nx = image->get_xsize();
9012 int ny = image->get_ysize();
9013 int nxy = image->get_ysize()*nx;
9014 int nzon2 = image->get_zsize()/2;
9015 int nyon2 = image->get_ysize()/2;
9016 float rx, ry, rz, length, amp, phase;
9017 int twox;
9018 for (int z = 0; z< image->get_zsize(); ++z) {
9019 for (int y = 0; y < image->get_ysize(); ++y) {
9020 for (int x = 0; x < image->get_xsize()/2; ++x) {
9021 rx = (float)x;
9022 ry = (float)nyon2 - (float)y;
9023 rz = (float)nzon2 - (float)z;
9024 length = sqrt(rx*rx + ry*ry + rz*rz);
9025 amp = exp(-sigma*length);
9026 phase = Util::get_frand(0,1)*2*M_PI;
9027
9028 twox = 2*x;
9029 size_t idx1 = twox + y*nx+(size_t)z*nxy;
9030 size_t idx2 = idx1 + 1;
9031 d[idx1] = amp;
9032 d[idx2] = phase;
9033
9034 }
9035 }
9036 }
9037
9038 image->ap2ri();
9039 if (image->get_ndim() == 2) {
9040 bool yodd = image->get_ysize() % 2 == 1;
9041
9042 int yit = image->get_ysize()/2-1;
9043 int offset = 1;
9044 if (yodd) {
9045 offset = 0;
9046 }
9047 for (int y = 0; y < yit; ++y) {
9048 int bot_idx = (y+offset)*nx;
9049 int top_idx = (ny-1-y)*nx;
9050 float r1 = d[bot_idx];
9051 float i1 = d[bot_idx+1];
9052 float r2 = d[top_idx];
9053 float i2 = d[top_idx+1];
9054 float r = (r1 + r2)/2.0f;
9055 float i = (i1 + i2)/2.0f;
9056 d[bot_idx] = r;
9057 d[top_idx] = r;
9058 d[bot_idx+1] = i;
9059 d[top_idx+1] = -i;
9060
9061 bot_idx = (y+offset)*nx+nx-2;
9062 top_idx = (ny-1-y)*nx+nx-2;
9063 r1 = d[bot_idx];
9064 i1 = d[bot_idx+1];
9065 r2 = d[top_idx];
9066 i2 = d[top_idx+1];
9067 r = (r1 + r2)/2.0f;
9068 i = (i1 + i2)/2.0f;
9069 d[bot_idx] = r;
9070 d[top_idx] = r;
9071 d[bot_idx+1] = i;
9072 d[top_idx+1] = -i;
9073 }
9074
9075 d[1] = 0; // 0 phase for this componenet
9076 d[nx-1] = 0; // 0 phase for this component
9077 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
9078 d[ny/2*nx+1] = 0;// 0 phase for this component
9079 }
9080
9081 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
9082 image->do_ift_inplace();
9083 image->depad();
9084}
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 float get_frand(int low, int high)
Get a float random number between low and high, [low, high)
Definition: util.cpp:725
EMData * sqrt() const
return square root of current image
EMData * phase() const
return phase part of a complex image as a real image format
double length(const Vector3 &v)
Definition: vecmath.h:313
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::get_frand(), EMAN::length(), EMAN::TestImageProcessor::nx, EMAN::TestImageProcessor::ny, EMAN::Processor::params, phase(), EMAN::Dict::set_default(), sqrt(), x, and y.

Member Data Documentation

◆ NAME

const string TestImageFourierNoiseGaussian::NAME = "testimage.noise.fourier.gaussian"
static

Definition at line 8139 of file processor.h.

Referenced by get_name().


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