Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File 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]
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 5863 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 5873 of file processor.h.

05874                 {
05875                         return "Replace a source image with pink Fourier noise, based on a Gaussian. Random phase.";
05876                 }

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

References NAME.

05869                 {
05870                         return NAME;
05871                 }

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

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

05884                 {
05885                         TypeDict d;
05886                         d.put("sigma", EMObject::FLOAT, "sigma value");
05887                         return d;
05888                 }

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

Definition at line 5878 of file processor.h.

05879                 {
05880                         return new TestImageFourierNoiseGaussian();
05881                 }

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 6721 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(), get_xsize(), EMAN::EMData::get_xsize(), get_ysize(), EMAN::EMData::get_ysize(), get_zsize(), 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.

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


Member Data Documentation

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

Definition at line 5890 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 13:07:19 2010 for EMAN2 by  doxygen 1.4.4