#include <processor.h>
Inheritance diagram for EMAN::TestImageFourierNoiseGaussian:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "testimage.noise.fourier.gaussian" |
sigma | sigma value for this Gaussian blob |
Definition at line 5905 of file processor.h.
virtual string EMAN::TestImageFourierNoiseGaussian::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 5915 of file processor.h.
05916 { 05917 return "Replace a source image with pink Fourier noise, based on a Gaussian. Random phase."; 05918 }
virtual string EMAN::TestImageFourierNoiseGaussian::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5910 of file processor.h.
References NAME.
05911 { 05912 return NAME; 05913 }
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.
Reimplemented from EMAN::Processor.
Definition at line 5925 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
05926 { 05927 TypeDict d; 05928 d.put("sigma", EMObject::FLOAT, "sigma value"); 05929 return d; 05930 }
static Processor* EMAN::TestImageFourierNoiseGaussian::NEW | ( | ) | [inline, static] |
Definition at line 5920 of file processor.h.
05921 { 05922 return new TestImageFourierNoiseGaussian(); 05923 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 6871 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(), 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.
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->ri2ap(); 06884 06885 float sigma = params.set_default("sigma",.25f); 06886 06887 float * d = image->get_data(); 06888 int nx = image->get_xsize(); 06889 int ny = image->get_ysize(); 06890 int nxy = image->get_ysize()*nx; 06891 int nzon2 = image->get_zsize()/2; 06892 int nyon2 = image->get_ysize()/2; 06893 float rx, ry, rz, length, amp, phase; 06894 int twox; 06895 for (int z = 0; z< image->get_zsize(); ++z) { 06896 for (int y = 0; y < image->get_ysize(); ++y) { 06897 for (int x = 0; x < image->get_xsize()/2; ++x) { 06898 rx = (float)x; 06899 ry = (float)nyon2 - (float)y; 06900 rz = (float)nzon2 - (float)z; 06901 length = sqrt(rx*rx + ry*ry + rz*rz); 06902 amp = exp(-sigma*length); 06903 phase = Util::get_frand(0,1)*2*M_PI; 06904 06905 twox = 2*x; 06906 size_t idx1 = twox + y*nx+(size_t)z*nxy; 06907 size_t idx2 = idx1 + 1; 06908 d[idx1] = amp; 06909 d[idx2] = phase; 06910 06911 } 06912 } 06913 } 06914 06915 image->ap2ri(); 06916 if (image->get_ndim() == 2) { 06917 bool yodd = image->get_ysize() % 2 == 1; 06918 06919 int yit = image->get_ysize()/2-1; 06920 int offset = 1; 06921 if (yodd) { 06922 offset = 0; 06923 } 06924 for (int y = 0; y < yit; ++y) { 06925 int bot_idx = (y+offset)*nx; 06926 int top_idx = (ny-1-y)*nx; 06927 float r1 = d[bot_idx]; 06928 float i1 = d[bot_idx+1]; 06929 float r2 = d[top_idx]; 06930 float i2 = d[top_idx+1]; 06931 float r = (r1 + r2)/2.0f; 06932 float i = (i1 + i2)/2.0f; 06933 d[bot_idx] = r; 06934 d[top_idx] = r; 06935 d[bot_idx+1] = i; 06936 d[top_idx+1] = -i; 06937 06938 bot_idx = (y+offset)*nx+nx-2; 06939 top_idx = (ny-1-y)*nx+nx-2; 06940 r1 = d[bot_idx]; 06941 i1 = d[bot_idx+1]; 06942 r2 = d[top_idx]; 06943 i2 = d[top_idx+1]; 06944 r = (r1 + r2)/2.0f; 06945 i = (i1 + i2)/2.0f; 06946 d[bot_idx] = r; 06947 d[top_idx] = r; 06948 d[bot_idx+1] = i; 06949 d[top_idx+1] = -i; 06950 } 06951 06952 d[1] = 0; // 0 phase for this componenet 06953 d[nx-1] = 0; // 0 phase for this component 06954 d[ny/2*nx+nx-1] = 0;// 0 phase for this component 06955 d[ny/2*nx+1] = 0;// 0 phase for this component 06956 } 06957 06958 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner"); 06959 image->do_ift_inplace(); 06960 image->depad(); 06961 }
const string TestImageFourierNoiseGaussian::NAME = "testimage.noise.fourier.gaussian" [static] |