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]
List of all members.

Public Member Functions

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

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

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

Detailed Description

Replace a source image as a strict Gaussian.

Parameters:
sigma sigma value for this Gaussian blob

Definition at line 5829 of file processor.h.


Member Function Documentation

virtual string EMAN::TestImageFourierNoiseGaussian::get_desc (  )  const [inline, virtual]

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 5839 of file processor.h.

05840                 {
05841                         return "Replace a source image with pink Fourier noise, based on a Gaussian. Random phase.";
05842                 }

virtual string EMAN::TestImageFourierNoiseGaussian::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 5834 of file processor.h.

References NAME.

05835                 {
05836                         return NAME;
05837                 }

virtual TypeDict EMAN::TestImageFourierNoiseGaussian::get_param_types (  )  const [inline, virtual]

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 5849 of file processor.h.

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

05850                 {
05851                         TypeDict d;
05852                         d.put("sigma", EMObject::FLOAT, "sigma value");
05853                         return d;
05854                 }

static Processor* EMAN::TestImageFourierNoiseGaussian::NEW (  )  [inline, static]

Definition at line 5844 of file processor.h.

05845                 {
05846                         return new TestImageFourierNoiseGaussian();
05847                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 6713 of file processor.cpp.

References EMAN::EMData::ap2ri(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::get_data(), EMAN::Util::get_frand(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::is_complex(), EMAN::length(), EMAN::Processor::params, phase(), EMAN::EMData::process_inplace(), EMAN::EMData::ri2ap(), EMAN::EMData::set_complex(), EMAN::Dict::set_default(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_size(), sqrt(), and x.

06714 {
06715         if (!image->is_complex()) {
06716                 int nx = image->get_xsize();
06717                 int offset = 2 - nx%2;
06718 
06719                 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
06720                 image->set_complex(true);
06721                 if (1 == offset) image->set_fftodd(true);
06722                 else image->set_fftodd(false);
06723                 image->set_fftpad(true);
06724         }
06725         image->ri2ap();
06726 
06727         float sigma = params.set_default("sigma",.25f);
06728 
06729         float * d = image->get_data();
06730         int nx = image->get_xsize();
06731         int ny = image->get_ysize();
06732         int nxy = image->get_ysize()*nx;
06733         int nzon2 = image->get_zsize()/2;
06734         int nyon2 = image->get_ysize()/2;
06735         float rx, ry, rz, length, amp, phase;
06736         int twox;
06737         for (int z = 0; z< image->get_zsize(); ++z) {
06738                 for (int y = 0; y < image->get_ysize(); ++y) {
06739                         for (int x = 0; x < image->get_xsize()/2; ++x) {
06740                                 rx = (float)x;
06741                                 ry = (float)nyon2 - (float)y;
06742                                 rz = (float)nzon2 - (float)z;
06743                                 length = sqrt(rx*rx + ry*ry + rz*rz);
06744                                 amp = exp(-sigma*length);
06745                                 phase = Util::get_frand(0,1)*2*M_PI;
06746 
06747                                 twox = 2*x;
06748                                 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06749                                 size_t idx2 = idx1 + 1;
06750                                 d[idx1] = amp;
06751                                 d[idx2] = phase;
06752 
06753                         }
06754                 }
06755         }
06756 
06757         image->ap2ri();
06758         if (image->get_ndim() == 2) {
06759                 bool yodd = image->get_ysize() % 2 == 1;
06760 
06761                 int yit = image->get_ysize()/2-1;
06762                 int offset = 1;
06763                 if (yodd) {
06764                         offset = 0;
06765                 }
06766                 for (int y = 0; y < yit; ++y) {
06767                         int bot_idx = (y+offset)*nx;
06768                         int top_idx = (ny-1-y)*nx;
06769                         float r1 = d[bot_idx];
06770                         float i1 = d[bot_idx+1];
06771                         float r2 = d[top_idx];
06772                         float i2 = d[top_idx+1];
06773                         float r = (r1 + r2)/2.0f;
06774                         float i = (i1 + i2)/2.0f;
06775                         d[bot_idx] = r;
06776                         d[top_idx] = r;
06777                         d[bot_idx+1] = i;
06778                         d[top_idx+1] = -i;
06779 
06780                         bot_idx = (y+offset)*nx+nx-2;
06781                         top_idx = (ny-1-y)*nx+nx-2;
06782                         r1 = d[bot_idx];
06783                         i1 = d[bot_idx+1];
06784                         r2 = d[top_idx];
06785                         i2 = d[top_idx+1];
06786                         r = (r1 + r2)/2.0f;
06787                         i = (i1 + i2)/2.0f;
06788                         d[bot_idx] = r;
06789                         d[top_idx] = r;
06790                         d[bot_idx+1] = i;
06791                         d[top_idx+1] = -i;
06792                 }
06793 
06794                 d[1] = 0; // 0 phase for this componenet
06795                 d[nx-1] = 0; // 0 phase for this component
06796                 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
06797                 d[ny/2*nx+1] = 0;// 0 phase for this component
06798         }
06799 
06800         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
06801         image->do_ift_inplace();
06802         image->depad();
06803 }


Member Data Documentation

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

Definition at line 5856 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:49:35 2011 for EMAN2 by  doxygen 1.4.7