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

05874                 {
05875                         return "Replace a source image with Fourier noise using amplitude information that is stored in a profile.";
05876                 }

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

05869                 {
05870                         return NAME;
05871                 }

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

References EMAN::TypeDict::put().

05884                 {
05885                         TypeDict d;
05886                         d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05887                         return d;
05888                 }

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

Definition at line 5878 of file processor.h.

05879                 {
05880                         return new TestImageFourierNoiseProfile();
05881                 }

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 6899 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.

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


Member Data Documentation

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

Definition at line 197 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:51:27 2011 for EMAN2 by  doxygen 1.3.9.1