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

ProcessorNEW ()

Static Public Attributes

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

05957                 {
05958                         return "Replace a source image with pink Fourier noise, based on a Gaussian. Random phase.";
05959                 }

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

05952                 {
05953                         return NAME;
05954                 }

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

References EMAN::TypeDict::put().

05967                 {
05968                         TypeDict d;
05969                         d.put("sigma", EMObject::FLOAT, "sigma value");
05970                         return d;
05971                 }

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

Definition at line 5961 of file processor.h.

05962                 {
05963                         return new TestImageFourierNoiseGaussian();
05964                 }

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 6951 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(), nx, ny, 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(), x, and y.

06952 {
06953         if (!image->is_complex()) {
06954                 int nx = image->get_xsize();
06955                 int offset = 2 - nx%2;
06956 
06957                 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
06958                 image->set_complex(true);
06959                 if (1 == offset) image->set_fftodd(true);
06960                 else image->set_fftodd(false);
06961                 image->set_fftpad(true);
06962         }
06963         image->ri2ap();
06964 
06965         float sigma = params.set_default("sigma",.25f);
06966 
06967         float * d = image->get_data();
06968         int nx = image->get_xsize();
06969         int ny = image->get_ysize();
06970         int nxy = image->get_ysize()*nx;
06971         int nzon2 = image->get_zsize()/2;
06972         int nyon2 = image->get_ysize()/2;
06973         float rx, ry, rz, length, amp, phase;
06974         int twox;
06975         for (int z = 0; z< image->get_zsize(); ++z) {
06976                 for (int y = 0; y < image->get_ysize(); ++y) {
06977                         for (int x = 0; x < image->get_xsize()/2; ++x) {
06978                                 rx = (float)x;
06979                                 ry = (float)nyon2 - (float)y;
06980                                 rz = (float)nzon2 - (float)z;
06981                                 length = sqrt(rx*rx + ry*ry + rz*rz);
06982                                 amp = exp(-sigma*length);
06983                                 phase = Util::get_frand(0,1)*2*M_PI;
06984 
06985                                 twox = 2*x;
06986                                 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06987                                 size_t idx2 = idx1 + 1;
06988                                 d[idx1] = amp;
06989                                 d[idx2] = phase;
06990 
06991                         }
06992                 }
06993         }
06994 
06995         image->ap2ri();
06996         if (image->get_ndim() == 2) {
06997                 bool yodd = image->get_ysize() % 2 == 1;
06998 
06999                 int yit = image->get_ysize()/2-1;
07000                 int offset = 1;
07001                 if (yodd) {
07002                         offset = 0;
07003                 }
07004                 for (int y = 0; y < yit; ++y) {
07005                         int bot_idx = (y+offset)*nx;
07006                         int top_idx = (ny-1-y)*nx;
07007                         float r1 = d[bot_idx];
07008                         float i1 = d[bot_idx+1];
07009                         float r2 = d[top_idx];
07010                         float i2 = d[top_idx+1];
07011                         float r = (r1 + r2)/2.0f;
07012                         float i = (i1 + i2)/2.0f;
07013                         d[bot_idx] = r;
07014                         d[top_idx] = r;
07015                         d[bot_idx+1] = i;
07016                         d[top_idx+1] = -i;
07017 
07018                         bot_idx = (y+offset)*nx+nx-2;
07019                         top_idx = (ny-1-y)*nx+nx-2;
07020                         r1 = d[bot_idx];
07021                         i1 = d[bot_idx+1];
07022                         r2 = d[top_idx];
07023                         i2 = d[top_idx+1];
07024                         r = (r1 + r2)/2.0f;
07025                         i = (i1 + i2)/2.0f;
07026                         d[bot_idx] = r;
07027                         d[top_idx] = r;
07028                         d[bot_idx+1] = i;
07029                         d[top_idx+1] = -i;
07030                 }
07031 
07032                 d[1] = 0; // 0 phase for this componenet
07033                 d[nx-1] = 0; // 0 phase for this component
07034                 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
07035                 d[ny/2*nx+1] = 0;// 0 phase for this component
07036         }
07037 
07038         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
07039         image->do_ift_inplace();
07040         image->depad();
07041 }


Member Data Documentation

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

Definition at line 192 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:49:07 2013 for EMAN2 by  doxygen 1.3.9.1