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

ProcessorNEW ()

Static Public Attributes

const string NAME = "testimage.noise.fourier.profile"

Detailed Description

Author:
David Woolford
Date:
June 15th 2009

Definition at line 5769 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 5779 of file processor.h.

05780                 {
05781                         return "Replace a source image with Fourier noise using amplitude information that is stored in a profile.";
05782                 }

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

05775                 {
05776                         return NAME;
05777                 }

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

References EMAN::TypeDict::put().

05790                 {
05791                         TypeDict d;
05792                         d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05793                         return d;
05794                 }

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

Definition at line 5784 of file processor.h.

05785                 {
05786                         return new TestImageFourierNoiseProfile();
05787                 }

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 6869 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::Dict::has_key(), InvalidParameterException, EMAN::EMData::is_complex(), EMAN::length(), nx, ny, 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(), x, and y.

06869                                                                  {
06870 
06871         if (params.has_key("profile")==false) throw InvalidParameterException("You must supply the profile argument");
06872 
06873         if (!image->is_complex()) {
06874                 int nx = image->get_xsize();
06875                 int offset = 2 - nx%2;
06876 
06877                 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
06878                 image->set_complex(true);
06879                 if (1 == offset) image->set_fftodd(true);
06880                 else image->set_fftodd(false);
06881                 image->set_fftpad(true);
06882         }
06883         image->to_zero();
06884         image->ri2ap();
06885 
06886         vector<float> profile = params["profile"];
06887         transform(profile.begin(),profile.end(),profile.begin(),sqrtf);
06888 
06889         int i = static_cast<int>(profile.size());
06890 
06891         float * d = image->get_data();
06892         int nx = image->get_xsize();
06893         int ny = image->get_ysize();
06894         int nxy = image->get_ysize()*nx;
06895         int nzon2 = image->get_zsize()/2;
06896         int nyon2 = image->get_ysize()/2;
06897         float rx, ry, rz, amp, phase;
06898         int length;
06899         int twox;
06900         for (int z = 0; z< image->get_zsize(); ++z) {
06901                 for (int y = 0; y < image->get_ysize(); ++y) {
06902                         for (int x = 0; x < image->get_xsize()/2; ++x) {
06903                                 rx = (float)x;
06904                                 ry = (float)nyon2 - (float)y;
06905                                 rz = (float)nzon2 - (float)z;
06906                                 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
06907 
06908                                 twox = 2*x;
06909                                 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06910                                 size_t idx2 = idx1 + 1;
06911 
06912 
06913                                 if (length >= i) {
06914                                         d[idx1] = 0;
06915                                         d[idx2] = 0;
06916                                         continue;
06917                                 }
06918                                 amp = profile[length];
06919                                 phase = Util::get_frand(0,1)*2*M_PI;
06920 
06921 
06922                                 d[idx1] = amp;
06923                                 d[idx2] = phase;
06924 
06925                         }
06926                 }
06927         }
06928 
06929         image->ap2ri();
06930         if (image->get_ndim() == 2) {
06931                 bool yodd = image->get_ysize() % 2 == 1;
06932 
06933                 int yit = image->get_ysize()/2-1;
06934                 int offset = 1;
06935                 if (yodd) {
06936                         offset = 0;
06937                 }
06938                 for (int y = 0; y < yit; ++y) {
06939                         int bot_idx = (y+offset)*nx;
06940                         int top_idx = (ny-1-y)*nx;
06941                         float r1 = d[bot_idx];
06942                         float i1 = d[bot_idx+1];
06943                         float r2 = d[top_idx];
06944                         float i2 = d[top_idx+1];
06945                         float r = (r1 + r2)/2.0f;
06946                         float i = (i1 + i2)/2.0f;
06947                         d[bot_idx] = r;
06948                         d[top_idx] = r;
06949                         d[bot_idx+1] = i;
06950                         d[top_idx+1] = -i;
06951 
06952                         bot_idx = (y+offset)*nx+nx-2;
06953                         top_idx = (ny-1-y)*nx+nx-2;
06954                         r1 = d[bot_idx];
06955                         i1 = d[bot_idx+1];
06956                         r2 = d[top_idx];
06957                         i2 = d[top_idx+1];
06958                         r = (r1 + r2)/2.0f;
06959                         i = (i1 + i2)/2.0f;
06960                         d[bot_idx] = r;
06961                         d[top_idx] = r;
06962                         d[bot_idx+1] = i;
06963                         d[top_idx+1] = -i;
06964                 }
06965 
06966                 d[1] = 0; // 0 phase for this componenet
06967                 d[nx-1] = 0; // 0 phase for this component
06968                 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
06969                 d[ny/2*nx+1] = 0;// 0 phase for this component
06970         }
06971 
06972         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
06973         image->do_ift_inplace();
06974         image->depad();
06975 }


Member Data Documentation

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

Definition at line 190 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Mar 7 18:21:17 2011 for EMAN2 by  doxygen 1.3.9.1