Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::TestImageFourierNoiseProfile Class Reference

#include <processor.h>

Inheritance diagram for EMAN::TestImageFourierNoiseProfile:

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

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

Detailed Description

Author:
David Woolford
Date:
June 15th 2009

Definition at line 5897 of file processor.h.


Member Function Documentation

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

05908                 {
05909                         return "Replace a source image with Fourier noise using amplitude information that is stored in a profile.";
05910                 }

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

References NAME.

05903                 {
05904                         return NAME;
05905                 }

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

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

05918                 {
05919                         TypeDict d;
05920                         d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05921                         return d;
05922                 }

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

Definition at line 5912 of file processor.h.

05913                 {
05914                         return new TestImageFourierNoiseProfile();
05915                 }

void TestImageFourierNoiseProfile::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 6907 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::Dict::has_key(), InvalidParameterException, EMAN::EMData::is_complex(), EMAN::length(), EMAN::Processor::params, phase(), EMAN::EMData::process_inplace(), EMAN::EMData::ri2ap(), EMAN::EMData::set_complex(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_size(), sqrt(), EMAN::EMData::to_zero(), and x.

06907                                                                  {
06908 
06909         if (params.has_key("profile")==false) throw InvalidParameterException("You must supply the profile argument");
06910 
06911         if (!image->is_complex()) {
06912                 int nx = image->get_xsize();
06913                 int offset = 2 - nx%2;
06914 
06915                 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
06916                 image->set_complex(true);
06917                 if (1 == offset) image->set_fftodd(true);
06918                 else image->set_fftodd(false);
06919                 image->set_fftpad(true);
06920         }
06921         image->to_zero();
06922         image->ri2ap();
06923 
06924         vector<float> profile = params["profile"];
06925         transform(profile.begin(),profile.end(),profile.begin(),sqrtf);
06926 
06927         int i = static_cast<int>(profile.size());
06928 
06929         float * d = image->get_data();
06930         int nx = image->get_xsize();
06931         int ny = image->get_ysize();
06932         int nxy = image->get_ysize()*nx;
06933         int nzon2 = image->get_zsize()/2;
06934         int nyon2 = image->get_ysize()/2;
06935         float rx, ry, rz, amp, phase;
06936         int length;
06937         int twox;
06938         for (int z = 0; z< image->get_zsize(); ++z) {
06939                 for (int y = 0; y < image->get_ysize(); ++y) {
06940                         for (int x = 0; x < image->get_xsize()/2; ++x) {
06941                                 rx = (float)x;
06942                                 ry = (float)nyon2 - (float)y;
06943                                 rz = (float)nzon2 - (float)z;
06944                                 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
06945 
06946                                 twox = 2*x;
06947                                 size_t idx1 = twox + y*nx+z*nxy;
06948                                 size_t idx2 = idx1 + 1;
06949 
06950 
06951                                 if (length >= i) {
06952                                         d[idx1] = 0;
06953                                         d[idx2] = 0;
06954                                         continue;
06955                                 }
06956                                 amp = profile[length];
06957                                 phase = Util::get_frand(0,1)*2*M_PI;
06958 
06959 
06960                                 d[idx1] = amp;
06961                                 d[idx2] = phase;
06962 
06963                         }
06964                 }
06965         }
06966 
06967         image->ap2ri();
06968         if (image->get_ndim() == 2) {
06969                 bool yodd = image->get_ysize() % 2 == 1;
06970 
06971                 int yit = image->get_ysize()/2-1;
06972                 int offset = 1;
06973                 if (yodd) {
06974                         offset = 0;
06975                 }
06976                 for (int y = 0; y < yit; ++y) {
06977                         int bot_idx = (y+offset)*nx;
06978                         int top_idx = (ny-1-y)*nx;
06979                         float r1 = d[bot_idx];
06980                         float i1 = d[bot_idx+1];
06981                         float r2 = d[top_idx];
06982                         float i2 = d[top_idx+1];
06983                         float r = (r1 + r2)/2.0f;
06984                         float i = (i1 + i2)/2.0f;
06985                         d[bot_idx] = r;
06986                         d[top_idx] = r;
06987                         d[bot_idx+1] = i;
06988                         d[top_idx+1] = -i;
06989 
06990                         bot_idx = (y+offset)*nx+nx-2;
06991                         top_idx = (ny-1-y)*nx+nx-2;
06992                         r1 = d[bot_idx];
06993                         i1 = d[bot_idx+1];
06994                         r2 = d[top_idx];
06995                         i2 = d[top_idx+1];
06996                         r = (r1 + r2)/2.0f;
06997                         i = (i1 + i2)/2.0f;
06998                         d[bot_idx] = r;
06999                         d[top_idx] = r;
07000                         d[bot_idx+1] = i;
07001                         d[top_idx+1] = -i;
07002                 }
07003 
07004                 d[1] = 0; // 0 phase for this componenet
07005                 d[nx-1] = 0; // 0 phase for this component
07006                 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
07007                 d[ny/2*nx+1] = 0;// 0 phase for this component
07008         }
07009 
07010         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
07011         image->do_ift_inplace();
07012         image->depad();
07013 }


Member Data Documentation

const string TestImageFourierNoiseProfile::NAME = "testimage.noise.fourier.profile" [static]
 

Definition at line 5924 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:20 2010 for EMAN2 by  doxygen 1.4.4