#include <processor.h>
Inheritance diagram for EMAN::TestImageFourierNoiseProfile:
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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "testimage.noise.fourier.profile" |
Definition at line 5894 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 5904 of file processor.h. 05905 { 05906 return "Replace a source image with Fourier noise using amplitude information that is stored in a profile."; 05907 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5899 of file processor.h. 05900 {
05901 return NAME;
05902 }
|
|
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 5914 of file processor.h. References EMAN::TypeDict::put(). 05915 { 05916 TypeDict d; 05917 d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute"); 05918 return d; 05919 }
|
|
Definition at line 5909 of file processor.h. 05910 { 05911 return new TestImageFourierNoiseProfile(); 05912 }
|
|
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.
Implements EMAN::Processor. Definition at line 6985 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. 06985 { 06986 06987 if (params.has_key("profile")==false) throw InvalidParameterException("You must supply the profile argument"); 06988 06989 if (!image->is_complex()) { 06990 int nx = image->get_xsize(); 06991 int offset = 2 - nx%2; 06992 06993 image->set_size(nx+offset,image->get_ysize(),image->get_zsize()); 06994 image->set_complex(true); 06995 if (1 == offset) image->set_fftodd(true); 06996 else image->set_fftodd(false); 06997 image->set_fftpad(true); 06998 } 06999 image->to_zero(); 07000 image->ri2ap(); 07001 07002 vector<float> profile = params["profile"]; 07003 transform(profile.begin(),profile.end(),profile.begin(),sqrtf); 07004 07005 int i = static_cast<int>(profile.size()); 07006 07007 float * d = image->get_data(); 07008 int nx = image->get_xsize(); 07009 int ny = image->get_ysize(); 07010 int nxy = image->get_ysize()*nx; 07011 int nzon2 = image->get_zsize()/2; 07012 int nyon2 = image->get_ysize()/2; 07013 float rx, ry, rz, amp, phase; 07014 int length; 07015 int twox; 07016 for (int z = 0; z< image->get_zsize(); ++z) { 07017 for (int y = 0; y < image->get_ysize(); ++y) { 07018 for (int x = 0; x < image->get_xsize()/2; ++x) { 07019 rx = (float)x; 07020 ry = (float)nyon2 - (float)y; 07021 rz = (float)nzon2 - (float)z; 07022 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz)); 07023 07024 twox = 2*x; 07025 size_t idx1 = twox + y*nx+(size_t)z*nxy; 07026 size_t idx2 = idx1 + 1; 07027 07028 07029 if (length >= i) { 07030 d[idx1] = 0; 07031 d[idx2] = 0; 07032 continue; 07033 } 07034 amp = profile[length]; 07035 phase = Util::get_frand(0,1)*2*M_PI; 07036 07037 07038 d[idx1] = amp; 07039 d[idx2] = phase; 07040 07041 } 07042 } 07043 } 07044 07045 image->ap2ri(); 07046 if (image->get_ndim() == 2) { 07047 bool yodd = image->get_ysize() % 2 == 1; 07048 07049 int yit = image->get_ysize()/2-1; 07050 int offset = 1; 07051 if (yodd) { 07052 offset = 0; 07053 } 07054 for (int y = 0; y < yit; ++y) { 07055 int bot_idx = (y+offset)*nx; 07056 int top_idx = (ny-1-y)*nx; 07057 float r1 = d[bot_idx]; 07058 float i1 = d[bot_idx+1]; 07059 float r2 = d[top_idx]; 07060 float i2 = d[top_idx+1]; 07061 float r = (r1 + r2)/2.0f; 07062 float i = (i1 + i2)/2.0f; 07063 d[bot_idx] = r; 07064 d[top_idx] = r; 07065 d[bot_idx+1] = i; 07066 d[top_idx+1] = -i; 07067 07068 bot_idx = (y+offset)*nx+nx-2; 07069 top_idx = (ny-1-y)*nx+nx-2; 07070 r1 = d[bot_idx]; 07071 i1 = d[bot_idx+1]; 07072 r2 = d[top_idx]; 07073 i2 = d[top_idx+1]; 07074 r = (r1 + r2)/2.0f; 07075 i = (i1 + i2)/2.0f; 07076 d[bot_idx] = r; 07077 d[top_idx] = r; 07078 d[bot_idx+1] = i; 07079 d[top_idx+1] = -i; 07080 } 07081 07082 d[1] = 0; // 0 phase for this componenet 07083 d[nx-1] = 0; // 0 phase for this component 07084 d[ny/2*nx+nx-1] = 0;// 0 phase for this component 07085 d[ny/2*nx+1] = 0;// 0 phase for this component 07086 } 07087 07088 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner"); 07089 image->do_ift_inplace(); 07090 image->depad(); 07091 }
|
|
Definition at line 192 of file processor.cpp. |