#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 5825 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 5835 of file processor.h. 05836 {
05837 return "Replace a source image with Fourier noise using amplitude information that is stored in a profile.";
05838 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5830 of file processor.h. 05831 {
05832 return NAME;
05833 }
|
|
|
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 5845 of file processor.h. References EMAN::TypeDict::put(). 05846 {
05847 TypeDict d;
05848 d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05849 return d;
05850 }
|
|
|
Definition at line 5840 of file processor.h. 05841 {
05842 return new TestImageFourierNoiseProfile();
05843 }
|
|
|
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 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::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. 06871 {
06872
06873 if (params.has_key("profile")==false) throw InvalidParameterException("You must supply the profile argument");
06874
06875 if (!image->is_complex()) {
06876 int nx = image->get_xsize();
06877 int offset = 2 - nx%2;
06878
06879 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
06880 image->set_complex(true);
06881 if (1 == offset) image->set_fftodd(true);
06882 else image->set_fftodd(false);
06883 image->set_fftpad(true);
06884 }
06885 image->to_zero();
06886 image->ri2ap();
06887
06888 vector<float> profile = params["profile"];
06889 transform(profile.begin(),profile.end(),profile.begin(),sqrtf);
06890
06891 int i = static_cast<int>(profile.size());
06892
06893 float * d = image->get_data();
06894 int nx = image->get_xsize();
06895 int ny = image->get_ysize();
06896 int nxy = image->get_ysize()*nx;
06897 int nzon2 = image->get_zsize()/2;
06898 int nyon2 = image->get_ysize()/2;
06899 float rx, ry, rz, amp, phase;
06900 int length;
06901 int twox;
06902 for (int z = 0; z< image->get_zsize(); ++z) {
06903 for (int y = 0; y < image->get_ysize(); ++y) {
06904 for (int x = 0; x < image->get_xsize()/2; ++x) {
06905 rx = (float)x;
06906 ry = (float)nyon2 - (float)y;
06907 rz = (float)nzon2 - (float)z;
06908 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
06909
06910 twox = 2*x;
06911 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06912 size_t idx2 = idx1 + 1;
06913
06914
06915 if (length >= i) {
06916 d[idx1] = 0;
06917 d[idx2] = 0;
06918 continue;
06919 }
06920 amp = profile[length];
06921 phase = Util::get_frand(0,1)*2*M_PI;
06922
06923
06924 d[idx1] = amp;
06925 d[idx2] = phase;
06926
06927 }
06928 }
06929 }
06930
06931 image->ap2ri();
06932 if (image->get_ndim() == 2) {
06933 bool yodd = image->get_ysize() % 2 == 1;
06934
06935 int yit = image->get_ysize()/2-1;
06936 int offset = 1;
06937 if (yodd) {
06938 offset = 0;
06939 }
06940 for (int y = 0; y < yit; ++y) {
06941 int bot_idx = (y+offset)*nx;
06942 int top_idx = (ny-1-y)*nx;
06943 float r1 = d[bot_idx];
06944 float i1 = d[bot_idx+1];
06945 float r2 = d[top_idx];
06946 float i2 = d[top_idx+1];
06947 float r = (r1 + r2)/2.0f;
06948 float i = (i1 + i2)/2.0f;
06949 d[bot_idx] = r;
06950 d[top_idx] = r;
06951 d[bot_idx+1] = i;
06952 d[top_idx+1] = -i;
06953
06954 bot_idx = (y+offset)*nx+nx-2;
06955 top_idx = (ny-1-y)*nx+nx-2;
06956 r1 = d[bot_idx];
06957 i1 = d[bot_idx+1];
06958 r2 = d[top_idx];
06959 i2 = d[top_idx+1];
06960 r = (r1 + r2)/2.0f;
06961 i = (i1 + i2)/2.0f;
06962 d[bot_idx] = r;
06963 d[top_idx] = r;
06964 d[bot_idx+1] = i;
06965 d[top_idx+1] = -i;
06966 }
06967
06968 d[1] = 0; // 0 phase for this componenet
06969 d[nx-1] = 0; // 0 phase for this component
06970 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
06971 d[ny/2*nx+1] = 0;// 0 phase for this component
06972 }
06973
06974 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
06975 image->do_ift_inplace();
06976 image->depad();
06977 }
|
|
|
Definition at line 192 of file processor.cpp. |
1.3.9.1