#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 5684 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 5694 of file processor.h. 05695 { 05696 return "Replace a source image with Fourier noise using amplitude information that is stored in a profile."; 05697 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5689 of file processor.h. 05690 {
05691 return NAME;
05692 }
|
|
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 5704 of file processor.h. References EMAN::TypeDict::put(). 05705 { 05706 TypeDict d; 05707 d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute"); 05708 return d; 05709 }
|
|
Definition at line 5699 of file processor.h. 05700 { 05701 return new TestImageFourierNoiseProfile(); 05702 }
|
|
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 6805 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. 06805 { 06806 06807 if (params.has_key("profile")==false) throw InvalidParameterException("You must supply the profile argument"); 06808 06809 if (!image->is_complex()) { 06810 int nx = image->get_xsize(); 06811 int offset = 2 - nx%2; 06812 06813 image->set_size(nx+offset,image->get_ysize(),image->get_zsize()); 06814 image->set_complex(true); 06815 if (1 == offset) image->set_fftodd(true); 06816 else image->set_fftodd(false); 06817 image->set_fftpad(true); 06818 } 06819 image->to_zero(); 06820 image->ri2ap(); 06821 06822 vector<float> profile = params["profile"]; 06823 transform(profile.begin(),profile.end(),profile.begin(),sqrtf); 06824 06825 int i = static_cast<int>(profile.size()); 06826 06827 float * d = image->get_data(); 06828 int nx = image->get_xsize(); 06829 int ny = image->get_ysize(); 06830 int nxy = image->get_ysize()*nx; 06831 int nzon2 = image->get_zsize()/2; 06832 int nyon2 = image->get_ysize()/2; 06833 float rx, ry, rz, amp, phase; 06834 int length; 06835 int twox; 06836 for (int z = 0; z< image->get_zsize(); ++z) { 06837 for (int y = 0; y < image->get_ysize(); ++y) { 06838 for (int x = 0; x < image->get_xsize()/2; ++x) { 06839 rx = (float)x; 06840 ry = (float)nyon2 - (float)y; 06841 rz = (float)nzon2 - (float)z; 06842 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz)); 06843 06844 twox = 2*x; 06845 size_t idx1 = twox + y*nx+z*nxy; 06846 size_t idx2 = idx1 + 1; 06847 06848 06849 if (length >= i) { 06850 d[idx1] = 0; 06851 d[idx2] = 0; 06852 continue; 06853 } 06854 amp = profile[length]; 06855 phase = Util::get_frand(0,1)*2*M_PI; 06856 06857 06858 d[idx1] = amp; 06859 d[idx2] = phase; 06860 06861 } 06862 } 06863 } 06864 06865 image->ap2ri(); 06866 if (image->get_ndim() == 2) { 06867 bool yodd = image->get_ysize() % 2 == 1; 06868 06869 int yit = image->get_ysize()/2-1; 06870 int offset = 1; 06871 if (yodd) { 06872 offset = 0; 06873 } 06874 for (int y = 0; y < yit; ++y) { 06875 int bot_idx = (y+offset)*nx; 06876 int top_idx = (ny-1-y)*nx; 06877 float r1 = d[bot_idx]; 06878 float i1 = d[bot_idx+1]; 06879 float r2 = d[top_idx]; 06880 float i2 = d[top_idx+1]; 06881 float r = (r1 + r2)/2.0f; 06882 float i = (i1 + i2)/2.0f; 06883 d[bot_idx] = r; 06884 d[top_idx] = r; 06885 d[bot_idx+1] = i; 06886 d[top_idx+1] = -i; 06887 06888 bot_idx = (y+offset)*nx+nx-2; 06889 top_idx = (ny-1-y)*nx+nx-2; 06890 r1 = d[bot_idx]; 06891 i1 = d[bot_idx+1]; 06892 r2 = d[top_idx]; 06893 i2 = d[top_idx+1]; 06894 r = (r1 + r2)/2.0f; 06895 i = (i1 + i2)/2.0f; 06896 d[bot_idx] = r; 06897 d[top_idx] = r; 06898 d[bot_idx+1] = i; 06899 d[top_idx+1] = -i; 06900 } 06901 06902 d[1] = 0; // 0 phase for this componenet 06903 d[nx-1] = 0; // 0 phase for this component 06904 d[ny/2*nx+nx-1] = 0;// 0 phase for this component 06905 d[ny/2*nx+1] = 0;// 0 phase for this component 06906 } 06907 06908 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner"); 06909 image->do_ift_inplace(); 06910 image->depad(); 06911 }
|
|
Definition at line 187 of file processor.cpp. |